Minor cleanups for railgun, fix 1.8/1.9 differences, remove use of string encoding routines for 1.8 back-compat
git-svn-id: file:///home/svn/framework3/trunk@9736 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
64fb3624d6
commit
a4c6280ae0
|
@ -206,7 +206,7 @@ module Rex
|
|||
# Special case:
|
||||
# The user can choose to supply a Null pointer instead of a buffer
|
||||
# in this case we don't need space in any heap buffer
|
||||
if param_desc[0][0] == 'P' # type is a pointer
|
||||
if param_desc[0][0,1] == 'P' # type is a pointer
|
||||
if args[param_idx] == nil
|
||||
next
|
||||
end
|
||||
|
@ -260,7 +260,7 @@ module Rex
|
|||
# Special case:
|
||||
# The user can choose to supply a Null pointer instead of a buffer
|
||||
# in this case we don't need space in any heap buffer
|
||||
if param_desc[0][0] == 'P' # type is a pointer
|
||||
if param_desc[0][0,1] == 'P' # type is a pointer
|
||||
if args[param_idx] == nil
|
||||
next
|
||||
end
|
||||
|
@ -475,25 +475,14 @@ module Rex
|
|||
|
||||
# converts ruby string to zero-terminated WCHAR string
|
||||
def str_to_uni_z(str)
|
||||
enc = str.encode('UTF-16le').force_encoding("binary")
|
||||
enc = str.unpack("C*").pack("v*")
|
||||
enc += "\x00\x00"
|
||||
return enc
|
||||
end
|
||||
|
||||
# converts 0-terminated UTF16 to ruby string
|
||||
def uniz_to_str(uniz)
|
||||
# cast to UTF16
|
||||
as_utf16 = uniz.force_encoding("UTF-16le")
|
||||
as_utf16_z = nil
|
||||
# find end
|
||||
zero_byte_idx = as_utf16.index("\x00\x00".force_encoding("UTF-16le"))
|
||||
if zero_byte_idx != nil
|
||||
as_utf16_z = as_utf16[0, zero_byte_idx]
|
||||
else
|
||||
as_utf16_z = as_utf16
|
||||
end
|
||||
|
||||
return as_utf16_z
|
||||
uniz.unpack("v*").pack("C*").unpack("A*")[0]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -559,3 +548,4 @@ module Rex
|
|||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
Loading…
Reference in New Issue