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

Function MyMapViewOfFile

src/pakpatch.cc:239–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239HANDLE 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

Callers

nothing calls this directly

Calls 2

DebugLogFunction · 0.85
PatchResourcesPakFunction · 0.85

Tested by

no test coverage detected