mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
windows.com.init does not raise anymore if CoInitializeEx fails but return error code + cosmetic
This commit is contained in:
+4
-3
@@ -16,9 +16,10 @@ from windows.generated_def.interfaces import generate_IID, IID
|
||||
# "-".join("{:02X}".format(c) for c in struct.unpack("<IHHHBBBBBB", x))
|
||||
|
||||
def init():
|
||||
t = winproxy.CoInitializeEx()
|
||||
if t:
|
||||
return t
|
||||
try:
|
||||
winproxy.CoInitializeEx()
|
||||
except WindowsError as e:
|
||||
return e.winerror
|
||||
return winproxy.CoInitializeSecurity(0, -1, None, 0, 0, RPC_C_IMP_LEVEL_IMPERSONATE, 0,0,0)
|
||||
|
||||
|
||||
|
||||
@@ -119,13 +119,13 @@ def load_dll_in_remote_process(target, dll_name):
|
||||
raise ValueError("Kernel32 have no export <LoadLibraryA> (wtf)")
|
||||
|
||||
with target.allocated_memory(0x1000) as addr:
|
||||
# target.write_memory(addr, dll_name + "\x00")
|
||||
target.write_memory(addr, (dll_name + "\x00").encode('utf-16le'))
|
||||
t = target.create_thread(load_libraryW, addr)
|
||||
t.wait()
|
||||
if not t.exit_code:
|
||||
raise InjectionFailedError(u"Injection of <{0}> failed".format(dll_name))
|
||||
dbgprint("DLL Injected via LoadLibray", "DLLINJECT")
|
||||
# Cannot return the full return value of load_libraryW in 64b target.. (exit_code is a DWORD)
|
||||
return t.exit_code
|
||||
# Hardcore mode
|
||||
# We don't have k32 or PEB->Ldr
|
||||
|
||||
@@ -7,10 +7,6 @@ from windows.generated_def.winstructs import *
|
||||
from windows.utils import transform_ctypes_fields
|
||||
import windows.remotectypes as rctypes
|
||||
|
||||
# This must go to windefs
|
||||
IMAGE_DIRECTORY_ENTRY_EXPORT = 0
|
||||
IMAGE_DIRECTORY_ENTRY_IMPORT = 1
|
||||
|
||||
IMAGE_ORDINAL_FLAG32 = 0x80000000
|
||||
IMAGE_ORDINAL_FLAG64 = 0x8000000000000000
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class WmiRequester(object):
|
||||
|
||||
class WmiManager(dict):
|
||||
"""The main WMI class exposed, used to list and access differents WMI namespace, can be used as a dict to access
|
||||
:cls:`WmiRequester` by namespace"""
|
||||
:class:`WmiRequester` by namespace"""
|
||||
DEFAULT_NAMESPACE = "root\\cimv2"
|
||||
def __init__(self):
|
||||
self.wmi_requester_by_namespace = {}
|
||||
|
||||
Reference in New Issue
Block a user