local raw_hwnd = utils.opcode_scan("engine.dll", "8B 0D ?? ?? ?? ?? 85 C9 74 16 8B 01 8B") or error("Invalid signature #1")
local raw_FlashWindow = utils.opcode_scan("gameoverlayrenderer.dll", "55 8B EC 83 EC 14 8B 45 0C F7") or error("Invalid signature #2")
local raw_insn_jmp_ecx = utils.opcode_scan("gameoverlayrenderer.dll", "FF E1") or error("Invalid signature #3")
local raw_GetForegroundWindow = utils.opcode_scan("gameoverlayrenderer.dll", "FF 15 ?? ?? ?? ?? 3B C6 74") or error("Invalid signature #4")
local hwnd_ptr = ((ffi.cast("uintptr_t***", ffi.cast("uintptr_t", raw_hwnd) + 2)[0])[0] + 2)
local FlashWindow = ffi.cast("int(__stdcall*)(uintptr_t, int)", raw_FlashWindow)
local insn_jmp_ecx = ffi.cast("int(__thiscall*)(uintptr_t)", raw_insn_jmp_ecx)
local GetForegroundWindow = (ffi.cast("uintptr_t**", ffi.cast("uintptr_t", raw_GetForegroundWindow) + 2)[0])[0]
local function get_csgo_hwnd()return hwnd_ptr[0]end
local function get_foreground_hwnd()return insn_jmp_ecx(GetForegroundWindow)end
ffi.cdef[[
typedef void* HWND;
int SetForegroundWindow(HWND hWnd);
]]
local user32 = ffi.load("user32")
notify = function()
if not menu.settings.modification.roundnotify:get() then return end
local csgo_hwnd = get_csgo_hwnd()
if get_foreground_hwnd() ~= csgo_hwnd then
if menu.settings.modification.roundnotify.notify:get() == 1 then
FlashWindow(csgo_hwnd, 1)
else
user32.SetForegroundWindow(ffi.cast("HWND", csgo_hwnd))
end
return true
end
return false
end
utils.execute_after(3, notify)