Advertisement
Runer112

Untitled

Jul 3rd, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; rst 08h, macros kld, kcall, kjp
  2. ; Loads the correct address into
  3. ; executing programs at runtime
  4. rmacro:
  5.     ex (sp),hl              ; Save hl and get the return address
  6.     push af                 ; Save af, bc, and de
  7.     push bc
  8.     push de
  9.         dec hl
  10.         ld (hl),0           ; Replace rst 08h with nop
  11.         inc hl
  12.         inc hl
  13.         ld c,(hl)           ; Load the offset into bc
  14.         inc hl
  15.         ld b,(hl)
  16.         push hl             ; Save the insertion point
  17.             ld a,(CurrentThreadID)
  18.             call GetThreadEntry ; Get the thread entry
  19.             inc hl          ; Move to the executable address entry
  20.             ld e,(hl)       ; Load the executable address into de
  21.             inc hl
  22.             ld d,(hl)
  23.             ex de,hl        ; Swap the address into hl
  24.             add hl,bc       ; Add the offset to the address
  25.             ex de,hl        ; Put the address back into de
  26.         pop hl              ; Restore the insertion point
  27.         ld (hl),d           ; Store the adjusted address
  28.         dec hl
  29.         ld (hl),e
  30.         dec hl              ; Adjust hl to point to the return address
  31.     pop de                  ; Restore af, bc, and de
  32.     pop bc
  33.     pop af
  34.     ex (sp),hl              ; Restore hl and put the return address on the stack
  35.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement