带地址和指针的算术

时间:2021-07-27 03:32:15

标签: c# memory

我不知道如何将两个地址相加。我正在尝试读取一个只是一个模块的地址。基地址 + 另一个地址(不是偏移量)

Process proc = Process.GetProcessByName;
IntPtr moduleadr = proc.MainModule.BaseAddress;

int adress2 = Convert.ToInt32(0x8F4C28) //just an example adress

//my first instinct that i tought would be logical
IntPtr FullAdress = new IntPtr(moduleadr + adress2) //dosent't work
//next thing i tought would be logical
IntPtr FullAdress = IntPtr(moduleadr + adress2) //doesen't give an error 
//but isen't what im looking for, as this treats adress2 like an offset

对于任何有 C++ 背景的人来说,这就是我希望在 C# 中做的事情:

UIntPtr_t FullAdress = (UIntPtr_t*)(moduleadr + adress2);

真的希望你们中的任何一个聪明人都能找到解决方案,因为这在过去的几个小时里让我非常沮丧。

提前致谢。

0 个答案:

没有答案
相关问题