0

I want to make a small tool that analyzes text from console in online game and I'm stuck at reading a string from a function and sending it to another program. I managed to find function that takes string as argument and calls function responsible for showing it in game and it looks something like this:

void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
{
    g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
}

Also, using Cheat Engine and x96dgb i found address of this function: asm code

String I need to capture is "Czerw pozostawia po sobie: 3 robaki". I tried .dll injection but I don't know how to hook to that function. Also I found something similar to what I want to do: https://github.com/ur0/DotATranslator/blob/master/Injectee/dllmain.cpp but I don't know what to change to make it work. What steps should I take?

1

Assuming you're trying to intercept function calls and manipulate / get the input to that function, you are going to need to hook it first.

I'd recommend reading about function hooking (there's a plenty of information out there regarding this subject).

Its basic idea is rather simple, given the start address of function to be hooked func01 you override the first five bytes (of course you have to save them) with a JMP instruction that will lead to your own fake func01 function that in it you'd do as you pleased with the argument, and when you're done, you call to the the original function (and here's the catch, you want to call a stub that will execute the first five bytes you were overriding and then jumps back to the original function's address plus five <func01_addr + 5>

If that's allowed (sorry if its not), there's a nice and easy-to-use hooking library called Mhook (but I'd first suggest getting some sense about the idea).

good luck

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.