Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function baRBytes([Byte[]]$ba, [Int]$pos, [Int]$length)
- {
- $newbytes = [System.Byte[]]::CreateInstance([System.Byte],$length)
- [System.Buffer]::BlockCopy($bytes, $pos, $newbytes, 0, $length)
- return $newbytes
- }
- Function baRInt16([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToInt16($ba, $pos)
- }
- Function baRInt32([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToInt32($ba, $pos)
- }
- Function baRInt64([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToInt64($ba, $pos)
- }
- Function baRUInt16([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToUInt16($ba, $pos)
- }
- Function baRUInt32([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToUInt32($ba, $pos)
- }
- Function baRUInt64([Byte[]]$ba, [Int]$pos)
- {
- return [System.BitConverter]::ToUInt64($ba, $pos)
- }
- Function baRAString([Byte[]]$ba, [Int]$pos)
- {
- $length = 0x200
- if (($pos + $length) -gt $ba.length)
- {
- $length = $ba.length - $pos
- }
- $ascii = [System.Text.ASCIIEncoding]::new()
- return ($ascii.GetString($ba, $pos, $length)).Split(0)[0]
- }
- Function baRUString([Byte[]]$ba, [Int]$pos)
- {
- $length = 0x200
- if (($pos + $length) -gt $ba.length)
- {
- $length = $ba.length - $pos
- }
- $unicode = [System.Text.UnicodeEncoding]::new()
- return ($unicode.GetString($ba, $pos, $length)).Split(0)[0]
- }
- Function baWBytes([Byte[]]$ba, [Int]$pos, [Byte[]]$bins)
- {
- [System.Buffer]::BlockCopy($bins, 0, $ba, $pos, $bins.length)
- }
- Function baWInt16([Byte[]]$ba, [Int]$pos, [Int16]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWInt32([Byte[]]$ba, [Int]$pos, [Int32]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWInt64([Byte[]]$ba, [Int]$pos, [Int64]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWUInt16([Byte[]]$ba, [Int]$pos, [UInt16]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWUInt32([Byte[]]$ba, [Int]$pos, [UInt32]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWUInt64([Byte[]]$ba, [Int]$pos, [UInt64]$val)
- {
- baWBytes $ba $pos ([System.BitConverter]::GetBytes($val))
- }
- Function baWAString([Byte[]]$ba, [Int]$pos, [string]$str)
- {
- $ascii = [System.Text.ASCIIEncoding]::new()
- baWBytes $ba $pos ($ascii.GetBytes($str))
- }
- Function baWUString([Byte[]]$ba, [Int]$pos, [string]$str)
- {
- $unicode = [System.Text.UnicodeEncoding]::new()
- baWBytes $ba $pos ($unicode.GetBytes($str))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement