26 #define VDD_DBG(...) \
28 DPRINT1(__VA_ARGS__); \
37 #ifndef WIN2K_COMPLIANT
38 CHAR StaticBuffer[256];
48 #ifndef WIN2K_COMPLIANT
61 Format =
"DisplayMessage()\nOriginal message is too long and allocating an auxiliary buffer failed.";
73 #ifndef WIN2K_COMPLIANT
81 #define VDD_DBG VddDbgMsg
195#define PAGE_SIZE 0x1000
198#ifndef PAGE_ROUND_DOWN
199#define PAGE_ROUND_DOWN(x) \
200 ( ((ULONG_PTR)(x)) & (~(PAGE_SIZE-1)) )
204#define PAGE_ROUND_UP(x) \
205 ( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) )
208#define MEM_SEG_START 0x0000
209#define MEM_SIZE PAGE_SIZE
222 VDD_DBG(
"MemoryHandler(0x%08x, %s)", FaultAddress, (RWMode == 1) ?
"Write" :
"Read");
282 VDD_DBG(
"Hooking attempt failed!");
295 VDD_DBG(
"Create1Handler(0x%04x)", DosPDB);
302 VDD_DBG(
"Create2Handler(0x%04x)", DosPDB);
309 VDD_DBG(
"Terminate1Handler(0x%04x)", DosPDB);
316 VDD_DBG(
"Terminate2Handler(0x%04x)", DosPDB);
392 VDD_DBG(
"Unable to hook IO ports, terminate...");
402 VDD_DBG(
"Unable to install memory handler, terminate...");
407 VDD_DBG(
"VDDInstallUserHook (1)");
415 VDD_DBG(
"Unable to install user hooks (1)...");
418 VDD_DBG(
"VDDInstallUserHook (2)");
426 VDD_DBG(
"Unable to install user hooks (2)...");
430 VDD_DBG(
"Initialization finished!");
435 VDD_DBG(
"VDDDeInstallUserHook (1)");
441 VDD_DBG(
"VDDDeInstallUserHook (2)");
445 VDD_DBG(
"VDDDeInstallUserHook (3)");
447 if (!
Success)
VDD_DBG(
"EXPECTED ERROR: Unable to uninstall user hooks (3)");
448 else VDD_DBG(
"UNEXPECTED ERROR: Uninstalling user hooks (3) succeeded?!");
454 VDD_DBG(
"VDDDeInstallMemoryHook");
ACPI_SIZE strlen(const char *String)
#define DLL_THREAD_DETACH
#define DLL_PROCESS_ATTACH
#define DLL_PROCESS_DETACH
#define HeapFree(x, y, z)
#define DLL_THREAD_ATTACH
_Check_return_ _CRTIMP int __cdecl _vscprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
BOOL WINAPI VDDInstallUserHook(_In_ HANDLE hVdd, _In_ PFNVDD_UCREATE Ucr_Handler, _In_ PFNVDD_UTERMINATE Uterm_Handler, _In_ PFNVDD_UBLOCK Ublock_Handler, _In_ PFNVDD_URESUME Uresume_Handler)
VOID WINAPI VDDTerminateVDM(VOID)
BOOL WINAPI VDDInstallIOHook(_In_ HANDLE hVdd, _In_ WORD cPortRange, _In_ PVDD_IO_PORTRANGE pPortRange, _In_ PVDD_IO_HANDLERS IoHandlers)
BOOL WINAPI VDDDeInstallUserHook(_In_ HANDLE hVdd)
PVOID WINAPI VdmMapFlat(_In_ USHORT Segment, _In_ ULONG Offset, _In_ VDM_MODE Mode)
BOOL WINAPI VDDInstallMemoryHook(_In_ HANDLE hVdd, _In_ PVOID pStart, _In_ DWORD dwCount, _In_ PVDD_MEMORY_HANDLER MemoryHandler)
BOOL WINAPI VDDFreeMem(_In_ HANDLE hVdd, _In_ PVOID Address, _In_ ULONG Size)
VOID WINAPI VDDDeInstallIOHook(_In_ HANDLE hVdd, _In_ WORD cPortRange, _In_ PVDD_IO_PORTRANGE pPortRange)
BOOL WINAPI VDDDeInstallMemoryHook(_In_ HANDLE hVdd, _In_ PVOID pStart, _In_ DWORD dwCount)
BOOL WINAPI VdmUnmapFlat(_In_ USHORT Segment, _In_ ULONG Offset, _In_ PVOID Buffer, _In_ VDM_MODE Mode)
BOOL WINAPI VDDAllocMem(_In_ HANDLE hVdd, _In_ PVOID Address, _In_ ULONG Size)
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG Offset
VOID WINAPI PortOutsB(IN USHORT Port, IN PUCHAR Data, IN USHORT Count)
VOID WINAPI PortInB(IN USHORT Port, OUT PUCHAR Data)
VOID WINAPI Block2Handler(VOID)
VOID WINAPI PortOutW(IN USHORT Port, IN USHORT Data)
VOID WINAPI Terminate2Handler(USHORT DosPDB)
VDD_IO_PORTRANGE PortDefs[NUM_PORTS]
VOID WINAPI MemoryHandler(IN PVOID FaultAddress, IN ULONG RWMode)
VOID WINAPI Create1Handler(USHORT DosPDB)
VOID WINAPI Resume2Handler(VOID)
VOID WINAPI PortOutB(IN USHORT Port, IN UCHAR Data)
VOID WINAPI Resume1Handler(VOID)
BOOLEAN RegisterVDD(BOOLEAN Register)
VOID WINAPI Terminate1Handler(USHORT DosPDB)
VOID WINAPI PortInsW(IN USHORT Port, OUT PUSHORT Data, IN USHORT Count)
PVOID FindHookableMemory(IN USHORT StartSegment, IN ULONG StartOffset, OUT PUSHORT HookedSegment, OUT PULONG HookedOffset)
static VOID VddDbgMsg(LPCSTR Format,...)
VOID WINAPI Block1Handler(VOID)
BOOL WINAPI DllMain(IN HINSTANCE hInstanceDll, IN DWORD dwReason, IN LPVOID lpReserved)
VOID WINAPI PortInsB(IN USHORT Port, OUT PUCHAR Data, IN USHORT Count)
VOID WINAPI TestVDDRegister(VOID)
VDD_IO_HANDLERS PortHandlers[NUM_PORTS]
VOID WINAPI TestVDDUnRegister(VOID)
VOID WINAPI TestVDDDispatch(VOID)
VOID WINAPI PortInW(IN USHORT Port, OUT PUSHORT Data)
VOID WINAPI Create2Handler(USHORT DosPDB)
VOID WINAPI PortOutsW(IN USHORT Port, IN PUSHORT Data, IN USHORT Count)
#define PAGE_ROUND_DOWN(x)
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)