很抱歉问了这个愚蠢的问题,但是我正在尝试获取一个在远程进程中运行的lib的地址(指针)。
地址被保存在intptr类型中,但是当我打印值时,我会得到一个庞大的int。
如何将它转换成0x00000等?
示例代码:
public uint GetModuleBase(string _moduleName)
{
MODULEENTRY32 me32 = new MODULEENTRY32();
IntPtr hSnapshot = IntPtr.Zero;
me32.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(me32);
hSnapshot = CreateToolhelp32Snapshot(0x00000008, this.processId);
// can we start looking?
if (!Module32First(hSnapshot, ref me32))
{
CloseHandle(hSnapshot);
return 0;
}
// enumerate all modules till we find the one we are looking for
// or until every one of them is checked
while (String.Compare(me32.szModule, _moduleName) != 0 && Module32Next(hSnapshot, ref me32))
{
modules.Add(me32.szModule, me32.modBaseAddr);
}
// close the handle
CloseHandle(hSnapshot);
// check if module handle was found and return it
if (String.Compare(me32.szModule, _moduleName) == 0)
{
return (uint)me32.modBaseAddr;
}
return 0;
}进程黑客显示库是在address (0x6f300000)加载的,但是当我试图打印intptr值时,我得到一个int值(1865416704)。
发布于 2014-10-11 00:21:16
您可以将整数转换为0x00000000格式(这只是一个十六进制表示),方法是使用ToString()并为0x部件加上如下前缀:
int yourNumber = 1234567890;
string hexNumber = string.Format("0x{0:X}", yourNumber);但是,没有必要这样做,因为它本质上只是一种显示格式。
https://stackoverflow.com/questions/26309747
复制相似问题