UIntPtr address = new UIntPtr(0x7fffd0132c90); //memory address of a function IntPtr funcPtr = address.ToPointer(); //convert UIntPtr to IntPtr var delegateFunc = Marshal.GetDelegateForFunctionPointer>(funcPtr); //create delegate for function int result = delegateFunc(10); //invoke function with argument
UIntPtr hProcess = OpenProcess(0x001F0FFF, false, pid); //get process handle UIntPtr lpBaseAddress = new UIntPtr(address); //memory address to read byte[] buffer = new byte[count]; //buffer to store read data UIntPtr lpNumberOfBytesRead = new UIntPtr(); //number of bytes read ReadProcessMemory(hProcess, lpBaseAddress, buffer, count, lpNumberOfBytesRead); //read from process memoryThese examples demonstrate how to use the System UIntPtr in unsafe code to invoke a function from a memory address and to read from a process memory address. The package library for this would be the .NET Framework Class Library.