[KERNEL32]: Formatting fixes (whitespace...) only.

svn path=/trunk/; revision=71768
This commit is contained in:
Hermès Bélusca-Maïto 2016-07-02 20:52:25 +00:00
parent 12df37e35b
commit 1feab2643f
2 changed files with 239 additions and 241 deletions

View file

@ -71,19 +71,19 @@ K32CreateDBMonMutex(void)
TRUE, TRUE,
L"DBWinMutex"); L"DBWinMutex");
if(hMutex != NULL) if (hMutex != NULL)
{ {
/* success */ /* success */
return hMutex; return hMutex;
} }
/* error other than the mutex not being found */ /* error other than the mutex not being found */
else if(GetLastError() != ERROR_FILE_NOT_FOUND) else if (GetLastError() != ERROR_FILE_NOT_FOUND)
{ {
/* failure */ /* failure */
return NULL; return NULL;
} }
/* if the mutex doesn't exist, create it */ /* if the mutex doesn't exist, create it */
/* first, set up the mutex security */ /* first, set up the mutex security */
/* allocate the NT AUTHORITY\SYSTEM SID */ /* allocate the NT AUTHORITY\SYSTEM SID */
@ -100,7 +100,7 @@ K32CreateDBMonMutex(void)
&psidSystem); &psidSystem);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* allocate the BUILTIN\Administrators SID */ /* allocate the BUILTIN\Administrators SID */
nErrCode = RtlAllocateAndInitializeSid(&siaNTAuth, nErrCode = RtlAllocateAndInitializeSid(&siaNTAuth,
@ -116,7 +116,7 @@ K32CreateDBMonMutex(void)
&psidAdministrators); &psidAdministrators);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* allocate the Everyone SID */ /* allocate the Everyone SID */
nErrCode = RtlAllocateAndInitializeSid(&siaWorldAuth, nErrCode = RtlAllocateAndInitializeSid(&siaWorldAuth,
@ -132,7 +132,7 @@ K32CreateDBMonMutex(void)
&psidEveryone); &psidEveryone);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* allocate space for the SIDs too */ /* allocate space for the SIDs too */
nDaclBufSize += RtlLengthSid(psidSystem); nDaclBufSize += RtlLengthSid(psidSystem);
@ -143,13 +143,13 @@ K32CreateDBMonMutex(void)
pDaclBuf = GlobalAlloc(GMEM_FIXED, nDaclBufSize); pDaclBuf = GlobalAlloc(GMEM_FIXED, nDaclBufSize);
/* failure */ /* failure */
if(pDaclBuf == NULL) goto l_Cleanup; if (pDaclBuf == NULL) goto l_Cleanup;
/* create the DACL */ /* create the DACL */
nErrCode = RtlCreateAcl(pDaclBuf, nDaclBufSize, ACL_REVISION); nErrCode = RtlCreateAcl(pDaclBuf, nDaclBufSize, ACL_REVISION);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* grant the minimum required access to Everyone */ /* grant the minimum required access to Everyone */
nErrCode = RtlAddAccessAllowedAce(pDaclBuf, nErrCode = RtlAddAccessAllowedAce(pDaclBuf,
@ -160,7 +160,7 @@ K32CreateDBMonMutex(void)
psidEveryone); psidEveryone);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* grant full access to BUILTIN\Administrators */ /* grant full access to BUILTIN\Administrators */
nErrCode = RtlAddAccessAllowedAce(pDaclBuf, nErrCode = RtlAddAccessAllowedAce(pDaclBuf,
@ -169,7 +169,7 @@ K32CreateDBMonMutex(void)
psidAdministrators); psidAdministrators);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* grant full access to NT AUTHORITY\SYSTEM */ /* grant full access to NT AUTHORITY\SYSTEM */
nErrCode = RtlAddAccessAllowedAce(pDaclBuf, nErrCode = RtlAddAccessAllowedAce(pDaclBuf,
@ -178,14 +178,14 @@ K32CreateDBMonMutex(void)
psidSystem); psidSystem);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* create the security descriptor */ /* create the security descriptor */
nErrCode = RtlCreateSecurityDescriptor(&sdMutexSecurity, nErrCode = RtlCreateSecurityDescriptor(&sdMutexSecurity,
SECURITY_DESCRIPTOR_REVISION); SECURITY_DESCRIPTOR_REVISION);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* set the descriptor's DACL to the ACL we created */ /* set the descriptor's DACL to the ACL we created */
nErrCode = RtlSetDaclSecurityDescriptor(&sdMutexSecurity, nErrCode = RtlSetDaclSecurityDescriptor(&sdMutexSecurity,
@ -194,19 +194,19 @@ K32CreateDBMonMutex(void)
FALSE); FALSE);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if (!NT_SUCCESS(nErrCode)) goto l_Cleanup;
/* create the mutex */ /* create the mutex */
hMutex = CreateMutexW(&saMutexAttribs, FALSE, L"DBWinMutex"); hMutex = CreateMutexW(&saMutexAttribs, FALSE, L"DBWinMutex");
l_Cleanup: l_Cleanup:
/* free the buffers */ /* free the buffers */
if(pDaclBuf) GlobalFree(pDaclBuf); if (pDaclBuf) GlobalFree(pDaclBuf);
if(psidEveryone) RtlFreeSid(psidEveryone); if (psidEveryone) RtlFreeSid(psidEveryone);
if(psidAdministrators) RtlFreeSid(psidAdministrators); if (psidAdministrators) RtlFreeSid(psidAdministrators);
if(psidSystem) RtlFreeSid(psidSystem); if (psidSystem) RtlFreeSid(psidSystem);
return hMutex; return hMutex;
} }
VOID VOID
@ -425,8 +425,8 @@ CheckRemoteDebuggerPresent(IN HANDLE hProcess,
/* Check if the process has a debug object/port */ /* Check if the process has a debug object/port */
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessDebugPort, ProcessDebugPort,
(PVOID)&DebugPort, &DebugPort,
sizeof(HANDLE), sizeof(DebugPort),
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -558,7 +558,7 @@ DebugBreakProcess(IN HANDLE Process)
/* Send the breakin request */ /* Send the breakin request */
Status = DbgUiIssueRemoteBreakin(Process); Status = DbgUiIssueRemoteBreakin(Process);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failure */ /* Failure */
BaseSetLastNTError(Status); BaseSetLastNTError(Status);
@ -727,212 +727,212 @@ VOID
WINAPI WINAPI
OutputDebugStringA(IN LPCSTR _OutputString) OutputDebugStringA(IN LPCSTR _OutputString)
{ {
_SEH2_TRY _SEH2_TRY
{ {
ULONG_PTR a_nArgs[2]; ULONG_PTR a_nArgs[2];
a_nArgs[0] = (ULONG_PTR)(strlen(_OutputString) + 1); a_nArgs[0] = (ULONG_PTR)(strlen(_OutputString) + 1);
a_nArgs[1] = (ULONG_PTR)_OutputString; a_nArgs[1] = (ULONG_PTR)_OutputString;
/* send the string to the user-mode debugger */ /* send the string to the user-mode debugger */
RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs); RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs);
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
/* no user-mode debugger: try the systemwide debug message monitor, or the /* no user-mode debugger: try the systemwide debug message monitor, or the
kernel debugger as a last resort */ kernel debugger as a last resort */
/* mutex used to synchronize invocations of OutputDebugString */ /* mutex used to synchronize invocations of OutputDebugString */
static HANDLE s_hDBMonMutex = NULL; static HANDLE s_hDBMonMutex = NULL;
/* true if we already attempted to open/create the mutex */ /* true if we already attempted to open/create the mutex */
static BOOL s_bDBMonMutexTriedOpen = FALSE; static BOOL s_bDBMonMutexTriedOpen = FALSE;
/* local copy of the mutex handle */ /* local copy of the mutex handle */
volatile HANDLE hDBMonMutex = s_hDBMonMutex; volatile HANDLE hDBMonMutex = s_hDBMonMutex;
/* handle to the Section of the shared buffer */ /* handle to the Section of the shared buffer */
volatile HANDLE hDBMonBuffer = NULL; volatile HANDLE hDBMonBuffer = NULL;
/* pointer to the mapped view of the shared buffer. It consist of the current /* pointer to the mapped view of the shared buffer. It consist of the current
process id followed by the message string */ process id followed by the message string */
struct { DWORD ProcessId; CHAR Buffer[1]; } * pDBMonBuffer = NULL; struct { DWORD ProcessId; CHAR Buffer[1]; } * pDBMonBuffer = NULL;
/* event: signaled by the debug message monitor when OutputDebugString can write /* event: signaled by the debug message monitor when OutputDebugString can write
to the shared buffer */ to the shared buffer */
volatile HANDLE hDBMonBufferReady = NULL; volatile HANDLE hDBMonBufferReady = NULL;
/* event: to be signaled by OutputDebugString when it's done writing to the /* event: to be signaled by OutputDebugString when it's done writing to the
shared buffer */ shared buffer */
volatile HANDLE hDBMonDataReady = NULL; volatile HANDLE hDBMonDataReady = NULL;
/* mutex not opened, and no previous attempts to open/create it */ /* mutex not opened, and no previous attempts to open/create it */
if(hDBMonMutex == NULL && !s_bDBMonMutexTriedOpen) if (hDBMonMutex == NULL && !s_bDBMonMutexTriedOpen)
{ {
/* open/create the mutex */ /* open/create the mutex */
hDBMonMutex = K32CreateDBMonMutex(); hDBMonMutex = K32CreateDBMonMutex();
/* store the handle */ /* store the handle */
s_hDBMonMutex = hDBMonMutex; s_hDBMonMutex = hDBMonMutex;
} }
_SEH2_TRY _SEH2_TRY
{ {
volatile PCHAR a_cBuffer = NULL; volatile PCHAR a_cBuffer = NULL;
/* opening the mutex failed */ /* opening the mutex failed */
if(hDBMonMutex == NULL) if (hDBMonMutex == NULL)
{ {
/* remember next time */ /* remember next time */
s_bDBMonMutexTriedOpen = TRUE; s_bDBMonMutexTriedOpen = TRUE;
} }
/* opening the mutex succeeded */ /* opening the mutex succeeded */
else else
{ {
do do
{ {
/* synchronize with other invocations of OutputDebugString */ /* synchronize with other invocations of OutputDebugString */
WaitForSingleObject(hDBMonMutex, INFINITE); WaitForSingleObject(hDBMonMutex, INFINITE);
/* buffer of the system-wide debug message monitor */ /* buffer of the system-wide debug message monitor */
hDBMonBuffer = OpenFileMappingW(SECTION_MAP_WRITE, FALSE, L"DBWIN_BUFFER"); hDBMonBuffer = OpenFileMappingW(SECTION_MAP_WRITE, FALSE, L"DBWIN_BUFFER");
/* couldn't open the buffer: send the string to the kernel debugger */ /* couldn't open the buffer: send the string to the kernel debugger */
if(hDBMonBuffer == NULL) break; if (hDBMonBuffer == NULL) break;
/* map the buffer */ /* map the buffer */
pDBMonBuffer = MapViewOfFile(hDBMonBuffer, pDBMonBuffer = MapViewOfFile(hDBMonBuffer,
SECTION_MAP_READ | SECTION_MAP_WRITE, SECTION_MAP_READ | SECTION_MAP_WRITE,
0, 0,
0, 0,
0); 0);
/* couldn't map the buffer: send the string to the kernel debugger */ /* couldn't map the buffer: send the string to the kernel debugger */
if(pDBMonBuffer == NULL) break; if (pDBMonBuffer == NULL) break;
/* open the event signaling that the buffer can be accessed */ /* open the event signaling that the buffer can be accessed */
hDBMonBufferReady = OpenEventW(SYNCHRONIZE, FALSE, L"DBWIN_BUFFER_READY"); hDBMonBufferReady = OpenEventW(SYNCHRONIZE, FALSE, L"DBWIN_BUFFER_READY");
/* couldn't open the event: send the string to the kernel debugger */ /* couldn't open the event: send the string to the kernel debugger */
if(hDBMonBufferReady == NULL) break; if (hDBMonBufferReady == NULL) break;
/* open the event to be signaled when the buffer has been filled */ /* open the event to be signaled when the buffer has been filled */
hDBMonDataReady = OpenEventW(EVENT_MODIFY_STATE, FALSE, L"DBWIN_DATA_READY"); hDBMonDataReady = OpenEventW(EVENT_MODIFY_STATE, FALSE, L"DBWIN_DATA_READY");
} }
while(0); while(0);
/* we couldn't connect to the system-wide debug message monitor: send the /* we couldn't connect to the system-wide debug message monitor: send the
string to the kernel debugger */ string to the kernel debugger */
if(hDBMonDataReady == NULL) ReleaseMutex(hDBMonMutex); if (hDBMonDataReady == NULL) ReleaseMutex(hDBMonMutex);
} }
_SEH2_TRY _SEH2_TRY
{ {
/* size of the current output block */ /* size of the current output block */
volatile SIZE_T nRoundLen; volatile SIZE_T nRoundLen;
/* size of the remainder of the string */ /* size of the remainder of the string */
volatile SIZE_T nOutputStringLen; volatile SIZE_T nOutputStringLen;
/* output the whole string */ /* output the whole string */
nOutputStringLen = strlen(_OutputString); nOutputStringLen = strlen(_OutputString);
do do
{ {
/* we're connected to the debug monitor: /* we're connected to the debug monitor:
write the current block to the shared buffer */ write the current block to the shared buffer */
if(hDBMonDataReady) if (hDBMonDataReady)
{ {
/* wait a maximum of 10 seconds for the debug monitor /* wait a maximum of 10 seconds for the debug monitor
to finish processing the shared buffer */ to finish processing the shared buffer */
if(WaitForSingleObject(hDBMonBufferReady, 10000) != WAIT_OBJECT_0) if (WaitForSingleObject(hDBMonBufferReady, 10000) != WAIT_OBJECT_0)
{ {
/* timeout or failure: give up */ /* timeout or failure: give up */
break; break;
} }
/* write the process id into the buffer */ /* write the process id into the buffer */
pDBMonBuffer->ProcessId = GetCurrentProcessId(); pDBMonBuffer->ProcessId = GetCurrentProcessId();
/* write only as many bytes as they fit in the buffer */ /* write only as many bytes as they fit in the buffer */
if(nOutputStringLen > (PAGE_SIZE - sizeof(DWORD) - 1)) if (nOutputStringLen > (PAGE_SIZE - sizeof(DWORD) - 1))
nRoundLen = PAGE_SIZE - sizeof(DWORD) - 1; nRoundLen = PAGE_SIZE - sizeof(DWORD) - 1;
else else
nRoundLen = nOutputStringLen; nRoundLen = nOutputStringLen;
/* copy the current block into the buffer */ /* copy the current block into the buffer */
memcpy(pDBMonBuffer->Buffer, _OutputString, nRoundLen); memcpy(pDBMonBuffer->Buffer, _OutputString, nRoundLen);
/* null-terminate the current block */ /* null-terminate the current block */
pDBMonBuffer->Buffer[nRoundLen] = 0; pDBMonBuffer->Buffer[nRoundLen] = 0;
/* signal that the data contains meaningful data and can be read */ /* signal that the data contains meaningful data and can be read */
SetEvent(hDBMonDataReady); SetEvent(hDBMonDataReady);
} }
/* else, send the current block to the kernel debugger */ /* else, send the current block to the kernel debugger */
else else
{ {
/* output in blocks of 512 characters */ /* output in blocks of 512 characters */
a_cBuffer = (CHAR*)HeapAlloc(GetProcessHeap(), 0, 512); a_cBuffer = (CHAR*)HeapAlloc(GetProcessHeap(), 0, 512);
if (!a_cBuffer) if (!a_cBuffer)
{ {
DbgPrint("OutputDebugStringA: Failed\n"); DbgPrint("OutputDebugStringA: Failed\n");
break; break;
} }
/* write a maximum of 511 bytes */ /* write a maximum of 511 bytes */
if(nOutputStringLen > 510) if (nOutputStringLen > 510)
nRoundLen = 510; nRoundLen = 510;
else else
nRoundLen = nOutputStringLen; nRoundLen = nOutputStringLen;
/* copy the current block */ /* copy the current block */
memcpy(a_cBuffer, _OutputString, nRoundLen); memcpy(a_cBuffer, _OutputString, nRoundLen);
/* null-terminate the current block */ /* null-terminate the current block */
a_cBuffer[nRoundLen] = 0; a_cBuffer[nRoundLen] = 0;
/* send the current block to the kernel debugger */ /* send the current block to the kernel debugger */
DbgPrint("%s", a_cBuffer); DbgPrint("%s", a_cBuffer);
if (a_cBuffer) if (a_cBuffer)
{ {
HeapFree(GetProcessHeap(), 0, a_cBuffer); HeapFree(GetProcessHeap(), 0, a_cBuffer);
a_cBuffer = NULL; a_cBuffer = NULL;
} }
} }
/* move to the next block */ /* move to the next block */
_OutputString += nRoundLen; _OutputString += nRoundLen;
nOutputStringLen -= nRoundLen; nOutputStringLen -= nRoundLen;
} }
/* repeat until the string has been fully output */ /* repeat until the string has been fully output */
while (nOutputStringLen > 0); while (nOutputStringLen > 0);
} }
/* ignore access violations and let other exceptions fall through */ /* ignore access violations and let other exceptions fall through */
_SEH2_EXCEPT((_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) _SEH2_EXCEPT((_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{ {
if (a_cBuffer) if (a_cBuffer)
HeapFree(GetProcessHeap(), 0, a_cBuffer); HeapFree(GetProcessHeap(), 0, a_cBuffer);
/* string copied verbatim from Microsoft's kernel32.dll */ /* string copied verbatim from Microsoft's kernel32.dll */
DbgPrint("\nOutputDebugString faulted during output\n"); DbgPrint("\nOutputDebugString faulted during output\n");
} }
_SEH2_END; _SEH2_END;
} }
_SEH2_FINALLY _SEH2_FINALLY
{ {
/* close all the still open resources */ /* close all the still open resources */
if(hDBMonBufferReady) CloseHandle(hDBMonBufferReady); if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady);
if(pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer); if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer);
if(hDBMonBuffer) CloseHandle(hDBMonBuffer); if (hDBMonBuffer) CloseHandle(hDBMonBuffer);
if(hDBMonDataReady) CloseHandle(hDBMonDataReady); if (hDBMonDataReady) CloseHandle(hDBMonDataReady);
/* leave the critical section */ /* leave the critical section */
if(hDBMonDataReady != NULL) if (hDBMonDataReady != NULL)
ReleaseMutex(hDBMonMutex); ReleaseMutex(hDBMonMutex);
} }
_SEH2_END; _SEH2_END;
} }
_SEH2_END; _SEH2_END;
} }
/* /*

View file

@ -3,8 +3,8 @@
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: dll/win32/kernel32/client/except.c * FILE: dll/win32/kernel32/client/except.c
* PURPOSE: Exception functions * PURPOSE: Exception functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl) * PROGRAMMER: Ariadne (ariadne@xs4all.nl)
* modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ] * Modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 01/11/98 * Created 01/11/98
*/ */
@ -24,18 +24,18 @@ static const char*
_module_name_from_addr(const void* addr, void **module_start_addr, _module_name_from_addr(const void* addr, void **module_start_addr,
char* psz, size_t nChars) char* psz, size_t nChars)
{ {
MEMORY_BASIC_INFORMATION mbi; MEMORY_BASIC_INFORMATION mbi;
if (VirtualQuery(addr, &mbi, sizeof(mbi)) != sizeof(mbi) || if (VirtualQuery(addr, &mbi, sizeof(mbi)) != sizeof(mbi) ||
!GetModuleFileNameA((HMODULE)mbi.AllocationBase, psz, nChars)) !GetModuleFileNameA((HMODULE)mbi.AllocationBase, psz, nChars))
{ {
psz[0] = '\0'; psz[0] = '\0';
*module_start_addr = 0; *module_start_addr = 0;
} }
else else
{ {
*module_start_addr = (void *)mbi.AllocationBase; *module_start_addr = (void *)mbi.AllocationBase;
} }
return psz; return psz;
} }
@ -43,45 +43,45 @@ static VOID
_dump_context(PCONTEXT pc) _dump_context(PCONTEXT pc)
{ {
#ifdef _M_IX86 #ifdef _M_IX86
/* /*
* Print out the CPU registers * Print out the CPU registers
*/ */
DbgPrint("CS:EIP %x:%x\n", pc->SegCs&0xffff, pc->Eip ); DbgPrint("CS:EIP %x:%x\n", pc->SegCs&0xffff, pc->Eip );
DbgPrint("DS %x ES %x FS %x GS %x\n", pc->SegDs&0xffff, pc->SegEs&0xffff, DbgPrint("DS %x ES %x FS %x GS %x\n", pc->SegDs&0xffff, pc->SegEs&0xffff,
pc->SegFs&0xffff, pc->SegGs&0xfff); pc->SegFs&0xffff, pc->SegGs&0xfff);
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", pc->Eax, pc->Ebx, pc->Ecx); DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n", pc->Eax, pc->Ebx, pc->Ecx);
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x ESP: %.8x\n", pc->Edx, DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x ESP: %.8x\n", pc->Edx,
pc->Ebp, pc->Esi, pc->Esp); pc->Ebp, pc->Esi, pc->Esp);
DbgPrint("EDI: %.8x EFLAGS: %.8x\n", pc->Edi, pc->EFlags); DbgPrint("EDI: %.8x EFLAGS: %.8x\n", pc->Edi, pc->EFlags);
#elif defined(_M_AMD64) #elif defined(_M_AMD64)
DbgPrint("CS:RIP %x:%I64x\n", pc->SegCs&0xffff, pc->Rip ); DbgPrint("CS:RIP %x:%I64x\n", pc->SegCs&0xffff, pc->Rip );
DbgPrint("DS %x ES %x FS %x GS %x\n", pc->SegDs&0xffff, pc->SegEs&0xffff, DbgPrint("DS %x ES %x FS %x GS %x\n", pc->SegDs&0xffff, pc->SegEs&0xffff,
pc->SegFs&0xffff, pc->SegGs&0xfff); pc->SegFs&0xffff, pc->SegGs&0xfff);
DbgPrint("RAX: %I64x RBX: %I64x RCX: %I64x RDI: %I64x\n", pc->Rax, pc->Rbx, pc->Rcx, pc->Rdi); DbgPrint("RAX: %I64x RBX: %I64x RCX: %I64x RDI: %I64x\n", pc->Rax, pc->Rbx, pc->Rcx, pc->Rdi);
DbgPrint("RDX: %I64x RBP: %I64x RSI: %I64x RSP: %I64x\n", pc->Rdx, pc->Rbp, pc->Rsi, pc->Rsp); DbgPrint("RDX: %I64x RBP: %I64x RSI: %I64x RSP: %I64x\n", pc->Rdx, pc->Rbp, pc->Rsi, pc->Rsp);
DbgPrint("R8: %I64x R9: %I64x R10: %I64x R11: %I64x\n", pc->R8, pc->R9, pc->R10, pc->R11); DbgPrint("R8: %I64x R9: %I64x R10: %I64x R11: %I64x\n", pc->R8, pc->R9, pc->R10, pc->R11);
DbgPrint("R12: %I64x R13: %I64x R14: %I64x R15: %I64x\n", pc->R12, pc->R13, pc->R14, pc->R15); DbgPrint("R12: %I64x R13: %I64x R14: %I64x R15: %I64x\n", pc->R12, pc->R13, pc->R14, pc->R15);
DbgPrint("EFLAGS: %.8x\n", pc->EFlags); DbgPrint("EFLAGS: %.8x\n", pc->EFlags);
#elif defined(_M_ARM) #elif defined(_M_ARM)
DbgPrint("PC: %08lx LR: %08lx SP: %08lx\n", pc->Pc); DbgPrint("PC: %08lx LR: %08lx SP: %08lx\n", pc->Pc);
DbgPrint("R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n", pc->R0, pc->R1, pc->R2, pc->R3); DbgPrint("R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n", pc->R0, pc->R1, pc->R2, pc->R3);
DbgPrint("R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n", pc->R4, pc->R5, pc->R6, pc->R7); DbgPrint("R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n", pc->R4, pc->R5, pc->R6, pc->R7);
DbgPrint("R8: %08lx R9: %08lx R10: %08lx R11: %08lx\n", pc->R8, pc->R9, pc->R10, pc->R11); DbgPrint("R8: %08lx R9: %08lx R10: %08lx R11: %08lx\n", pc->R8, pc->R9, pc->R10, pc->R11);
DbgPrint("R12: %08lx CPSR: %08lx FPSCR: %08lx\n", pc->R12, pc->Cpsr, pc->R1, pc->Fpscr, pc->R3); DbgPrint("R12: %08lx CPSR: %08lx FPSCR: %08lx\n", pc->R12, pc->Cpsr, pc->R1, pc->Fpscr, pc->R3);
#else #else
#error "Unknown architecture" #error "Unknown architecture"
#endif #endif
} }
static VOID static VOID
PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo) PrintStackTrace(IN PEXCEPTION_POINTERS ExceptionInfo)
{ {
PVOID StartAddr; PVOID StartAddr;
CHAR szMod[128] = ""; CHAR szMod[128] = "";
PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord; PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord;
PCONTEXT ContextRecord = ExceptionInfo->ContextRecord; PCONTEXT ContextRecord = ExceptionInfo->ContextRecord;
/* Print a stack trace. */ /* Print a stack trace */
DbgPrint("Unhandled exception\n"); DbgPrint("Unhandled exception\n");
DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode); DbgPrint("ExceptionCode: %8x\n", ExceptionRecord->ExceptionCode);
@ -91,7 +91,7 @@ PrintStackTrace(struct _EXCEPTION_POINTERS *ExceptionInfo)
DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]); DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]);
} }
_dump_context (ContextRecord); _dump_context(ContextRecord);
_module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)); _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod));
DbgPrint("Address:\n %8x+%-8x %s\n", DbgPrint("Address:\n %8x+%-8x %s\n",
(PVOID)StartAddr, (PVOID)StartAddr,
@ -368,9 +368,7 @@ RaiseException(IN DWORD dwExceptionCode,
{ {
/* We do, normalize the count */ /* We do, normalize the count */
if (nNumberOfArguments > EXCEPTION_MAXIMUM_PARAMETERS) if (nNumberOfArguments > EXCEPTION_MAXIMUM_PARAMETERS)
{
nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS; nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS;
}
/* Set the count of parameters and copy them */ /* Set the count of parameters and copy them */
ExceptionRecord.NumberParameters = nNumberOfArguments; ExceptionRecord.NumberParameters = nNumberOfArguments;
@ -388,14 +386,14 @@ RaiseException(IN DWORD dwExceptionCode,
} }
/* Trace the wine special error and show the modulename and functionname */ /* Trace the wine special error and show the modulename and functionname */
if (dwExceptionCode == 0x80000100 /*EXCEPTION_WINE_STUB*/) if (dwExceptionCode == 0x80000100 /* EXCEPTION_WINE_STUB */)
{ {
/* Numbers of parameter must be equal to two */ /* Numbers of parameter must be equal to two */
if (ExceptionRecord.NumberParameters == 2) if (ExceptionRecord.NumberParameters == 2)
{ {
DPRINT1("Missing function in : %s\n", ExceptionRecord.ExceptionInformation[0]); DPRINT1("Missing function in : %s\n", ExceptionRecord.ExceptionInformation[0]);
DPRINT1("with the functionname : %s\n", ExceptionRecord.ExceptionInformation[1]); DPRINT1("with the functionname : %s\n", ExceptionRecord.ExceptionInformation[1]);
} }
} }
/* Raise the exception */ /* Raise the exception */