Solved

DLL forwarding

Posted on 1998-12-21
3
412 Views
Last Modified: 2008-02-20
Does anybody has an idea on how to redirect a call to a function in a dll to your own dll ?

Thank you!
0
Comment
Question by:kctan100
3 Comments
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1180813
This is code:

   const char szcScpWDLLName [] = "MYDLL.DLL";
   const char szcFuncName [] = "MyFunction";  
   TModule  *DLLModule;

   DLLModule = new TModule ( DLLName, TRUE);
   int FAR PASCAL ( *Fun )( char * );
   ( FARPROC ) Fun = DLLModule ->
                      GetProcAddress ( szcFuncName );
   if ( Fun )
     Fun ( ....);
It is for OWL, in pure Windows you
must use LoafLibrary function(instead of TModule)
Best Regards, Alex
0
 

Author Comment

by:kctan100
ID: 1180814
I there is a misunderstanding on the question. In fact, I'm trying to intercept a call to a function in a specified dll.

Example :
A.Dll exports function A.

B.exe calls A.

Instead of calling A, I will force B.exe to call my version of A in another DLL.
0
 
LVL 6

Accepted Solution

by:
stsanz earned 50 total points
ID: 1180815
Create a new DLL that exports all the functions exported by the original DLL. In each function of your new DLL, call the corresponding function in the original DLL (or replace it by your own code).
Rename the original DLL (say LIB.DLL to LIBORI.DLL) an name your new DLL as LIB.DLL

This solution can be a bit long if the DLL exports hundreds of functions. Does anyone know a better solution ?

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question