MarioVilas/winappdbg

no unicode write for process write

deadash opened this issue · 1 comments

def unicode_to_str(string):
    hex_s = binascii.hexlify(string)
    return ('00'.join(wrap(hex_s, 2)) + '000000').decode('hex')

I write a code for unicode to str and work fine. like process.write(addr, unicode_to_str('string' or u'unicode'))

should check lpBuffer in WriteProcessMemory ,like this:

    if isinstance(lpBuffer, (unicode,)):
        nSize                   = len(lpBuffer) * 2
        lpBuffer                = ctypes.create_unicode_buffer(lpBuffer)
   else:
       # old

and modify process.poke for len change

The problem with that unicode_to_str() function is it won't work for non-English text.

More generally this is the problem Python 3 tried to solve by splitting bytes and string types. I meant the process.write() method to be a low level way to write bytes into memory rather than actual strings with text.

I'd rather let the user define however they want how to encode their unicode strings into bytes and then use the write method.