summaryrefslogtreecommitdiffhomepage
path: root/src/process/nt32/tt_fork_v1_i386.c
blob: 6f6a73b3c6344fa666ccc22b3212ab244b07b93f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013,2014,2015  Z. Gilboa             */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>

#if (__COMPILER__ == __MSVC__) && defined(__X86_MODEL)

intptr_t __fastcall __tt_fork_impl_v1(
	__in	uintptr_t	saved_regs_stack_pointer,
	__in	uintptr_t	stack_adjustment);

int32_t __declspec(naked) __cdecl __tt_fork_v1(void)
{
	__asm {
		push	ebp
		mov	ebp, esp

		push	ecx
		push	edx
		push	ebx
		push	esi
		push	edi

		mov	ecx, esp
		call	__tt_fork_impl_v1

		pop	edi
		pop	esi
		pop	ebx
		pop	edx
		pop	ecx

		mov	esp, ebp
		pop	ebp
		ret
	};
}

void __declspec(naked) __fastcall __tt_fork_child_entry_point(uintptr_t esp_saved)
{
	__asm {
		xor	eax, eax
		mov	esp, ecx

		pop	edi
		pop	esi
		pop	ebx
		pop	edx
		pop	ecx

		pop	ebp
		ret
	};
}

void __declspec(naked) __fastcall __tt_fork_child_entry_point_adj(uintptr_t esp_saved)
{
	__asm {
		jmp	__tt_fork_child_entry_point
	};
}

#endif