📄 wdbgexts.h
字号:
Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
CopyMemory( buf, prc->Buf, size );
LocalFree( prc );
}
__inline VOID
ReadControlSpace64(
USHORT processor,
ULONG64 address,
PVOID buf,
ULONG size
)
{
PREADCONTROLSPACE64 prc;
prc = (PREADCONTROLSPACE64)LocalAlloc(LPTR, sizeof(*prc) + size );
ZeroMemory( prc->Buf, size );
prc->Processor = processor;
prc->Address = address;
prc->BufLen = size;
Ioctl( IG_READ_CONTROL_SPACE, (PVOID)prc, sizeof(*prc) + size );
CopyMemory( buf, prc->Buf, size );
LocalFree( prc );
}
// #endif // _WINBASE_
__inline VOID
ReadIoSpace(
ULONG address,
PULONG data,
PULONG size
)
{
IOSPACE is;
is.Address = address;
is.Length = *size;
Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
memcpy(data, &is.Data, is.Length);
*size = is.Length;
}
__inline VOID
ReadIoSpace32(
ULONG address,
PULONG data,
PULONG size
)
{
IOSPACE32 is;
is.Address = address;
is.Length = *size;
Ioctl( IG_READ_IO_SPACE, (PVOID)&is, sizeof(is) );
memcpy(data, &is.Data, is.Length);
*size = is.Length;
}
__inline VOID
ReadIoSpace64(
ULONG64 address,
PULONG data,
PULONG size
)
{
IOSPACE64 is;
is.Address = 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
WriteIoSpace32(
ULONG address,
ULONG data,
PULONG size
)
{
IOSPACE32 is;
is.Address = address;
is.Length = *size;
is.Data = data;
Ioctl( IG_WRITE_IO_SPACE, (PVOID)&is, sizeof(is) );
*size = is.Length;
}
__inline VOID
WriteIoSpace64(
ULONG64 address,
ULONG data,
PULONG size
)
{
IOSPACE64 is;
is.Address = 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
ReadIoSpaceEx32(
ULONG address,
PULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX32 is;
is.Address = 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
ReadIoSpaceEx64(
ULONG64 address,
PULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX64 is;
is.Address = 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
WriteIoSpaceEx32(
ULONG address,
ULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX32 is;
is.Address = 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
WriteIoSpaceEx64(
ULONG64 address,
ULONG data,
PULONG size,
ULONG interfacetype,
ULONG busnumber,
ULONG addressspace
)
{
IOSPACE_EX64 is;
is.Address = 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
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));
}
#if defined(KDEXT_64BIT)
__inline
ULONG
IsPtr64(
void
)
{
static ULONG flag = -1;
ULONG dw;
if (flag == -1) {
if (Ioctl(IG_IS_PTR64, &dw, sizeof(dw))) {
flag = ((dw != 0) ? 1 : 0);
} else {
flag = 0;
}
}
return flag;
}
__inline
ULONG
ReadListEntry(
ULONG64 Address,
PLIST_ENTRY64 List
)
{
ULONG cb;
if (IsPtr64()) {
return (ReadMemory(Address, (PVOID)List, sizeof(*List), &cb) && cb == sizeof(*List));
} else {
LIST_ENTRY32 List32;
ULONG Status;
Status = ReadMemory(Address,
(PVOID)&List32,
sizeof(List32),
&cb);
if (Status && cb == sizeof(List32)) {
List->Flink = (ULONG64)(LONG64)(LONG)List32.Flink;
List->Blink = (ULONG64)(LONG64)(LONG)List32.Blink;
return 1;
}
return 0;
}
}
__inline
ULONG
ReadPointer(
ULONG64 Address,
PULONG64 Pointer
)
{
ULONG cb;
if (IsPtr64()) {
return (ReadMemory(Address, (PVOID)Pointer, sizeof(*Pointer), &cb) && cb == sizeof(*Pointer));
} else {
ULONG Pointer32;
ULONG Status;
Status = ReadMemory(Address,
(PVOID)&Pointer32,
sizeof(Pointer32),
&cb);
if (Status && cb == sizeof(Pointer32)) {
*Pointer = (ULONG64)(LONG64)(LONG)Pointer32;
return 1;
}
return 0;
}
}
__inline
ULONG
WritePointer(
ULONG64 Address,
ULONG64 Pointer
)
{
ULONG cb;
if (IsPtr64()) {
return (WriteMemory(Address, &Pointer, sizeof(Pointer), &cb) && cb == sizeof(Pointer));
} else {
ULONG Pointer32 = (ULONG)Pointer;
ULONG Status;
Status = WriteMemory(Address,
&Pointer32,
sizeof(Pointer32),
&cb);
return (Status && cb == sizeof(Pointer32)) ? 1 : 0;
}
}
#endif // defined(KDEXT_64BIT)
__inline VOID
GetTebAddress(
PULONGLONG Address
)
{
GET_TEB_ADDRESS gpt;
gpt.Address = 0;
Ioctl(IG_GET_TEB_ADDRESS, (PVOID)&gpt, sizeof(gpt));
*Address = gpt.Address;
}
__inline VOID
SearchMemory(
ULONG64 SearchAddress,
ULONG64 SearchLength,
ULONG PatternLength,
PVOID Pattern,
PULONG64 FoundAddress
)
{
SEARCHMEMORY sm;
sm.SearchAddress = SearchAddress;
sm.SearchLength = SearchLength;
sm.FoundAddress = 0;
sm.PatternLength = PatternLength;
sm.Pattern = Pattern;
Ioctl(IG_SEARCH_MEMORY, (PVOID)&sm, sizeof(sm));
*FoundAddress = sm.FoundAddress;
}
#endif
#ifdef __cplusplus
}
#endif
#pragma option pop /*P_O_Pop*/
#endif // _WDBGEXTS_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -