From db14bc0294c35fcc525ce8c8406e6389e5334676 Mon Sep 17 00:00:00 2001 From: hakril Date: Wed, 23 Oct 2024 10:10:40 +0200 Subject: [PATCH] Small COM fix/improvements --- windows/com.py | 10 ++++++++++ windows/debug/symbols.py | 4 +++- windows/security.py | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/windows/com.py b/windows/com.py index 4c8f925..418f485 100644 --- a/windows/com.py +++ b/windows/com.py @@ -69,12 +69,22 @@ class TypeInfo(interfaces.ITypeInfo): self.GetDocumentation(id, res, None, None, None) return res + +class MemoryIStream(gdef.IStream): + @classmethod + def create(cls): + self = cls() + windows.winproxy.CreateStreamOnHGlobal(ppstm=self) + return self + def create_instance(clsiid, targetinterface, custom_iid=None, context=CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER): """A simple wrapper around ``CoCreateInstance ``""" if custom_iid is None: custom_iid = targetinterface.IID if isinstance(clsiid, basestring): clsiid = IID.from_string(clsiid) + if isinstance(custom_iid, basestring): + custom_iid = IID.from_string(custom_iid) winproxy.CoCreateInstance(byref(clsiid), None, context, byref(custom_iid), byref(targetinterface)) return targetinterface diff --git a/windows/debug/symbols.py b/windows/debug/symbols.py index 94e0200..d14fb7f 100644 --- a/windows/debug/symbols.py +++ b/windows/debug/symbols.py @@ -238,6 +238,8 @@ class SymbolType(object): @property def children(self): count = self.nb_children + if count is None: + return None class res_struct(ctypes.Structure): _fields_ = [("Count", gdef.ULONG), ("Start", gdef.ULONG), ("Types", (gdef.ULONG * count))] x = res_struct() @@ -520,7 +522,7 @@ class SymbolHandler(object): else: callback = ctypes.WINFUNCTYPE(gdef.BOOL, ctypes.POINTER(SymbolInfo), gdef.ULONG , ctypes.py_object)(callback) - addr = getattr(mod, "addr", mod) # Retrieve mod.addr, else us the value directly + addr = getattr(mod, "addr", mod) # Retrieve mod.addr, else use the value directly windows.winproxy.SymSearchW(self.handle, gdef.DWORD64(addr), 0, tag, mask, 0, callback, res, options) for sym in res: sym.resolver = self diff --git a/windows/security.py b/windows/security.py index ced6d22..cc5ed9a 100644 --- a/windows/security.py +++ b/windows/security.py @@ -218,6 +218,7 @@ SPECIFIC_ACCESS_RIGTH_BY_TYPE = { "callback": CALLBACK_ACCESS_RIGHT, "mutant": MUTANT_ACCESS_RIGHT, "event": EVENT_ACCESS_RIGHT, + "section": SECTION_ACCESS_RIGHT, "semaphore": SEMAPHORE_ACCESS_RIGHT, "io_completion": IO_COMPLETION_ACCESS_RIGHT, "port": PORT_ACCESS_RIGHT,