MCPcopy Create free account
hub / github.com/0xJs/RedTeaming_CheatSheet / FindTarget

Function FindTarget

coding/projects/Code_Injection/MapView/implant.cpp:135–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135int FindTarget(const char *procname) {
136
137 HANDLE hProcSnap;
138 PROCESSENTRY32 pe32;
139 int pid = 0;
140
141 hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
142 if (INVALID_HANDLE_VALUE == hProcSnap) return 0;
143
144 pe32.dwSize = sizeof(PROCESSENTRY32);
145
146 if (!Process32First(hProcSnap, &pe32)) {
147 CloseHandle(hProcSnap);
148 return 0;
149 }
150
151 while (Process32Next(hProcSnap, &pe32)) {
152 if (lstrcmpiA(procname, pe32.szExeFile) == 0) {
153 pid = pe32.th32ProcessID;
154 break;
155 }
156 }
157
158 CloseHandle(hProcSnap);
159
160 return pid;
161}
162
163HANDLE FindThread(int pid){
164

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected