test: kdexts.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# kdexts.c File Reference

`#include "precomp.h"`
`#include <imagehlp.h>`
`#include <wdbgexts.h>`
`#include <ntsdexts.h>`
`#include <ntverp.h>`

Go to the source code of this file.

## Defines

#define | cArchitecture (sizeof(szProcessorArchitecture) / sizeof(PSZ))

## Functions

| DllInit (HANDLE hModule, DWORD dwReason, DWORD dwReserved)
VOID | WinDbgExtensionDllInit (PWINDBG_EXTENSION_APIS lpExtensionApis, USHORT MajorVersion, USHORT MinorVersion)
| DECLARE_API (version)
VOID | CheckVersion (VOID)
LPEXT_API_VERSION | ExtensionApiVersion (VOID)

## Variables

EXT_API_VERSION | ApiVersion
WINDBG_EXTENSION_APIS | ExtensionApis
ULONG | STeip
ULONG | STebp
ULONG | STesp
USHORT | SavedMajorVersion
USHORT | SavedMinorVersion
USHORT | usProcessorArchitecture
BOOL | bDebuggingChecked
ULONG_PTR | UserProbeAddress
PSZ | szProcessorArchitecture []
PGETEPROCESSDATAFUNC | aGetEProcessDataFunc []
PGETEPROCESSDATAFUNC | GetEProcessData

## Define Documentation

#define cArchitecture (sizeof(szProcessorArchitecture) / sizeof(PSZ))

| Definition at line 56 of file kdexts.c. Referenced by WinDbgExtensionDllInit().

## Function Documentation

VOID CheckVersion | ( | VOID |  | ) |

Definition at line 160 of file kdexts.c.

References SavedMajorVersion, and SavedMinorVersion.

    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 }

DECLARE_API | ( | version |  | ) |

Definition at line 143 of file kdexts.c.

References SavedMajorVersion, and SavedMinorVersion.

    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 }

DllInit | ( | HANDLE | hModule,
|  | DWORD | dwReason,
|  | DWORD | dwReserved
| ) |

Definition at line 68 of file kdexts.c.

References TRUE.

Referenced by SetUpConsoleInfo().

    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 }

LPEXT_API_VERSION ExtensionApiVersion | ( | VOID |  | ) |

Definition at line 178 of file kdexts.c.

References ApiVersion.

    00181 {
    00182     return &ApiVersion;
    00183 }

VOID WinDbgExtensionDllInit | ( | PWINDBG_EXTENSION_APIS | lpExtensionApis,
|  | USHORT | MajorVersion,
|  | USHORT | MinorVersion
| ) |

Definition at line 93 of file kdexts.c.

References aGetEProcessDataFunc, bDebuggingChecked, cArchitecture, ExtensionApis, FALSE, GetEProcessData, GetEProcessData_IA64(), GetEProcessData_X86(), SavedMajorVersion, SavedMinorVersion, UserProbeAddress, USHORT, and usProcessorArchitecture.

    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     // Read the user probe address from the target system.
    00125     //
    00126     // N.B. The user probe address is constant on MIPS, Alpha, and the PPC.
    00127     //      On the x86, it may not be defined for the target system if it
    00128     //      does not contain the code to support 3gb of user address space.
    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 }

## Variable Documentation

PGETEPROCESSDATAFUNC aGetEProcessDataFunc[]

Initial value:

     {
        GetEProcessData_X86,
        NULL,
        GetEProcessData_ALPHA,
        NULL,
        GetEProcessData_IA64
    }

Definition at line 58 of file kdexts.c.

Referenced by WinDbgExtensionDllInit().

EXT_API_VERSION ApiVersion

Initial value:

     { VER_PRODUCTVERSION_W >> 8,
                                          VER_PRODUCTVERSION_W & 0xff,
                                          EXT_API_VERSION_NUMBER, 0 }

Definition at line 36 of file kdexts.c.

Referenced by ExtensionApiVersion().

BOOL bDebuggingChecked

| Definition at line 46 of file kdexts.c. Referenced by WinDbgExtensionDllInit().

WINDBG_EXTENSION_APIS ExtensionApis

| Definition at line 39 of file kdexts.c. Referenced by WinDbgExtensionDllInit().

PGETEPROCESSDATAFUNC GetEProcessData

| Definition at line 66 of file kdexts.c.

USHORT SavedMajorVersion

| Definition at line 43 of file kdexts.c. Referenced by CheckVersion(), DECLARE_API(), and WinDbgExtensionDllInit().

USHORT SavedMinorVersion

| Definition at line 44 of file kdexts.c. Referenced by CheckVersion(), DECLARE_API(), and WinDbgExtensionDllInit().

ULONG STebp

| Definition at line 41 of file kdexts.c.

ULONG STeip

| Definition at line 40 of file kdexts.c.

ULONG STesp

| Definition at line 42 of file kdexts.c.

PSZ szProcessorArchitecture[]

Initial value:

     {
        "Intel",
        "MIPS",
        "Alpha",
        "PPC",
        "IA64"
    }

Definition at line 49 of file kdexts.c.

ULONG_PTR UserProbeAddress

| Definition at line 47 of file kdexts.c. Referenced by WinDbgExtensionDllInit().

USHORT usProcessorArchitecture

| Definition at line 45 of file kdexts.c. Referenced by WinDbgExtensionDllInit().