MCPcopy Create free account
hub / github.com/Bush2021/chrome_plus / MyCreateFileMapping

Function MyCreateFileMapping

src/pakpatch.cc:300–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300HANDLE 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

Callers

nothing calls this directly

Calls 2

IsResourcesPakFunction · 0.85
DebugLogFunction · 0.85

Tested by

no test coverage detected