[ros-kernel] NT-compatible Kd support

Skywing skywing at valhallalegends.com
Fri Jul 2 19:40:42 CEST 2004


I've been working on an NT-compatible Kd with help from one of the DDK
samples included in the NT4 DDK.  Before it can be used with ReactOS, a
couple of things will need to happen:

1. Obviously, we need to implement the Kd protocol and routines to support
it in the kernel.  I haven't started with this yet, but having a working Kd
client will probably be very helpful in getting this right.

2. Some internal variables and functions are exposed directly to Kd by the
protocol.  So, we will want to try and take particular care that the exposed
structures and functions are especially close to their NT equivalents.
These are referenced through a DbgK structure with the following format:

typedef struct _DBGKD_DEBUG_DATA_HEADER {
	LIST_ENTRY List;
	DWORD OwnerTag; // Pool Tag
	DWORD Size;
} DBGKD_DEBUG_DATA_HEADER, *PDBGKD_DEBUG_DATA_HEADER;

typedef struct _KDDEBUGGER_DATA {
	DBGKD_DEBUG_DATA_HEADER Header;

	DWORD_PTR KernBase;

	DWORD_PTR BreakpointWithStatus; // Breakpoint instruction in
DbgBreakPointWithStatus, EAX/Param Reg 1 is status

	DWORD_PTR SavedContext; // Only valid after KeBugCheckEx

	WORD ThCallbackStack; // displacement from kernel stack
	WORD NextCallback; //
	WORD FramePointer; //
	WORD Unused1;
	DWORD_PTR KiCallUserMode; // ntoskrnl
	DWORD_PTR KeUserCallbackDispatcher; // ntdll

	//
	// The following are ntoskrnl global data structure addresses.
	//

	DWORD_PTR PsLoadedModuleList;
	DWORD_PTR PsActiveProcessHead;
	DWORD_PTR PspCidTable;

	DWORD_PTR ExpSystemResourcesList;
	DWORD_PTR ExpPagedPoolDescriptor;
	DWORD_PTR ExpNumberOfPagedPools;

	DWORD_PTR KeTimeIncrement;
	DWORD_PTR KeBugCheckCallbackListHead;
	DWORD_PTR KiBugcheckData;

	DWORD_PTR IopErrorLogListHead;

	DWORD_PTR ObpRootDirectoryObject;
	DWORD_PTR ObpTypeObjectType;

	DWORD_PTR MmSystemCacheStart;
	DWORD_PTR MmSystemCacheEnd;
	DWORD_PTR MmSystemCacheWs;

	DWORD_PTR MmPfnDatabase;
	DWORD_PTR MmSystemPtesStart;
	DWORD_PTR MmSystemPtesEnd;
	DWORD_PTR MmSubsectionBase;
	DWORD_PTR MmNumberOfPagingFiles;

	DWORD_PTR MmLowestPhysicalPage;
	DWORD_PTR MmHighestPhysicalPage;
	DWORD_PTR MmNumberOfPhysicalPages;

	DWORD_PTR MmMaximumNonPagedPoolInBytes;
	DWORD_PTR MmNonPagedSystemStart;
	DWORD_PTR MmNonPagedPoolStart;
	DWORD_PTR MmNonPagedPoolEnd;

	DWORD_PTR MmPagedPoolStart;
	DWORD_PTR MmPagedPoolEnd;
	DWORD_PTR MmPagedPoolInformation;
	DWORD_PTR MmPageSize;

	DWORD_PTR MmSizeOfPagedPoolInBytes;

	DWORD_PTR MmTotalCommitLimit;
	DWORD_PTR MmTotalCommittedPages;
	DWORD_PTR MmSharedCommit;
	DWORD_PTR MmDriverCommit;
	DWORD_PTR MmProcessCommit;
	DWORD_PTR MmPagedPoolCommit;
	DWORD_PTR MmExtendedCommit;

	DWORD_PTR MmZeroedPageListHead;
	DWORD_PTR MmFreePageListHead;
	DWORD_PTR MmStandbyPageListHead;
	DWORD_PTR MmModifiedPageListHead;
	DWORD_PTR MmModifiedNoWritePageListHead;
	DWORD_PTR MmAvailablePages;
	DWORD_PTR MmResidentAvailablePages;

	DWORD_PTR PoolTrackTable;
	DWORD_PTR NonPagedPoolDescriptor;

	DWORD_PTR MmHighestUserAddress;
	DWORD_PTR MmSystemRangeStart;
	DWORD_PTR MmUserProbeAddress;

	DWORD_PTR KdPrintCircularBuffer;
	DWORD_PTR KdPrintCircularBufferEnd;
	DWORD_PTR KdPrintWritePointer;
	DWORD_PTR KdPrintRolloverCount;

	DWORD_PTR MmLoadedUserImageList;

	DWORD_PTR NtBuildLab;
	DWORD_PTR KiNormalSystemCall;

	DWORD_PTR KiProcessorBlock;
	DWORD_PTR MmUnloadedDrivers;
	DWORD_PTR MmLastUnloadedDriver;
	DWORD_PTR MmTriageActionTaken;
	DWORD_PTR MmSpecialPoolTag;
	DWORD_PTR KernelVerifier;
	DWORD_PTR MmVerifierData;
	DWORD_PTR MmAllocatedNonPagedPool;
	DWORD_PTR MmPeakCommitment;
	DWORD_PTR MmTotalCommitLimitMaximum;
	DWORD_PTR CmNtCSDVersion;

	DWORD_PTR MmPhysicalMemoryBlock;
	DWORD_PTR MmSessionBase;
	DWORD_PTR MmSessionSize;
	DWORD_PTR MmSystemParentTablePage;
} KDDEBUGGER_DATA, *PKDDEBUGGER_DATA;

Some versions of the WinDbg extension headers have more information about
these.




More information about the Ros-kernel mailing list