Pymem
Pymem copied to clipboard
There was a problem converting the string to bytes
Input_ String1="E8 29 05 00 00 43"
Ex_ String=bytes. from hex (input_string1)
#Output: b ' xe8) x05 x00 x00 , an error will appear below
#If using ex_ String=rb "\xe8\x29\x05\x00\x00", there will be no errors.
Pm=pymem Pymem ("* *. exe")
ModelMem=pymem. process. module_ From_ Name (pm. process_handle, "* *. exe")
Temp=pm. pattern_ Scan_ All (ex_string)
#An error occurred: unbalanced presentation at position 1
Python 3.11, the latest version of Pymem, Win10
Can you please tell me How should I solve it?
can you provide the original code and the full traceback?
I had a similar problem and it seems you have the classical problem of number of \ in the code, try this:
raw_input_string = "E8 29 05 00 00 43"
mod_input_string = r"\x" + raw_input_string.replace(" ", r"\x") # Spaces --> \x. Notice the r before the strings with \ in them
# mod_input_string should now be r"\xE8\x29\x05\x00\x00\x43"
ex_string = mod_input_string.encode("UTF-8")
print(f"len of ex_string is {len(ex_string)} which should show 24 (6*4)")
temp = pm.pattern_scan_all(ex_string)