diff --git a/tests/test_object_manager.py b/tests/test_object_manager.py index 6cc14ed..d3fde7f 100644 --- a/tests/test_object_manager.py +++ b/tests/test_object_manager.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import pytest import windows @@ -41,4 +43,17 @@ def test_complex_object_path(): def test_link_object(): obj = objmanager["\\KnownDLLs\\KnownDLLPath"] assert obj.type == "SymbolicLink" - assert obj.target.lower() == "c:\windows\system32" \ No newline at end of file + assert obj.target.lower() == "c:\windows\system32" + +# Test unicode string in Kernel object using an ALPC port + +UNICODE_PORT_NAME = u"こんにちは、世界!" +UNICODE_PORT_PATH = u"\\RPC Control\\" + UNICODE_PORT_NAME + +def test_unicode_kernel_object(): + alpc_port = windows.alpc.AlpcServer(UNICODE_PORT_PATH) + assert UNICODE_PORT_NAME in objmanager[u"\\RPC Control"].keys() + assert objmanager[UNICODE_PORT_PATH] + assert objmanager[UNICODE_PORT_PATH].fullname == UNICODE_PORT_PATH + import pdb;pdb.set_trace() + alpc_port.disconnect() \ No newline at end of file diff --git a/windows/winobject/object_manager.py b/windows/winobject/object_manager.py index 5a4c2f5..e1ac456 100644 --- a/windows/winobject/object_manager.py +++ b/windows/winobject/object_manager.py @@ -29,7 +29,7 @@ def query_link(linkpath): # If our initial 1000 buffer is not enought (improbable) retry with correct size v = gdef.LSA_UNICODE_STRING.from_size(s.value) winproxy.NtQuerySymbolicLinkObject(res, v, s) - return v.str + return v.str # Unicode class KernelObject(object): diff --git a/windows/winobject/process.py b/windows/winobject/process.py index 105e5f0..92d8121 100644 --- a/windows/winobject/process.py +++ b/windows/winobject/process.py @@ -672,9 +672,7 @@ class CurrentProcess(Process): def write_memory(self, addr, data): """Write data at addr""" - data = bytes(raw_encode(data)) - # buffertype = (c_char * len(data)).from_address(addr) - # buffertype[:len(data)] = data + data = bytes(raw_encode(data)) # We should only accept byte, but we are kind and will try to encode to latin-1 for simple ascii compat ctypes.memmove(addr, data, len(data)) return True @@ -1056,7 +1054,7 @@ class WinProcess(Process): def write_memory(self, addr, data): """Write `data` at `addr`""" - data = raw_encode(data) + data = raw_encode(data) # We should only accept byte, but we are kind and will try to encode to latin-1 for simple ascii compat if windows.current_process.bitness == 32 and self.bitness == 64: if not winproxy.is_implemented(winproxy.NtWow64WriteVirtualMemory64): raise ValueError("NtWow64WriteVirtualMemory64 non available in ntdll: cannot write into 64bits processus")