Becasue we don't have enough ways to point to memory.
MoarPtr is a C++23 header-only library that adds new idiomatic pointers, geared towards software modification at run time.
C++23
A conforming preprossor (/Zc:preprocessor on MSVC)
Windows
Copy the headers into an included directory in your project and #include moar_ptr.h the library.
A non-owning pointer to a resource.
moar::extern_ptr<int> player_ammo { 0x1234abcd };A non-owning pointer to a function.
// standard example
moar::function_ptr<int(const char*, va_list)> vprintf_ptr { &vprintf };
// variadic example
moar::function_ptr<int(const char*, ...)> printf_ptr { &printf };
// with x86 calling convention
moar::function_ptr<int __stdcall (HWND, LPCSTR, LPCSTR, UINT)> messagebox_ptr { &MessageBoxA };
// invokable via () operator
vprintf_ptr(first, second);
printf_ptr(first, second, third);
printf_ptr(first, second, third, fourth);
messagebox_ptr(first, second, third, fourth);Similar to function_ptr with support for hooking via trampoline hooks.
moar::trampoline_ptr<int(int,int)> add_two_ptr { 0x1234abcd };
DetourAttach(add_two_ptr.mut(), &callback);
// invokable via () operator
add_two_ptr(5,7);
// call original code if trampoline is installed
add_two_ptr.original(5, 7);