Article View: borland.public.cppbuilder.nativeapi
Article #10302Re: linking to VC++ Dll's (_stdcall)
From: Remy Lebeau (TeamB)
Date: Fri, 23 Apr 2004 00:19
Date: Fri, 23 Apr 2004 00:19
28 lines
1905 bytes
1905 bytes
"Kevin Johnson" <kevjson@hotmail.com> wrote in message
news:408802ed$1@newsgroups.borland.com...
> I've defined my typedefs as:
>
> typedef __declspec(dllimport) short Inp32(short PortAddress);
> typedef __declspec(dllimport) void Out32(short PortAddress, short
data);
That is not correct. It should be like this instead:
typedef short __stdcall (*Inp32Ptr)(short PortAddress);
typedef void __stdcall (*Out32Ptr)(short PortAddress, short data);
Inp32Ptr *Input;
Out32Ptr *Output;
> However when I call Output and get an "application-defined"
> exception (code 0c0000029) at 0x77fb1e0c.
That is probably because you did not set up the typedefs correctly. When
you call the functions, you are actually not using the __Stdcall convention
at all, and as such you are corrupting the stack, so anything can happen
because you have undefined behavior in your code from that point on.
Gambit
Technical Details
Message-ID:
<408862a6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<408802ed$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,8a83c52dcba9336c X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-22 17:38:08 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <408802ed$1@newsgroups.borland.com> Subject: Re: linking to VC++ Dll's (_stdcall) Date: Thu, 22 Apr 2004 17:19:58 -0700 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <408862a6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1082679974 67.22.138.253 (22 Apr 2004 17:26:14 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail