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 / CallbackObj.asm < prev    next >
Assembly Source File  |  2008-03-10  |  1KB  |  35 lines

  1.  
  2. ;******************************************************************************************
  3. ;
  4. ; Wrap an object (.cls/.frm/.ctl) callback from a cdecl or stdcall function
  5. ;
  6. ; v1.00 20071201 Original cut.......................................................... prc
  7. ; v1.01 20080203 Storing the return value as part of mov instruction................... prc
  8. ;******************************************************************************************
  9.  
  10. use32                        ;32bit
  11.  
  12.     mov    eax, esp            ;Copy the stack pointer
  13.  
  14.     call    L1                ;Call the next instruction
  15. L1:    pop    edx                ;Pop the return address into edx (edx = L1)
  16.  
  17.     add    edx, (L4-L1)            ;Add the offeset to L4 (edx = L4)
  18.     push    edx                ;Push the return value location
  19.  
  20.     mov    ecx, 55h            ;Number of parameters into ecx, patched by cCallFunc2.CallbackObj
  21.     jecxz    L3                ;If ecx = 0 (no parameters) then jump over the parameter push loop
  22.  
  23. L2:    push    dword [eax + ecx * 4]        ;Push the parameter
  24.     loop    L2                ;Next parameter
  25.  
  26. L3:    push    55555555h            ;Push the object address, patched by cCallFunc2.CallbackObj
  27.     db    0E8h                ;Op-code for call relative
  28.     dd    55555555h            ;EIP relative address of target object function, patched by cCallFunc2.CallbackObj
  29.  
  30.     db    0B8h                ;Op-code for move eax immediate value
  31. L4:    dd    55555555h            ;immediate return value
  32.     ret    55h                ;Return to caller, stack adjustment patched by cCallFunc2.CallbackObj
  33.     nop
  34.     nop
  35.