C#怎么取得某进程的所有线程ID和模块名。
答案:2 悬赏:40 手机版
解决时间 2021-03-24 08:45
- 提问者网友:火车头
- 2021-03-23 18:57
C#怎么取得某进程的所有线程ID和模块名。
最佳答案
- 五星知识达人网友:迷人又混蛋
- 2021-03-23 20:24
public static string GetModuleFileNameByAddressRange(
int processId,
IntPtr memoryAddress)
{
try
{
int MemAdd32 = memoryAddress.ToInt32();
long MemAdd64 = memoryAddress.ToInt64();
using (Process p = Process.GetProcessById(processId))
{
ProcessModuleCollection LoadedProcessModules = p.Modules;
try
{
if (is32bit == true)
{
foreach (ProcessModule pm in LoadedProcessModules)
{
if (MemAdd32 >= pm.BaseAddress.ToInt32() &&
MemAdd32 <= (pm.ModuleMemorySize + pm.BaseAddress.ToInt32()))
{
return pm.FileName;
}
Application.DoEvents();
}
}
else
{
foreach (ProcessModule pm in LoadedProcessModules)
{
if (MemAdd64 >= pm.BaseAddress.ToInt64() &&
MemAdd64 <= (pm.ModuleMemorySize + pm.BaseAddress.ToInt64()))
{
return pm.FileName;
}
Application.DoEvents();
}
}
}
}
return string.Empty;
}
catch
{
return string.Empty;
}
}追问
不能通过
int processId,
IntPtr memoryAddress)
{
try
{
int MemAdd32 = memoryAddress.ToInt32();
long MemAdd64 = memoryAddress.ToInt64();
using (Process p = Process.GetProcessById(processId))
{
ProcessModuleCollection LoadedProcessModules = p.Modules;
try
{
if (is32bit == true)
{
foreach (ProcessModule pm in LoadedProcessModules)
{
if (MemAdd32 >= pm.BaseAddress.ToInt32() &&
MemAdd32 <= (pm.ModuleMemorySize + pm.BaseAddress.ToInt32()))
{
return pm.FileName;
}
Application.DoEvents();
}
}
else
{
foreach (ProcessModule pm in LoadedProcessModules)
{
if (MemAdd64 >= pm.BaseAddress.ToInt64() &&
MemAdd64 <= (pm.ModuleMemorySize + pm.BaseAddress.ToInt64()))
{
return pm.FileName;
}
Application.DoEvents();
}
}
}
}
return string.Empty;
}
catch
{
return string.Empty;
}
}追问
不能通过
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯