|
You last visited: Today at 03:48
Advertisement
[QUESTION] How to hook this function properly?
Discussion on [QUESTION] How to hook this function properly? within the Metin2 forum part of the Popular Games category.
05/11/2022, 11:20
|
#1
|
elite*gold: 0
Join Date: Nov 2016
Posts: 245
Received Thanks: 147
|
[QUESTION] How to hook this function properly?
Hi everyone, im trying to get some arguments from a function. But i couldnt hook this function;
Code:
module_addr = 0x123456;
module_instance = reinterpret_cast<DWORD>(module_addr);
typedef bool(__thiscall* tModuleFunc)(void* This, int arg1, int arg2);
static DWORD func_addr = 0x112233;
static tModuleFunc ModuleFunc;
ModuleFunc = (tModuleFunc)(func_addr);
void ShowArgs(int arg1, int arg2){
std::cout << arg1= << arg1 << std::endl;
std::cout << arg2= << arg2 << std::endl;
}
static bool CallModuleFunc(int arg1, int arg2)
{
try
{
return ModuleFunc((void*)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}
static bool HookCallModuleFunc(int arg1, int arg2)
{
try
{
ShowArgs(arg1, arg2);
return ModuleFunc((void*)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}
What is the right way to do this ? Thanks all!
|
|
|
05/11/2022, 18:36
|
#2
|
elite*gold: 0
Join Date: Nov 2021
Posts: 70
Received Thanks: 58
|
Quote:
Originally Posted by senpaiex
Hi everyone, im trying to get some arguments from a function. But i couldnt hook this function;
Code:
module_addr = 0x123456;
module_instance = reinterpret_cast<DWORD>(module_addr);
typedef bool(__thiscall* tModuleFunc)(void* This, int arg1, int arg2);
static DWORD func_addr = 0x112233;
static tModuleFunc ModuleFunc;
ModuleFunc = (tModuleFunc)(func_addr);
void ShowArgs(int arg1, int arg2){
std::cout << arg1= << arg1 << std::endl;
std::cout << arg2= << arg2 << std::endl;
}
static bool CallModuleFunc(int arg1, int arg2)
{
try
{
return ModuleFunc((void)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}
static bool HookCallModuleFunc(int arg1, int arg2)
{
try
{
ShowArgs(arg1, arg2);
return ModuleFunc((void)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}
What is the right way to do this ? Thanks all!
|
1. (void) -> (void*)
if it still wont work please show disassembly/pseudocode/c++ of the function and give more informations about what isnt working
|
|
|
05/11/2022, 20:56
|
#3
|
elite*gold: 0
Join Date: Nov 2016
Posts: 245
Received Thanks: 147
|
Quote:
Originally Posted by br4ve-trave1er.asf
1. (void) -> (void*)
if it still wont work please show disassembly/pseudocode/c++ of the function and give more informations about what isnt working
|
Sorry it is already (void*) actually, my bad. Yes i'll share asm part of it as soon as possible.
|
|
|
05/13/2022, 03:52
|
#4
|
elite*gold: 0
Join Date: Sep 2021
Posts: 11
Received Thanks: 0
|
you may be giving missing arguments
|
|
|
05/13/2022, 19:13
|
#5
|
elite*gold: 0
Join Date: Nov 2016
Posts: 245
Received Thanks: 147
|
Quote:
Originally Posted by badforce788
you may be giving missing arguments
|
No im sure but it doesnt matter anyway. Im just asking "How to hook a function like this one?". I mean what is the right way?
|
|
|
05/13/2022, 23:02
|
#6
|
elite*gold: 405
Join Date: Dec 2007
Posts: 6,615
Received Thanks: 6,358
|
"i couldnt hook this function" is not a very detailed error description, neither is your code. All I can see is that your `HookCallModuleFunc` is not `__stdcall`, which I assume is the function you hook the game function to.
|
|
|
05/16/2022, 01:10
|
#7
|
elite*gold: 0
Join Date: Nov 2016
Posts: 245
Received Thanks: 147
|
Quote:
Originally Posted by Mi4uric3
"i couldnt hook this function" is not a very detailed error description, neither is your code. All I can see is that your `HookCallModuleFunc` is not `__stdcall`, which I assume is the function you hook the game function to.
|
Yes its game function. Its not "detailed error description" because its not an error. If you read the title of thread "How to hook this fuction properly?" you can see that im just asking "What is the right way to do this?".
(I think the code is totally fine btw)
|
|
|
05/16/2022, 09:57
|
#8
|
elite*gold: 0
Join Date: Nov 2021
Posts: 70
Received Thanks: 58
|
Quote:
Originally Posted by senpaiex
Yes its game function. Its not "detailed error description" because its not an error. If you read the title of thread "How to hook this fuction properly?" you can see that im just asking "What is the right way to do this?".
(I think the code is totally fine btw)
|
well yes, but what is the original function, we just see your pseudo code - the already mentioned asm hasn't been added. Even a simple "im trying to hook CPythonNetworkStream::SendOnClickPacket" or "im trying to hook function 0x123456 on gf metin2 turkish servers which is used for xyz *here* is the disassembly which i used to get the address and the calltype from" would help helping you
|
|
|
05/16/2022, 16:22
|
#9
|
elite*gold: 405
Join Date: Dec 2007
Posts: 6,615
Received Thanks: 6,358
|
There are tons of resources online on how to hook (stdcall) functions, there is no need for us to spoonfeed you. You can look them up in your favorite search engine. If you then have any problem applying the methods you learned there you can come back with a specific question, detailing what you tried and what problems you encountered.
|
|
|
Similar Threads
|
std::function of a function returning an std::function
11/11/2013 - C/C++ - 19 Replies
Nun muss ich nach langer Zeit auch mal wieder einen Thread erstellen, weil mir Google nicht mehr weiterhelfen kann.
Ich verzweifle an Folgendem Vorhaben:
#include <Windows.h>
#include <string>
#include <iostream>
using namespace std;
|
1 way to make the bot function properly
04/03/2009 - Rohan - 7 Replies
sometimes when using the bot, the "start" button won't activate..,
there are two reasons,
Patched up GG, or
you missed to bypass GG...,
1 way to prevent this, is using the start game (auto-log in).
to use this,
go to the folder where you extracted the bot,
then look for the configuration file named "Rohan" on a notepad
|
All times are GMT +1. The time now is 03:49.
|
|