Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no unicode write for process write #59

Closed
deadash opened this issue Mar 24, 2020 · 1 comment
Closed

no unicode write for process write #59

deadash opened this issue Mar 24, 2020 · 1 comment

Comments

@deadash
Copy link

deadash commented Mar 24, 2020

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

@MarioVilas
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants