Last active
May 25, 2026 00:59
-
-
Save valinet/a4c9871a3bb26a956c143b57bad29879 to your computer and use it in GitHub Desktop.
WinRing0 redirect to PawnIO for EC access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright 2026 Valentin Radu | |
| // License: GPLv2 | |
| // | |
| // cl /nologo winring0.c kernel32.lib ntdll.lib /O1 /GS- /Gs9999999 /GF /kernel /link /DLL /ENTRY:DllMain /NODEFAULTLIB /SUBSYSTEM:windows /NOCOFFGRPINFO /ALIGN:16 /MERGE:.rdata=.text /MERGE:.pdata=.text /OUT:WinRing0x64.dll | |
| // | |
| // cl /nologo winring0.c kernel32.lib ntdll.lib /O1 /GS- /Gs9999999 /GF /kernel /link /DLL /ENTRY:DllMain /NODEFAULTLIB /SUBSYSTEM:windows /NOCOFFGRPINFO /ALIGN:16 /MERGE:.rdata=.text /MERGE:.pdata=.text /OUT:WinRing0.dll | |
| // | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <ntstatus.h> | |
| #define WIN32_NO_STATUS | |
| #include <Windows.h> | |
| #include <winternl.h> | |
| #include <winioctl.h> | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI GetDllVersion() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI GetDriverVersion() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI GetDriverType() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI IsCpuid() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI IsMsr() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI IsTsc() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Hlt() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI HltTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI HltPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Rdmsr() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdmsrTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdmsrPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Wrmsr() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WrmsrTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WrmsrPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Rdpmc() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdpmcTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdpmcPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Cpuid() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI CpuidTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI CpuidPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI Rdtsc() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdtscTx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI RdtscPx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadIoPortWord() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadIoPortDword() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadIoPortByteEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadIoPortWordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadIoPortDwordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortWord() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortDword() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortByteEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortWordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortDwordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI SetPciMaxBusIndex() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigByte() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigWord() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigDword() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigByteEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigWordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPciConfigDwordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigByte() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigWord() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigDword() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigByteEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigWordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePciConfigDwordEx() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI FindPciDeviceById() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI FindPciDeviceByClass() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadDmiMemory() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI ReadPhysicalMemory() {} | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WritePhysicalMemory() {} | |
| #ifndef _WIN64 | |
| #pragma comment(linker, "/export:DeinitializeOls=_DeinitializeOls@0") | |
| #pragma comment(linker, "/export:GetDllStatus=_GetDllStatus@0") | |
| #pragma comment(linker, "/export:InitializeOls=_InitializeOls@0") | |
| #pragma comment(linker, "/export:ReadIoPortByte=_ReadIoPortByte@4") | |
| #pragma comment(linker, "/export:WriteIoPortByte=_WriteIoPortByte@8") | |
| #pragma comment(linker, "/export:GetDllVersion=_GetDllVersion@0") | |
| #pragma comment(linker, "/export:GetDriverVersion=_GetDriverVersion@0") | |
| #pragma comment(linker, "/export:GetDriverType=_GetDriverType@0") | |
| #pragma comment(linker, "/export:IsCpuid=_IsCpuid@0") | |
| #pragma comment(linker, "/export:IsMsr=_IsMsr@0") | |
| #pragma comment(linker, "/export:IsTsc=_IsTsc@0") | |
| #pragma comment(linker, "/export:Hlt=_Hlt@0") | |
| #pragma comment(linker, "/export:HltTx=_HltTx@0") | |
| #pragma comment(linker, "/export:HltPx=_HltPx@0") | |
| #pragma comment(linker, "/export:Rdmsr=_Rdmsr@0") | |
| #pragma comment(linker, "/export:RdmsrTx=_RdmsrTx@0") | |
| #pragma comment(linker, "/export:RdmsrPx=_RdmsrPx@0") | |
| #pragma comment(linker, "/export:Wrmsr=_Wrmsr@0") | |
| #pragma comment(linker, "/export:WrmsrTx=_WrmsrTx@0") | |
| #pragma comment(linker, "/export:WrmsrPx=_WrmsrPx@0") | |
| #pragma comment(linker, "/export:Rdpmc=_Rdpmc@0") | |
| #pragma comment(linker, "/export:RdpmcTx=_RdpmcTx@0") | |
| #pragma comment(linker, "/export:RdpmcPx=_RdpmcPx@0") | |
| #pragma comment(linker, "/export:Cpuid=_Cpuid@0") | |
| #pragma comment(linker, "/export:CpuidTx=_CpuidTx@0") | |
| #pragma comment(linker, "/export:CpuidPx=_CpuidPx@0") | |
| #pragma comment(linker, "/export:Rdtsc=_Rdtsc@0") | |
| #pragma comment(linker, "/export:RdtscTx=_RdtscTx@0") | |
| #pragma comment(linker, "/export:RdtscPx=_RdtscPx@0") | |
| #pragma comment(linker, "/export:ReadIoPortWord=_ReadIoPortWord@0") | |
| #pragma comment(linker, "/export:ReadIoPortDword=_ReadIoPortDword@0") | |
| #pragma comment(linker, "/export:ReadIoPortByteEx=_ReadIoPortByteEx@0") | |
| #pragma comment(linker, "/export:ReadIoPortWordEx=_ReadIoPortWordEx@0") | |
| #pragma comment(linker, "/export:ReadIoPortDwordEx=_ReadIoPortDwordEx@0") | |
| #pragma comment(linker, "/export:WriteIoPortWord=_WriteIoPortWord@0") | |
| #pragma comment(linker, "/export:WriteIoPortDword=_WriteIoPortDword@0") | |
| #pragma comment(linker, "/export:WriteIoPortByteEx=_WriteIoPortByteEx@0") | |
| #pragma comment(linker, "/export:WriteIoPortWordEx=_WriteIoPortWordEx@0") | |
| #pragma comment(linker, "/export:WriteIoPortDwordEx=_WriteIoPortDwordEx@0") | |
| #pragma comment(linker, "/export:SetPciMaxBusIndex=_SetPciMaxBusIndex@0") | |
| #pragma comment(linker, "/export:ReadPciConfigByte=_ReadPciConfigByte@0") | |
| #pragma comment(linker, "/export:ReadPciConfigWord=_ReadPciConfigWord@0") | |
| #pragma comment(linker, "/export:ReadPciConfigDword=_ReadPciConfigDword@0") | |
| #pragma comment(linker, "/export:ReadPciConfigByteEx=_ReadPciConfigByteEx@0") | |
| #pragma comment(linker, "/export:ReadPciConfigWordEx=_ReadPciConfigWordEx@0") | |
| #pragma comment(linker, "/export:ReadPciConfigDwordEx=_ReadPciConfigDwordEx@0") | |
| #pragma comment(linker, "/export:WritePciConfigByte=_WritePciConfigByte@0") | |
| #pragma comment(linker, "/export:WritePciConfigWord=_WritePciConfigWord@0") | |
| #pragma comment(linker, "/export:WritePciConfigDword=_WritePciConfigDword@0") | |
| #pragma comment(linker, "/export:WritePciConfigByteEx=_WritePciConfigByteEx@0") | |
| #pragma comment(linker, "/export:WritePciConfigWordEx=_WritePciConfigWordEx@0") | |
| #pragma comment(linker, "/export:WritePciConfigDwordEx=_WritePciConfigDwordEx@0") | |
| #pragma comment(linker, "/export:FindPciDeviceById=_FindPciDeviceById@0") | |
| #pragma comment(linker, "/export:FindPciDeviceByClass=_FindPciDeviceByClass@0") | |
| #pragma comment(linker, "/export:ReadDmiMemory=_ReadDmiMemory@0") | |
| #pragma comment(linker, "/export:ReadPhysicalMemory=_ReadPhysicalMemory@0") | |
| #pragma comment(linker, "/export:WritePhysicalMemory=_WritePhysicalMemory@0") | |
| #endif | |
| static unsigned char LpcACPIEC[] = { | |
| 0x00, 0x02, 0x00, 0x00, 0x0b, 0xed, 0x20, 0x3f, 0xa9, 0x6f, 0x29, 0x7e, 0xba, 0x9b, 0x97, 0x52, | |
| 0x86, 0xda, 0x0d, 0x46, 0xe5, 0x8f, 0x01, 0xdb, 0xec, 0x36, 0x64, 0x00, 0x71, 0x87, 0x6c, 0xa6, | |
| 0x45, 0x64, 0x49, 0x73, 0x01, 0xf4, 0xd0, 0x69, 0x20, 0x94, 0x4a, 0xac, 0x33, 0xad, 0xd5, 0x8a, | |
| 0x84, 0x31, 0x62, 0x54, 0x83, 0x61, 0xe8, 0x68, 0xc8, 0xe3, 0xd7, 0xdf, 0x49, 0x86, 0xd3, 0xf4, | |
| 0xc0, 0x46, 0x46, 0xa9, 0x17, 0xf6, 0xba, 0xce, 0x51, 0x4f, 0xf2, 0x6f, 0xb7, 0x86, 0x6a, 0xcf, | |
| 0xb8, 0xcc, 0xc1, 0x41, 0x17, 0xfb, 0x38, 0xe4, 0xb0, 0x36, 0x62, 0xdc, 0x0f, 0x46, 0xed, 0xb2, | |
| 0x3c, 0x07, 0x51, 0x34, 0x5e, 0x4f, 0xbc, 0x6e, 0xd3, 0x55, 0x31, 0x9d, 0x78, 0x91, 0x6f, 0xcb, | |
| 0x3a, 0xe3, 0xde, 0x09, 0x98, 0xed, 0x7e, 0xc3, 0xee, 0xf6, 0x46, 0x31, 0x9a, 0x29, 0xa7, 0x74, | |
| 0x33, 0x56, 0x52, 0xa1, 0x97, 0xa6, 0x93, 0xaf, 0x90, 0x22, 0x3d, 0x4f, 0xb0, 0xad, 0xce, 0xc5, | |
| 0x31, 0x99, 0x21, 0xe0, 0x26, 0xd9, 0xd2, 0x8b, 0xbf, 0xdb, 0xeb, 0xd0, 0x07, 0x06, 0x2b, 0xdb, | |
| 0x09, 0xb9, 0xfc, 0xb9, 0xc0, 0x47, 0xcb, 0x9c, 0xb7, 0x45, 0xf5, 0x1e, 0xb3, 0xde, 0x7a, 0xd6, | |
| 0x92, 0xc8, 0xc5, 0xdb, 0xd1, 0xad, 0x27, 0x93, 0x98, 0x83, 0xb6, 0xc0, 0x36, 0x68, 0x0c, 0xa4, | |
| 0x2f, 0xdc, 0x2b, 0xfe, 0xe6, 0x13, 0x9f, 0xb5, 0x2a, 0x35, 0x1e, 0x27, 0x0f, 0x81, 0x6d, 0x8d, | |
| 0xe4, 0x00, 0x2f, 0x6d, 0xe5, 0xa5, 0x9b, 0x8c, 0x4c, 0x3a, 0xf5, 0x11, 0x41, 0xc7, 0xf3, 0x12, | |
| 0x39, 0xa9, 0x0e, 0x1f, 0x1a, 0x84, 0xb6, 0x88, 0x00, 0xbc, 0x16, 0xea, 0xb9, 0xa9, 0x31, 0x9f, | |
| 0x66, 0xf2, 0xdd, 0x89, 0xfc, 0x48, 0x0c, 0x37, 0x51, 0x30, 0x6c, 0xed, 0x86, 0x9c, 0x83, 0x4d, | |
| 0x7d, 0x3a, 0x26, 0x10, 0x7f, 0xc3, 0x4f, 0xbd, 0x77, 0x22, 0xdb, 0x60, 0x76, 0x9c, 0xec, 0x38, | |
| 0x03, 0x2a, 0xc2, 0x3f, 0xa5, 0x5b, 0x29, 0x33, 0xfe, 0x12, 0xbd, 0x7b, 0xc2, 0x7f, 0xa9, 0xee, | |
| 0xd8, 0x46, 0xc2, 0xec, 0xc3, 0xb7, 0x79, 0xd8, 0x1e, 0x7f, 0xe6, 0xc9, 0x2c, 0x97, 0xf3, 0x29, | |
| 0x0c, 0x26, 0xc5, 0xa4, 0x55, 0x9a, 0xd9, 0x3b, 0x99, 0x42, 0xf8, 0xe7, 0x5f, 0x9a, 0x5f, 0xa1, | |
| 0xd6, 0x12, 0x49, 0x4b, 0x04, 0xfb, 0x9d, 0x19, 0xd9, 0x73, 0x9c, 0xd7, 0x3c, 0x54, 0xfd, 0xec, | |
| 0xe4, 0xb1, 0x7a, 0xc8, 0xf3, 0x0b, 0xa8, 0x00, 0xb3, 0x58, 0x95, 0x02, 0x4e, 0x88, 0xf6, 0xd9, | |
| 0x30, 0x2e, 0xfd, 0xa1, 0x88, 0x84, 0xc3, 0x81, 0x02, 0xc7, 0x63, 0xb6, 0x86, 0xd2, 0x5c, 0x86, | |
| 0x0f, 0x64, 0x7b, 0xb4, 0x43, 0xc7, 0xae, 0x03, 0x71, 0x8d, 0x46, 0xc0, 0x5a, 0xd2, 0x38, 0x05, | |
| 0x47, 0x50, 0x2d, 0xcb, 0x73, 0x1a, 0x19, 0xce, 0x92, 0xf2, 0x06, 0x85, 0x3c, 0x2d, 0x57, 0x66, | |
| 0xd0, 0xb4, 0x2b, 0x56, 0xae, 0xd0, 0xf7, 0x5f, 0xb4, 0xa0, 0xf4, 0x21, 0xba, 0x07, 0xc0, 0xce, | |
| 0x58, 0xdf, 0x43, 0xae, 0x4f, 0xb4, 0x05, 0x24, 0xad, 0xbf, 0xf7, 0xe9, 0x1f, 0xa3, 0xc7, 0xaf, | |
| 0x4a, 0xfb, 0xa3, 0x05, 0xd3, 0x22, 0xad, 0x2f, 0x05, 0xcd, 0x2b, 0x81, 0xcb, 0xb4, 0xae, 0x68, | |
| 0x94, 0x76, 0xeb, 0xcf, 0x28, 0xe4, 0x4e, 0xcc, 0x8d, 0x19, 0x7d, 0x52, 0x18, 0x0b, 0xbe, 0xe8, | |
| 0x93, 0xa5, 0x12, 0xec, 0x2e, 0x80, 0x6e, 0x3f, 0x40, 0xe8, 0xf4, 0x5f, 0xb0, 0xd2, 0x88, 0x6a, | |
| 0x42, 0xe3, 0xac, 0x03, 0xb0, 0xff, 0xf5, 0x70, 0x5c, 0x08, 0xb6, 0x48, 0xf0, 0x30, 0x00, 0x8b, | |
| 0x16, 0xd6, 0x46, 0xc8, 0x8f, 0x36, 0xeb, 0x75, 0xf7, 0x58, 0x13, 0x09, 0xcf, 0xb0, 0x6d, 0x0f, | |
| 0x74, 0x7d, 0x70, 0xff, 0x30, 0x08, 0x00, 0x00, 0xe1, 0xf1, 0x0b, 0x0b, 0x00, 0x00, 0x08, 0x00, | |
| 0x98, 0x00, 0x00, 0x00, 0x30, 0x08, 0x00, 0x00, 0x30, 0x08, 0x00, 0x00, 0x30, 0x88, 0x00, 0x00, | |
| 0x70, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, | |
| 0x5c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, | |
| 0xc8, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, | |
| 0x1f, 0x00, 0x69, 0x6f, 0x63, 0x74, 0x6c, 0x5f, 0x70, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, | |
| 0x00, 0x69, 0x6f, 0x63, 0x74, 0x6c, 0x5f, 0x70, 0x69, 0x6f, 0x5f, 0x77, 0x72, 0x69, 0x74, 0x65, | |
| 0x00, 0x69, 0x6f, 0x5f, 0x69, 0x6e, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x00, 0x69, 0x6f, 0x5f, 0x6f, | |
| 0x75, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xfd, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x1c, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x90, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x24, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0xc0, | |
| 0xff, 0xff, 0xff, 0xff, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, | |
| 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00 | |
| }; | |
| #define CTL_CODE( DeviceType, Function, Method, Access ) ( \ | |
| ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ | |
| ) | |
| //ULONG IOCTL_PIO_GET_REFCOUNT = CTL_CODE(41394, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS), | |
| ULONG IOCTL_PIO_LOAD_BINARY = CTL_CODE(41394, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS); | |
| ULONG IOCTL_PIO_EXECUTE_FN = CTL_CODE(41394, 0x841, METHOD_BUFFERED, FILE_ANY_ACCESS); | |
| ULONG IOCTL_PIO_VERSION = CTL_CODE(41394, 0x861, METHOD_BUFFERED, FILE_ANY_ACCESS); | |
| void SubstitutePort(USHORT* port) { | |
| if (*port == 0x1600) | |
| *port = 0x62; | |
| else if (*port == 0x1604) | |
| *port = 0x66; | |
| } | |
| #define STR(a) XSTR(a) | |
| #define XSTR(a) #a | |
| DWORD DllStatus = S_OK; | |
| #ifdef WITH_ACCESS_EC | |
| HANDLE hAccEC = NULL; | |
| #endif | |
| HANDLE hPawnIO = NULL; | |
| IO_STATUS_BLOCK iosb; | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| BOOL WINAPI InitializeOls() { | |
| #ifdef WITH_ACCESS_EC | |
| hAccEC = CreateMutexW(NULL, FALSE, L"Global\\Access_EC"); | |
| if (!hAccEC) { | |
| DllStatus = 2; | |
| return FALSE; | |
| } | |
| #endif | |
| UNICODE_STRING ustr; | |
| RtlInitUnicodeString(&ustr, L"\\Device\\PawnIO"); | |
| OBJECT_ATTRIBUTES attr; | |
| attr.Length = sizeof(attr); | |
| attr.RootDirectory = NULL; | |
| attr.ObjectName = &ustr; | |
| attr.Attributes = 0; | |
| attr.SecurityDescriptor = NULL; | |
| attr.SecurityQualityOfService = NULL; | |
| NTSTATUS status = NtOpenFile(&hPawnIO, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, &attr, &iosb, | |
| FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_SYNCHRONOUS_IO_NONALERT); | |
| HRESULT hr = HRESULT_FROM_WIN32(RtlNtStatusToDosError(status)); | |
| if (FAILED(hr)) { | |
| DllStatus = hr; | |
| return FALSE; | |
| } | |
| status = NtDeviceIoControlFile(hPawnIO, NULL, NULL, NULL, &iosb, | |
| IOCTL_PIO_LOAD_BINARY, LpcACPIEC, sizeof(LpcACPIEC), NULL, 0); | |
| hr = HRESULT_FROM_WIN32(RtlNtStatusToDosError(status)); | |
| if (FAILED(hr)) { | |
| NtClose(hPawnIO); | |
| hPawnIO = NULL; | |
| DllStatus = hr; | |
| return FALSE; | |
| } | |
| DllStatus = 0; | |
| return TRUE; | |
| } | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| DWORD WINAPI GetDllStatus() { | |
| return DllStatus; | |
| } | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI DeinitializeOls() { | |
| if (hPawnIO) { | |
| NtClose(hPawnIO); | |
| hPawnIO = NULL; | |
| } | |
| #ifdef WITH_ACCESS_EC | |
| if (hAccEC) { | |
| CloseHandle(hAccEC); | |
| hAccEC = NULL; | |
| } | |
| #endif | |
| } | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| BYTE WINAPI ReadIoPortByte(USHORT port) { | |
| SubstitutePort(&port); | |
| ULONG64 in[5] = { 0x69705f6c74636f69, 0x646165725f6f, 0, 0, port }; | |
| ULONG64 out[1] = { 0 }; | |
| if (hPawnIO) { | |
| #ifdef WITH_ACCESS_EC | |
| if (hAccEC) | |
| WaitForSingleObject(hAccEC, INFINITE); | |
| #endif | |
| NtDeviceIoControlFile(hPawnIO, NULL, NULL, NULL, &iosb, | |
| IOCTL_PIO_EXECUTE_FN, in, sizeof(in), out, sizeof(out)); | |
| #ifdef WITH_ACCESS_EC | |
| if (hAccEC) | |
| ReleaseMutex(hAccEC); | |
| #endif | |
| } | |
| return out[0]; | |
| } | |
| #ifdef _WIN64 | |
| __declspec(dllexport) | |
| #endif | |
| void WINAPI WriteIoPortByte(USHORT port, BYTE value) { | |
| SubstitutePort(&port); | |
| ULONG64 in[6] = { 0x69705f6c74636f69, 0x65746972775f6f, 0, 0, port, value }; | |
| if (hPawnIO) { | |
| #ifdef WITH_ACCESS_EC | |
| if (hAccEC) | |
| WaitForSingleObject(hAccEC, INFINITE); | |
| #endif | |
| NtDeviceIoControlFile(hPawnIO, NULL, NULL, NULL, &iosb, | |
| IOCTL_PIO_EXECUTE_FN, in, sizeof(in), NULL, 0); | |
| #ifdef WITH_ACCESS_EC | |
| if (hAccEC) | |
| ReleaseMutex(hAccEC); | |
| #endif | |
| } | |
| } | |
| BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved) { | |
| UNREFERENCED_PARAMETER(lpReserved); | |
| switch (fdwReason) { | |
| case DLL_PROCESS_ATTACH: | |
| DisableThreadLibraryCalls(hModule); | |
| break; | |
| case DLL_PROCESS_DETACH: | |
| break; | |
| default: | |
| break; | |
| } | |
| return TRUE; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment