From: Stefan Ginsberg Date: Sun, 25 Oct 2009 15:56:38 +0000 (+0000) Subject: - DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Proto... X-Git-Tag: ReactOS-0.3.11~305 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=eae6521fb257869a049e1d4d703468a9b3ff27cc - DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Protocol 6 uses the DBGKD_ANY_WAIT_STATE_CHANGE structure which is sized according to the largest control-report structure (AMD64_DBGKD_CONTROL_REPORT currently), and is larger than DBGKD_WAIT_STATE_CHANGE64 on x86. This worked because our DBGKD_WAIT_STATE_CHANGE32/64 structures contained incorrect DBGKD_CONTROL_REPORT (used) and CONTEXT (unused) members that sized up the wait-state structure to pass WinDbg's length verification! It actually becomes larger than DBGKD_ANY_WAIT_STATE_CHANGE, but WinDbg only seems bail out only if the structure is too small. Remove the incorrect members from the protocol 5 structures and change to DBGKD_ANY_WAIT_STATE_CHANGE everywhere. - Correct the value of SIZE_OF_FX_REGISTERS -- it was 4 times too low which resulted in KeContextToTrapFrame not properly clearing out the XMM register area. Correct the define and move it out from ke.h to x86's ketypes.h and use it in the FXSAVE format structure. Also remove the IOPM definitions from ke.h as they have been in the NDK for a while. - KD uses STRINGs, not ANSI_STRINGs -- they are the same thing, but let's be consistent. - ExceptionRecord32To64 should be available for both 32 and 64 bit builds (and it shouldn't be a forceinline). Get rid of CopyExceptionRecord and determine if we need to convert or can just copy it directly instead. - Use _WIN64 instead of _M_AMD64 when determining if we need to set the DBGKD_VERS_FLAG_PTR64 flag. - Don't check Nt/DbgQueryDebugFilterState for zero or nonzero -- it actually returns TRUE, FALSE or STATUS_INVALID_PARAMETER_1! Check for != TRUE in preparation for proper implementation of NtSet/QueryDebugFilterState. - Fix Format parameter of DbgPrintReturnControlC -- it is const like the other DbgPrint* routines. - Be consistent with the types used in debug.c and don't set local variables to zero if we are going to return to caller -- this doesn't seem to be required anymore. - Fix DebugService and DebugService2: DebugService should take a ULONG followed by 4 pointers and DebugService2 doesn't return anything. - Use ZwCurrentProcess() instead of -1 or 0xFFFFFFFF (which is incorrect for 64-bit) for the ProcessId parameter of DbgLoad/UnloadImageSymbols to clarify what is being passed. Don't use ZwCurrentProcess() in KeBugCheckWithTf for the pointer parameter of DbgUnLoadImageSymbols either. Use MAXULONG_PTR casted to PVOID instead. - Use better named and sized variables in KdpTrap for setting the "return register" in the caller's CONTEXT. - Correct and clarify the comment documenting under what conditions we pass user mode exceptions to the kernel debugger. svn path=/trunk/; revision=43741 --- diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index 491d2ba8fea..6b957b0320b 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -10359,23 +10359,23 @@ NTAPI vDbgPrintEx( IN ULONG ComponentId, IN ULONG Level, - IN LPCSTR Format, + IN PCCH Format, IN va_list ap); ULONG NTAPI vDbgPrintExWithPrefix( - IN LPCSTR Prefix, + IN PCCH Prefix, IN ULONG ComponentId, IN ULONG Level, - IN LPCSTR Format, + IN PCCH Format, IN va_list ap); NTKERNELAPI ULONG DDKCDECLAPI DbgPrintReturnControlC( - IN PCH Format, + IN PCCH Format, IN ...); ULONG diff --git a/reactos/include/ndk/i386/ketypes.h b/reactos/include/ndk/i386/ketypes.h index e9c8d7feb5b..e94658771ef 100644 --- a/reactos/include/ndk/i386/ketypes.h +++ b/reactos/include/ndk/i386/ketypes.h @@ -131,6 +131,11 @@ Author: (USHORT)(sizeof(KTSS)) : \ (USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap)) +// +// Size of the XMM register save area in the FXSAVE format +// +#define SIZE_OF_FX_REGISTERS 128 + // // Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual) // @@ -333,7 +338,7 @@ typedef struct _FXSAVE_FORMAT ULONG DataSelector; ULONG MXCsr; ULONG MXCsrMask; - UCHAR RegisterArea[128]; + UCHAR RegisterArea[SIZE_OF_FX_REGISTERS]; UCHAR Reserved3[128]; UCHAR Reserved4[224]; UCHAR Align16Byte[8]; diff --git a/reactos/include/ndk/rtlfuncs.h b/reactos/include/ndk/rtlfuncs.h index fa2199c828c..7f33e8011f9 100644 --- a/reactos/include/ndk/rtlfuncs.h +++ b/reactos/include/ndk/rtlfuncs.h @@ -2669,7 +2669,7 @@ DbgBreakPoint( VOID NTAPI DbgLoadImageSymbols( - IN PANSI_STRING Name, + IN PSTRING Name, IN PVOID Base, IN ULONG_PTR ProcessId ); @@ -2677,7 +2677,7 @@ DbgLoadImageSymbols( VOID NTAPI DbgUnLoadImageSymbols( - IN PANSI_STRING Name, + IN PSTRING Name, IN PVOID Base, IN ULONG_PTR ProcessId ); diff --git a/reactos/include/reactos/windbgkd.h b/reactos/include/reactos/windbgkd.h index bc88bf590f1..9aafb2c7635 100644 --- a/reactos/include/reactos/windbgkd.h +++ b/reactos/include/reactos/windbgkd.h @@ -446,8 +446,6 @@ typedef struct _DBGKD_WAIT_STATE_CHANGE32 DBGKM_EXCEPTION32 Exception; DBGKD_LOAD_SYMBOLS32 LoadSymbols; } u; - DBGKD_CONTROL_REPORT ControlReport; - CONTEXT Context; } DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32; typedef struct _DBGKD_WAIT_STATE_CHANGE64 @@ -463,8 +461,6 @@ typedef struct _DBGKD_WAIT_STATE_CHANGE64 DBGKM_EXCEPTION64 Exception; DBGKD_LOAD_SYMBOLS64 LoadSymbols; } u; - DBGKD_CONTROL_REPORT ControlReport; - CONTEXT Context; } DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64; typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE @@ -864,15 +860,10 @@ typedef struct _DBGKD_TRACE_IO } u; } DBGKD_TRACE_IO, *PDBGKD_TRACE_IO; -#if defined(_M_AMD64) - -#define CopyExceptionRecord(Ex64From, Ex64To) \ - RtlCopyMemory(Ex64To, Ex64From, sizeof(EXCEPTION_RECORD64)) - -#else - -FORCEINLINE +static +__inline VOID +NTAPI ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32, OUT PEXCEPTION_RECORD64 Ex64) { @@ -890,9 +881,4 @@ ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32, } } -#define CopyExceptionRecord(Ex32From, Ex64To) \ - ExceptionRecord32To64((PEXCEPTION_RECORD32)Ex32From, Ex64To) - -#endif - #endif diff --git a/reactos/lib/drivers/ip/network/routines.c b/reactos/lib/drivers/ip/network/routines.c index d25ecd6ba65..6407ecb25c7 100644 --- a/reactos/lib/drivers/ip/network/routines.c +++ b/reactos/lib/drivers/ip/network/routines.c @@ -94,8 +94,8 @@ VOID DisplayTCPPacket( UINT Length; PCHAR Buffer; - if (!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK)) || - !(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_TCP | DPFLTR_MASK))) { + if ((DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK) != TRUE) || + (DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_TCP | DPFLTR_MASK) != TRUE)) { return; } @@ -139,8 +139,8 @@ VOID DisplayIPPacket( PNDIS_BUFFER NextBuffer; PCHAR CharBuffer; - if (!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK)) || - !(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_IP | DPFLTR_MASK))) { + if ((DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK) != TRUE) || + (DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_IP | DPFLTR_MASK) != TRUE)) { return; } diff --git a/reactos/lib/rtl/debug.c b/reactos/lib/rtl/debug.c index 1ba40c70af9..5ac10e7573d 100644 --- a/reactos/lib/rtl/debug.c +++ b/reactos/lib/rtl/debug.c @@ -16,29 +16,29 @@ /* PRIVATE FUNCTIONS ********************************************************/ -NTSTATUS +ULONG NTAPI -DebugPrint(IN PANSI_STRING DebugString, +DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level) { /* Call the Debug Service */ return DebugService(BREAKPOINT_PRINT, DebugString->Buffer, - DebugString->Length, + UlongToPtr(DebugString->Length), UlongToPtr(ComponentId), UlongToPtr(Level)); } -NTSTATUS +ULONG NTAPI -DebugPrompt(IN PCSTRING Output, +DebugPrompt(IN PSTRING Output, IN PSTRING Input) { /* Call the Debug Service */ return DebugService(BREAKPOINT_PROMPT, Output->Buffer, - Output->Length, + UlongToPtr(Output->Length), Input->Buffer, UlongToPtr(Input->MaximumLength)); } @@ -47,22 +47,22 @@ DebugPrompt(IN PCSTRING Output, ULONG NTAPI -vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix, +vDbgPrintExWithPrefixInternal(IN PCCH Prefix, IN ULONG ComponentId, IN ULONG Level, - IN LPCSTR Format, + IN PCCH Format, IN va_list ap, IN BOOLEAN HandleBreakpoint) { NTSTATUS Status; - ANSI_STRING DebugString; + STRING DebugString; CHAR Buffer[512]; ULONG Length, PrefixLength; EXCEPTION_RECORD ExceptionRecord; /* Check if we should print it or not */ if ((ComponentId != MAXULONG) && - !(NtQueryDebugFilterState(ComponentId, Level))) + (NtQueryDebugFilterState(ComponentId, Level)) != TRUE) { /* This message is masked */ return STATUS_SUCCESS; @@ -90,7 +90,6 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix, _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Fail */ - Length = PrefixLength = 0; _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; @@ -160,10 +159,10 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix, */ ULONG NTAPI -vDbgPrintExWithPrefix(IN LPCSTR Prefix, +vDbgPrintExWithPrefix(IN PCCH Prefix, IN ULONG ComponentId, IN ULONG Level, - IN LPCSTR Format, + IN PCCH Format, IN va_list ap) { /* Call the internal routine that also handles ControlC */ @@ -182,7 +181,7 @@ ULONG NTAPI vDbgPrintEx(IN ULONG ComponentId, IN ULONG Level, - IN LPCSTR Format, + IN PCCH Format, IN va_list ap) { /* Call the internal routine that also handles ControlC */ @@ -202,19 +201,19 @@ __cdecl DbgPrint(PCCH Format, ...) { - ULONG n; + ULONG Status; va_list ap; /* Call the internal routine that also handles ControlC */ va_start(ap, Format); - n = vDbgPrintExWithPrefixInternal("", - -1, - DPFLTR_ERROR_LEVEL, - Format, - ap, - TRUE); + Status = vDbgPrintExWithPrefixInternal("", + -1, + DPFLTR_ERROR_LEVEL, + Format, + ap, + TRUE); va_end(ap); - return n; + return Status; } /* @@ -227,19 +226,19 @@ DbgPrintEx(IN ULONG ComponentId, IN PCCH Format, ...) { - ULONG n; + ULONG Status; va_list ap; /* Call the internal routine that also handles ControlC */ va_start(ap, Format); - n = vDbgPrintExWithPrefixInternal("", - ComponentId, - Level, - Format, - ap, - TRUE); + Status = vDbgPrintExWithPrefixInternal("", + ComponentId, + Level, + Format, + ap, + TRUE); va_end(ap); - return n; + return Status; } /* @@ -247,22 +246,22 @@ DbgPrintEx(IN ULONG ComponentId, */ ULONG __cdecl -DbgPrintReturnControlC(PCH Format, +DbgPrintReturnControlC(PCCH Format, ...) { - ULONG n; + ULONG Status; va_list ap; /* Call the internal routine that also handles ControlC */ va_start(ap, Format); - n = vDbgPrintExWithPrefixInternal("", - -1, - DPFLTR_ERROR_LEVEL, - Format, - ap, - FALSE); + Status = vDbgPrintExWithPrefixInternal("", + -1, + DPFLTR_ERROR_LEVEL, + Format, + ap, + FALSE); va_end(ap); - return n; + return Status; } /* @@ -274,7 +273,7 @@ DbgPrompt(IN PCCH Prompt, OUT PCH Response, IN ULONG MaximumResponseLength) { - CSTRING Output; + STRING Output; STRING Input; /* Setup the input string */ @@ -283,7 +282,7 @@ DbgPrompt(IN PCCH Prompt, /* Setup the output string */ Output.Length = strlen(Prompt); - Output.Buffer = Prompt; + Output.Buffer = (PCH)Prompt; /* Call the system service */ return DebugPrompt(&Output, &Input); @@ -319,7 +318,7 @@ DbgSetDebugFilterState(IN ULONG ComponentId, */ VOID NTAPI -DbgLoadImageSymbols(IN PANSI_STRING Name, +DbgLoadImageSymbols(IN PSTRING Name, IN PVOID Base, IN ULONG_PTR ProcessId) { @@ -328,7 +327,7 @@ DbgLoadImageSymbols(IN PANSI_STRING Name, /* Setup the symbol data */ SymbolInfo.BaseOfDll = Base; - SymbolInfo.ProcessId = (ULONG)ProcessId; + SymbolInfo.ProcessId = ProcessId; /* Get NT Headers */ NtHeader = RtlImageNtHeader(Base); @@ -353,7 +352,7 @@ DbgLoadImageSymbols(IN PANSI_STRING Name, */ VOID NTAPI -DbgUnLoadImageSymbols(IN PANSI_STRING Name, +DbgUnLoadImageSymbols(IN PSTRING Name, IN PVOID Base, IN ULONG_PTR ProcessId) { @@ -361,7 +360,7 @@ DbgUnLoadImageSymbols(IN PANSI_STRING Name, /* Setup the symbol data */ SymbolInfo.BaseOfDll = Base; - SymbolInfo.ProcessId = (ULONG)ProcessId; + SymbolInfo.ProcessId = ProcessId; SymbolInfo.CheckSum = SymbolInfo.SizeOfImage = 0; /* Load the symbols */ diff --git a/reactos/lib/rtl/powerpc/debug.c b/reactos/lib/rtl/powerpc/debug.c index dfedd25a629..41f8f79a8a5 100644 --- a/reactos/lib/rtl/powerpc/debug.c +++ b/reactos/lib/rtl/powerpc/debug.c @@ -9,12 +9,12 @@ NTKERNELAPI VOID DbgBreakPointWithStatus(ULONG Status) { __asm__("ti 31,0,0"); } -NTSTATUS +ULONG NTAPI DebugService -(ULONG Service, const void *Buffer, ULONG Length, PVOID Arg1, PVOID Arg2) +(ULONG Service, PVOID Argument1, PVOID Argument1, PVOID Argument3, PVOID Argument4) { - NTSTATUS Result; + ULONG Result; __asm__("mr 0,%1\n\t" "mr 3,%2\n\t" "mr 4,%3\n\t" @@ -26,17 +26,16 @@ DebugService "=r" (Result) : "r" (0x10000), "r" (Service), - "r" (Buffer), - "r" (Length), - "r" (Arg1), - "r" (Arg2) ); + "r" (Argument1), + "r" (Argument2), + "r" (Argument3), + "r" (Argument4) ); return Result; } -NTSTATUS +VOID NTAPI DebugService2 (PVOID Arg1, PVOID Arg2, ULONG Service) { - return STATUS_SUCCESS; } diff --git a/reactos/lib/rtl/rtlp.h b/reactos/lib/rtl/rtlp.h index e0f2436e8b6..297b0bc0952 100644 --- a/reactos/lib/rtl/rtlp.h +++ b/reactos/lib/rtl/rtlp.h @@ -145,20 +145,26 @@ VOID NTAPI RtlpCaptureContext(OUT PCONTEXT ContextRecord); -/* i386/debug.S */ -NTSTATUS -NTAPI -DebugService(IN ULONG Service, - IN const void* Buffer, - IN ULONG Length, - IN PVOID Argument1, - IN PVOID Argument2); +// +// Debug Service calls +// +ULONG +NTAPI +DebugService( + IN ULONG Service, + IN PVOID Argument1, + IN PVOID Argument2, + IN PVOID Argument3, + IN PVOID Argument4 +); -NTSTATUS +VOID NTAPI -DebugService2(IN PVOID Argument1, - IN PVOID Argument2, - IN ULONG Service); +DebugService2( + IN PVOID Argument1, + IN PVOID Argument2, + IN ULONG Service +); /* Tags for the String Allocators */ #define TAG_USTR 'RTSU' diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index d6415411be6..012f9fa81a6 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -734,7 +734,7 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PLDR_DATA_TABLE_ENTRY LdrEntry; BOOLEAN OverFlow = FALSE; CHAR NameBuffer[256]; - ANSI_STRING SymbolString; + STRING SymbolString; /* Loop the driver list */ NextEntry = LoaderBlock->LoadOrderListHead.Flink; @@ -799,13 +799,13 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Check if the buffer was ok */ if (!OverFlow) { - /* Initialize the ANSI_STRING for the debugger */ + /* Initialize the STRING for the debugger */ RtlInitString(&SymbolString, NameBuffer); /* Load the symbols */ DbgLoadImageSymbols(&SymbolString, LdrEntry->DllBase, - 0xFFFFFFFF); + (ULONG_PTR)ZwCurrentProcess()); } } diff --git a/reactos/ntoskrnl/include/internal/kd64.h b/reactos/ntoskrnl/include/internal/kd64.h index fb193a4b60e..a3e9d280f7e 100644 --- a/reactos/ntoskrnl/include/internal/kd64.h +++ b/reactos/ntoskrnl/include/internal/kd64.h @@ -217,7 +217,7 @@ VOID NTAPI KdpSymbol( IN PSTRING DllPath, - IN PKD_SYMBOLS_INFO DllBase, + IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, @@ -322,7 +322,7 @@ KdpGetStateChange( VOID NTAPI KdpSetContextState( - IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, + IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context ); diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index a85180e8daa..4173a3a85e3 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -180,16 +180,6 @@ extern ULONG KiDPCTimeout; /* One of the Reserved Wait Blocks, this one is for the Thread's Timer */ #define TIMER_WAIT_BLOCK 0x3L -/* IOPM Definitions */ -#define IO_ACCESS_MAP_NONE 0 -#define IOPM_OFFSET FIELD_OFFSET(KTSS, IoMaps[0].IoMap) -#define KiComputeIopmOffset(MapNumber) \ - (MapNumber == IO_ACCESS_MAP_NONE) ? \ - (USHORT)(sizeof(KTSS)) : \ - (USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap)) - -#define SIZE_OF_FX_REGISTERS 32 - /* INTERNAL KERNEL FUNCTIONS ************************************************/ VOID diff --git a/reactos/ntoskrnl/kd/kdmain.c b/reactos/ntoskrnl/kd/kdmain.c index 791be4e8326..bc541733103 100644 --- a/reactos/ntoskrnl/kd/kdmain.c +++ b/reactos/ntoskrnl/kd/kdmain.c @@ -368,13 +368,13 @@ NtQueryDebugFilterState(IN ULONG ComponentId, if (ComponentId == KdComponentTable[i].ComponentId) { /* Check if mask are matching */ - return (Level & KdComponentTable[i].Level) != 0; + return (Level & KdComponentTable[i].Level) ? TRUE : FALSE; } } } /* Entry not found in the table, use default mask */ - return (Level & Kd_DEFAULT_MASK) != 0; + return (Level & Kd_DEFAULT_MASK) ? TRUE : FALSE; } NTSTATUS diff --git a/reactos/ntoskrnl/kd64/amd64/kdsup.c b/reactos/ntoskrnl/kd64/amd64/kdsup.c index f31a4e8ae3c..c8e83a15495 100644 --- a/reactos/ntoskrnl/kd64/amd64/kdsup.c +++ b/reactos/ntoskrnl/kd64/amd64/kdsup.c @@ -28,7 +28,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State, VOID NTAPI -KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, +KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context) { UNIMPLEMENTED; diff --git a/reactos/ntoskrnl/kd64/arm/kdsup.c b/reactos/ntoskrnl/kd64/arm/kdsup.c index 9ba90450c4e..c763b6f8086 100644 --- a/reactos/ntoskrnl/kd64/arm/kdsup.c +++ b/reactos/ntoskrnl/kd64/arm/kdsup.c @@ -28,7 +28,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State, VOID NTAPI -KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, +KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context) { UNIMPLEMENTED; diff --git a/reactos/ntoskrnl/kd64/i386/kdsup.c b/reactos/ntoskrnl/kd64/i386/kdsup.c index b232a023f9a..db2dc8b496a 100644 --- a/reactos/ntoskrnl/kd64/i386/kdsup.c +++ b/reactos/ntoskrnl/kd64/i386/kdsup.c @@ -69,7 +69,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State, VOID NTAPI -KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange, +KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context) { PKPRCB Prcb = KeGetCurrentPrcb(); diff --git a/reactos/ntoskrnl/kd64/kdapi.c b/reactos/ntoskrnl/kd64/kdapi.c index 329fec5de54..6efa5f3f03c 100644 --- a/reactos/ntoskrnl/kd64/kdapi.c +++ b/reactos/ntoskrnl/kd64/kdapi.c @@ -267,7 +267,7 @@ VOID NTAPI KdpSetCommonState(IN ULONG NewState, IN PCONTEXT Context, - IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange) + IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange) { USHORT InstructionCount; BOOLEAN HadBreakpoints; @@ -280,9 +280,9 @@ KdpSetCommonState(IN ULONG NewState, WaitStateChange->Thread = (ULONG64)(LONG_PTR)KeGetCurrentThread(); WaitStateChange->ProgramCounter = (ULONG64)(LONG_PTR)KeGetContextPc(Context); - /* Zero out the Control Report */ - RtlZeroMemory(&WaitStateChange->ControlReport, - sizeof(DBGKD_CONTROL_REPORT)); + /* Zero out the entire Control Report */ + RtlZeroMemory(&WaitStateChange->AnyControlReport, + sizeof(DBGKD_ANY_CONTROL_REPORT)); /* Now copy the instruction stream and set the count */ RtlCopyMemory(&WaitStateChange->ControlReport.InstructionStream[0], @@ -1296,7 +1296,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName, { PSTRING ExtraData; STRING Data, Header; - DBGKD_WAIT_STATE_CHANGE64 WaitStateChange; + DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange; KCONTINUE_STATUS Status; /* Start wait loop */ @@ -1335,7 +1335,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName, } /* Setup the header */ - Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64); + Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE); Header.Buffer = (PCHAR)&WaitStateChange; /* Send the packet */ @@ -1356,7 +1356,7 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, IN BOOLEAN SecondChanceException) { STRING Header, Data; - DBGKD_WAIT_STATE_CHANGE64 WaitStateChange; + DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange; KCONTINUE_STATUS Status; /* Start report loop */ @@ -1366,15 +1366,21 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, KdpSetCommonState(DbgKdExceptionStateChange, Context, &WaitStateChange); /* Copy the Exception Record and set First Chance flag */ - CopyExceptionRecord(ExceptionRecord, - &WaitStateChange.u.Exception.ExceptionRecord); +#if !defined(_WIN64) + ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord, + &WaitStateChange.u.Exception.ExceptionRecord); +#else + RtlCopyMemory(&WaitStateChange.u.Exception.ExceptionRecord, + ExceptionRecord, + sizeof(EXCEPTION_RECORD)); +#endif WaitStateChange.u.Exception.FirstChance = !SecondChanceException; /* Now finish creating the structure */ KdpSetContextState(&WaitStateChange, Context); /* Setup the actual header to send to KD */ - Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64); + Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE); Header.Buffer = (PCHAR)&WaitStateChange; /* Setup the trace data */ @@ -1828,20 +1834,26 @@ KdRefreshDebuggerNotPresent(VOID) return KdDebuggerNotPresent; } +/* + * @unimplemented + */ NTSTATUS NTAPI -NtQueryDebugFilterState(ULONG ComponentId, - ULONG Level) +NtQueryDebugFilterState(IN ULONG ComponentId, + IN ULONG Level) { /* HACK */ return STATUS_SUCCESS; } +/* + * @unimplemented + */ NTSTATUS NTAPI -NtSetDebugFilterState(ULONG ComponentId, - ULONG Level, - BOOLEAN State) +NtSetDebugFilterState(IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State) { /* HACK */ return STATUS_SUCCESS; diff --git a/reactos/ntoskrnl/kd64/kddata.c b/reactos/ntoskrnl/kd64/kddata.c index 9af857afbd9..c911037d4f6 100644 --- a/reactos/ntoskrnl/kd64/kddata.c +++ b/reactos/ntoskrnl/kd64/kddata.c @@ -360,7 +360,7 @@ DBGKD_GET_VERSION64 KdVersionBlock = 0, DBGKD_64BIT_PROTOCOL_VERSION2, CURRENT_KD_SECONDARY_VERSION, -#if defined(_M_AMD64) +#if defined(_WIN64) DBGKD_VERS_FLAG_DATA | DBGKD_VERS_FLAG_PTR64, #else DBGKD_VERS_FLAG_DATA, diff --git a/reactos/ntoskrnl/kd64/kdinit.c b/reactos/ntoskrnl/kd64/kdinit.c index 81395643710..77c0b1aa192 100644 --- a/reactos/ntoskrnl/kd64/kdinit.c +++ b/reactos/ntoskrnl/kd64/kdinit.c @@ -75,7 +75,7 @@ KdInitSystem(IN ULONG BootPhase, { BOOLEAN EnableKd, DisableKdAfterInit = FALSE, BlockEnable; LPSTR CommandLine, DebugLine, DebugOptionStart, DebugOptionEnd; - ANSI_STRING ImageName; + STRING ImageName; PLDR_DATA_TABLE_ENTRY LdrEntry; PLIST_ENTRY NextEntry; ULONG i, j, Length, DebugOptionLength; @@ -350,8 +350,10 @@ KdInitSystem(IN ULONG BootPhase, NameBuffer[j] = ANSI_NULL; /* Load symbols for image */ - RtlInitAnsiString(&ImageName, NameBuffer); - DbgLoadImageSymbols(&ImageName, LdrEntry->DllBase, -1); + RtlInitString(&ImageName, NameBuffer); + DbgLoadImageSymbols(&ImageName, + LdrEntry->DllBase, + (ULONG_PTR)ZwCurrentProcess()); /* Go to the next entry */ NextEntry = NextEntry->Flink; diff --git a/reactos/ntoskrnl/kd64/kdprint.c b/reactos/ntoskrnl/kd64/kdprint.c index 135b1ed8d48..11380c79042 100644 --- a/reactos/ntoskrnl/kd64/kdprint.c +++ b/reactos/ntoskrnl/kd64/kdprint.c @@ -138,7 +138,7 @@ KdpCommandString(IN ULONG Length, VOID NTAPI KdpSymbol(IN PSTRING DllPath, - IN PKD_SYMBOLS_INFO DllBase, + IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, @@ -163,7 +163,7 @@ KdpSymbol(IN PSTRING DllPath, /* Report the new state */ Status = KdpReportLoadSymbolsStateChange(DllPath, - DllBase, + SymbolInfo, Unload, &Prcb->ProcessorState. ContextFrame); @@ -243,7 +243,7 @@ KdpPrint(IN ULONG ComponentId, { NTSTATUS ReturnStatus; BOOLEAN Entered; - ANSI_STRING AnsiString; + STRING OutputString; /* Assume failure */ *Status = FALSE; @@ -268,12 +268,12 @@ KdpPrint(IN ULONG ComponentId, /* FIXME: Support user-mode */ } - /* Setup the ANSI string */ - AnsiString.Buffer = String; - AnsiString.Length = Length; + /* Setup the output string */ + OutputString.Buffer = String; + OutputString.Length = Length; /* Log the print */ - //KdLogDbgPrint(&AnsiString); + //KdLogDbgPrint(&OutputString); /* Check for a debugger */ if (KdDebuggerNotPresent) @@ -287,7 +287,7 @@ KdpPrint(IN ULONG ComponentId, Entered = KdEnterDebugger(TrapFrame, ExceptionFrame); /* Print the string */ - if (KdpPrintString(&AnsiString)) + if (KdpPrintString(&OutputString)) { /* User pressed CTRL-C, breakpoint on return */ ReturnStatus = STATUS_BREAKPOINT; diff --git a/reactos/ntoskrnl/kd64/kdtrap.c b/reactos/ntoskrnl/kd64/kdtrap.c index aed14beba55..28a72e8d12b 100644 --- a/reactos/ntoskrnl/kd64/kdtrap.c +++ b/reactos/ntoskrnl/kd64/kdtrap.c @@ -135,8 +135,10 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, IN BOOLEAN SecondChanceException) { BOOLEAN Unload = FALSE; - ULONG_PTR ProgramCounter, ReturnValue; + ULONG_PTR ProgramCounter; BOOLEAN Status = FALSE; + NTSTATUS ReturnStatus; + USHORT ReturnLength; /* * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or @@ -156,38 +158,38 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, case BREAKPOINT_PRINT: /* Call the worker routine */ - ReturnValue = KdpPrint((ULONG)KdpGetFirstParameter(ContextRecord), - (ULONG)KdpGetSecondParameter(ContextRecord), - (LPSTR)ExceptionRecord-> - ExceptionInformation[1], - (USHORT)ExceptionRecord-> - ExceptionInformation[2], - PreviousMode, - TrapFrame, - ExceptionFrame, - &Status); + ReturnStatus = KdpPrint((ULONG)KdpGetFirstParameter(ContextRecord), + (ULONG)KdpGetSecondParameter(ContextRecord), + (LPSTR)ExceptionRecord-> + ExceptionInformation[1], + (USHORT)ExceptionRecord-> + ExceptionInformation[2], + PreviousMode, + TrapFrame, + ExceptionFrame, + &Status); /* Update the return value for the caller */ - KeSetContextReturnRegister(ContextRecord, ReturnValue); + KeSetContextReturnRegister(ContextRecord, ReturnStatus); break; /* DbgPrompt */ case BREAKPOINT_PROMPT: /* Call the worker routine */ - ReturnValue = KdpPrompt((LPSTR)ExceptionRecord-> - ExceptionInformation[1], - (USHORT)ExceptionRecord-> - ExceptionInformation[2], - (LPSTR)KdpGetFirstParameter(ContextRecord), - (USHORT)KdpGetSecondParameter(ContextRecord), - PreviousMode, - TrapFrame, - ExceptionFrame); + ReturnLength = KdpPrompt((LPSTR)ExceptionRecord-> + ExceptionInformation[1], + (USHORT)ExceptionRecord-> + ExceptionInformation[2], + (LPSTR)KdpGetFirstParameter(ContextRecord), + (USHORT)KdpGetSecondParameter(ContextRecord), + PreviousMode, + TrapFrame, + ExceptionFrame); Status = TRUE; /* Update the return value for the caller */ - KeSetContextReturnRegister(ContextRecord, ReturnValue); + KeSetContextReturnRegister(ContextRecord, ReturnLength); break; /* DbgUnLoadImageSymbols */ diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index 056fb7b202a..499b134b858 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -1197,7 +1197,7 @@ KeBugCheckWithTf(IN ULONG BugCheckCode, if (Reboot) { /* Unload symbols */ - DbgUnLoadImageSymbols(NULL, NtCurrentProcess(), 0); + DbgUnLoadImageSymbols(NULL, (PVOID)MAXULONG_PTR, 0); HalReturnToFirmware(HalRebootRoutine); } diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index bd0df7ac6ec..28fdeb8fea1 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -930,9 +930,8 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, { /* * Break into the kernel debugger unless a user mode debugger - * is present or user mode exceptions are ignored, unless this is - * a breakpoint or a debug service in which case we have to - * handle it. + * is present or user mode exceptions are ignored, except if this + * is a debug service which we must always pass to KD */ if ((!(PsGetCurrentProcess()->DebugPort) && !(KdIgnoreUmExceptions)) || diff --git a/reactos/ntoskrnl/mm/sysldr.c b/reactos/ntoskrnl/mm/sysldr.c index f63a7ca3ed6..23cb5fe5f9d 100644 --- a/reactos/ntoskrnl/mm/sysldr.c +++ b/reactos/ntoskrnl/mm/sysldr.c @@ -730,7 +730,7 @@ MmUnloadSystemImage(IN PVOID ImageHandle) PLDR_DATA_TABLE_ENTRY LdrEntry = ImageHandle; PVOID BaseAddress = LdrEntry->DllBase; NTSTATUS Status; - ANSI_STRING TempName; + STRING TempName; BOOLEAN HadEntry = FALSE; /* Acquire the loader lock */ @@ -761,7 +761,9 @@ MmUnloadSystemImage(IN PVOID ImageHandle) if (NT_SUCCESS(Status)) { /* Unload the symbols */ - DbgUnLoadImageSymbols(&TempName, BaseAddress, -1); + DbgUnLoadImageSymbols(&TempName, + BaseAddress, + (ULONG_PTR)ZwCurrentProcess()); RtlFreeAnsiString(&TempName); } } @@ -1528,7 +1530,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName, BOOLEAN LockOwned = FALSE; PLIST_ENTRY NextEntry; IMAGE_INFO ImageInfo; - ANSI_STRING AnsiTemp; + STRING AnsiTemp; PAGED_CODE(); /* Detect session-load */ @@ -1941,7 +1943,9 @@ LoaderScan: RtlInitString(&AnsiTemp, Buffer); /* Notify the debugger */ - DbgLoadImageSymbols(&AnsiTemp, LdrEntry->DllBase, -1); + DbgLoadImageSymbols(&AnsiTemp, + LdrEntry->DllBase, + (ULONG_PTR)ZwCurrentProcess()); LdrEntry->Flags |= LDRP_DEBUG_SYMBOLS_LOADED; }