mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
- 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
This commit is contained in:
parent
522564186c
commit
eae6521fb2
23 changed files with 174 additions and 170 deletions
|
@ -10359,23 +10359,23 @@ NTAPI
|
||||||
vDbgPrintEx(
|
vDbgPrintEx(
|
||||||
IN ULONG ComponentId,
|
IN ULONG ComponentId,
|
||||||
IN ULONG Level,
|
IN ULONG Level,
|
||||||
IN LPCSTR Format,
|
IN PCCH Format,
|
||||||
IN va_list ap);
|
IN va_list ap);
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
vDbgPrintExWithPrefix(
|
vDbgPrintExWithPrefix(
|
||||||
IN LPCSTR Prefix,
|
IN PCCH Prefix,
|
||||||
IN ULONG ComponentId,
|
IN ULONG ComponentId,
|
||||||
IN ULONG Level,
|
IN ULONG Level,
|
||||||
IN LPCSTR Format,
|
IN PCCH Format,
|
||||||
IN va_list ap);
|
IN va_list ap);
|
||||||
|
|
||||||
NTKERNELAPI
|
NTKERNELAPI
|
||||||
ULONG
|
ULONG
|
||||||
DDKCDECLAPI
|
DDKCDECLAPI
|
||||||
DbgPrintReturnControlC(
|
DbgPrintReturnControlC(
|
||||||
IN PCH Format,
|
IN PCCH Format,
|
||||||
IN ...);
|
IN ...);
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
|
|
|
@ -131,6 +131,11 @@ Author:
|
||||||
(USHORT)(sizeof(KTSS)) : \
|
(USHORT)(sizeof(KTSS)) : \
|
||||||
(USHORT)(FIELD_OFFSET(KTSS, IoMaps[MapNumber-1].IoMap))
|
(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)
|
// Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual)
|
||||||
//
|
//
|
||||||
|
@ -333,7 +338,7 @@ typedef struct _FXSAVE_FORMAT
|
||||||
ULONG DataSelector;
|
ULONG DataSelector;
|
||||||
ULONG MXCsr;
|
ULONG MXCsr;
|
||||||
ULONG MXCsrMask;
|
ULONG MXCsrMask;
|
||||||
UCHAR RegisterArea[128];
|
UCHAR RegisterArea[SIZE_OF_FX_REGISTERS];
|
||||||
UCHAR Reserved3[128];
|
UCHAR Reserved3[128];
|
||||||
UCHAR Reserved4[224];
|
UCHAR Reserved4[224];
|
||||||
UCHAR Align16Byte[8];
|
UCHAR Align16Byte[8];
|
||||||
|
|
|
@ -2669,7 +2669,7 @@ DbgBreakPoint(
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgLoadImageSymbols(
|
DbgLoadImageSymbols(
|
||||||
IN PANSI_STRING Name,
|
IN PSTRING Name,
|
||||||
IN PVOID Base,
|
IN PVOID Base,
|
||||||
IN ULONG_PTR ProcessId
|
IN ULONG_PTR ProcessId
|
||||||
);
|
);
|
||||||
|
@ -2677,7 +2677,7 @@ DbgLoadImageSymbols(
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgUnLoadImageSymbols(
|
DbgUnLoadImageSymbols(
|
||||||
IN PANSI_STRING Name,
|
IN PSTRING Name,
|
||||||
IN PVOID Base,
|
IN PVOID Base,
|
||||||
IN ULONG_PTR ProcessId
|
IN ULONG_PTR ProcessId
|
||||||
);
|
);
|
||||||
|
|
|
@ -446,8 +446,6 @@ typedef struct _DBGKD_WAIT_STATE_CHANGE32
|
||||||
DBGKM_EXCEPTION32 Exception;
|
DBGKM_EXCEPTION32 Exception;
|
||||||
DBGKD_LOAD_SYMBOLS32 LoadSymbols;
|
DBGKD_LOAD_SYMBOLS32 LoadSymbols;
|
||||||
} u;
|
} u;
|
||||||
DBGKD_CONTROL_REPORT ControlReport;
|
|
||||||
CONTEXT Context;
|
|
||||||
} DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
|
} DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
|
||||||
|
|
||||||
typedef struct _DBGKD_WAIT_STATE_CHANGE64
|
typedef struct _DBGKD_WAIT_STATE_CHANGE64
|
||||||
|
@ -463,8 +461,6 @@ typedef struct _DBGKD_WAIT_STATE_CHANGE64
|
||||||
DBGKM_EXCEPTION64 Exception;
|
DBGKM_EXCEPTION64 Exception;
|
||||||
DBGKD_LOAD_SYMBOLS64 LoadSymbols;
|
DBGKD_LOAD_SYMBOLS64 LoadSymbols;
|
||||||
} u;
|
} u;
|
||||||
DBGKD_CONTROL_REPORT ControlReport;
|
|
||||||
CONTEXT Context;
|
|
||||||
} DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
|
} DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
|
||||||
|
|
||||||
typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
|
typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
|
||||||
|
@ -864,15 +860,10 @@ typedef struct _DBGKD_TRACE_IO
|
||||||
} u;
|
} u;
|
||||||
} DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
|
} DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
|
||||||
|
|
||||||
#if defined(_M_AMD64)
|
static
|
||||||
|
__inline
|
||||||
#define CopyExceptionRecord(Ex64From, Ex64To) \
|
|
||||||
RtlCopyMemory(Ex64To, Ex64From, sizeof(EXCEPTION_RECORD64))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
FORCEINLINE
|
|
||||||
VOID
|
VOID
|
||||||
|
NTAPI
|
||||||
ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
|
ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
|
||||||
OUT PEXCEPTION_RECORD64 Ex64)
|
OUT PEXCEPTION_RECORD64 Ex64)
|
||||||
{
|
{
|
||||||
|
@ -890,9 +881,4 @@ ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CopyExceptionRecord(Ex32From, Ex64To) \
|
|
||||||
ExceptionRecord32To64((PEXCEPTION_RECORD32)Ex32From, Ex64To)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,8 +94,8 @@ VOID DisplayTCPPacket(
|
||||||
UINT Length;
|
UINT Length;
|
||||||
PCHAR Buffer;
|
PCHAR Buffer;
|
||||||
|
|
||||||
if (!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK)) ||
|
if ((DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK) != TRUE) ||
|
||||||
!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_TCP | DPFLTR_MASK))) {
|
(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_TCP | DPFLTR_MASK) != TRUE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ VOID DisplayIPPacket(
|
||||||
PNDIS_BUFFER NextBuffer;
|
PNDIS_BUFFER NextBuffer;
|
||||||
PCHAR CharBuffer;
|
PCHAR CharBuffer;
|
||||||
|
|
||||||
if (!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK)) ||
|
if ((DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_PBUFFER | DPFLTR_MASK) != TRUE) ||
|
||||||
!(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_IP | DPFLTR_MASK))) {
|
(DbgQueryDebugFilterState(DPFLTR_TCPIP_ID, DEBUG_IP | DPFLTR_MASK) != TRUE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,29 +16,29 @@
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS ********************************************************/
|
/* PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugPrint(IN PANSI_STRING DebugString,
|
DebugPrint(IN PSTRING DebugString,
|
||||||
IN ULONG ComponentId,
|
IN ULONG ComponentId,
|
||||||
IN ULONG Level)
|
IN ULONG Level)
|
||||||
{
|
{
|
||||||
/* Call the Debug Service */
|
/* Call the Debug Service */
|
||||||
return DebugService(BREAKPOINT_PRINT,
|
return DebugService(BREAKPOINT_PRINT,
|
||||||
DebugString->Buffer,
|
DebugString->Buffer,
|
||||||
DebugString->Length,
|
UlongToPtr(DebugString->Length),
|
||||||
UlongToPtr(ComponentId),
|
UlongToPtr(ComponentId),
|
||||||
UlongToPtr(Level));
|
UlongToPtr(Level));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugPrompt(IN PCSTRING Output,
|
DebugPrompt(IN PSTRING Output,
|
||||||
IN PSTRING Input)
|
IN PSTRING Input)
|
||||||
{
|
{
|
||||||
/* Call the Debug Service */
|
/* Call the Debug Service */
|
||||||
return DebugService(BREAKPOINT_PROMPT,
|
return DebugService(BREAKPOINT_PROMPT,
|
||||||
Output->Buffer,
|
Output->Buffer,
|
||||||
Output->Length,
|
UlongToPtr(Output->Length),
|
||||||
Input->Buffer,
|
Input->Buffer,
|
||||||
UlongToPtr(Input->MaximumLength));
|
UlongToPtr(Input->MaximumLength));
|
||||||
}
|
}
|
||||||
|
@ -47,22 +47,22 @@ DebugPrompt(IN PCSTRING Output,
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
|
vDbgPrintExWithPrefixInternal(IN PCCH Prefix,
|
||||||
IN ULONG ComponentId,
|
IN ULONG ComponentId,
|
||||||
IN ULONG Level,
|
IN ULONG Level,
|
||||||
IN LPCSTR Format,
|
IN PCCH Format,
|
||||||
IN va_list ap,
|
IN va_list ap,
|
||||||
IN BOOLEAN HandleBreakpoint)
|
IN BOOLEAN HandleBreakpoint)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ANSI_STRING DebugString;
|
STRING DebugString;
|
||||||
CHAR Buffer[512];
|
CHAR Buffer[512];
|
||||||
ULONG Length, PrefixLength;
|
ULONG Length, PrefixLength;
|
||||||
EXCEPTION_RECORD ExceptionRecord;
|
EXCEPTION_RECORD ExceptionRecord;
|
||||||
|
|
||||||
/* Check if we should print it or not */
|
/* Check if we should print it or not */
|
||||||
if ((ComponentId != MAXULONG) &&
|
if ((ComponentId != MAXULONG) &&
|
||||||
!(NtQueryDebugFilterState(ComponentId, Level)))
|
(NtQueryDebugFilterState(ComponentId, Level)) != TRUE)
|
||||||
{
|
{
|
||||||
/* This message is masked */
|
/* This message is masked */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -90,7 +90,6 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* Fail */
|
||||||
Length = PrefixLength = 0;
|
|
||||||
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
@ -160,10 +159,10 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
|
||||||
*/
|
*/
|
||||||
ULONG
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
vDbgPrintExWithPrefix(IN LPCSTR Prefix,
|
vDbgPrintExWithPrefix(IN PCCH Prefix,
|
||||||
IN ULONG ComponentId,
|
IN ULONG ComponentId,
|
||||||
IN ULONG Level,
|
IN ULONG Level,
|
||||||
IN LPCSTR Format,
|
IN PCCH Format,
|
||||||
IN va_list ap)
|
IN va_list ap)
|
||||||
{
|
{
|
||||||
/* Call the internal routine that also handles ControlC */
|
/* Call the internal routine that also handles ControlC */
|
||||||
|
@ -182,7 +181,7 @@ ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
vDbgPrintEx(IN ULONG ComponentId,
|
vDbgPrintEx(IN ULONG ComponentId,
|
||||||
IN ULONG Level,
|
IN ULONG Level,
|
||||||
IN LPCSTR Format,
|
IN PCCH Format,
|
||||||
IN va_list ap)
|
IN va_list ap)
|
||||||
{
|
{
|
||||||
/* Call the internal routine that also handles ControlC */
|
/* Call the internal routine that also handles ControlC */
|
||||||
|
@ -202,19 +201,19 @@ __cdecl
|
||||||
DbgPrint(PCCH Format,
|
DbgPrint(PCCH Format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
ULONG n;
|
ULONG Status;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
/* Call the internal routine that also handles ControlC */
|
/* Call the internal routine that also handles ControlC */
|
||||||
va_start(ap, Format);
|
va_start(ap, Format);
|
||||||
n = vDbgPrintExWithPrefixInternal("",
|
Status = vDbgPrintExWithPrefixInternal("",
|
||||||
-1,
|
-1,
|
||||||
DPFLTR_ERROR_LEVEL,
|
DPFLTR_ERROR_LEVEL,
|
||||||
Format,
|
Format,
|
||||||
ap,
|
ap,
|
||||||
TRUE);
|
TRUE);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return n;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -227,19 +226,19 @@ DbgPrintEx(IN ULONG ComponentId,
|
||||||
IN PCCH Format,
|
IN PCCH Format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
ULONG n;
|
ULONG Status;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
/* Call the internal routine that also handles ControlC */
|
/* Call the internal routine that also handles ControlC */
|
||||||
va_start(ap, Format);
|
va_start(ap, Format);
|
||||||
n = vDbgPrintExWithPrefixInternal("",
|
Status = vDbgPrintExWithPrefixInternal("",
|
||||||
ComponentId,
|
ComponentId,
|
||||||
Level,
|
Level,
|
||||||
Format,
|
Format,
|
||||||
ap,
|
ap,
|
||||||
TRUE);
|
TRUE);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return n;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -247,22 +246,22 @@ DbgPrintEx(IN ULONG ComponentId,
|
||||||
*/
|
*/
|
||||||
ULONG
|
ULONG
|
||||||
__cdecl
|
__cdecl
|
||||||
DbgPrintReturnControlC(PCH Format,
|
DbgPrintReturnControlC(PCCH Format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
ULONG n;
|
ULONG Status;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
/* Call the internal routine that also handles ControlC */
|
/* Call the internal routine that also handles ControlC */
|
||||||
va_start(ap, Format);
|
va_start(ap, Format);
|
||||||
n = vDbgPrintExWithPrefixInternal("",
|
Status = vDbgPrintExWithPrefixInternal("",
|
||||||
-1,
|
-1,
|
||||||
DPFLTR_ERROR_LEVEL,
|
DPFLTR_ERROR_LEVEL,
|
||||||
Format,
|
Format,
|
||||||
ap,
|
ap,
|
||||||
FALSE);
|
FALSE);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return n;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -274,7 +273,7 @@ DbgPrompt(IN PCCH Prompt,
|
||||||
OUT PCH Response,
|
OUT PCH Response,
|
||||||
IN ULONG MaximumResponseLength)
|
IN ULONG MaximumResponseLength)
|
||||||
{
|
{
|
||||||
CSTRING Output;
|
STRING Output;
|
||||||
STRING Input;
|
STRING Input;
|
||||||
|
|
||||||
/* Setup the input string */
|
/* Setup the input string */
|
||||||
|
@ -283,7 +282,7 @@ DbgPrompt(IN PCCH Prompt,
|
||||||
|
|
||||||
/* Setup the output string */
|
/* Setup the output string */
|
||||||
Output.Length = strlen(Prompt);
|
Output.Length = strlen(Prompt);
|
||||||
Output.Buffer = Prompt;
|
Output.Buffer = (PCH)Prompt;
|
||||||
|
|
||||||
/* Call the system service */
|
/* Call the system service */
|
||||||
return DebugPrompt(&Output, &Input);
|
return DebugPrompt(&Output, &Input);
|
||||||
|
@ -319,7 +318,7 @@ DbgSetDebugFilterState(IN ULONG ComponentId,
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgLoadImageSymbols(IN PANSI_STRING Name,
|
DbgLoadImageSymbols(IN PSTRING Name,
|
||||||
IN PVOID Base,
|
IN PVOID Base,
|
||||||
IN ULONG_PTR ProcessId)
|
IN ULONG_PTR ProcessId)
|
||||||
{
|
{
|
||||||
|
@ -328,7 +327,7 @@ DbgLoadImageSymbols(IN PANSI_STRING Name,
|
||||||
|
|
||||||
/* Setup the symbol data */
|
/* Setup the symbol data */
|
||||||
SymbolInfo.BaseOfDll = Base;
|
SymbolInfo.BaseOfDll = Base;
|
||||||
SymbolInfo.ProcessId = (ULONG)ProcessId;
|
SymbolInfo.ProcessId = ProcessId;
|
||||||
|
|
||||||
/* Get NT Headers */
|
/* Get NT Headers */
|
||||||
NtHeader = RtlImageNtHeader(Base);
|
NtHeader = RtlImageNtHeader(Base);
|
||||||
|
@ -353,7 +352,7 @@ DbgLoadImageSymbols(IN PANSI_STRING Name,
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgUnLoadImageSymbols(IN PANSI_STRING Name,
|
DbgUnLoadImageSymbols(IN PSTRING Name,
|
||||||
IN PVOID Base,
|
IN PVOID Base,
|
||||||
IN ULONG_PTR ProcessId)
|
IN ULONG_PTR ProcessId)
|
||||||
{
|
{
|
||||||
|
@ -361,7 +360,7 @@ DbgUnLoadImageSymbols(IN PANSI_STRING Name,
|
||||||
|
|
||||||
/* Setup the symbol data */
|
/* Setup the symbol data */
|
||||||
SymbolInfo.BaseOfDll = Base;
|
SymbolInfo.BaseOfDll = Base;
|
||||||
SymbolInfo.ProcessId = (ULONG)ProcessId;
|
SymbolInfo.ProcessId = ProcessId;
|
||||||
SymbolInfo.CheckSum = SymbolInfo.SizeOfImage = 0;
|
SymbolInfo.CheckSum = SymbolInfo.SizeOfImage = 0;
|
||||||
|
|
||||||
/* Load the symbols */
|
/* Load the symbols */
|
||||||
|
|
|
@ -9,12 +9,12 @@ NTKERNELAPI
|
||||||
VOID
|
VOID
|
||||||
DbgBreakPointWithStatus(ULONG Status) { __asm__("ti 31,0,0"); }
|
DbgBreakPointWithStatus(ULONG Status) { __asm__("ti 31,0,0"); }
|
||||||
|
|
||||||
NTSTATUS
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugService
|
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"
|
__asm__("mr 0,%1\n\t"
|
||||||
"mr 3,%2\n\t"
|
"mr 3,%2\n\t"
|
||||||
"mr 4,%3\n\t"
|
"mr 4,%3\n\t"
|
||||||
|
@ -26,17 +26,16 @@ DebugService
|
||||||
"=r" (Result) :
|
"=r" (Result) :
|
||||||
"r" (0x10000),
|
"r" (0x10000),
|
||||||
"r" (Service),
|
"r" (Service),
|
||||||
"r" (Buffer),
|
"r" (Argument1),
|
||||||
"r" (Length),
|
"r" (Argument2),
|
||||||
"r" (Arg1),
|
"r" (Argument3),
|
||||||
"r" (Arg2) );
|
"r" (Argument4) );
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugService2
|
DebugService2
|
||||||
(PVOID Arg1, PVOID Arg2, ULONG Service)
|
(PVOID Arg1, PVOID Arg2, ULONG Service)
|
||||||
{
|
{
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,20 +145,26 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpCaptureContext(OUT PCONTEXT ContextRecord);
|
RtlpCaptureContext(OUT PCONTEXT ContextRecord);
|
||||||
|
|
||||||
/* i386/debug.S */
|
//
|
||||||
NTSTATUS
|
// Debug Service calls
|
||||||
|
//
|
||||||
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugService(IN ULONG Service,
|
DebugService(
|
||||||
IN const void* Buffer,
|
IN ULONG Service,
|
||||||
IN ULONG Length,
|
IN PVOID Argument1,
|
||||||
IN PVOID Argument1,
|
IN PVOID Argument2,
|
||||||
IN PVOID Argument2);
|
IN PVOID Argument3,
|
||||||
|
IN PVOID Argument4
|
||||||
|
);
|
||||||
|
|
||||||
NTSTATUS
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DebugService2(IN PVOID Argument1,
|
DebugService2(
|
||||||
IN PVOID Argument2,
|
IN PVOID Argument1,
|
||||||
IN ULONG Service);
|
IN PVOID Argument2,
|
||||||
|
IN ULONG Service
|
||||||
|
);
|
||||||
|
|
||||||
/* Tags for the String Allocators */
|
/* Tags for the String Allocators */
|
||||||
#define TAG_USTR 'RTSU'
|
#define TAG_USTR 'RTSU'
|
||||||
|
|
|
@ -734,7 +734,7 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||||
BOOLEAN OverFlow = FALSE;
|
BOOLEAN OverFlow = FALSE;
|
||||||
CHAR NameBuffer[256];
|
CHAR NameBuffer[256];
|
||||||
ANSI_STRING SymbolString;
|
STRING SymbolString;
|
||||||
|
|
||||||
/* Loop the driver list */
|
/* Loop the driver list */
|
||||||
NextEntry = LoaderBlock->LoadOrderListHead.Flink;
|
NextEntry = LoaderBlock->LoadOrderListHead.Flink;
|
||||||
|
@ -799,13 +799,13 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
/* Check if the buffer was ok */
|
/* Check if the buffer was ok */
|
||||||
if (!OverFlow)
|
if (!OverFlow)
|
||||||
{
|
{
|
||||||
/* Initialize the ANSI_STRING for the debugger */
|
/* Initialize the STRING for the debugger */
|
||||||
RtlInitString(&SymbolString, NameBuffer);
|
RtlInitString(&SymbolString, NameBuffer);
|
||||||
|
|
||||||
/* Load the symbols */
|
/* Load the symbols */
|
||||||
DbgLoadImageSymbols(&SymbolString,
|
DbgLoadImageSymbols(&SymbolString,
|
||||||
LdrEntry->DllBase,
|
LdrEntry->DllBase,
|
||||||
0xFFFFFFFF);
|
(ULONG_PTR)ZwCurrentProcess());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSymbol(
|
KdpSymbol(
|
||||||
IN PSTRING DllPath,
|
IN PSTRING DllPath,
|
||||||
IN PKD_SYMBOLS_INFO DllBase,
|
IN PKD_SYMBOLS_INFO SymbolInfo,
|
||||||
IN BOOLEAN Unload,
|
IN BOOLEAN Unload,
|
||||||
IN KPROCESSOR_MODE PreviousMode,
|
IN KPROCESSOR_MODE PreviousMode,
|
||||||
IN PCONTEXT ContextRecord,
|
IN PCONTEXT ContextRecord,
|
||||||
|
@ -322,7 +322,7 @@ KdpGetStateChange(
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSetContextState(
|
KdpSetContextState(
|
||||||
IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
|
IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
IN PCONTEXT Context
|
IN PCONTEXT Context
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -180,16 +180,6 @@ extern ULONG KiDPCTimeout;
|
||||||
/* One of the Reserved Wait Blocks, this one is for the Thread's Timer */
|
/* One of the Reserved Wait Blocks, this one is for the Thread's Timer */
|
||||||
#define TIMER_WAIT_BLOCK 0x3L
|
#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 ************************************************/
|
/* INTERNAL KERNEL FUNCTIONS ************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -368,13 +368,13 @@ NtQueryDebugFilterState(IN ULONG ComponentId,
|
||||||
if (ComponentId == KdComponentTable[i].ComponentId)
|
if (ComponentId == KdComponentTable[i].ComponentId)
|
||||||
{
|
{
|
||||||
/* Check if mask are matching */
|
/* 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 */
|
/* Entry not found in the table, use default mask */
|
||||||
return (Level & Kd_DEFAULT_MASK) != 0;
|
return (Level & Kd_DEFAULT_MASK) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -28,7 +28,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
|
KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
IN PCONTEXT Context)
|
IN PCONTEXT Context)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
|
|
@ -28,7 +28,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
|
KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
IN PCONTEXT Context)
|
IN PCONTEXT Context)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
|
|
@ -69,7 +69,7 @@ KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
|
KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
IN PCONTEXT Context)
|
IN PCONTEXT Context)
|
||||||
{
|
{
|
||||||
PKPRCB Prcb = KeGetCurrentPrcb();
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
||||||
|
|
|
@ -267,7 +267,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSetCommonState(IN ULONG NewState,
|
KdpSetCommonState(IN ULONG NewState,
|
||||||
IN PCONTEXT Context,
|
IN PCONTEXT Context,
|
||||||
IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange)
|
IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange)
|
||||||
{
|
{
|
||||||
USHORT InstructionCount;
|
USHORT InstructionCount;
|
||||||
BOOLEAN HadBreakpoints;
|
BOOLEAN HadBreakpoints;
|
||||||
|
@ -280,9 +280,9 @@ KdpSetCommonState(IN ULONG NewState,
|
||||||
WaitStateChange->Thread = (ULONG64)(LONG_PTR)KeGetCurrentThread();
|
WaitStateChange->Thread = (ULONG64)(LONG_PTR)KeGetCurrentThread();
|
||||||
WaitStateChange->ProgramCounter = (ULONG64)(LONG_PTR)KeGetContextPc(Context);
|
WaitStateChange->ProgramCounter = (ULONG64)(LONG_PTR)KeGetContextPc(Context);
|
||||||
|
|
||||||
/* Zero out the Control Report */
|
/* Zero out the entire Control Report */
|
||||||
RtlZeroMemory(&WaitStateChange->ControlReport,
|
RtlZeroMemory(&WaitStateChange->AnyControlReport,
|
||||||
sizeof(DBGKD_CONTROL_REPORT));
|
sizeof(DBGKD_ANY_CONTROL_REPORT));
|
||||||
|
|
||||||
/* Now copy the instruction stream and set the count */
|
/* Now copy the instruction stream and set the count */
|
||||||
RtlCopyMemory(&WaitStateChange->ControlReport.InstructionStream[0],
|
RtlCopyMemory(&WaitStateChange->ControlReport.InstructionStream[0],
|
||||||
|
@ -1296,7 +1296,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName,
|
||||||
{
|
{
|
||||||
PSTRING ExtraData;
|
PSTRING ExtraData;
|
||||||
STRING Data, Header;
|
STRING Data, Header;
|
||||||
DBGKD_WAIT_STATE_CHANGE64 WaitStateChange;
|
DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange;
|
||||||
KCONTINUE_STATUS Status;
|
KCONTINUE_STATUS Status;
|
||||||
|
|
||||||
/* Start wait loop */
|
/* Start wait loop */
|
||||||
|
@ -1335,7 +1335,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the header */
|
/* Setup the header */
|
||||||
Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64);
|
Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
|
||||||
Header.Buffer = (PCHAR)&WaitStateChange;
|
Header.Buffer = (PCHAR)&WaitStateChange;
|
||||||
|
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
@ -1356,7 +1356,7 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
IN BOOLEAN SecondChanceException)
|
IN BOOLEAN SecondChanceException)
|
||||||
{
|
{
|
||||||
STRING Header, Data;
|
STRING Header, Data;
|
||||||
DBGKD_WAIT_STATE_CHANGE64 WaitStateChange;
|
DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange;
|
||||||
KCONTINUE_STATUS Status;
|
KCONTINUE_STATUS Status;
|
||||||
|
|
||||||
/* Start report loop */
|
/* Start report loop */
|
||||||
|
@ -1366,15 +1366,21 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
KdpSetCommonState(DbgKdExceptionStateChange, Context, &WaitStateChange);
|
KdpSetCommonState(DbgKdExceptionStateChange, Context, &WaitStateChange);
|
||||||
|
|
||||||
/* Copy the Exception Record and set First Chance flag */
|
/* Copy the Exception Record and set First Chance flag */
|
||||||
CopyExceptionRecord(ExceptionRecord,
|
#if !defined(_WIN64)
|
||||||
&WaitStateChange.u.Exception.ExceptionRecord);
|
ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord,
|
||||||
|
&WaitStateChange.u.Exception.ExceptionRecord);
|
||||||
|
#else
|
||||||
|
RtlCopyMemory(&WaitStateChange.u.Exception.ExceptionRecord,
|
||||||
|
ExceptionRecord,
|
||||||
|
sizeof(EXCEPTION_RECORD));
|
||||||
|
#endif
|
||||||
WaitStateChange.u.Exception.FirstChance = !SecondChanceException;
|
WaitStateChange.u.Exception.FirstChance = !SecondChanceException;
|
||||||
|
|
||||||
/* Now finish creating the structure */
|
/* Now finish creating the structure */
|
||||||
KdpSetContextState(&WaitStateChange, Context);
|
KdpSetContextState(&WaitStateChange, Context);
|
||||||
|
|
||||||
/* Setup the actual header to send to KD */
|
/* 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;
|
Header.Buffer = (PCHAR)&WaitStateChange;
|
||||||
|
|
||||||
/* Setup the trace data */
|
/* Setup the trace data */
|
||||||
|
@ -1828,20 +1834,26 @@ KdRefreshDebuggerNotPresent(VOID)
|
||||||
return KdDebuggerNotPresent;
|
return KdDebuggerNotPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
NtQueryDebugFilterState(ULONG ComponentId,
|
NtQueryDebugFilterState(IN ULONG ComponentId,
|
||||||
ULONG Level)
|
IN ULONG Level)
|
||||||
{
|
{
|
||||||
/* HACK */
|
/* HACK */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
NtSetDebugFilterState(ULONG ComponentId,
|
NtSetDebugFilterState(IN ULONG ComponentId,
|
||||||
ULONG Level,
|
IN ULONG Level,
|
||||||
BOOLEAN State)
|
IN BOOLEAN State)
|
||||||
{
|
{
|
||||||
/* HACK */
|
/* HACK */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
|
@ -360,7 +360,7 @@ DBGKD_GET_VERSION64 KdVersionBlock =
|
||||||
0,
|
0,
|
||||||
DBGKD_64BIT_PROTOCOL_VERSION2,
|
DBGKD_64BIT_PROTOCOL_VERSION2,
|
||||||
CURRENT_KD_SECONDARY_VERSION,
|
CURRENT_KD_SECONDARY_VERSION,
|
||||||
#if defined(_M_AMD64)
|
#if defined(_WIN64)
|
||||||
DBGKD_VERS_FLAG_DATA | DBGKD_VERS_FLAG_PTR64,
|
DBGKD_VERS_FLAG_DATA | DBGKD_VERS_FLAG_PTR64,
|
||||||
#else
|
#else
|
||||||
DBGKD_VERS_FLAG_DATA,
|
DBGKD_VERS_FLAG_DATA,
|
||||||
|
|
|
@ -75,7 +75,7 @@ KdInitSystem(IN ULONG BootPhase,
|
||||||
{
|
{
|
||||||
BOOLEAN EnableKd, DisableKdAfterInit = FALSE, BlockEnable;
|
BOOLEAN EnableKd, DisableKdAfterInit = FALSE, BlockEnable;
|
||||||
LPSTR CommandLine, DebugLine, DebugOptionStart, DebugOptionEnd;
|
LPSTR CommandLine, DebugLine, DebugOptionStart, DebugOptionEnd;
|
||||||
ANSI_STRING ImageName;
|
STRING ImageName;
|
||||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||||
PLIST_ENTRY NextEntry;
|
PLIST_ENTRY NextEntry;
|
||||||
ULONG i, j, Length, DebugOptionLength;
|
ULONG i, j, Length, DebugOptionLength;
|
||||||
|
@ -350,8 +350,10 @@ KdInitSystem(IN ULONG BootPhase,
|
||||||
NameBuffer[j] = ANSI_NULL;
|
NameBuffer[j] = ANSI_NULL;
|
||||||
|
|
||||||
/* Load symbols for image */
|
/* Load symbols for image */
|
||||||
RtlInitAnsiString(&ImageName, NameBuffer);
|
RtlInitString(&ImageName, NameBuffer);
|
||||||
DbgLoadImageSymbols(&ImageName, LdrEntry->DllBase, -1);
|
DbgLoadImageSymbols(&ImageName,
|
||||||
|
LdrEntry->DllBase,
|
||||||
|
(ULONG_PTR)ZwCurrentProcess());
|
||||||
|
|
||||||
/* Go to the next entry */
|
/* Go to the next entry */
|
||||||
NextEntry = NextEntry->Flink;
|
NextEntry = NextEntry->Flink;
|
||||||
|
|
|
@ -138,7 +138,7 @@ KdpCommandString(IN ULONG Length,
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KdpSymbol(IN PSTRING DllPath,
|
KdpSymbol(IN PSTRING DllPath,
|
||||||
IN PKD_SYMBOLS_INFO DllBase,
|
IN PKD_SYMBOLS_INFO SymbolInfo,
|
||||||
IN BOOLEAN Unload,
|
IN BOOLEAN Unload,
|
||||||
IN KPROCESSOR_MODE PreviousMode,
|
IN KPROCESSOR_MODE PreviousMode,
|
||||||
IN PCONTEXT ContextRecord,
|
IN PCONTEXT ContextRecord,
|
||||||
|
@ -163,7 +163,7 @@ KdpSymbol(IN PSTRING DllPath,
|
||||||
|
|
||||||
/* Report the new state */
|
/* Report the new state */
|
||||||
Status = KdpReportLoadSymbolsStateChange(DllPath,
|
Status = KdpReportLoadSymbolsStateChange(DllPath,
|
||||||
DllBase,
|
SymbolInfo,
|
||||||
Unload,
|
Unload,
|
||||||
&Prcb->ProcessorState.
|
&Prcb->ProcessorState.
|
||||||
ContextFrame);
|
ContextFrame);
|
||||||
|
@ -243,7 +243,7 @@ KdpPrint(IN ULONG ComponentId,
|
||||||
{
|
{
|
||||||
NTSTATUS ReturnStatus;
|
NTSTATUS ReturnStatus;
|
||||||
BOOLEAN Entered;
|
BOOLEAN Entered;
|
||||||
ANSI_STRING AnsiString;
|
STRING OutputString;
|
||||||
|
|
||||||
/* Assume failure */
|
/* Assume failure */
|
||||||
*Status = FALSE;
|
*Status = FALSE;
|
||||||
|
@ -268,12 +268,12 @@ KdpPrint(IN ULONG ComponentId,
|
||||||
/* FIXME: Support user-mode */
|
/* FIXME: Support user-mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the ANSI string */
|
/* Setup the output string */
|
||||||
AnsiString.Buffer = String;
|
OutputString.Buffer = String;
|
||||||
AnsiString.Length = Length;
|
OutputString.Length = Length;
|
||||||
|
|
||||||
/* Log the print */
|
/* Log the print */
|
||||||
//KdLogDbgPrint(&AnsiString);
|
//KdLogDbgPrint(&OutputString);
|
||||||
|
|
||||||
/* Check for a debugger */
|
/* Check for a debugger */
|
||||||
if (KdDebuggerNotPresent)
|
if (KdDebuggerNotPresent)
|
||||||
|
@ -287,7 +287,7 @@ KdpPrint(IN ULONG ComponentId,
|
||||||
Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
|
Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
|
||||||
|
|
||||||
/* Print the string */
|
/* Print the string */
|
||||||
if (KdpPrintString(&AnsiString))
|
if (KdpPrintString(&OutputString))
|
||||||
{
|
{
|
||||||
/* User pressed CTRL-C, breakpoint on return */
|
/* User pressed CTRL-C, breakpoint on return */
|
||||||
ReturnStatus = STATUS_BREAKPOINT;
|
ReturnStatus = STATUS_BREAKPOINT;
|
||||||
|
|
|
@ -135,8 +135,10 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame,
|
||||||
IN BOOLEAN SecondChanceException)
|
IN BOOLEAN SecondChanceException)
|
||||||
{
|
{
|
||||||
BOOLEAN Unload = FALSE;
|
BOOLEAN Unload = FALSE;
|
||||||
ULONG_PTR ProgramCounter, ReturnValue;
|
ULONG_PTR ProgramCounter;
|
||||||
BOOLEAN Status = FALSE;
|
BOOLEAN Status = FALSE;
|
||||||
|
NTSTATUS ReturnStatus;
|
||||||
|
USHORT ReturnLength;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
|
* 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:
|
case BREAKPOINT_PRINT:
|
||||||
|
|
||||||
/* Call the worker routine */
|
/* Call the worker routine */
|
||||||
ReturnValue = KdpPrint((ULONG)KdpGetFirstParameter(ContextRecord),
|
ReturnStatus = KdpPrint((ULONG)KdpGetFirstParameter(ContextRecord),
|
||||||
(ULONG)KdpGetSecondParameter(ContextRecord),
|
(ULONG)KdpGetSecondParameter(ContextRecord),
|
||||||
(LPSTR)ExceptionRecord->
|
(LPSTR)ExceptionRecord->
|
||||||
ExceptionInformation[1],
|
ExceptionInformation[1],
|
||||||
(USHORT)ExceptionRecord->
|
(USHORT)ExceptionRecord->
|
||||||
ExceptionInformation[2],
|
ExceptionInformation[2],
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
TrapFrame,
|
TrapFrame,
|
||||||
ExceptionFrame,
|
ExceptionFrame,
|
||||||
&Status);
|
&Status);
|
||||||
|
|
||||||
/* Update the return value for the caller */
|
/* Update the return value for the caller */
|
||||||
KeSetContextReturnRegister(ContextRecord, ReturnValue);
|
KeSetContextReturnRegister(ContextRecord, ReturnStatus);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* DbgPrompt */
|
/* DbgPrompt */
|
||||||
case BREAKPOINT_PROMPT:
|
case BREAKPOINT_PROMPT:
|
||||||
|
|
||||||
/* Call the worker routine */
|
/* Call the worker routine */
|
||||||
ReturnValue = KdpPrompt((LPSTR)ExceptionRecord->
|
ReturnLength = KdpPrompt((LPSTR)ExceptionRecord->
|
||||||
ExceptionInformation[1],
|
ExceptionInformation[1],
|
||||||
(USHORT)ExceptionRecord->
|
(USHORT)ExceptionRecord->
|
||||||
ExceptionInformation[2],
|
ExceptionInformation[2],
|
||||||
(LPSTR)KdpGetFirstParameter(ContextRecord),
|
(LPSTR)KdpGetFirstParameter(ContextRecord),
|
||||||
(USHORT)KdpGetSecondParameter(ContextRecord),
|
(USHORT)KdpGetSecondParameter(ContextRecord),
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
TrapFrame,
|
TrapFrame,
|
||||||
ExceptionFrame);
|
ExceptionFrame);
|
||||||
Status = TRUE;
|
Status = TRUE;
|
||||||
|
|
||||||
/* Update the return value for the caller */
|
/* Update the return value for the caller */
|
||||||
KeSetContextReturnRegister(ContextRecord, ReturnValue);
|
KeSetContextReturnRegister(ContextRecord, ReturnLength);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* DbgUnLoadImageSymbols */
|
/* DbgUnLoadImageSymbols */
|
||||||
|
|
|
@ -1197,7 +1197,7 @@ KeBugCheckWithTf(IN ULONG BugCheckCode,
|
||||||
if (Reboot)
|
if (Reboot)
|
||||||
{
|
{
|
||||||
/* Unload symbols */
|
/* Unload symbols */
|
||||||
DbgUnLoadImageSymbols(NULL, NtCurrentProcess(), 0);
|
DbgUnLoadImageSymbols(NULL, (PVOID)MAXULONG_PTR, 0);
|
||||||
HalReturnToFirmware(HalRebootRoutine);
|
HalReturnToFirmware(HalRebootRoutine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -930,9 +930,8 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Break into the kernel debugger unless a user mode debugger
|
* Break into the kernel debugger unless a user mode debugger
|
||||||
* is present or user mode exceptions are ignored, unless this is
|
* is present or user mode exceptions are ignored, except if this
|
||||||
* a breakpoint or a debug service in which case we have to
|
* is a debug service which we must always pass to KD
|
||||||
* handle it.
|
|
||||||
*/
|
*/
|
||||||
if ((!(PsGetCurrentProcess()->DebugPort) &&
|
if ((!(PsGetCurrentProcess()->DebugPort) &&
|
||||||
!(KdIgnoreUmExceptions)) ||
|
!(KdIgnoreUmExceptions)) ||
|
||||||
|
|
|
@ -730,7 +730,7 @@ MmUnloadSystemImage(IN PVOID ImageHandle)
|
||||||
PLDR_DATA_TABLE_ENTRY LdrEntry = ImageHandle;
|
PLDR_DATA_TABLE_ENTRY LdrEntry = ImageHandle;
|
||||||
PVOID BaseAddress = LdrEntry->DllBase;
|
PVOID BaseAddress = LdrEntry->DllBase;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ANSI_STRING TempName;
|
STRING TempName;
|
||||||
BOOLEAN HadEntry = FALSE;
|
BOOLEAN HadEntry = FALSE;
|
||||||
|
|
||||||
/* Acquire the loader lock */
|
/* Acquire the loader lock */
|
||||||
|
@ -761,7 +761,9 @@ MmUnloadSystemImage(IN PVOID ImageHandle)
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Unload the symbols */
|
/* Unload the symbols */
|
||||||
DbgUnLoadImageSymbols(&TempName, BaseAddress, -1);
|
DbgUnLoadImageSymbols(&TempName,
|
||||||
|
BaseAddress,
|
||||||
|
(ULONG_PTR)ZwCurrentProcess());
|
||||||
RtlFreeAnsiString(&TempName);
|
RtlFreeAnsiString(&TempName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1528,7 +1530,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName,
|
||||||
BOOLEAN LockOwned = FALSE;
|
BOOLEAN LockOwned = FALSE;
|
||||||
PLIST_ENTRY NextEntry;
|
PLIST_ENTRY NextEntry;
|
||||||
IMAGE_INFO ImageInfo;
|
IMAGE_INFO ImageInfo;
|
||||||
ANSI_STRING AnsiTemp;
|
STRING AnsiTemp;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Detect session-load */
|
/* Detect session-load */
|
||||||
|
@ -1941,7 +1943,9 @@ LoaderScan:
|
||||||
RtlInitString(&AnsiTemp, Buffer);
|
RtlInitString(&AnsiTemp, Buffer);
|
||||||
|
|
||||||
/* Notify the debugger */
|
/* Notify the debugger */
|
||||||
DbgLoadImageSymbols(&AnsiTemp, LdrEntry->DllBase, -1);
|
DbgLoadImageSymbols(&AnsiTemp,
|
||||||
|
LdrEntry->DllBase,
|
||||||
|
(ULONG_PTR)ZwCurrentProcess());
|
||||||
LdrEntry->Flags |= LDRP_DEBUG_SYMBOLS_LOADED;
|
LdrEntry->Flags |= LDRP_DEBUG_SYMBOLS_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue