00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include "precomp.h"
00025
#pragma hdrstop
00026
00027
#include <imagehlp.h>
00028
#include <wdbgexts.h>
00029
#include <ntsdexts.h>
00030
#include <ntverp.h>
00031
00032
00033
00034
00035
00036 EXT_API_VERSION
ApiVersion = { VER_PRODUCTVERSION_W >> 8,
00037 VER_PRODUCTVERSION_W & 0xff,
00038 EXT_API_VERSION_NUMBER, 0 };
00039 WINDBG_EXTENSION_APIS
ExtensionApis;
00040 ULONG
STeip;
00041 ULONG
STebp;
00042 ULONG
STesp;
00043 USHORT SavedMajorVersion;
00044 USHORT SavedMinorVersion;
00045 USHORT usProcessorArchitecture;
00046 BOOL bDebuggingChecked;
00047 ULONG_PTR
UserProbeAddress;
00048
00049 PSZ
szProcessorArchitecture[] = {
00050
"Intel",
00051
"MIPS",
00052
"Alpha",
00053
"PPC",
00054
"IA64"
00055 };
00056 #define cArchitecture (sizeof(szProcessorArchitecture) / sizeof(PSZ))
00057
00058 PGETEPROCESSDATAFUNC aGetEProcessDataFunc[] = {
00059
GetEProcessData_X86,
00060
NULL,
00061
GetEProcessData_ALPHA,
00062
NULL,
00063
GetEProcessData_IA64
00064 };
00065
00066 extern PGETEPROCESSDATAFUNC GetEProcessData;
00067
00068 DllInit(
00069 HANDLE hModule,
00070 DWORD dwReason,
00071 DWORD dwReserved
00072 )
00073 {
00074
switch (dwReason) {
00075
case DLL_THREAD_ATTACH:
00076
break;
00077
00078
case DLL_THREAD_DETACH:
00079
break;
00080
00081
case DLL_PROCESS_DETACH:
00082
break;
00083
00084
case DLL_PROCESS_ATTACH:
00085
break;
00086 }
00087
00088
return TRUE;
00089 }
00090
00091
00092
VOID
00093 WinDbgExtensionDllInit(
00094 PWINDBG_EXTENSION_APIS lpExtensionApis,
00095 USHORT MajorVersion,
00096 USHORT MinorVersion
00097 )
00098 {
00099 ULONG_PTR offKeProcessorArchitecture;
00100 ULONG Result;
00101
00102
ExtensionApis = *lpExtensionApis;
00103
00104
SavedMajorVersion = MajorVersion;
00105
SavedMinorVersion = MinorVersion;
00106
00107
bDebuggingChecked = (
SavedMajorVersion == 0x0c);
00108
usProcessorArchitecture = (
USHORT)-1;
00109 offKeProcessorArchitecture = GetExpression(
"KeProcessorArchitecture");
00110
if (offKeProcessorArchitecture != 0)
00111 ReadMemory(offKeProcessorArchitecture, &
usProcessorArchitecture,
00112
sizeof(
USHORT), &Result);
00113
if (
usProcessorArchitecture >=
cArchitecture) {
00114
#ifdef IA64
00115
GetEProcessData =
GetEProcessData_IA64;
00116
#else
00117
GetEProcessData =
GetEProcessData_X86;
00118
#endif
00119
}
else {
00120
GetEProcessData =
aGetEProcessDataFunc[
usProcessorArchitecture];
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
UserProbeAddress = GetExpression(
"MmUserProbeAddress");
00132
if ((
UserProbeAddress == 0) ||
00133 (ReadMemory(
UserProbeAddress,
00134 &
UserProbeAddress,
00135
sizeof(
UserProbeAddress),
00136 &Result) ==
FALSE)) {
00137
UserProbeAddress = 0x7fff0000;
00138 }
00139
00140
return;
00141 }
00142
00143 DECLARE_API( version )
00144 {
00145
#if DBG
00146
PCHAR DebuggerType =
"Checked";
00147
#else
00148
PCHAR DebuggerType =
"Free";
00149
#endif
00150
00151 dprintf(
"%s Extension dll for Build %d debugging %s kernel for Build %d\n",
00152 DebuggerType,
00153 VER_PRODUCTBUILD,
00154
SavedMajorVersion == 0x0c ?
"Checked" :
"Free",
00155
SavedMinorVersion
00156 );
00157 }
00158
00159
VOID
00160 CheckVersion(
00161 VOID
00162 )
00163 {
00164
#if DBG
00165
if ((
SavedMajorVersion != 0x0c) || (
SavedMinorVersion != VER_PRODUCTBUILD)) {
00166 dprintf(
"\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
00167 VER_PRODUCTBUILD,
SavedMinorVersion, (
SavedMajorVersion==0x0f) ?
"Free" :
"Checked" );
00168 }
00169
#else
00170
if ((
SavedMajorVersion != 0x0f) || (
SavedMinorVersion != VER_PRODUCTBUILD)) {
00171 dprintf(
"\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
00172 VER_PRODUCTBUILD,
SavedMinorVersion, (
SavedMajorVersion==0x0f) ?
"Free" :
"Checked" );
00173 }
00174
#endif
00175
}
00176
00177 LPEXT_API_VERSION
00178 ExtensionApiVersion(
00179 VOID
00180 )
00181 {
00182
return &
ApiVersion;
00183 }
00184