Top Level Namespace

Defined Under Namespace

Classes: LiveIdentity

Instance Method Summary collapse

Instance Method Details

#getStringLength(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/live_identity/idcrl.rb', line 10

def getStringLength(data)
    length = 0
    count = 0
    offset = 0
    previous = nil
    while count < 2
        data.get_bytes(offset, 100).each_byte do |byte|
            length = length + 1
            count = count + 1 if byte.zero? and previous.zero?
            previous = byte
            return length - 2 if count >= 2
        end
        offset += 100
        break if offset >= 100000
    end
    length
end

#read_wide_string(data, encoding = 'UTF-16LE') ⇒ Object



32
33
34
# File 'lib/live_identity/idcrl.rb', line 32

def read_wide_string(data, encoding = 'UTF-16LE')
    data.read_bytes(getStringLength(data)).force_encoding(encoding).encode('UTF-8')
end

#StringToWSTR(str, encoding = 'UTF-16LE') ⇒ Object



28
29
30
# File 'lib/live_identity/idcrl.rb', line 28

def StringToWSTR(str, encoding = 'UTF-16LE')
    [str.encode('UTF-16LE')].pack('a*xx')
end