Skip to content

techiew/Modding-stuff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Modding stuff

Below are some of the most useful functions in the header.

Function Description Notes
uintptr_t aob_scan(std::string aob) Scans the current process memory for the provided AOB. AOB must be provided in the format "ff 01 ab ff". Wildcards can be provided with "?", e.g. "cd 14 ba ? 74 ? 00". Same format that is used in Cheat Engine.
bool replace_bytes_at_address(uintptr_t address, std::string expected_bytes, std::string new_bytes) Replace bytes that are expected to be at the provided address with new bytes. If the expected bytes are not present at the address the bytes will not be modified and the function returns false. This is to avoid modifying the wrong memory and causing game crashes or unexpected behavior.
void mem_copy(uintptr_t destination, uintptr_t source, size_t num_bytes)

void mem_set(uintptr_t address, unsigned char byte, size_t num_bytes)
Wrappers around C's memcpy and memset with added memory protection handling. The memory at both the destination and source is temporarily modified to be PAGE_EXECUTE_READWRITE to avoid access violation errors.
void toggle_memory_protection(bool enable_protection, uintptr_t address, size_t size) Used in the above wrappers. Toggles between the existing memory protection and PAGE_EXECUTE_READWRITE, effectively turning the memory protection on and off. The function remembers the original memory protection and restores it when toggled back on.
void hook(uintptr_t address, uintptr_t destination) Creates an assembly jump from address to destination. Works for 32-bit and 64-bit. For function hooking.
bool keys_pressed(std::vector<std::string> key_combination, bool return_true_while_held) Checks if the given keyboard or Xinput-supported controller keys are pressed. For the string key names to be used in key_combination, take a look inside the header.

If return_true_while_held is set to true, the function keeps returning true while the key is kept down.

For the function to work, the window name of the application must first be provided using set_target_window_name(std::string target_window_name).
void show_error_popup(std::string error) Shows a classic Windows-style error popup containing the provided text. Useful when something wrong happens internally in your mod and the user should know about it.
void log(Types... args) Highly flexible logging function which simultaneously writes to stdout and a log file. Example: log("Counter: ", counter, " is OK: ", is_ok);

The log file is automatically created in the current working directory and will be named "<name_of_your_dll_or_exe>_log.txt".

Note: Calls to this function are usually ignored as this function is used internally and is set to be quiet by default. To stop ignoring calls to it, call enable_logging().

About

Collection of functions I usually use for game modding packaged in a neat header-only library.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages