MCPcopy Create free account
hub / github.com/crosire/blink / GetProcessByName

Function GetProcessByName

source/main.cpp:42–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42static 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
62DWORD CALLBACK remote_main(BYTE *image_base)
63{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected