Getting handle to calling dll/exe (Calling Exe Function )

Getting handle to calling dll/exe (Calling Exe Function )

Post by Abhishe » Tue, 26 Sep 2006 21:42:09


Hello All
I am able to call the function exported by Exe from a dll file
im getting the address of the function but whille calling that function im
getting access violation Error as bellow my code



Function Exported by EXE
void __declspec(dllexport) ExeFn()
{
MessageBox(NULL,"hi","From Exe",MB_OK);
}


Function call from Dll

HMODULE hModule;
LPTSTR modname;
hModule=GetModuleHandle("Placeholder.exe");
if (hModule == NULL)
{
hModule=(HMODULE)LoadLibrary ("Placeholder.exe");
}

FnPtrT FnPtr = (FnPtrT)::GetProcAddress((HMODULE)hModule, "ExeFn");
if(FnPtr)
{
MessageBox(NULL,(LPCTSTR)FnPtr,"Exec",MB_OK);
(*FnPtr)();
}



Followinf Error

Unhandled exception at 0xfffffff9 in Mayur.dll 0xC0000005: Access violation
reading location 0xfffffff9.
 
 
 

1. Calling EXE Function Getting handle to calling exe

2. Calling EXE function(Getting address of EXE function)

Hello All
I am able to call the function exported by Exe from a dll file
im getting the address of the function but whille calling that function im
getting access violation Error as bellow my code



Function Exported by EXE
void __declspec(dllexport) ExeFn()
{
MessageBox(NULL,"hi","From Exe",MB_OK);
}


Function call from Dll

HMODULE hModule;
LPTSTR modname;
hModule=GetModuleHandle("Placeholder.exe");
if (hModule == NULL)
{
hModule=(HMODULE)LoadLibrary ("Placeholder.exe");
}

FnPtrT FnPtr = (FnPtrT)::GetProcAddress((HMODULE)hModule, "ExeFn");
if(FnPtr)
{
MessageBox(NULL,(LPCTSTR)FnPtr,"Exec",MB_OK);
(*FnPtr)();
}



Followinf Error

Unhandled exception at 0xfffffff9 in Mayur.dll 0xC0000005: Access violation
reading location 0xfffffff9.

3. How to call exe function from other exe or dll.

4. Getting handle to calling dll/exe

5. Calling EXE function (Exporting function in EXE)

6. Calling a C++/CLI dll function from an MFC dll/exe

7. C6 dll or exe calling function in COM Interop C# dll

8. Call an exported function from .EXE by rundll32.exe with TARGETTYPE=PROGLIB

9. matlab calling DLL vs. .exe calling matlab engine

10. msaccess.exe API calls: where to get the function call description

11. Calling function in EXE from DLL

12. calling a function in a DLL from an EXE

13. Determine which DLL-functions an exe calls

14. Call EXE from DLL (A crystal User defined DLL)

15. Classes in DLL: question of calling from several DLL -> EXE