* Use objects rather than archive when linking ntoskrnl
[reactos.git] / reactos / ntoskrnl / rtl / capture.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * PROJECT: ReactOS kernel
22 * FILE: ntoskrnl/rtl/capture.c
23 * PURPOSE: Helper routines for system calls.
24 * PROGRAMMER: David Welch (welch@cwcom.net)
25 * UPDATE HISTORY:
26 * 02/09/01: Created
27 */
28
29 /* INCLUDES ******************************************************************/
30
31 #include <ntoskrnl.h>
32 #define NDEBUG
33 #include <internal/debug.h>
34
35 /* FUNCTIONS *****************************************************************/
36
37 NTSTATUS
38 RtlCaptureUnicodeString(PUNICODE_STRING Dest,
39 PUNICODE_STRING UnsafeSrc)
40 {
41 PUNICODE_STRING Src;
42 NTSTATUS Status;
43
44 /*
45 * Copy the source string structure to kernel space.
46 */
47 Status = MmCopyFromCaller(&Src, UnsafeSrc, sizeof(UNICODE_STRING));
48 if (!NT_SUCCESS(Status))
49 {
50 return(Status);
51 }
52
53 /*
54 * Initialize the destination string.
55 */
56 Dest->Length = Src->Length;
57 Dest->MaximumLength = Src->MaximumLength;
58 Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
59 if (Dest->Buffer == NULL)
60 {
61 return(STATUS_NO_MEMORY);
62 }
63
64 /*
65 * Copy the source string to kernel space.
66 */
67 Status = MmCopyFromCaller(Dest->Buffer, Src->Buffer, Dest->Length);
68 if (!NT_SUCCESS(Status))
69 {
70 ExFreePool(Dest->Buffer);
71 return(Status);
72 }
73
74 return(STATUS_SUCCESS);
75 }
76
77 NTSTATUS
78 RtlCaptureAnsiString(PANSI_STRING Dest,
79 PANSI_STRING UnsafeSrc)
80 {
81 PANSI_STRING Src;
82 NTSTATUS Status;
83
84 /*
85 * Copy the source string structure to kernel space.
86 */
87 Status = MmCopyFromCaller(&Src, UnsafeSrc, sizeof(ANSI_STRING));
88 if (!NT_SUCCESS(Status))
89 {
90 return(Status);
91 }
92
93 /*
94 * Initialize the destination string.
95 */
96 Dest->Length = Src->Length;
97 Dest->MaximumLength = Src->MaximumLength;
98 Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
99 if (Dest->Buffer == NULL)
100 {
101 return(Status);
102 }
103
104 /*
105 * Copy the source string to kernel space.
106 */
107 Status = MmCopyFromCaller(Dest->Buffer, Src->Buffer, Dest->Length);
108 if (!NT_SUCCESS(Status))
109 {
110 ExFreePool(Dest->Buffer);
111 return(Status);
112 }
113
114 return(STATUS_SUCCESS);
115 }
116
117 /*
118 * @unimplemented
119 */
120 VOID
121 STDCALL
122 RtlCaptureContext (
123 OUT PCONTEXT ContextRecord
124 )
125 {
126 UNIMPLEMENTED;
127 }
128
129 /*
130 * @unimplemented
131 */
132 USHORT
133 STDCALL
134 RtlCaptureStackBackTrace (
135 IN ULONG FramesToSkip,
136 IN ULONG FramesToCapture,
137 OUT PVOID *BackTrace,
138 OUT PULONG BackTraceHash OPTIONAL
139 )
140 {
141 UNIMPLEMENTED;
142 return 0;
143 }
144
145 /* EOF */
146