Solved

How do I get the DLL name?

Posted on 1998-01-06
2
761 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

630 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