📄 wdbgexts.h
字号:
#ifdef __cplusplus
#define CPPMOD extern "C"
#else
#define CPPMOD
#endif
#define DECLARE_API(s) \
CPPMOD VOID \
s( \
HANDLE hCurrentProcess, \
HANDLE hCurrentThread, \
ULONG dwCurrentPc, \
ULONG dwProcessor, \
PCSTR args \
)
#ifndef NOEXTAPI
#define dprintf (ExtensionApis.lpOutputRoutine)
#define GetExpression (ExtensionApis.lpGetExpressionRoutine)
#define GetSymbol (ExtensionApis.lpGetSymbolRoutine)
#define Disassm (ExtensionApis.lpDisasmRoutine)
#define CheckControlC (ExtensionApis.lpCheckControlCRoutine)
#define ReadMemory (ExtensionApis.lpReadProcessMemoryRoutine)
#define WriteMemory (ExtensionApis.lpWriteProcessMemoryRoutine)
#define GetContext (ExtensionApis.lpGetThreadContextRoutine)
#define SetContext (ExtensionApis.lpSetThreadContextRoutine)
#define Ioctl (ExtensionApis.lpIoctlRoutine)
#define StackTrace (ExtensionApis.lpStackTraceRoutine)
#define GetKdContext(ppi) \
Ioctl( IG_KD_CONTEXT, (PVOID)ppi, sizeof(*ppi) )
//
// BOOL
// GetDebuggerData(
// ULONG Tag,
// PVOID Buf,
// ULONG Size
// )
//
/*++
Routine Description:
Arguments:
Return Value:
--*/
#define GetDebuggerData(TAG, BUF, SIZE) \
( (((PDBGKD_DEBUG_DATA_HEADER)(BUF))->OwnerTag = (TAG)), \
(((PDBGKD_DEBUG_DATA_HEADER)(BUF))->Size = (SIZE)), \
Ioctl( IG_GET_DEBUGGER_DATA, (PVOID)(BUF), (SIZE) ) )
extern WINDBG_EXTENSION_APIS ExtensionApis;
__inline VOID
ReadControlSpace(
USHORT processor,
ULONG address,
PVOID buf,
ULONG size
)
{
PREADCONTROLSPACE prc;
prc = (PREADCONTROLSPACE)LocalAlloc(LPTR, sizeof(*prc) + size );
ZeroMemory( prc->Buf, size );
prc->Processor = processor;
prc->Address = (ULONG)address;
prc->BufLen = size;
Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
CopyMemory( buf, prc->Buf, size );
LocalFree( prc );
}
__inline VOID
ReadIoSpace(
ULONG address,
PULONG data,
PULONG size
)
{
IOSPACE is;
is.Address = (ULONG)address;
is.Length = *size;
Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
memcpy(data, &is.Data, is.Length);
*size = is.Length;
}
__inline VOID
WriteIoSpace(
ULONG address,
ULONG data,
PULONG size
)
{
IOSPACE is;
is.Address = (ULONG)address;
is.Length = *size;
is.Data = data;
Ioctl( IG_WRITE_IO_SPACE, (PVOID)&is, sizeof(is) );
*size = is.Length;
}
__inline VOID
ReadIoSpaceEx(
ULONG address,
PULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX is;
is.Address = (ULONG)address;
is.Length = *size;
is.Data = 0;
is.InterfaceType = interfacetype;
is.BusNumber = busnumber;
is.AddressSpace = addressspace;
Ioctl( IG_READ_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
*data = is.Data;
*size = is.Length;
}
__inline VOID
WriteIoSpaceEx(
ULONG address,
ULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX is;
is.Address = (ULONG)address;
is.Length = *size;
is.Data = data;
is.InterfaceType = interfacetype;
is.BusNumber = busnumber;
is.AddressSpace = addressspace;
Ioctl( IG_WRITE_IO_SPACE_EX, (PVOID)&is, sizeof(is) );
*size = is.Length;
}
__inline VOID
ReadPhysical(
LARGE_INTEGER address,
PVOID buf,
ULONG size,
PULONG sizer
)
{
PPHYSICAL phy;
phy = (PPHYSICAL)LocalAlloc(LPTR, sizeof(*phy) + size );
ZeroMemory( phy->Buf, size );
phy->Address = address;
phy->BufLen = size;
Ioctl( IG_READ_PHYSICAL, (PVOID)phy, sizeof(*phy) + size );
*sizer = phy->BufLen;
CopyMemory( buf, phy->Buf, *sizer );
LocalFree( phy );
}
__inline VOID
WritePhysical(
LARGE_INTEGER address,
PVOID buf,
ULONG size,
PULONG sizew
)
{
PPHYSICAL phy;
phy = (PPHYSICAL)LocalAlloc(LPTR, sizeof(*phy) + size );
ZeroMemory( phy->Buf, size );
phy->Address = address;
phy->BufLen = size;
CopyMemory( phy->Buf, buf, size );
Ioctl( IG_WRITE_PHYSICAL, (PVOID)phy, sizeof(*phy) + size );
*sizew = phy->BufLen;
LocalFree( phy );
}
__inline VOID
SetThreadForOperation(
PULONG Thread
)
{
Ioctl(IG_SET_THREAD, (PVOID)Thread, sizeof(ULONG));
}
__inline VOID
ReadMsr(
ULONG MsrReg,
ULONGLONG *MsrValue
)
{
PREAD_WRITE_MSR msr;
LARGE_INTEGER li;
msr = (PREAD_WRITE_MSR)LocalAlloc(LPTR, sizeof(*msr));
msr->Msr = MsrReg;
Ioctl( IG_READ_MSR, (PVOID)msr, sizeof(*msr) );
*MsrValue = msr->Value;
LocalFree( msr );
}
__inline VOID
WriteMsr(
ULONG MsrReg,
ULONGLONG MsrValue
)
{
PREAD_WRITE_MSR msr;
msr = (PREAD_WRITE_MSR)LocalAlloc(LPTR, sizeof(*msr));
msr->Msr = MsrReg;
msr->Value = MsrValue;
Ioctl( IG_WRITE_MSR, (PVOID)msr, sizeof(*msr) );
LocalFree( msr );
}
__inline VOID
ReloadSymbols(
IN PSTR Arg OPTIONAL
)
/*++
Routine Description:
Calls the debugger to reload symbols.
Arguments:
Args - Supplies the tail of a !reload command string.
!reload [flags] [module[=address]]
flags: /n do not load from usermode list
/u unload symbols, no reload
/v verbose
A value of NULL is equivalent to an empty string
Return Value:
None
--*/
{
Ioctl(IG_RELOAD_SYMBOLS, (PVOID)Arg, Arg?(strlen(Arg)+1):0);
}
__inline VOID
GetSetSympath(
IN PSTR Arg,
OUT PSTR Result OPTIONAL,
IN int Length
)
/*++
Routine Description:
Calls the debugger to set or retrieve symbol search path.
Arguments:
Arg - Supplies new search path. If Arg is NULL or string is empty,
the search path is not changed and the current setting is
returned in Result. When the symbol search path is changed,
a call to ReloadSymbols is made implicitly.
Result - OPTIONAL Returns the symbol search path setting.
Length - Supplies the size of the buffer supplied by Result.
Return Value:
None
--*/
{
GET_SET_SYMPATH gss;
gss.Args = Arg;
gss.Result = Result;
gss.Length = Length;
Ioctl(IG_GET_SET_SYMPATH, (PVOID)&gss, sizeof(gss));
}
#endif
#ifdef __cplusplus
}
#endif
#endif // _WDBGEXTS_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -