Solved

How do I get the DLL name?

Posted on 1998-01-06
2
751 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 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

10 Experts available now in Live!

Get 1:1 Help Now