Ctypes:写入访问冲突

2024-09-24 12:27:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我在研究ctypes的一些功能时遇到了这个问题:

import ctypes

hello = open("hello.exe")
shellcode = hello.read()

shellcode_buffer = ctypes.create_string_buffer(shellcode, len(shellcode))

shellcode_func = ctypes.cast(shellcode_buffer, ctypes.CFUNCTYPE(ctypes.c_void_p))

shellcode_func()

我创造了你好.exe从powershell以这种方式

^{pr2}$

运行python时会出现这个错误

WindowsError: exception: access violation writing 0x70098553

Tags: import功能helloreadstringlenbuffercreate