473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

MSDEV C - "debug error esp"

Hello All,

I have been trying to fix the following problem; this bit of code works fine when it is compiled as part of a Windows application but when I move it out to a DLL I get the debug error - esp not saved etc. The error is obviously caused by some sort of stack problem but why in the DLL and not the application? Any ideas.

HINSTANCE h_instdll;
PROC func1;

h_instdll = LoadLibrary(dllname);
if (h_instdll == NULL)
{
handle error
}
func1 = GetProcAddress(h_instdll, funcname);

retval = func1(......); // generates esp error in DLL
Jun 18 '07 #1
1 2254
weaknessforcats
9,208 Expert Mod 8TB
Your HINSTANCE should be HMODULE and your PROC should be FARPROC.

Other thna that, this code:
Expand|Select|Wrap|Line Numbers
  1. retval = func1(......); // generates esp error in DLL
  2.  
cannot compile because FARPROC cannot be used as a pointer to just any function.

Let's assume you function in the dll has this prototype:
Expand|Select|Wrap|Line Numbers
  1. void MyFunct(int);
  2.  
Then you would need to typecast the FARPROC returned by GetProcAddress to a pointer to a function that takes an int argument and returns a void:
Expand|Select|Wrap|Line Numbers
  1. void (*fp)(int) = (void(*)(int))retval;
  2.  
Also, I am assuming you are writinfg in C. If you are writing in C++, be sure to use extern "C" on your dll functions to turn off the C++ mangler or create a DEF file for the dll to export the mangled name under an alias.
Jun 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John Smith | last post by:
Sorry if this is the wrong forum... Does anyone know what the difference is between a debug build and an optimised debug build in Visual Studio 2003?
10
by: John Smith | last post by:
After reading C# documentation the Conditional attribute seemed the way to go, but after inspecting the IL it seems those methods are still there and I imagine the CLR removes them. Using #if DEBUG...
0
by: Gianni Nitti | last post by:
If I set in web.config this: <compilation defaultLanguage="vb" debug="false"/> I receive this error: "Compiler Error Message: BC30560: 'barratop_ascx' is ambiguous in the namespace '_ASP'....
2
by: Jeremy S. | last post by:
By default, Web.config has the following section: <compilation defaultLanguage="c#" debug="true" /> note that debug="true" There is a comment - also in the default Web.config - that states...
3
by: Whiplash | last post by:
I've got a web app that has the debug parameter in the web.config file set to true. Everything works great. However, I want to set debug to false before putting the app into production. When I do...
1
by: Alexander Walker | last post by:
Hello I have recently published a web application using the "Publish Web Site" option of the solution explorer from Visual Studio 2005, I have published the website so that the pages could not...
3
by: André | last post by:
Hi, I put that question already, but it's still not very clear to me, so ... Assume following option in web.config= debug="false" but in one aspx page (test.aspx) <%@ debug="true" ..%>
2
by: bbasberg | last post by:
Hello, I am a neophyte with Visual Basic but have been trying to hurry and get up to speed. I used to be able to "step into" code using Debug..step into but for the last couple of days I am...
1
by: =?Utf-8?B?RWluYXY=?= | last post by:
hi, im developing a dll app under vs2005 (sp1). when trying to load my exe app (which uses the dll) im getting the following err message: "the application failed to initialize properly...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.