00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "kdp.h"
00022
#include "ke.h"
00023
#include "pool.h"
00024
#include "stdio.h"
00025
00026
00027
00028
00029
00030
00031
00032 extern ULONG
KiBugCheckData[];
00033
00034 extern PHANDLE_TABLE PspCidTable;
00035
00036 extern LIST_ENTRY
ExpSystemResourcesList;
00037 extern PPOOL_DESCRIPTOR ExpPagedPoolDescriptor;
00038 extern ULONG
ExpNumberOfPagedPools;
00039
00040 extern ULONG
KeTimeIncrement;
00041 extern LIST_ENTRY
KeBugCheckCallbackListHead;
00042 extern ULONG
KiBugcheckData[];
00043
00044 extern LIST_ENTRY
IopErrorLogListHead;
00045
00046 extern POBJECT_DIRECTORY ObpRootDirectoryObject;
00047 extern POBJECT_TYPE ObpTypeObjectType;
00048
00049 extern PVOID
MmSystemCacheStart;
00050 extern PVOID
MmSystemCacheEnd;
00051
00052 extern PVOID
MmPfnDatabase;
00053 extern ULONG
MmSystemPtesStart[];
00054 extern ULONG
MmSystemPtesEnd[];
00055 extern ULONG
MmSubsectionBase;
00056 extern ULONG
MmNumberOfPagingFiles;
00057
00058 extern ULONG
MmLowestPhysicalPage;
00059 extern ULONG
MmHighestPhysicalPage;
00060 extern PFN_COUNT
MmNumberOfPhysicalPages;
00061
00062 extern ULONG
MmMaximumNonPagedPoolInBytes;
00063 extern PVOID
MmNonPagedSystemStart;
00064 extern PVOID
MmNonPagedPoolStart;
00065 extern PVOID
MmNonPagedPoolEnd;
00066
00067 extern PVOID
MmPagedPoolStart;
00068 extern PVOID
MmPagedPoolEnd;
00069 extern ULONG
MmPagedPoolInfo[];
00070 extern ULONG
MmSizeOfPagedPoolInBytes;
00071
00072 extern ULONG
MmTotalCommitLimit;
00073 extern ULONG
MmTotalCommittedPages;
00074 extern ULONG
MmSharedCommit;
00075 extern ULONG
MmDriverCommit;
00076 extern ULONG
MmProcessCommit;
00077 extern ULONG
MmPagedPoolCommit;
00078 extern ULONG
MmExtendedCommit;
00079
00080 extern MMPFNLIST MmZeroedPageListHead;
00081 extern MMPFNLIST MmFreePageListHead;
00082 extern MMPFNLIST MmStandbyPageListHead;
00083 extern MMPFNLIST MmModifiedPageListHead;
00084 extern MMPFNLIST MmModifiedNoWritePageListHead;
00085 extern ULONG
MmAvailablePages;
00086 extern LONG
MmResidentAvailablePages;
00087 extern LIST_ENTRY
MmLoadedUserImageList;
00088
00089 extern PPOOL_TRACKER_TABLE PoolTrackTable;
00090 extern POOL_DESCRIPTOR NonPagedPoolDescriptor;
00091
00092
00093
#ifdef _X86_
00094
#ifdef ALLOC_PRAGMA
00095
#pragma data_seg("PAGEKD")
00096
#endif
00097
#endif // _X86_
00098
00099
00100
00101 UCHAR
KdPrintCircularBuffer[
KDPRINTBUFFERSIZE] = {0};
00102 PUCHAR
KdPrintWritePointer =
KdPrintCircularBuffer;
00103 ULONG
KdPrintRolloverCount = 0;
00104 KSPIN_LOCK
KdpPrintSpinLock = 0;
00105
00106 KDDEBUGGER_DATA
KdDebuggerDataBlock = {
00107 {0},
00108 0,
00109 (ULONG_PTR)
RtlpBreakWithStatusInstruction,
00110 0,
00111 0,
00112 FIELD_OFFSET(KCALLOUT_FRAME, CbStk),
00113
#if defined(_X86_)
00114
FIELD_OFFSET(KCALLOUT_FRAME, Ebp),
00115
#else
00116
0,
00117
#endif
00118
00119
#if defined(_X86PAE_)
00120
1,
00121
#else
00122
0,
00123
#endif
00124
(ULONG_PTR)
KiCallUserMode,
00125 0,
00126
00127 (ULONG_PTR)&
PsLoadedModuleList,
00128 (ULONG_PTR)&
PsActiveProcessHead,
00129 (ULONG_PTR)&
PspCidTable,
00130
00131 (ULONG_PTR)&
ExpSystemResourcesList,
00132 (ULONG_PTR)&
ExpPagedPoolDescriptor,
00133 (ULONG_PTR)&
ExpNumberOfPagedPools,
00134
00135 (ULONG_PTR)&
KeTimeIncrement,
00136 (ULONG_PTR)&
KeBugCheckCallbackListHead,
00137 (ULONG_PTR)
KiBugCheckData,
00138
00139 (ULONG_PTR)&
IopErrorLogListHead,
00140
00141 (ULONG_PTR)&
ObpRootDirectoryObject,
00142 (ULONG_PTR)&
ObpTypeObjectType,
00143
00144 (ULONG_PTR)&
MmSystemCacheStart,
00145 (ULONG_PTR)&
MmSystemCacheEnd,
00146 (ULONG_PTR)&
MmSystemCacheWs,
00147
00148 (ULONG_PTR)&
MmPfnDatabase,
00149 (ULONG_PTR)
MmSystemPtesStart,
00150 (ULONG_PTR)
MmSystemPtesEnd,
00151 (ULONG_PTR)&
MmSubsectionBase,
00152 (ULONG_PTR)&
MmNumberOfPagingFiles,
00153
00154 (ULONG_PTR)&
MmLowestPhysicalPage,
00155 (ULONG_PTR)&
MmHighestPhysicalPage,
00156 (ULONG_PTR)&
MmNumberOfPhysicalPages,
00157
00158 (ULONG_PTR)&
MmMaximumNonPagedPoolInBytes,
00159 (ULONG_PTR)&
MmNonPagedSystemStart,
00160 (ULONG_PTR)&
MmNonPagedPoolStart,
00161 (ULONG_PTR)&
MmNonPagedPoolEnd,
00162
00163 (ULONG_PTR)&
MmPagedPoolStart,
00164 (ULONG_PTR)&
MmPagedPoolEnd,
00165 (ULONG_PTR)&
MmPagedPoolInfo,
00166 0,
00167 (ULONG_PTR)&
MmSizeOfPagedPoolInBytes,
00168
00169 (ULONG_PTR)&
MmTotalCommitLimit,
00170 (ULONG_PTR)&
MmTotalCommittedPages,
00171 (ULONG_PTR)&
MmSharedCommit,
00172 (ULONG_PTR)&
MmDriverCommit,
00173 (ULONG_PTR)&
MmProcessCommit,
00174 (ULONG_PTR)&
MmPagedPoolCommit,
00175 (ULONG_PTR)&
MmExtendedCommit,
00176
00177 (ULONG_PTR)&
MmZeroedPageListHead,
00178 (ULONG_PTR)&
MmFreePageListHead,
00179 (ULONG_PTR)&
MmStandbyPageListHead,
00180 (ULONG_PTR)&
MmModifiedPageListHead,
00181 (ULONG_PTR)&
MmModifiedNoWritePageListHead,
00182 (ULONG_PTR)&
MmAvailablePages,
00183 (ULONG_PTR)&
MmResidentAvailablePages,
00184
00185 (ULONG_PTR)&
PoolTrackTable,
00186 (ULONG_PTR)&
NonPagedPoolDescriptor,
00187
00188 (ULONG_PTR)&
MmHighestUserAddress,
00189 (ULONG_PTR)&
MmSystemRangeStart,
00190 (ULONG_PTR)&
MmUserProbeAddress,
00191
00192 (ULONG_PTR)
KdPrintCircularBuffer,
00193 (ULONG_PTR)
KdPrintCircularBuffer+
sizeof(
KdPrintCircularBuffer),
00194
00195 (ULONG_PTR) &
KdPrintWritePointer,
00196 (ULONG_PTR) &
KdPrintRolloverCount,
00197 (ULONG_PTR) &
MmLoadedUserImageList,
00198 };
00199
00200
00201 BREAKPOINT_ENTRY KdpBreakpointTable[BREAKPOINT_TABLE_SIZE] = {0};
00202 UCHAR
KdpMessageBuffer[
KDP_MESSAGE_BUFFER_SIZE] = {0};
00203 UCHAR
KdpPathBuffer[
KDP_MESSAGE_BUFFER_SIZE] = {0};
00204 DBGKD_INTERNAL_BREAKPOINT KdpInternalBPs[
DBGKD_MAX_INTERNAL_BREAKPOINTS] = {0};
00205
00206 LARGE_INTEGER
KdPerformanceCounterRate = {0,0};
00207 LARGE_INTEGER
KdTimerStart = {0,0} ;
00208 LARGE_INTEGER
KdTimerStop = {0,0};
00209 LARGE_INTEGER
KdTimerDifference = {0,0};
00210
00211 ULONG_PTR
KdpCurrentSymbolStart = 0;
00212 ULONG_PTR
KdpCurrentSymbolEnd = 0;
00213 LONG
KdpNextCallLevelChange = 0;
00214
00215 ULONG_PTR
KdSpecialCalls[
DBGKD_MAX_SPECIAL_CALLS];
00216 ULONG
KdNumberOfSpecialCalls = 0;
00217 ULONG_PTR
InitialSP = 0;
00218 ULONG
KdpNumInternalBreakpoints = 0;
00219 KTIMER InternalBreakpointTimer = {0};
00220 KDPC InternalBreakpointCheckDpc = {0};
00221
00222 BOOLEAN
KdpPortLocked =
FALSE;
00223
00224
00225 DBGKD_TRACE_DATA
TraceDataBuffer[TRACE_DATA_BUFFER_MAX_SIZE] = {0};
00226 ULONG
TraceDataBufferPosition = 1;
00227
00228
00229 TRACE_DATA_SYM TraceDataSyms[256] = {0};
00230 UCHAR
NextTraceDataSym = 0;
00231 UCHAR
NumTraceDataSyms = 0;
00232
00233 ULONG
IntBPsSkipping = 0;
00234
00235
00236 BOOLEAN
WatchStepOver =
FALSE;
00237 PVOID
WSOThread =
NULL;
00238 ULONG
WSOEsp = 0;
00239 ULONG
WatchStepOverHandle = 0;
00240 ULONG_PTR
WatchStepOverBreakAddr = 0;
00241 BOOLEAN
WatchStepOverSuspended =
FALSE;
00242 ULONG
InstructionsTraced = 0;
00243 BOOLEAN
SymbolRecorded =
FALSE;
00244 LONG
CallLevelChange = 0;
00245 LONG
oldpc = 0;
00246 BOOLEAN
InstrCountInternal =
FALSE;
00247
00248 BOOLEAN
BreakpointsSuspended =
FALSE;
00249
00250
00251
00252
00253
00254
00255
00256
00257 ULONG
KdpRetryCount = 5;
00258 ULONG
KdpNumberRetries = 5;
00259
00260 BOOLEAN
KdpControlCPending =
FALSE;
00261 BOOLEAN
KdpControlCPressed =
FALSE;
00262
00263 KDP_BREAKPOINT_TYPE KdpBreakpointInstruction = {0};
00264 ULONG
KdpNextPacketIdToSend = 0;
00265 ULONG
KdpPacketIdExpected = 0;
00266 PVOID
KdpNtosImageBase =
NULL;
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 DEBUG_PARAMETERS KdDebugParameters = {0, 0};
00278
00279 KSPIN_LOCK
KdpDataSpinLock = 0;
00280 LIST_ENTRY
KdpDebuggerDataListHead = {
NULL,
NULL};
00281
00282
#ifdef _X86_
00283
#ifdef ALLOC_PRAGMA
00284
#pragma data_seg()
00285
#endif
00286
#endif // _X86_
00287
00288 KSPIN_LOCK
KdpTimeSlipEventLock = 0;
00289 PVOID
KdpTimeSlipEvent =
NULL;
00290 KDPC KdpTimeSlipDpc = {0};
00291 WORK_QUEUE_ITEM KdpTimeSlipWorkItem = {
NULL};
00292 KTIMER KdpTimeSlipTimer = {0};
00293 ULONG
KdpTimeSlipPending = 1;
00294
00295
00296 BOOLEAN
KdDebuggerNotPresent =
FALSE;
00297 BOOLEAN
KdDebuggerEnabled =
FALSE;
00298 BOOLEAN
KdPitchDebugger =
TRUE;
00299 BOOLEAN
KdpDebuggerStructuresInitialized =
FALSE ;
00300 ULONG
KdpOweBreakpoint;
00301 ULONG
KdEnteredDebugger =
FALSE;