home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Universal_2106383172008.psc / Assembler / CallbackCdecl.asm next >
Assembly Source File  |  2008-03-10  |  1KB  |  26 lines

  1.  
  2. ;******************************************************************************************
  3. ;
  4. ; Wrap a .bas module callback from a CDECL function
  5. ;
  6. ; v1.00 20071201 Original cut.......................................................... prc
  7. ; v1.01 20080203 Storing the return address as part of the push instruction............ prc
  8. ;******************************************************************************************
  9.  
  10. use32                        ;32bit
  11.  
  12.     call    L1                ;Call the next instruction
  13. L1:    pop    eax                ;Pop the return address into eax (eax = L1)
  14.  
  15.     pop    dword [eax+(L2-L1)]        ;Pop the calling function's return address into the immediate value 'push' instruction at L2
  16.  
  17.     db    0E8h                ;Op-code for a relative address call
  18.     dd    55555555h            ;EIP-relative address of target vb module function, patched by cCallFunc2.CallbackCdecl
  19.  
  20.     sub    esp, 55h            ;Adjust the stack... patched by cCallFunc2.CallbackCdecl
  21.  
  22.     db    068h                ;Op-code for an immediate value push
  23. L2:    dd    55555555h            ;Return address, patched by the instruction after L2
  24.     ret                    ;Return to caller
  25.     nop
  26.