From 813dccd9fa499fa74f192c52779a107da7338365 Mon Sep 17 00:00:00 2001 From: sacx Date: Wed, 14 Dec 2022 22:05:12 +0200 Subject: [PATCH] Added GlobalFlags --- speakeasy/winenv/api/usermode/kernel32.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/speakeasy/winenv/api/usermode/kernel32.py b/speakeasy/winenv/api/usermode/kernel32.py index 56baca0..8e0d581 100644 --- a/speakeasy/winenv/api/usermode/kernel32.py +++ b/speakeasy/winenv/api/usermode/kernel32.py @@ -1958,6 +1958,26 @@ def GlobalSize(self, emu, argv, ctx={}): return size + @apihook('GlobalFlags', argc=1) + def GlobalFlags(self, emu, argv, ctx={}): + ''' + UINT GlobalFlags( + [in] HGLOBAL hMem + ); + ''' + hMem, = argv + flags = 0 + for mmap in emu.get_mem_maps(): + if hMem == mmap.get_base(): + flags = mmap.get_flags() + emu.set_last_error(windefs.ERROR_SUCCESS) + + if not flags: + emu.set_last_error(windefs.ERROR_INVALID_PARAMETER) + flags = 0x8000 #GMEM_INVALID_HANDLE + + return flags + @apihook('LocalAlloc', argc=2) def LocalAlloc(self, emu, argv, ctx={}): '''