- ; Validate user ESP
- ; - Page Table
- mov edx, [eax+KSTACK_USERSTATE_SIZE-12] ; User ESP is at top of kstack - 3*4
- mov ecx, edx
- shr ecx, 22
- test BYTE [0xFC3F0000+ecx*4], 1
- jnz .justKillIt
- ; - Page
- mov ecx, edx
- shr ecx, 12
- test BYTE [0xFC000000+ecx*4], 1
- jnz .justKillIt
- ; Adjust
- sub edx, 8
- ; - Page Table
- mov ecx, edx
- shr ecx, 22
- test BYTE [0xFC3F0000+ecx*4], 1
- jnz .justKillIt
- ; - Page
- mov ecx, edx
- shr ecx, 12
- test BYTE [0xFC000000+ecx*4], 1
- jnz .justKillIt
-
- ; Get and alter User SP
- mov edi, edx
- mov edx, [ebp+12] ; Get parameter
- mov [edi+4], edx ; save to user stack
- mov [edi], DWORD User_Syscall_RetAndExit ; Return Address
-
- ; Restore Segment Registers
- mov ax, 0x23
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
-
- push 0x23 ; SS
- push edi ; ESP
- push 0x202 ; EFLAGS (IP and Rsvd)
- push 0x1B ; CS
- mov eax, [ebp+8] ; Method to call
- push eax ; EIP
-
- iret
+ ; Create data to add to user stack
+ push DWORD [ebp+12]
+ push User_Syscall_RetAndExit
+ mov ecx, esp
+
+ ; Call user method
+ push 2*4
+ push ecx
+ push DWORD [eax+KSTACK_USERSTATE_SIZE-12] ; User ESP is at top of kstack - 3*4
+ push DWORD [ebp+8]
+ call Proc_CallUser