Fix memory leak in POLYGONFILL_MakeEdgeList when it fail.
[reactos.git] / msvc6 / ntoskrnl / mm_i386_memsafe.c
1 #include <ddk/ntddk.h>
2
3
4 void MmSafeCopyToUserRestart();
5 void MmSafeCopyToUserUnsafeStart();
6 void MmSafeCopyFromUserUnsafeStart();
7 void MmSafeCopyFromUserRestart();
8
9 /*
10 * NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src,
11 * ULONG NumberOfBytes)
12 */
13 __declspec(naked)
14 NTSTATUS MmSafeCopyFromUser(PVOID Dest, const VOID *Src, ULONG Count)
15 {
16 __asm
17 {
18 push ebp
19 mov ebp,esp
20
21 push esi
22 push edi
23 push ecx
24
25 mov edi, 8[ebp]
26 mov esi, 12[ebp]
27 mov ecx, 16[ebp]
28
29 /*
30 * Default return code
31 */
32 xor eax,eax
33
34 jmp MmSafeCopyFromUserUnsafeStart
35 }
36 }
37
38
39 __declspec(naked)
40 void MmSafeCopyFromUserUnsafeStart()
41 {
42 __asm
43 {
44 /*
45 * This is really a synthetic instruction since if we incur a
46 * pagefault then eax will be set to an appropiate STATUS code
47 */
48 cld
49 rep movsb
50
51 jmp MmSafeCopyFromUserRestart
52 }
53 }
54
55 __declspec(naked)
56 void MmSafeCopyFromUserRestart()
57 {
58 __asm
59 {
60 pop ecx
61 pop edi
62 pop esi
63
64 pop ebp
65 ret
66 }
67 }
68
69 /*****************************************************************************/
70
71 /*
72 * NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src,
73 * ULONG NumberOfBytes)
74 */
75 NTSTATUS MmSafeCopyToUser(PVOID Dest, const VOID *Src, ULONG Count)
76 {
77 __asm
78 {
79 push ebp
80 mov esp,ebp
81
82 push esi
83 push edi
84 push ecx
85
86 mov edi, 8[ebp]
87 mov esi, 12[ebp]
88 mov ecx, 16[ebp]
89
90 /*
91 * Default return code
92 */
93 xor eax,eax
94
95 jmp MmSafeCopyToUserUnsafeStart
96 }
97 }
98
99 __declspec(naked)
100 void MmSafeCopyToUserUnsafeStart()
101 {
102 __asm
103 {
104 /*
105 * This is really a synthetic instruction since if we incur a
106 * pagefault then eax will be set to an appropiate STATUS code
107 */
108 cld
109 rep movsb
110 jmp MmSafeCopyToUserRestart
111 }
112 }
113
114 __declspec(naked)
115 void MmSafeCopyToUserRestart()
116 {
117 __asm
118 {
119 pop ecx
120 pop edi
121 pop esi
122
123 pop ebp
124 ret
125 }
126 }