从python调用地址函数时出现问题

时间:2014-07-17 08:24:33

标签: python winapi ctypes

所以,我想将我的python代码与我的游戏代码集成(使用Source Engine进行游戏),我想使用engine.dll中的CreateInterface函数

我试过这段代码:

#######################################################################
# 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函数,并且它正在工作。应用程序调用函数,它返回一个有效的指针,但我无法在python代码上收到它...

0 个答案:

没有答案
相关问题