| 237 | } |
| 238 | |
| 239 | HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject, |
| 240 | _In_ DWORD dwDesiredAccess, |
| 241 | _In_ DWORD dwFileOffsetHigh, |
| 242 | _In_ DWORD dwFileOffsetLow, |
| 243 | _In_ SIZE_T dwNumberOfBytesToMap) { |
| 244 | if (hFileMappingObject == resources_pak_map) { |
| 245 | // Modify it to be modifiable. |
| 246 | LPVOID buffer = |
| 247 | RawMapViewOfFile(hFileMappingObject, FILE_MAP_COPY, dwFileOffsetHigh, |
| 248 | dwFileOffsetLow, dwNumberOfBytesToMap); |
| 249 | |
| 250 | // No more hook needed. |
| 251 | resources_pak_map = nullptr; |
| 252 | DetourTransactionBegin(); |
| 253 | DetourUpdateThread(GetCurrentThread()); |
| 254 | DetourDetach(reinterpret_cast<LPVOID*>(&RawMapViewOfFile), |
| 255 | reinterpret_cast<void*>(MyMapViewOfFile)); |
| 256 | auto status = DetourTransactionCommit(); |
| 257 | if (status != NO_ERROR) { |
| 258 | DebugLog(L"Unhook RawMapViewOfFile failed {}", status); |
| 259 | } |
| 260 | |
| 261 | if (buffer) { |
| 262 | PatchResourcesPak(static_cast<uint8_t*>(buffer)); |
| 263 | } |
| 264 | |
| 265 | return buffer; |
| 266 | } |
| 267 | |
| 268 | return RawMapViewOfFile(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, |
| 269 | dwFileOffsetLow, dwNumberOfBytesToMap); |
| 270 | } |
| 271 | |
| 272 | // Identify `resources.pak` where it is mapped, by querying the handle, rather |
| 273 | // than where it is opened. Chrome maps the pak with |
nothing calls this directly
no test coverage detected