Advertisement
Guest User

Broken rip

a guest
Dec 7th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. irq_common_stub:
  2.     pushad
  3.     mov ax, ds
  4.     push eax
  5.     mov ax, 0x10 ;0x10
  6.     mov ds, ax
  7.     mov es, ax
  8.     mov fs, ax
  9.     mov gs, ax
  10.     mov eax, dr6
  11.     push eax
  12.     push esp                 ; At this point ESP is a pointer to where DS (and the rest
  13.                              ; of the interrupt handler state resides)
  14.                              ; Push ESP as 1st parameter as it's a
  15.                              ; pointer to a registers_t  
  16.     call irq_handler
  17.     mov eax, [switch_task]
  18.     cmp eax, 1
  19.     je changeTasks
  20.     pop ebx
  21.     pop ebx                  ; Remove the saved ESP on the stack. Efficient to just pop it
  22.                              ; into any register. You could have done: add esp, 4 as well
  23.     pop ebx
  24.     mov ds, bx
  25.     mov es, bx
  26.     mov fs, bx
  27.     mov gs, bx
  28.     popad
  29.     add esp, 8
  30.     sti
  31.     iret
  32.  
  33. changeTasks:
  34.     mov eax, 0
  35.     mov [switch_task], eax
  36.     call store_global ; Set a global variable with C
  37.     add esp, 72 ; "Pop" 18 values off the stack
  38.     jmp irq_schedule ; Switch task
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement