Module: WinCred::Conversion

Defined in:
lib/wincred/conversion.rb

Overview

Responsible for converting w_char pointer to Ruby string

Class Method Summary collapse

Class Method Details

.pwchar_to_str(ptr) ⇒ Object



11
12
13
# File 'lib/wincred/conversion.rb', line 11

def pwchar_to_str(ptr)
  ptr.to_str(wcsnlen(ptr) * 2).force_encoding('utf-16le')
end

.wcsnlen(ptr, maxlen = 1024) ⇒ Object



7
8
9
# File 'lib/wincred/conversion.rb', line 7

def wcsnlen(ptr, maxlen = 1024)
  (0...maxlen).find { |i| (ptr[i * 2] | ptr[i * 2 + 1]).zero? }
end