问题描述
我有一个名为BGB和口袋妖怪红/蓝游戏的Game Boy模拟器。在仿真器中,我可以打开调试窗口。在窗口中,我可以在十六进制表(内存映射)中看到游戏的全部内存:
我试图通过pywin32库访问此数据:
import win32gui
import win32con
def _windowEnumerationHandler(hwnd,resultlist):
"""Pass to win32gui.EnumWindows() to generate list of window handle,window text,window class tuples."""
resultlist.append((hwnd,win32gui.GetwindowText(hwnd),win32gui.GetClassName(hwnd)))
def enumChild(hwnd):
prevIoUs = None
while True:
cur = win32gui.findwindowex(hwnd,prevIoUs,None,None)
if not cur:
return
yield cur
prevIoUs = cur
def main():
hWnd = win32gui.FindWindow(None,'bgb debugger - R:\Games\BGB\ROMs\Pokemon - Red Version (UE) [S][!].gb')
print(win32gui.GetwindowText(hWnd))
windows = []
win32gui.EnumChildWindows(hWnd,_windowEnumerationHandler,windows)
hTpl = windows[19]
hFrm = hTpl[0]
print('Handle Window = {hWnd}\nHandle Tuple = {hTpl}\nHandle Frame = {hFrm}'
.format(hWnd=hWnd,hTpl=hTpl,hFrm=hFrm))
print(windows)
lWindowTexts = [win32gui.GetwindowText(item) for item in enumChild(hWnd)]
print(lWindowTexts)
print('--------------')
FrameChilds = []
win32gui.EnumChildWindows(hFrm,FrameChilds)
print(FrameChilds)
hCtrl = FrameChilds[0][0]
print('Handle Control = {0}'.format(hCtrl))
lChildTexts = [win32gui.GetwindowText(item) for item in enumChild(hFrm)]
print(lChildTexts)
buffer = win32gui.PyMakeBuffer(300000)
print('Text:',win32gui.SendMessage(hCtrl,win32con.WM_GETTEXT,len(buffer),buffer))
if __name__ == '__main__':
main()
但是什么都不起作用...我得到的只是:
[Console out]
bgb debugger - R:\Games\BGB\ROMs\Pokemon - Red Version (UE) [S][!].gb
Handle Window = 2033576
Handle Tuple = (1574836,'','tscrollermemmap')
Handle Frame = 1574836
[(395264,'Tdrawcontrol'),(460850,'c','TPanel'),(395250,'TCheckBox'),(395266,'h',(395212,(460824,'n',(460720,(395204,'z',(460686,(395232,'tcpumetercontrol'),(395202,(395254,'tscrollerasm'),(395260,(395284,'TScrollBar'),(395210,'tscrollerstack'),(395286,(395292,(591780,'tscrollerregs'),(395256,(1574836,'tscrollermemmap'),(395270,(395272,(395274,'TStatusBar')]
['','']
--------------
[(395270,'TScrollBar')]
Handle Control = 395270
['','']
Text: 0
我们看不到任何解决方法。 所以问题是,我可以从程序的内存中获取几个字节的数据,还是可以从窗口中复制它?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)