<commit_before>require 'ffi'
require 'win_common/typedefs'
require 'win_common/structs'
require 'win_common/crypt/structs'

require_relative 'idcrl/constants'
require_relative 'idcrl/enums'
require_relative 'idcrl/hresult'

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 >= 10000
    end
    length
end

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

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

module WinCommon::Errors::HRESULT
    include LiveIdentity::IDCRL::HRESULT
end

class LiveIdentity
    include IDCRL::Constants
    module IDCRL<commit_msg>Increase wide string max byte limit to 100000<commit_after>require 'ffi'
require 'win_common/typedefs'
require 'win_common/structs'
require 'win_common/crypt/structs'

require_relative 'idcrl/constants'
require_relative 'idcrl/enums'
require_relative 'idcrl/hresult'

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

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

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

module WinCommon::Errors::HRESULT
    include LiveIdentity::IDCRL::HRESULT
end

class LiveIdentity
    include IDCRL::Constants
    module IDCRL
{'fraction_non_alphanumeric': 0.09666505558240696, 'fraction_numerical': 0.027549540840985983, 'mean_word_length': 3.074803149606299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4980538', 'n_tokens_mistral': 705, 'n_tokens_neox': 648, 'n_words': 170}