[BITS 32] global isrs global catchall_return catchall: ; At this point the gate number has been pushed to the stack pushad mov eax, cr3 push eax push 0 ; Pushed 40 bytes mov eax, [esp+40] mov ebx, gates mov eax, [ebx+4*eax] ; Check if we came from Ring 3 movzx ecx, word [esp+56] and ecx, 3 cmp ecx, 3 jne no_copy mov ecx, 72 mov esi, esp mov edi, [_ZN6Global13currentThreadE] rep movsb mov ecx, [_ZN6Global13currentThreadE] push ecx jmp call no_copy: push esp jmp call call: ; Increment the current thread's count mov ecx, [_ZN6Global13currentThreadE] mov edx, [ecx] add edx, 1 mov [ecx], edx call eax catchall_return: add esp, 4 push 0x20 push 0x20 call outb add esp, 8 ; Decrement and check the current thread's count mov ecx, [_ZN6Global13currentThreadE] mov edx, [ecx] sub edx, 1 mov [ecx], edx cmp edx, 0 jne skip_copying sub esp, 72 mov ecx, 72 mov esi, [_ZN6Global13currentThreadE] mov edi, esp rep movsb skip_copying: add esp, 4 pop eax mov cr3, eax popad add esp, 8 pop ebp iret extern gates ; (void(*)(frame_struct))* extern outb extern _ZN6Global13currentThreadE