Fix corruption of non-latin characters in W methods

MS-2855/keylogger-mettle-extension
scriptjunkie 2017-11-21 20:58:38 -06:00
parent 879db5cf38
commit 9a81cc70dd
1 changed files with 2 additions and 2 deletions

View File

@ -53,14 +53,14 @@ module LibraryHelper
# converts ruby string to zero-terminated WCHAR string
def str_to_uni_z(str)
enc = str.unpack("C*").pack("v*")
enc = str.encode('UTF-16LE').force_encoding('binary')
enc += "\x00\x00"
return enc
end
# converts 0-terminated UTF16 to ruby string
def uniz_to_str(uniz)
uniz.unpack("v*").pack("C*").unpack("A*")[0]
uniz.force_encoding('UTF-16LE').encode('UTF-8')
end
# parses a number param and returns the value