| 298 | } |
| 299 | |
| 300 | HANDLE WINAPI MyCreateFileMapping(_In_ HANDLE hFile, |
| 301 | _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, |
| 302 | _In_ DWORD flProtect, |
| 303 | _In_ DWORD dwMaximumSizeHigh, |
| 304 | _In_ DWORD dwMaximumSizeLow, |
| 305 | _In_opt_ LPCTSTR lpName) { |
| 306 | if (IsResourcesPak(hFile)) { |
| 307 | // Force copy-on-write so the mapped view can be patched in memory. |
| 308 | resources_pak_map = |
| 309 | RawCreateFileMapping(hFile, lpAttributes, PAGE_WRITECOPY, |
| 310 | dwMaximumSizeHigh, dwMaximumSizeLow, lpName); |
| 311 | |
| 312 | // No more hook needed. |
| 313 | DetourTransactionBegin(); |
| 314 | DetourUpdateThread(GetCurrentThread()); |
| 315 | DetourDetach(reinterpret_cast<LPVOID*>(&RawCreateFileMapping), |
| 316 | reinterpret_cast<void*>(MyCreateFileMapping)); |
| 317 | auto status = DetourTransactionCommit(); |
| 318 | if (status != NO_ERROR) { |
| 319 | DebugLog(L"Unhook RawCreateFileMapping failed {}", status); |
| 320 | } |
| 321 | |
| 322 | DetourTransactionBegin(); |
| 323 | DetourUpdateThread(GetCurrentThread()); |
| 324 | DetourAttach(reinterpret_cast<LPVOID*>(&RawMapViewOfFile), |
| 325 | reinterpret_cast<void*>(MyMapViewOfFile)); |
| 326 | status = DetourTransactionCommit(); |
| 327 | if (status != NO_ERROR) { |
| 328 | DebugLog(L"Hook RawMapViewOfFile failed {}", status); |
| 329 | } |
| 330 | |
| 331 | return resources_pak_map; |
| 332 | } |
| 333 | return RawCreateFileMapping(hFile, lpAttributes, flProtect, dwMaximumSizeHigh, |
| 334 | dwMaximumSizeLow, lpName); |
| 335 | } |
| 336 | |
| 337 | } // namespace |
| 338 |
nothing calls this directly
no test coverage detected