-------------------------------------------------------------------------
| 79 | |
| 80 | //------------------------------------------------------------------------- |
| 81 | std::wstring GetMappedFileNameStr(HANDLE hfile) |
| 82 | { |
| 83 | DWORD dwFileSizeHi = 0; |
| 84 | DWORD dwFileSizeLo = GetFileSize(hfile, &dwFileSizeHi); |
| 85 | |
| 86 | if (dwFileSizeLo == 0 && dwFileSizeHi == 0) |
| 87 | THROW(L"Cannot map a file with a length of zero."); |
| 88 | |
| 89 | auto fileMappingHandle = CreateHandle( |
| 90 | CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 1, NULL), |
| 91 | CloseHandle); |
| 92 | |
| 93 | auto mapViewOfFile = CreateHandle( |
| 94 | MapViewOfFile(fileMappingHandle.GetValue(), FILE_MAP_READ, 0, 0, 1), |
| 95 | UnmapViewOfFile); |
| 96 | |
| 97 | TCHAR pszFilename[MAX_PATH + 1]; |
| 98 | |
| 99 | if (!GetMappedFileName(GetCurrentProcess(), |
| 100 | mapViewOfFile.GetValue(), |
| 101 | pszFilename, |
| 102 | MAX_PATH)) |
| 103 | { |
| 104 | THROW(L"Cannot GetMappedFileName"); |
| 105 | } |
| 106 | |
| 107 | return pszFilename; |
| 108 | } |
| 109 | |
| 110 | //------------------------------------------------------------------------- |
| 111 | std::wstring GetFinalPathName(HANDLE hfile) |
no test coverage detected