| 4 | #include <filesystem> |
| 5 | |
| 6 | void SymbolHelper::Init() { |
| 7 | void* win32kBase = Helpers::GetWin32kBase(); |
| 8 | DWORD size = Helpers::GetWin32kImageSize(); |
| 9 | char symPath[MAX_PATH]; |
| 10 | ::GetCurrentDirectoryA(MAX_PATH, symPath); |
| 11 | std::string pdbPath = "\\Symbols"; |
| 12 | std::string name; |
| 13 | pdbPath = symPath + pdbPath; |
| 14 | |
| 15 | for (auto& iter : std::filesystem::directory_iterator(pdbPath)) { |
| 16 | auto filename = iter.path().filename().string(); |
| 17 | if (filename.find("win32") != std::string::npos) { |
| 18 | name = filename; |
| 19 | break; |
| 20 | } |
| 21 | } |
| 22 | std::string pdbFile = pdbPath + "\\" + name; |
| 23 | _win32kSize = size; |
| 24 | _win32kPdb = pdbFile; |
| 25 | _win32kModule = std::string(name, 0, name.find(".")); |
| 26 | |
| 27 | #ifdef _WIN64 |
| 28 | _win32kBase = (DWORD64)win32kBase; |
| 29 | #else |
| 30 | _win32kBase = (DWORD32)win32kBase; |
| 31 | #endif |
| 32 | |
| 33 | void* kernelBase = Helpers::GetKernelBase(); |
| 34 | size = Helpers::GetKernelImageSize(); |
| 35 | |
| 36 | for (auto& iter : std::filesystem::directory_iterator(pdbPath)) { |
| 37 | auto filename = iter.path().filename().string(); |
| 38 | if (filename.find("ntk") != std::string::npos) { |
| 39 | name = filename; |
| 40 | break; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | ATLTRACE("%s", name.c_str()); |
| 45 | |
| 46 | |
| 47 | |
| 48 | pdbFile = pdbPath + "\\" + name; |
| 49 | _kernelSize = size; |
| 50 | _kernelPdb = pdbFile; |
| 51 | _kernelModule = std::string(name, 0, name.find(".")); |
| 52 | #ifdef _WIN64 |
| 53 | _kernelBase = (DWORD64)kernelBase; |
| 54 | #else |
| 55 | _kernelBase = (DWORD)kernelBase; |
| 56 | #endif |
| 57 | |
| 58 | void* flgmgrBase = Helpers::GetKernelModuleBase("fltmgr.sys"); |
| 59 | size = Helpers::GetKernelModuleImageSize("fltmgr.sys"); |
| 60 | for (auto& iter : std::filesystem::directory_iterator(pdbPath)) { |
| 61 | auto filename = iter.path().filename().string(); |
| 62 | if (filename.find("flt") != std::string::npos) { |
| 63 | name = filename; |
no test coverage detected