I'm trying to differentiate the threads of a particular program. with the "ProcessExplorer" software I can easily get through the Start Address, since the method name appears:
ItriedtogettheStartAddresswiththiscodeinC#:
Process[]process=Process.GetProcessesByName("notepad");
foreach (ProcessThread CurrentThread in process[0].Threads)
{
Console.WriteLine(CurrentThread.StartAddress);
}
and this was the result:
TheStartAddresscameupwiththesamevalue,soItriedtousethiscode:
IntPtrpOpenThread=OpenThread(ThreadAccess.SUSPEND_RESUME,false,(uint)CurrentThread.Id);if(pOpenThread!=IntPtr.Zero){varbuf=Marshal.AllocHGlobal(IntPtr.Size);intresult=-1;try{result=NtQueryInformationThread(pOpenThread,ThreadInfoClass.ThreadQuerySetWin32StartAddress,buf,IntPtr.Size,IntPtr.Zero);}finally{IntPtrCurrentThread=Marshal.ReadIntPtr(buf);Console.WriteLine("TID: " + CurrentThread.Id + " StartAddress " + FinalResult);
}
}
and testing was the result:
It solved my problem for a while but after the StartAddress changed ... I need to get the module name to identify each thread.