MCPcopy Create free account
hub / github.com/cinit/WSAPatch / isAddressReadable

Function isAddressReadable

WsaPatch.cpp:92–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90usize kPageSize = 0;
91
92bool isAddressReadable(void *address) {
93 if (kPageSize == 0) {
94 SYSTEM_INFO si = {};
95 GetSystemInfo(&si);
96 kPageSize = si.dwPageSize;
97 }
98 void *pageBase = reinterpret_cast<void *>(reinterpret_cast<uintptr>(address) & ~(kPageSize - 1));
99 MEMORY_BASIC_INFORMATION info = {};
100 if (VirtualQuery(pageBase, &info, sizeof(info)) == 0) {
101 return false;
102 }
103 return (info.Protect & PAGE_READONLY) != 0 || (info.Protect & PAGE_READWRITE) != 0;
104}
105
106int HookIATProcedure(HMODULE hModule, LPCSTR procName, FARPROC replacement) {
107 if (hModule == nullptr || procName == nullptr || replacement == nullptr) {

Callers 1

HookIATProcedureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected