| 8 | #include <thread> |
| 9 | |
| 10 | bool GetExeInfo(LPCSTR fileName, ExeInfo& info) { |
| 11 | LOADED_IMAGE loadedImage; |
| 12 | if (!MapAndLoad(const_cast<PSTR>(fileName), nullptr, &loadedImage, FALSE, TRUE)) { |
| 13 | return false; |
| 14 | } |
| 15 | |
| 16 | info.managed = false; |
| 17 | if (loadedImage.FileHeader->Signature == IMAGE_NT_SIGNATURE) { |
| 18 | const DWORD netHeaderAddress = |
| 19 | loadedImage.FileHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress; |
| 20 | |
| 21 | if (netHeaderAddress) { |
| 22 | info.managed = true; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | info.entryPoint = loadedImage.FileHeader->OptionalHeader.AddressOfEntryPoint; |
| 27 | info.i386 = loadedImage.FileHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_I386; |
| 28 | |
| 29 | UnMapAndLoad(&loadedImage); |
| 30 | |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | int GetProcessByName(const char* name) { |
| 35 | DWORD pid = 0; |