Last active
November 25, 2016 11:45
-
-
Save aevitas/555b7e73f6c3b074f726511c665a5e47 to your computer and use it in GitHub Desktop.
Special type reads LocalProcessMemory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ret = null; | |
var typeCode = Type.GetTypeCode(type); | |
// Special case simple value types: | |
// - Boolean | |
// - Byte, SByte | |
// - Char | |
// - Decimal | |
// - Int32, UInt32 | |
// - Int64, UInt64 | |
// - Int16, UInt16 | |
// - IntPtr, UIntPtr | |
if (typeCode == TypeCode.Boolean) | |
ret = *(byte*)address != 0; | |
if (typeCode == TypeCode.Byte) | |
ret = *(byte*)address; | |
if (typeCode == TypeCode.SByte) | |
ret = *(sbyte*)address; | |
if (typeCode == TypeCode.Char) | |
ret = *(char*)address; | |
if (typeCode == TypeCode.Decimal) | |
ret = *(decimal*)address; | |
if (typeCode == TypeCode.Int32) | |
ret = *(int*)address; | |
if (typeCode == TypeCode.UInt32) | |
ret = *(uint*)address; | |
if (typeCode == TypeCode.Int64) | |
ret = *(long*)address; | |
if (typeCode == TypeCode.UInt64) | |
ret = *(ulong*)address; | |
if (typeCode == TypeCode.Int16) | |
ret = *(short*)address; | |
if (typeCode == TypeCode.UInt16) | |
ret = *(ushort*)address; | |
return (T)ret; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment