MCPcopy Create free account
hub / github.com/NtQuery/Scylla / createFileMappingView

Method createFileMappingView

Scylla/ProcessAccessHelp.cpp:576–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576LPVOID ProcessAccessHelp::createFileMappingView(const WCHAR * filePath, DWORD accessFile, DWORD flProtect, DWORD accessMap)
577{
578 HANDLE hFile = CreateFile(filePath, accessFile, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
579
580 if( hFile == INVALID_HANDLE_VALUE )
581 {
582#ifdef DEBUG_COMMENTS
583 Scylla::debugLog.log(L"createFileMappingView :: INVALID_HANDLE_VALUE %u", GetLastError());
584#endif
585 return NULL;
586 }
587
588 HANDLE hMappedFile = CreateFileMapping(hFile, NULL, flProtect, 0, 0, NULL);
589 CloseHandle(hFile);
590
591 if( hMappedFile == NULL )
592 {
593#ifdef DEBUG_COMMENTS
594 Scylla::debugLog.log(L"createFileMappingView :: hMappedFile == NULL");
595#endif
596 return NULL;
597 }
598
599 if (GetLastError() == ERROR_ALREADY_EXISTS)
600 {
601#ifdef DEBUG_COMMENTS
602 Scylla::debugLog.log(L"createFileMappingView :: GetLastError() == ERROR_ALREADY_EXISTS");
603#endif
604 return NULL;
605 }
606
607 LPVOID addrMappedDll = MapViewOfFile(hMappedFile, accessMap, 0, 0, 0);
608
609 if( addrMappedDll == NULL )
610 {
611#ifdef DEBUG_COMMENTS
612 Scylla::debugLog.log(L"createFileMappingView :: addrMappedDll == NULL");
613#endif
614 CloseHandle(hMappedFile);
615 return NULL;
616 }
617
618 CloseHandle(hMappedFile);
619
620 return addrMappedDll;
621}
622
623DWORD ProcessAccessHelp::getProcessByName(const WCHAR * processName)
624{

Callers

nothing calls this directly

Calls 1

logMethod · 0.80

Tested by

no test coverage detected