I am writing a program to read and write memory from another program, however there are two different versions and the memory values have an offset in one version, but not in the second, so depending on the setting the user has selected (v1 or v2) I need to determine which address to read/write.
As the moment my code is as below, but I dont feel this is very effecient, and replicating this same code makes the class very long when it really doesnt need to be.
Is there a more efficient way of doing all of this:
public static int Property
{
get
{
switch (Version)
{
case Version.v1:
return Memory.ReadMemory<int>(0xB7CE50 + 0x2680);
case Version.v2:
return Memory.ReadMemory<int>(0xB7CE50);
default:
return 0;
}
}
set
{
switch (Version)
{
case Version.v1:
Memory.WriteMemory<int>(0xB7CE50 + 0x2680, value);
break;
case Version.v2:
Memory.WriteMemory<int>(0xB7CE50, value);
break;
default:
break;
}
}
}
Not all addresses need this offset, but most do, so I also need to account for this, hence I cant just add the 0x2680 value if v2