Solved

How do I get the DLL name?

Posted on 1998-01-06
2
754 Views
Last Modified: 2013-12-26
Hi,
When we call a function inside a DLL we'd like to be able to get the name of the DLL itself, but DosQueryModuleName doesn't seem to support a default module handle of NULL, and requires a full path to the DLL, which we don't have. Anyone have a solution for us??

Damian Wilson.
0
Comment
Question by:rddamian
2 Comments
 

Accepted Solution

by:
Michael Schmidt earned 100 total points
ID: 1292097
Hi Damian,

The following code fragment should do what you try to accomplish.  
Note that 'DosQueryModFromEIP' is an undocumented function, which is not available before OS/2 2.1.

EIP is some valid instruction pointer value in this DLL, which you probably have to retrieve via an assembler subroutine.

You find the whole code in many DevCons (look for the exception handler sample).


Good Luck!

Michael



DEF file:

IMPORTS
    DosQueryModFromEIP=DOSCALL1.360


source file:

APIRET APIENTRY DosQueryModFromEIP( HMODULE *phMod,  // output
                                    ULONG *pObjNum,  // output
                                    ULONG BuffLen,   // input
                                    PCHAR Name,      // output
                                    ULONG *pOffset,  // output
                                    PVOID EIP );     // input


rc=DosQueryModFromEIP( &hMod, &ObjNum, CCHMAXPATH, Name,
                       &Offset, EIP);

rc=DosQueryModuleName(hMod,CCHMAXPATH, Name);

0
 

Author Comment

by:rddamian
ID: 1292098
This technique could prove invaluable in the future, thank you! Meanwhile, however, we discovered that Watcom actually provides an undocumented (or poorly documented) global copy of the DLL's module handle and module name so we used that.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 63
Tab names are off by one 5 54
Doc'in system (example?) BA 7 112
no14 challenge 14 69
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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