Enums are not a great choice for offsets. Seeing as they're constant, you'll need to rebase them every time you use them. They're even worse to use in C# because of the way enum types work. IntPtr is your best option and you should rebase them once. Example:
Code:
private static bool _initialized;
internal static IntPtr
Offset1 = (IntPtr) 0x11223344,
Offset2 = (IntPtr) 0x55667788;
internal static void Initialize() {
if (_initialized)
return;
var mainModule = ...;
Rebase(mainModule, ref Offset1);
Rebase(mainModule, ref Offset2);
_initialized = true;
}
private static void Rebase(IntPtr baseAddress, ref IntPtr address) {
address = (IntPtr)(baseAddress + address.ToInt64());
}
Also viable:
Code:
internal static readonly IntPtr
Offset1,
Offset2;
static Offsets() {
var mainModule = ...;
Offset1 = mainModule + 0x11223344;
Offset2 = mainModule + 0x55667788;
}
I use the former because the base address is not necessarily ready before the static constructor is called. Whichever works best for you, you should use.