C
C
Chaiseel2015-05-08 22:34:08
C++ / C#
Chaiseel, 2015-05-08 22:34:08

How to get the name of a function imported from a DLL?

Let's say I have the name of a function that I want to load from a DLL:
char* fn = "myFunctionName";
If you need to get a pointer to a function named fn, then everything is simple:

TFuncPointer pFunc = (TFuncPointer)GetProcAddress(myDLLinstance, fn);

But what if I have a pFunc pointer to a function, but don't have the function name fn to get? Is it possible to get not a pointer, having a name, but vice versa - a name, having a pointer?
Right now, I'm just listing all the existing import function names, getting all their pointers, and comparing pFunc against them to determine the name of the function it refers to. But it works very slowly. Is there a faster and correct solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-05-08
@vilgeforce

You can parse the export table by hand: it is much more difficult, but it should be faster. Your approach, in principle, should also be fast...

J
jcmvbkbc, 2015-05-09
@jcmvbkbc

Is it possible to get not a pointer, having a name, but vice versa - a name, having a pointer?

Search in the export table. However, a function can have several names or none (export by number).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question