Calling an function in a DLL
-
I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side
int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?
-
I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side
int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?
JJeffrey wrote:
TopoFunc();
Did you miss to pass string here ?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side
int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?
-
JJeffrey wrote:
TopoFunc();
Did you miss to pass string here ?
Prasad Notifier using ATL | Operator new[],delete[][^]
No, I just removed all the irrelevant code. I did remember to pass the string. It is a LPTSTR. And as to the other poster's statement, been there, done that. It is calling into the debug dll correctly, but the stack overflows when the program steps through from the calling EXE to the debug DLL in VC++