Click here to Skip to main content
15,902,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to extract Exported functions from a DLL Pin
Stephen Hewitt12-Feb-08 20:34
Stephen Hewitt12-Feb-08 20:34 
GeneralRe: How to extract Exported functions from a DLL Pin
poda12-Feb-08 21:10
poda12-Feb-08 21:10 
AnswerRe: How to extract Exported functions from a DLL Pin
Nibu babu thomas12-Feb-08 20:47
Nibu babu thomas12-Feb-08 20:47 
GeneralRe: How to extract Exported functions from a DLL Pin
poda12-Feb-08 21:40
poda12-Feb-08 21:40 
GeneralRe: How to extract Exported functions from a DLL Pin
Nibu babu thomas13-Feb-08 0:15
Nibu babu thomas13-Feb-08 0:15 
GeneralRe: How to extract Exported functions from a DLL Pin
poda13-Feb-08 23:23
poda13-Feb-08 23:23 
GeneralRe: How to extract Exported functions from a DLL Pin
David Crow13-Feb-08 3:16
David Crow13-Feb-08 3:16 
AnswerRe: How to extract Exported functions from a DLL Pin
Stephen Hewitt12-Feb-08 21:09
Stephen Hewitt12-Feb-08 21:09 
Here's a program I knocked up which lists the functions exported by name from a dll:
// Exports.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <Imagehlp.h>
#pragma comment(lib, "Imagehlp.lib")
using namespace std;
 
int main(int argc, char* argv[])
{
	if (argc!=2)
	{
		cerr << "Usage:\n\tExports <path to dll>" << endl;
		return 1;
	}
 
	// Try to map the DLL into memory.
	LOADED_IMAGE li;
	BOOL bOK = MapAndLoad(
			argv[1],	// PSTR ImageName
			NULL,		// PSTR DllPath
			&li,		// PLOADED_IMAGE LoadedImage
			TRUE,		// BOOL DotDll
			TRUE		// BOOL ReadOnly
			);
	if (!bOK)
	{
		cerr << "MapAndLoad failed!" << endl;
		return 2;
	}
 
	// Now get the address of the export table.
	DWORD expVA = li.FileHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
	PIMAGE_EXPORT_DIRECTORY pExp = (PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(
								li.FileHeader,		// IN PIMAGE_NT_HEADERS NtHeaders
								li.MappedAddress,	// IN PVOID Base
								expVA,			// IN ULONG Rva
								NULL			// IN OUT PIMAGE_SECTION_HEADER *LastRvaSection
								);
 
 
	// Now dump the functions names.
	DWORD rvaNames = pExp->AddressOfNames;
	DWORD *prvaNames = (DWORD*)ImageRvaToVa(
					li.FileHeader,		// IN PIMAGE_NT_HEADERS NtHeaders
					li.MappedAddress,	// IN PVOID Base
					rvaNames,		// IN ULONG Rva
					NULL			// IN OUT PIMAGE_SECTION_HEADER *LastRvaSection
					);
	for (DWORD i=0; i<pExp->NumberOfNames; ++i)
	{
		DWORD rvaName = prvaNames[i];
		const char *pName = (const char*)ImageRvaToVa(
						li.FileHeader,		// IN PIMAGE_NT_HEADERS NtHeaders
						li.MappedAddress,	// IN PVOID Base
						rvaName,		// IN ULONG Rva
						NULL			// IN OUT PIMAGE_SECTION_HEADER *LastRvaSection
						);
 
		cout << pName << endl;
	}
 
	// Unmap it.
	UnMapAndLoad(&li);
 
	return 0;
}


Steve

modified on Wednesday, February 13, 2008 10:58 PM

GeneralRe: How to extract Exported functions from a DLL Pin
poda12-Feb-08 21:30
poda12-Feb-08 21:30 
GeneralRe: How to extract Exported functions from a DLL Pin
poda12-Feb-08 21:49
poda12-Feb-08 21:49 
GeneralRe: How to extract Exported functions from a DLL Pin
Stephen Hewitt13-Feb-08 0:30
Stephen Hewitt13-Feb-08 0:30 
GeneralInterface default constructor Error Pin
half-life12-Feb-08 20:08
half-life12-Feb-08 20:08 
GeneralRe: Interface default constructor Error Pin
Cedric Moonen12-Feb-08 20:21
Cedric Moonen12-Feb-08 20:21 
GeneralRe: Interface default constructor Error Pin
half-life12-Feb-08 20:39
half-life12-Feb-08 20:39 
GeneralRe: Interface default constructor Error Pin
jhwurmbach13-Feb-08 0:52
jhwurmbach13-Feb-08 0:52 
GeneralDebug Assertion Error Occurs while making the Static Linked Dll Pin
nitin_pro12-Feb-08 20:03
nitin_pro12-Feb-08 20:03 
QuestionRelease Mode not running Pin
vethathiri12-Feb-08 19:57
vethathiri12-Feb-08 19:57 
GeneralRe: Release Mode not running Pin
Rajesh R Subramanian12-Feb-08 20:22
professionalRajesh R Subramanian12-Feb-08 20:22 
GeneralRe: Release Mode not running Pin
Iain Clarke, Warrior Programmer13-Feb-08 0:14
Iain Clarke, Warrior Programmer13-Feb-08 0:14 
QuestionRe: Release Mode not running Pin
David Crow13-Feb-08 3:25
David Crow13-Feb-08 3:25 
Generalwhile debugging not able see the source code [modified] Pin
VC_RYK12-Feb-08 19:55
VC_RYK12-Feb-08 19:55 
GeneralRe: while debugging not able see the source code Pin
Cedric Moonen12-Feb-08 20:24
Cedric Moonen12-Feb-08 20:24 
QuestionHow to create 3D vector? Pin
TooShy2Talk12-Feb-08 19:52
TooShy2Talk12-Feb-08 19:52 
GeneralRe: How to create 3D vector? Pin
BadKarma12-Feb-08 20:50
BadKarma12-Feb-08 20:50 
Generalhide and unhide panes created by CSplitterWnd class Pin
preeti sharma12-Feb-08 19:17
preeti sharma12-Feb-08 19:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.