Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python—如何获取进程的起始/基址?_Python_Windows_Process_Ctypes_Pywin32 - Fatal编程技术网

Python—如何获取进程的起始/基址?

Python—如何获取进程的起始/基址?,python,windows,process,ctypes,pywin32,Python,Windows,Process,Ctypes,Pywin32,如何获取进程的起始/基址?根据示例Solitaire.exe(Solitaire.exe+BAFA8) 我想计算一个内存地址,为此,我需要solitaire.exe的基址 以下是我的意思: 我认为返回的句柄实际上是给定模块的基址。您通过传递NULL来获得exe的句柄。安装pydbg 资料来源: 非官方二进制文件: 你可能想看看PaiMei,尽管它现在不是很活跃 我无法让attach()工作,而是使用了load。Pydbg有很多功能,比如读处理内存、写处理内存等 请注意,您不能随机更改内存,因为操

如何获取进程的起始/基址?根据示例Solitaire.exe(Solitaire.exe+BAFA8)

我想计算一个内存地址,为此,我需要solitaire.exe的基址

以下是我的意思:


我认为返回的句柄实际上是给定模块的基址。您通过传递NULL来获得exe的句柄。

安装pydbg

资料来源:

非官方二进制文件:

你可能想看看PaiMei,尽管它现在不是很活跃

我无法让attach()工作,而是使用了load。Pydbg有很多功能,比如读处理内存、写处理内存等

请注意,您不能随机更改内存,因为操作系统会保护其他进程的内存不受您进程的影响(保护模式)。在x86处理器之前,有些处理器允许所有处理器以实模式运行,即每个程序都可以完全访问内存。非恶意软件通常(始终?)不读取/写入其他进程的内存。

的HMDOULE值是加载模块的基址,可能是计算偏移量所需的地址

如果不是,则该地址是模块(DLL/EXE)头的开始,可以使用Visual Studio附带的
dumpbin
实用程序显示该头,或者您可以使用来解释它,以确定
AddressOfEntryPoint
BaseOfCode
作为与基地址的偏移量。如果模块的基址不是您所需要的,则这两个选项之一是另一个选项

例如:

>>> BaseAddress = win32api.GetModuleHandle(None) + 0xBAFA8
>>> print '{:08X}'.format(BaseAddress)
1D0BAFA8

如果需要
AddressOfEntryPoint
BaseOfCode
,则必须使用
ctypes
调用
ReadProcessMemory
,按照PE规范查找偏移量,或者使用
dumpbin/headers solitaire.exe
来学习偏移量。

我不知道你的真正意思:程序条目的内存地址或exe文件的文件路径?@Rubby:程序条目的内存地址。但我不知道怎么做。win32api.GetModuleHandle有什么问题(无)?当我找到地址时,我必须添加一个静态偏移量(0xBAFA8)=>才能获得一个新地址…嗨,我现在使用的是EnumProcessModules()。但问题是现在我只得到32位句柄…您的进程是32位进程吗?您需要64位才能获得64位句柄。您好,我的进程是64位进程。
from pydbg import *
from pydbg.defines import *

import struct

dbg = pydbg()

path_exe = "C:\\windows\\system32\\calc.exe"

dbg.load(path_exe, "-u amir")
dbg.debug_event_loop()

parameter_addr = dbg.context.Esp #(+ 0x8)

print 'ESP (address) ',parameter_addr


#attach not working under Win7 for me

#pid = raw_input("Enter PID:")
#print 'PID entered %i'%int(pid)
#dbg.attach(int(pid)) #attaching to running process not working
>>> BaseAddress = win32api.GetModuleHandle(None) + 0xBAFA8
>>> print '{:08X}'.format(BaseAddress)
1D0BAFA8