C#读取指针地址值 [英] C# Read pointer address value
问题描述
(对不起我的英语不好)
(Sorry for my bad English )
如何从C#指针中读取值地址?
How to read a value address from pointer in C#?
示例: 我知道我的指针,但是在应用程序启动时值会改变.
Example: I know my pointer but the value change at application starting.
1)开始
(Pointer) 0x0018F36C = ( Value) 0x0342AD68
2)重新启动
(Pointer) 0x0018F36C = ( Value Changed ) 0x0342AE20
实际上我的基本地址为0x0018F36C 但是需要从指针中读取值并保存很长
Actually i have a base address 0x0018F36C but need to read value from pointer and save in long
示例:
long addr_base = 0x0018F36C;
long address; //Obviously I do not know the Address
现在我需要从addr_base读取long值并将值(long)放入地址
now i need to read long value from addr_base and put the value (long) in address
示例
addr_base = memory.ReadAddress(addr_base)
有人知道如何读取存储在名为addr_base的变量中的地址吗?
anyone know how to read address stored in the variable called addr_base?
推荐答案
如果您的地址类似于0x0018F36C
,则可以:
If you have a an address like 0x0018F36C
, you can:
IntPtr ptr = (IntPtr)0x0018F36C;
long longValue = Marshal.ReadInt64(ptr);
如果您需要从某个地址读取另一个地址,则还有另一个Marshal
方法:
If from an address you need to read another address, there is another Marshal
method:
IntPtr ptr = (IntPtr)0x0018F36C;
IntPtr ptr2 = Marshal.ReadIntPtr(ptr);
这篇关于C#读取指针地址值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!