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:
|
# Special case:
|
||||||
# The user can choose to supply a Null pointer instead of a buffer
|
# 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
|
# 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
|
if args[param_idx] == nil
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -260,7 +260,7 @@ module Rex
|
||||||
# Special case:
|
# Special case:
|
||||||
# The user can choose to supply a Null pointer instead of a buffer
|
# 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
|
# 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
|
if args[param_idx] == nil
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -474,26 +474,15 @@ module Rex
|
||||||
end
|
end
|
||||||
|
|
||||||
# converts ruby string to zero-terminated WCHAR string
|
# converts ruby string to zero-terminated WCHAR string
|
||||||
def str_to_uni_z (str)
|
def str_to_uni_z(str)
|
||||||
enc = str.encode('UTF-16le').force_encoding("binary")
|
enc = str.unpack("C*").pack("v*")
|
||||||
enc += "\x00\x00"
|
enc += "\x00\x00"
|
||||||
return enc
|
return enc
|
||||||
end
|
end
|
||||||
|
|
||||||
# converts 0-terminated UTF16 to ruby string
|
# converts 0-terminated UTF16 to ruby string
|
||||||
def uniz_to_str(uniz)
|
def uniz_to_str(uniz)
|
||||||
# cast to UTF16
|
uniz.unpack("v*").pack("C*").unpack("A*")[0]
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -559,3 +548,4 @@ module Rex
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue