Win32 api calls in asm 
Author Message
 Win32 api calls in asm

Hi,

Where can I get a comprehensive documentation on the win32 api calls
(for assembler)? I need this for debugging.

Thanks in advance,

Edsko



Fri, 13 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm
Well if you have a C reference, that'll be fine because they work
exactly the same in assembly.  Just remember to push the parameters
on the stack from right to left.  Other than that they work the same.

Dave

Quote:

> Hi,

> Where can I get a comprehensive documentation on the win32 api calls
> (for assembler)? I need this for debugging.

> Thanks in advance,

> Edsko



Fri, 13 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm
Try the MSDN CD(s) that come with Visual Studio. They are in C but
if you know C, you probably know assembler.
Quote:

>Hi,

>Where can I get a comprehensive documentation on the win32 api calls
>(for assembler)? I need this for debugging.

>Thanks in advance,

>Edsko



Fri, 13 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm
: Well if you have a C reference, that'll be fine because they work
: exactly the same in assembly.  Just remember to push the parameters
: on the stack from right to left.  Other than that they work the same.

: Dave

This is not entirely true. Yes, parameters are pushed onto the stack
in the same order as in C, but when the function returns it removes
them itself, just like in Pascal (in C the caller is responsible for removing
parameters). The only exception from this rule is the wsprintfA() function,
which follows C-style calling/parameter removal model.

Example:
   ; MessageBoxA ((HWND)0, Text, Title, MB_OK)
       push    MB_OK
       push    offset Title
       push    offset Text
       push    0
       call    MessageBoxA
   ; wsprintfA (Destination, Mask, Text1, Text2, 34)
       push    34
       push    offset Text2
       push    offset Text1
       push    offset Mask         ; eg. "%s %s %i"
       push    offset Destination
       call    wsprintfA
       add     esp, 20  ; 5*4

Chris


: >
: > Hi,
: >
: > Where can I get a comprehensive documentation on the win32 api calls
: > (for assembler)? I need this for debugging.
: >
: > Thanks in advance,
: >
: > Edsko

--
Chris Dragan



Sat, 14 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm

Quote:

> Well if you have a C reference, that'll be fine because they work
> exactly the same in assembly.  Just remember to push the parameters
> on the stack from right to left.  Other than that they work the same.

Small correction: from left to right, since they are "__stdcall" type.


Sat, 14 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm

Quote:
>but
>if you know C, you probably know assembler.

Wouldn't it be the other way around?


Sat, 14 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm
shouldn't it be right to left?

if you have this function:

foo(param1,param2,param3);

you would do:

push param3
push param2
push param1
call...

Quote:


> > Well if you have a C reference, that'll be fine because they work
> > exactly the same in assembly.  Just remember to push the parameters
> > on the stack from right to left.  Other than that they work the same.

> Small correction: from left to right, since they are "__stdcall" type.



Sat, 14 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm
I didn't mean that everything was the same as C.  I think the original
guy thought that the API calls would be different or take different
parameters in asm.

Dave

Quote:


> : Well if you have a C reference, that'll be fine because they work
> : exactly the same in assembly.  Just remember to push the parameters
> : on the stack from right to left.  Other than that they work the same.

> : Dave

> This is not entirely true. Yes, parameters are pushed onto the stack
> in the same order as in C, but when the function returns it removes
> them itself, just like in Pascal (in C the caller is responsible for removing
> parameters). The only exception from this rule is the wsprintfA() function,
> which follows C-style calling/parameter removal model.

> Example:
>    ; MessageBoxA ((HWND)0, Text, Title, MB_OK)
>        push    MB_OK
>        push    offset Title
>        push    offset Text
>        push    0
>        call    MessageBoxA
>    ; wsprintfA (Destination, Mask, Text1, Text2, 34)
>        push    34
>        push    offset Text2
>        push    offset Text1
>        push    offset Mask         ; eg. "%s %s %i"
>        push    offset Destination
>        call    wsprintfA
>        add     esp, 20  ; 5*4

> Chris


> : >
> : > Hi,
> : >
> : > Where can I get a comprehensive documentation on the win32 api calls
> : > (for assembler)? I need this for debugging.
> : >
> : > Thanks in advance,
> : >
> : > Edsko

> --
> Chris Dragan




Sat, 14 Jul 2001 03:00:00 GMT  
 Win32 api calls in asm

Quote:

> shouldn't it be right to left?

> if you have this function:

> foo(param1,param2,param3);

> you would do:

> push param3
> push param2
> push param1
> call...

Sorry for misleading... :(
Here is verified info:

For Win32 application parameters are pushed from right to left. The
function is responsible to clean the stack. After the function name
comes "A" or "W" letter, specifying ASCII or Unicode version of the

is parameters size in bytes.

For Win16 application the convention is what I wrote in previous post.
Parameters are pushed from left to right, no stuff added to "basic" function
name. The function is responsible to clean the stack.



Sun, 15 Jul 2001 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Calling Win32 API functions with Gnat 3.09 (Win32 version)

2. win32 API call types?

3. Win32 API-socket-calls in CW20

4. Looking for example of Win32 API Registry call from VO2

5. Calling Win32 API Functions

6. Question on SBM2 WIN32 API Calls

7. "Safe" registers in Win32 API calls

8. Win32: Calling API Function via Inline Assembly

9. Calling WIN32 APIs

10. Revectoring calls to Win32 API

11. Calling Win32 API functions with GNAT 3.09 on Windows 95

12. Calling win32 API CreateDirectoryA from Realia cobol program

 

 
Powered by phpBB® Forum Software