Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ Standard Library:
- #include <iostream>
- #include <string>
- #include <cstdint>
- // Ethonmem:
- #include <Ethonmem.hpp>
- static std::uintptr_t const CHARACTER_NAME = 0xD7DA88; // WoW ver. 4.20
- int main()
- {
- try
- {
- // First, lets search for the Wow process.
- auto process = Ethon::getProcessByName("Wow.exe");
- if(!process)
- {
- std::cerr << "No process called 'Wow.exe' found.";
- return 1;
- }
- // Attach the debugger to the process.
- Ethon::Debugger::get().attach(*process);
- // Create a MemoryEditor to read/write memory.
- Ethon::MemoryEditor editor(*process);
- // What about our character's name?
- std::string name = editor.read<std::string>(CHARACTER_NAME);
- std::cout << "Currently logged in character: " << name << "\n";
- // But maybe we want to update that address later?
- // So let's pattern scan for ClientServices__GetCharacterName function!
- char const pattern_[] =
- "\x0F\xBE\x05\x88\xDA\xD7\x00\xF7\xD8\x1B\xC0\x25\x88\xDA\xD7\x00"
- "\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC";
- std::string pattern(pattern_, sizeof(pattern_) - 1);
- std::string mask("xxx****xxxxx****xxxxxxxxxxxxxxxx");
- // Create a scanner object to scan memory.
- Ethon::Scanner scanner(editor);
- // Search for pattern in memory regions which are
- // read/executable and not shared
- std::uintptr_t address = scanner.findPattern(pattern, mask, "r-xp");
- std::cout << "Found ClientServices__GetCharacterName at 0x" <<
- std::hex << address << std::dec << std::endl;
- // Ok, this was a bad example as this pattern matches to another
- // function earliert in memory. But you get it, huh? ;)
- // Let's search for some random value in private data.
- int bla = 1234;
- std::uintptr_t found = scanner.find(bla, "rw-p");
- if(found)
- std::cout << "Found " << editor.read<int>(found) << " at 0x" << found << std::endl;
- else
- std::cout << bla << " was not found" << std::endl;
- }
- catch(Ethon::EthonError const& e)
- {
- Ethon::printError(e, std::cerr);
- }
- // Detach the debugger. This should be done automatically,
- // but I consider it good practise.
- Ethon::Debugger::get().detach();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement