c# - Application.exe + 000000 读取内存
问题描述
如您所见,我在获取 .exe 基地址时遇到了一些麻烦。
在这种情况下,假设是 Tutorial-x86_64.exe
如何获取进程地址?
希望任何人都可以提供帮助。
解决方案
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("Tutorial-x86_64");
int base = processes[0].MainModule.BaseAddress.ToInt32();
您还可以获得入口点
int base_adr = processes[0].MainModule.EntryPointAddress.ToInt32();
int height_offset = 0x0007E1BC; //some address example
int height_adr = (IntPtr)(base_adr + height_offset);
这是另一个功能。
private static IntPtr GetModuleBaseAddress(string AppName, string ModuleName)
{
IntPtr BaseAddress = IntPtr.Zero;
Process[] myProcess = null;
ProcessModule myProcessModule = null;
myProcess = Process.GetProcessesByName(AppName);
if (myProcess.Length > 0)
{
ProcessModuleCollection myProcessModuleCollection;
try
{
myProcessModuleCollection = myProcess[0].Modules;
}
catch { return IntPtr.Zero; /*Maybe would be ok show the exception after/instead return*/ }
for (int i = 0; i < myProcessModuleCollection.Count; i++)
{
myProcessModule = myProcessModuleCollection[i];
if (myProcessModule.ModuleName.Contains(ModuleName))
{
BaseAddress = myProcessModule.BaseAddress;
break;
}
}
}
return BaseAddress;
}
推荐阅读
- r - 使用 match() 函数和 rename_all() R
- r - 改进 R 中不带逗号的函数输入
- php - php DOMDocument()->getAttribute() 不工作
- .net - 如果在异步调用中调用阻塞方法会发生什么?
- ios - 我想线程化从 iOS 中的领域读取的数据
- linux - Elasticsearch 集群未显示
- python - 从熊猫日期时间列中提取年份作为数值,用 NaN 表示空单元格而不是 NaT
- python - 在循环中将从字符串转换为浮点数的数字列表相乘(Python)时遇到问题
- python - 有没有办法在不涉及任何内容的情况下在谷歌中输入 python 类型?
- java - 在不传入根对象的情况下读取嵌套的 yaml 值