MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / OnScanProcess

Method OnScanProcess

Source/Client/NM_Engine/IProcessScanner.cpp:241–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void IScanner::OnScanProcess(DWORD dwProcessId)
242{
243 std::lock_guard <std::recursive_mutex> __lock(m_Mutex);
244
245 SCANNER_LOG(LL_SYS, "Process scanner has been started! Target process id: %u", dwProcessId);
246
247 if (IsScannedProcess(dwProcessId))
248 {
249 SCANNER_LOG(LL_SYS, "Process already scanned!");
250 return;
251 }
252
253 // Add to checked list
254 m_vScannedProcessIDs.push_back(dwProcessId);
255
256 // Quick filter for system process
257 if (dwProcessId <= 4)
258 {
259 SCANNER_LOG(LL_SYS, "System process scan passed!");
260 return;
261 }
262
263 // Check target pid is it our pid
264 if (g_winapiApiTable->GetCurrentProcessId() == dwProcessId)
265 {
266 SCANNER_LOG(LL_SYS, "Itself scan passed!");
267 return;
268 }
269
270 // Check target pid is protected from ourself
271 auto vLauncherProcesses = g_nmApp->InitMgrInstance()->m_vLaunchedProcesses;
272 if (vLauncherProcesses.empty() == false)
273 {
274 for (const auto & pCurrProc : vLauncherProcesses)
275 {
276 if (IS_VALID_SMART_PTR(pCurrProc))
277 {
278 if (pCurrProc->dwProcessId == dwProcessId)
279 {
280 SCANNER_LOG(LL_SYS, "Target process is protected by ourself!");
281 return;
282 }
283 }
284 }
285 }
286
287 // todo: get handle from kernelside
288
289 // Check quick alive status
290 auto hProcessSync = g_nmApp->DynamicWinapiInstance()->NTHelper()->OpenProcess(SYNCHRONIZE, dwProcessId);
291 if (!IS_VALID_HANDLE(hProcessSync))
292 {
293 SCANNER_LOG(LL_ERR, "Target process is not alive! Last error: %p", g_winapiApiTable->GetLastError());
294 return;
295 }
296 g_nmApp->DynamicWinapiInstance()->SafeCloseHandle(hProcessSync);
297
298 // Create handle access

Callers

nothing calls this directly

Calls 6

InitMgrInstanceMethod · 0.80
OpenProcessMethod · 0.80
NTHelperMethod · 0.80
DynamicWinapiInstanceMethod · 0.80
SafeCloseHandleMethod · 0.80
AccessHelperInstanceMethod · 0.80

Tested by

no test coverage detected