在Python中调用地址函数时出现问题

2024-10-05 14:23:57 发布

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

因此,我想将python代码与游戏代码集成(使用游戏的源引擎),并使用引擎.dll在

我试过这个代码:

#######################################################################
# Imports
from ctypes import *
from ctypes.wintypes import *

#######################################################################
MessageBox = ctypes.windll.user32.MessageBoxW
GetModuleHandle = ctypes.windll.kernel32.GetModuleHandleW
GetProcAddress = ctypes.windll.kernel32.GetProcAddress
#######################################################################
EngineFactory = WINFUNCTYPE(c_void_p, c_char_p, c_void_p)(GetProcAddress(GetModuleHandle("engine.dll"), b"CreateInterface"))
dwResult = EngineFactory(b"VEngineClient013", 0)
MessageBox(0, "{0}".format(hex(dwResult)), 0, 0)

它没有工作,代码在调用EngineFactory后停止,我看不到消息框,我检查了ollydbg,看看代码是否正在执行CreateInterface函数,它确实在执行正在工作。那个app调用这个函数并返回一个有效的指针,但我在python代码中无法接收到它。。。在


Tags: 代码from引擎import游戏ctypesdllvoid