Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion windows/rpc/ndr.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def pack(cls, data):
return None
if not data.endswith('\x00'):
data += '\x00'
# Technically windows NDR seems to accept any bitstream that ends with '\x00\x00' here
# And not limited to valid utf-16
# Exemple: b'\x41\x00\x00\xD8'
data = data.encode("utf-16-le")
l = (len(data) // 2)
result = struct.pack("<3I", l, 0, l)
Expand All @@ -179,7 +182,7 @@ def unpack(cls, stream):

@classmethod
def get_alignment(self):
# Not sur, but size is on 4 bytes so...
# Not sure, but size is on 4 bytes so...
return 4

class NdrCString(object):
Expand All @@ -190,6 +193,10 @@ def pack(cls, data):
return None
if not data.endswith('\x00'):
data += '\x00'
# Windows NDR seems to accept any bitstream in a FC_C_CSTRING
# I was able to send range(1, 256) + b"\x00"
# For now play safe for user and only accept encoded with always keep the same number of bytes
data = data.encode("ascii")
l = len(data)
result = struct.pack("<3I", l, 0, l)
result += data
Expand Down
Loading