Solved

DLL forwarding

Posted on 1998-12-21
3
389 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Interoperability issue between VC++ (ocx) & VB.NET applications 7 73
Writing a parser for java language 4 71
Create a path if not exists 7 69
C++ mouse_event mouse look 7 65
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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++.

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now