Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLinks to tutorials Pin
tom groezer12-Jun-07 16:48
tom groezer12-Jun-07 16:48 
AnswerRe: Pointers Pin
Christian Graus12-Jun-07 16:57
protectorChristian Graus12-Jun-07 16:57 
AnswerRe: Links to tutorials Pin
Naveen12-Jun-07 18:00
Naveen12-Jun-07 18:00 
QuestionDll protection Pin
tom groezer12-Jun-07 15:42
tom groezer12-Jun-07 15:42 
AnswerRe: Dll protection Pin
Sathesh Sakthivel12-Jun-07 15:48
Sathesh Sakthivel12-Jun-07 15:48 
AnswerRe: Dll protection Pin
Christian Graus12-Jun-07 16:58
protectorChristian Graus12-Jun-07 16:58 
GeneralRe: Dll protection Pin
tom groezer12-Jun-07 17:01
tom groezer12-Jun-07 17:01 
AnswerRe: Dll protection Pin
Stephen Hewitt12-Jun-07 19:28
Stephen Hewitt12-Jun-07 19:28 
Something like this may interest you:
#pragma optimize( "y", off )	// Make sure we have standard stack frames.
				// This is important because of how we dig the
				// return address out of the stack frame.
void ExportedFunction()
{
	// Get the return address.
	LPCVOID pReturnAddress;
	__asm
	{
		mov eax, [ebp+4]
		mov pReturnAddress, eax
	}
 
	// Find the HMODULE from the return address.
	MEMORY_BASIC_INFORMATION mbi;
	DWORD res = VirtualQuery(pReturnAddress, &mbi, sizeof(mbi));
	if (res!=sizeof(mbi))
	{
		return; // Error!
	}
	HMODULE hModCaller = reinterpret_cast<HMODULE>(mbi.AllocationBase);
 
	// Get the name of the calling module.
	char ModName[MAX_PATH];
	if ( GetModuleFileName(hModCaller, ModName, MAX_PATH) )
	{
		// Output the calling module's name.
		MessageBox(NULL, ModName, "Calling module's name is", MB_OK);
	}
}
#pragma optimize( "", on ) 		// Reset to default.


Printing the module's name is just an example. This shows how you can identify your caller however.


Steve

QuestionOpen a folder. Pin
James Laing12-Jun-07 13:40
James Laing12-Jun-07 13:40 
AnswerRe: Open a folder. Pin
Mark Salsbery12-Jun-07 13:50
Mark Salsbery12-Jun-07 13:50 
GeneralRe: Open a folder. Pin
James Laing12-Jun-07 14:16
James Laing12-Jun-07 14:16 
GeneralRe: Open a folder. Pin
Mark Salsbery12-Jun-07 14:23
Mark Salsbery12-Jun-07 14:23 
GeneralRe: Open a folder. Pin
James Laing12-Jun-07 14:30
James Laing12-Jun-07 14:30 
GeneralRe: Open a folder. Pin
Mark Salsbery12-Jun-07 14:37
Mark Salsbery12-Jun-07 14:37 
GeneralRe: Open a folder. Pin
Mark Salsbery12-Jun-07 14:28
Mark Salsbery12-Jun-07 14:28 
GeneralRe: Open a folder. Pin
James Laing12-Jun-07 14:43
James Laing12-Jun-07 14:43 
GeneralRe: Open a folder. Pin
James Laing13-Jun-07 12:59
James Laing13-Jun-07 12:59 
QuestionEasy one on install of Visual Studio 2005 Pin
al250012-Jun-07 11:00
al250012-Jun-07 11:00 
AnswerRe: Easy one on install of Visual Studio 2005 Pin
Michael Dunn12-Jun-07 18:19
sitebuilderMichael Dunn12-Jun-07 18:19 
AnswerRe: Easy one on install of Visual Studio 2005 Pin
Paresh Chitte12-Jun-07 18:53
Paresh Chitte12-Jun-07 18:53 
QuestionRegistry simple question in MFC Pin
Electronic7512-Jun-07 10:34
Electronic7512-Jun-07 10:34 
AnswerRe: Registry simple question in MFC Pin
David Crow12-Jun-07 10:45
David Crow12-Jun-07 10:45 
GeneralRe: Registry simple question in MFC Pin
Electronic7512-Jun-07 11:12
Electronic7512-Jun-07 11:12 
GeneralRe: Registry simple question in MFC Pin
Hamid_RT12-Jun-07 19:50
Hamid_RT12-Jun-07 19:50 
QuestionGetting Network Info and writing "TcpView" Pin
Akin Ocal12-Jun-07 10:12
Akin Ocal12-Jun-07 10:12 

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.