C# Read pointer address value

亡梦爱人 提交于 2019-12-08 04:43:24

问题


(Sorry for my bad English )

How to read a value address from pointer in C#?

Example: I know my pointer but the value change at application starting.

1) Start

(Pointer) 0x0018F36C   =  ( Value) 0x0342AD68

2) Restart

(Pointer) 0x0018F36C  = ( Value Changed ) 0x0342AE20

Actually i have a base address 0x0018F36C but need to read value from pointer and save in long

example:

long addr_base = 0x0018F36C;
long address;  //Obviously I do not know the Address

now i need to read long value from addr_base and put the value (long) in address

example

addr_base = memory.ReadAddress(addr_base)

anyone know how to read address stored in the variable called addr_base?


回答1:


If you have a an address like 0x0018F36C, you can:

IntPtr ptr = (IntPtr)0x0018F36C;
long longValue = Marshal.ReadInt64(ptr);

If from an address you need to read another address, there is another Marshal method:

IntPtr ptr = (IntPtr)0x0018F36C;
IntPtr ptr2 = Marshal.ReadIntPtr(ptr);


来源:https://stackoverflow.com/questions/30476131/c-sharp-read-pointer-address-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!