mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Add unicode tests + comments
This commit is contained in:
@@ -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"
|
||||
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()
|
||||
@@ -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):
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user