| 40 | } |
| 41 | |
| 42 | static DWORD GetProcessByName(PCSTR name) |
| 43 | { |
| 44 | WCHAR wide_name[MAX_PATH] = {}; |
| 45 | mbstowcs_s(NULL, wide_name, name, MAX_PATH); |
| 46 | |
| 47 | const scoped_handle snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); |
| 48 | |
| 49 | // Walk through all processes and search for the name |
| 50 | PROCESSENTRY32W process = { sizeof(process) }; |
| 51 | for (BOOL next = Process32FirstW(snapshot, &process); next; next = Process32NextW(snapshot, &process)) |
| 52 | { |
| 53 | if (wcscmp(process.szExeFile, wide_name) == 0) |
| 54 | { |
| 55 | return process.th32ProcessID; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | DWORD CALLBACK remote_main(BYTE *image_base) |
| 63 | { |