DLL import
From: Marsupilami (spamtrap_at_crayne.org)
Date: 10/19/04
- Previous message: Jack Klein: "Re: invert value"
- Next in thread: David Lindauer : "Re: DLL import"
- Reply: David Lindauer : "Re: DLL import"
- Reply: wolfgang kern: "Re: DLL import"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 19 Oct 2004 02:52:06 +0000 (UTC)
Hi.
I didn't fight with ASM/C for a long time, so, plz, don't laugh.
This is a mini-DLL and very basic code (MASM) :
=====
.586
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
.data
.code
DllEntry proc hInstDLL:DWORD, reason:DWORD, reserved1:DWORD
mov eax,1
ret
DllEntry Endp
Addxy proc A:DWORD, B:DWORD
mov eax,A
add eax,B
ret
Addxy endp
END DllEntry
=====
How do I call Addxy() from C/C++ code ?
I tried :
=====
typedef int (_stdcall *Addxyproc)(int,int);
Addxyproc addNumbers;
HINSTANCE handle = LoadLibrary(DllName); // DllName is the path to the DLL
addNumbers = (Addxyproc)GetProcAddress(handle,"Addxy");
printf("x+y = %d\n", addNumbers(1,2));
=====
At runtime, when running the printf() instruction I get
"Run-Time Check Failure #0 - The value of ESP was not properly saved across
a function call. This is usually a result of calling a function declared
with one calling convention with a function pointer declared with a
different calling convention."
Where's the stupid stuff I don't see...
Thx for ur help.
- Previous message: Jack Klein: "Re: invert value"
- Next in thread: David Lindauer : "Re: DLL import"
- Reply: David Lindauer : "Re: DLL import"
- Reply: wolfgang kern: "Re: DLL import"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|