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

Function WindowCheckRoutine

Source/Client/NM_Engine/WindowCallback.cpp:24–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24DWORD WINAPI WindowCheckRoutine(LPVOID)
25{
26 DEBUG_LOG(LL_SYS, "Window watcher thread event has been started");
27
28 auto pWindowCheckTimer = CTimer<std::chrono::milliseconds>();
29
30 auto currentThread = std::shared_ptr<CThread>();
31 do
32 {
33 if (pWindowCheckTimer.diff() > 5000)
34 g_nmApp->OnCloseRequest(EXIT_ERR_WINDOW_CHECK_THREAD_TIMEOUT, g_winapiApiTable->GetLastError());
35
36 g_winapiApiTable->Sleep(10);
37 currentThread = g_nmApp->ThreadManagerInstance()->GetThreadFromThreadCode(SELF_THREAD_WINDOWCHECK);
38
39 } while (!IS_VALID_SMART_PTR(currentThread));
40
41
42 gs_hWndHandlerHook = g_winapiApiTable->SetWinEventHook(EVENT_MIN, EVENT_MAX, NULL, HandleWinEvent, 0, 0, WINEVENT_OUTOFCONTEXT);
43 if (!gs_hWndHandlerHook)
44 {
45 DEBUG_LOG(LL_ERR, "SetWinEventHook fail! Error: %u", g_winapiApiTable->GetLastError());
46 g_nmApp->OnCloseRequest(EXIT_ERR_WinEventHook_FAIL, g_winapiApiTable->GetLastError());
47 return 0;
48 }
49
50 auto pCheckTimer = CTimer<std::chrono::milliseconds>();
51
52 MSG message;
53 while (g_winapiApiTable->GetMessageA(&message, NULL, 0, 0))
54 {
55 g_winapiApiTable->TranslateMessage(&message);
56 g_winapiApiTable->DispatchMessageA(&message);
57
58 if (pCheckTimer.diff() > 5000)
59 {
60 // increase tick count
61 pCheckTimer.reset();
62 }
63 }
64
65 DEBUG_LOG(LL_ERR, "Window watcher timeout!");
66 g_nmApp->OnCloseRequest(EXIT_ERR_WinEventHook_TIMEOUT, g_winapiApiTable->GetLastError());
67
68 return 0;
69}
70
71#ifndef _M_X64
72__declspec(naked) void DummyFunc12()

Callers

nothing calls this directly

Calls 6

diffMethod · 0.80
OnCloseRequestMethod · 0.80
SleepMethod · 0.80
ThreadManagerInstanceMethod · 0.80
resetMethod · 0.80

Tested by

no test coverage detected