News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Callback functions

Started by m0nk3yi3unz, July 07, 2009, 12:21:53 AM

Previous topic - Next topic

m0nk3yi3unz

Hey all. I'm looking into the function WaveInOpen, and say it required a callback function.

I know what they are from my C# knowledge, however I have -no- idea how to implement them in MASM. I've googled everywhere but, not surprisingly, I found nothing. :/

Any help?

MSDN page: http://msdn.microsoft.com/en-us/library/ms913593.aspx


Cheers!

-Monkey

dedndave

if you look in the masm32 examples folder, there are many programs that use them

hutch--

Monkey,

Ther basics of a callback are the arguments required and the return value if any along with a returned address in intercept style callbacks like controls. Usually Microsoft will publish the argument list with its corresponding dayta sizes so you lay out the bare callback in the form they publish.

If for example a callback has 3 DWORD sized arguments and requires a return value of 0 to terminate it you would lay it out something like this.


MyCallBack proc arg1:DWORD,arg2:DWORD,arg3:DWORD

    ; write the processing code here

    .if (terminating_condition) != 0
      xor eax, eax
      ret
    .endif

    ret

MyCallBack endp


Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

m0nk3yi3unz

@dedndave - OH wow! xDD I didn't even know there was an examples folder. xD I'll definitely be looking at that (I've never noticed since I use RadASM).

Thanks for the tip :)

@hutch - ah, I see now. Thanks for that! It makes sense :)

-Monkey

BlackVortex

Also remember about register preservation.

ToutEnMasm


Usefull is the MMSystem.sdk. I think you can add it to the windows.inc , include the translate.inc first.

The callback function isn't define in the msdn help (your link.There is a choose to made with constants values.
The MMSystem defines only two callback functions.
The sdk defines allways callback prototypes with callback in there names.
Result is:
Quote
DRVCALLBACK PROTO :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD
TIMECALLBACK PROTO :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD
Perhaps a sample in c++ will help you to made choices ?.





m0nk3yi3unz

@BlackVortex - Thanks, will do :)

@ToutEnMasm - Thanks, I'll definitely look it up. The whole MM process contains a lot of steps :X this SDK should be rewarding.

Thanks for all of the support guys!