mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Merge branch 'master' of github.com:hakril/PythonForWindows into master
This commit is contained in:
+4
-1
@@ -67,6 +67,9 @@ NDR_PACK_TEST_CASE = [
|
||||
(ndr.make_parameters([ndr.NdrByte, ndr.NdrHyper, ndr.NdrByte, ndr.NdrLong, ndr.NdrHyper]),
|
||||
(0x01, 0x4141414141414141, 0x42, 0x43434343, 0x4444444444444444 ),
|
||||
b"\x01PPPPPPPAAAAAAAABPPPCCCCDDDDDDDD"),
|
||||
# Test NdrContextHandle / NdrGuid (see https://github.com/hakril/PythonForWindows/issues/30)
|
||||
(ndr.NdrContextHandle, gdef.GUID.from_string("11223344-1122-3344-5566-424344454647"), b'\x00\x00\x00\x00D3"\x11"\x11D3UfBCDEFG'),
|
||||
(ndr.NdrGuid, gdef.GUID.from_string("11223344-1122-3344-5566-424344454647"), b'D3"\x11"\x11D3UfBCDEFG'),
|
||||
# Complexe structure (with 4B alignement of 20B structure)
|
||||
(ndr.make_parameters([ndr.NdrShort, DoubleDwordStructure]),
|
||||
(0x0101, [0x41414141, 0x42424242, 0x43434343, 0x44444444, 0x45454545]),
|
||||
@@ -165,4 +168,4 @@ def test_ndr_packing_complex_uac_call():
|
||||
0xffffffff]) # UAC Timeout
|
||||
|
||||
expected_result = b'\x02\x02\x02\x02 \x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00c\x00:\x00\\\x00w\x00i\x00n\x00d\x00o\x00w\x00s\x00\\\x00s\x00y\x00s\x00t\x00e\x00m\x003\x002\x00\\\x00n\x00o\x00t\x00e\x00p\x00a\x00d\x00.\x00e\x00x\x00e\x00\x00\x00\x02\x02\x02\x02\x16\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00\x00N\x00O\x00T\x00_\x00A\x00L\x00I\x00G\x00N\x00E\x00D\x00_\x00S\x00T\x00R\x00I\x00N\x00G\x00X\x00X\x00X\x00\x00\x00\x11\x00\x00\x00\x00\x04\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00PP\x10\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00W\x00i\x00n\x00S\x00t\x00a\x000\x00\\\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff'
|
||||
assert parameters == expected_result
|
||||
assert parameters == expected_result
|
||||
|
||||
+8
-2
@@ -3,6 +3,11 @@ import windows.generated_def as gdef
|
||||
|
||||
import struct
|
||||
|
||||
try:
|
||||
unichr # Py2/Py3 compat
|
||||
except NameError:
|
||||
unichr = chr
|
||||
|
||||
# http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm#tagcjh_19_03_07
|
||||
|
||||
## Array
|
||||
@@ -259,7 +264,7 @@ class NdrGuid(object):
|
||||
def pack(cls, data):
|
||||
if not isinstance(data, gdef.IID):
|
||||
data = gdef.IID.from_string(data)
|
||||
return str(bytearray(data))
|
||||
return bytes(bytearray(data))
|
||||
|
||||
@classmethod
|
||||
def unpack(self, stream):
|
||||
@@ -276,7 +281,7 @@ class NdrContextHandle(object):
|
||||
def pack(cls, data):
|
||||
if not isinstance(data, gdef.IID):
|
||||
data = gdef.IID.from_string(data)
|
||||
return struct.pack("<I", 0) + str(bytearray(data))
|
||||
return bytes(struct.pack("<I", 0) + bytearray(data))
|
||||
|
||||
@classmethod
|
||||
def unpack(self, stream):
|
||||
@@ -499,6 +504,7 @@ class NdrConformantVaryingArrays(object):
|
||||
# TODO: test on array of Hyper
|
||||
return max(4, self.MEMBER_TYPE.get_alignment())
|
||||
|
||||
|
||||
class NdrWcharConformantVaryingArrays(NdrConformantVaryingArrays):
|
||||
MEMBER_TYPE = NdrShort
|
||||
|
||||
|
||||
Reference in New Issue
Block a user