Hello all again
im coding somekind of asm prog witch loads some Dlls writen/compiled in C++

and i have this in the asm source when calling a function stored in a c++ dll :

push 0 ; null-reserved
push hBlock ; hBlock
push hWnd ; hWnd
call eax             ; call it

a normal call to a pointer to a funtion in another module...
it works OK with my plugins coded in asm(MASM)
but when i have a C++ plugin with the same exported functions it wont work !
i have been debugging the 2 sides ( with a asm dll and a cpp dll)
by some unknow reason the stack gets dealign !! by ... 12 bytes
those ones that i just pushed up ...

does anyone knows how to prevent that? or to make the cpp dll act correctly?
i just attached my cpp dll source for more infor of the problem..
its just weird... why the stack is dealign after my call?

do i need to specificate something in the cpp declarations?

hope you guys can help me out
Posted on 2006-06-15 20:09:42 by GR33d
stdcall = stack is handled by the proc you call
c call = stack is handled by YOUR code upon the ret...

example of a c call in kernel32 -> wsprintfa

so chances are the c dll you're using is for c, so you have to handle the stack on ret with
add esp, (params_passed * 4)
Posted on 2006-06-16 03:19:04 by evlncrn8
cpp plugins?
This sounds like oop.
The first param to cpp class methods is a pointer to the object instance, followed by the method params, in reverse order as usual.
If this is for a cpp class, have you got the class definition?
I can show you how to convert it to OA32 syntax for use with MASM :)
Posted on 2006-06-16 04:09:20 by Homer
If you want the C/C++ code to handle stack cleanup itself, as per STDCALL, change the .cpp a bit...

int __stdcall Main(HWND hWnd,DWORD hBlock,DWORD _null)

Also, to make linking a bit easier (without decorated names), declare prototypes like this:

#ifdef __cplusplus
extern "C" {

int __stdcall Main(HWND hWnd,DWORD hBlock,DWORD _null);

// more exports can go here...

#ifdef __cplusplus

the #ifdef stuff is so you can use the header file from both C and C++ code.
Posted on 2006-06-16 04:45:25 by f0dder
example of a c call in kernel32 -> wsprintfa

wsprintfA is a member of user32.dll
Posted on 2006-06-16 04:50:06 by Vortex
moot point, i typed it from memory, and you're kinda digressing from the problem with your post...
Posted on 2006-06-16 06:16:35 by evlncrn8
thats it

i knew that probably was the stdcall thing
but how im not an expert in cpp
the __stdcall type did the trick
now both dlls are working great!

thanks indeed
Posted on 2006-06-16 08:14:57 by GR33d
no problemo :)
Posted on 2006-06-16 08:17:05 by f0dder