Re: Override any function in DLL
Feel the difference between function interception and substitution.
First is used for intrvention into target function call - it requires both original and intercepting code execution. And exactly this case requires trampoline code.
Second is used for redirection of code instruction flow, therefore it never needs trampoline, 'cause it just modifies target code the very beginning with jump to new code and forgets about original code. This is your case, isn't it?
Re: Override any function in DLL
Oh, I Understood..Thank you!
You showed me how to use Intercept().
I knew how to use Substitution()
So I knew 2 methods in Roger's link
And the last method in Roger's link (use Inject.h and Inject.cpp), can you guide me? (Give me the demo and source code ?^_^)
Re: Override any function in DLL
Quote:
Originally Posted by ngoctrongda
And the last method in Roger's link (use Inject.h and Inject.cpp), can you guide me?
OK, I'll give some backgrounds for this method understanding and some advice.
Imagine you have some process running you wish to intrude to for certain function interception (doesn't matter why). You write dll which is able to intercept that target function, but how to force your dll to be loaded into target process? Exactly for this purpose inject.cpp & inject.h serve. This code gives you ability to inject your dll into running process.
The code is absolutely transparent and straightforward - if you cannot get it you have way much things to learn yet before starting use it. I suggest you to read Richter's "Programming Applications for MS Windows" thoroughly.
Quote:
(Give me the demo and source code ?^_^)
Frankly saying I don't think I have to. First, the article (together with my sample) gives you almost all sufficient code fragments to assemble demo by yourself and gives you all-about bla-bla-bla for methods background understanding. Second, I've been told you are university student - so why don't you do your own study efforts. Third, our conversation now is pretty far from topic you started, and, hence fourth, I'm getting pretty bored of those call interception samples, sorry.
Re: Override any function in DLL
The main reason of that why I asked you so much because I didn't have any document talking about that.
I got the ""Programming Applications for MS Windows" just a few day. It's hard to find it.
Thanks a lot.
PS: do you know any document talk about Syringre method and Decours method?
Re: Override any function in DLL
Quote:
Originally Posted by ngoctrongda
The main reason of that why I asked you so much because I didn't have any document talking about that.
Use web search. :)
Quote:
I got the ""Programming Applications for MS Windows" just a few day. It's hard to find it.
Hope it will be easy to understand it.
Before practicing in some techniques you have to get solid understanding of processes, threads, module loading and IPC methods. Been not aquainted with all these things you'll never comprehend the essence of those techniques and their inner logic.
Quote:
PS: do you know any document talk about Syringre method and Decours method?
Never heard of them, but have a couple of thoughts:
1. It's well known a syringe is a tool for injections. :)
2. "Decours" might appear to be Detours.
Re: Override any function in DLL
Why don't I creat and compile these file?
/***************************************************************************
Module: MyLib.h
***************************************************************************/
#ifdef MYLIBAPI
// MYLIBAPI should be defined in all of the DLL's source
// code modules before this header file is included.
// All functions/variables are being exported.
#else
// This header file is included by an EXE source code module.
// Indicate that all functions/variables are being imported.
#define MYLIBAPI extern "C" _ _declspec(dllimport)
#endif
////////////////////////////////////////////////////////////////////////////
// Define any data structures and symbols here.
////////////////////////////////////////////////////////////////////////////
// Define exported variables here. (NOTE: Avoid exporting variables.)
MYLIBAPI int g_nResult;
////////////////////////////////////////////////////////////////////////////
// Define exported function prototypes here.
MYLIBAPI int Add(int nLeft, int nRight);
////////////////////////////// End of File /////////////////////////////////
In each of your DLL's source code files, you should include the header file as follows:
/***************************************************************************
Module: MyLibFile1.cpp
***************************************************************************/
// Include the standard Windows and C-Runtime header files here.
#include <windows.h>
4
// This DLL source code file exports functions and variables.
#define MYLIBAPI extern "C" _ _declspec(dllexport)
// Include the exported data structures, symbols, functions, and variables.
#include "MyLib.h"
////////////////////////////////////////////////////////////////////////////
// Place the code for this DLL source code file here.
int g_nResult;
int Add(int nLeft, int nRight) {
g_nResult = nLeft + nRight;
return(g_nResult);
}
////////////////////////////// End of File /////////////////////////////////
Help me Igor!!!
Re: Override any function in DLL
There're errors in sources: instead of _ _declspec it should be __declspec (no space between underscores)
Besides, symbol 4 after #include <windows.h> is meaningless - kill it.
Hope it'd help. :)
Re: Override any function in DLL
It's still doesn't work.
There are 2 error
1/" d:\baitap\mylib\mylib.h(18) : error C2144: syntax error : missing ';' before type 'int' " at line " MYLIBAPI int g_nResult; "
2/" d:\baitap\mylib\mylib.h(18) : fatal error C1004: unexpected end of file found "
I'm using MS VC++6.0 . Does the source code not compatible to VC++?
Need help???
Re: Override any function in DLL
Quote:
Originally Posted by ngoctrongda
It's still doesn't work.
There are 2 error
1/" d:\baitap\mylib\mylib.h(18) : error C2144: syntax error : missing ';' before type 'int' " at line " MYLIBAPI int g_nResult; "
2/" d:\baitap\mylib\mylib.h(18) : fatal error C1004: unexpected end of file found "
That _ _declspec is met twice - in .h and in .cpp. Fix them both.
Quote:
I'm using MS VC++6.0 . Does the source code not compatible to VC++?
Absolutely compatible. Don't you see it with your eyes?
Re: Override any function in DLL
Hi, Igor
I need a CD companion with that book.
Would you like to up it on some host free?
Or you can show me where to download it.
Thanks
Re: Override any function in DLL
Sorry, I have no that book (though I read it a long time ago :) ), and I don't know web resource which has it for free download.