问题
(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