Skip to content

Update main.cpp #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ int main(int argc, char** argv) {

// Read the value at 0x017EED18 and place its value into the variable gold_value.
DWORD gold_value = 0;
DWORD bytes_read = 0;
ReadProcessMemory(wesnoth_process, (void*)0x017EED18, &gold_value, 4, &bytes_read);
// DWORD bytes_read = 0; //no bytes_read necessary
ReadProcessMemory(wesnoth_process, (void*)0x017EED18, &gold_value, 4, NULL); //NULL used as arguement instead of bytes_read

// Add 0xA90 to the value read from the last step and then read the value at that new address. These
// offsets are covered in https://gamehacking.academy/lesson/13
gold_value += 0xA90;
ReadProcessMemory(wesnoth_process, (void*)gold_value, &gold_value, 4, &bytes_read);
gold_value += 0xA90;
ReadProcessMemory(wesnoth_process, (void*)gold_value, &gold_value, 4, NULL); //NULL used as arguement instead of bytes_read

// Add 4 to the gold_value, which will then be pointing at the player's current gold address.
// Write the value of new_gold_value (555) into this address
gold_value += 4;
DWORD new_gold_value = 555;
DWORD bytes_written = 0;
WriteProcessMemory(wesnoth_process, (void*)gold_value, &new_gold_value, 4, &bytes_written);
//DWORD bytes_written = 0; //no bytes_written necessary
WriteProcessMemory(wesnoth_process, (void*)gold_value, &new_gold_value, 4, NULL); //NULL used as arguement instead of bytes_written

return 0;
}