3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
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.
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.
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.
21 * PROJECT: ReactOS kernel
22 * FILE: ntoskrnl/rtl/capture.c
23 * PURPOSE: Helper routines for system calls.
24 * PROGRAMMER: David Welch (welch@cwcom.net)
29 /* INCLUDES ******************************************************************/
33 #include <internal/debug.h>
35 /* FUNCTIONS *****************************************************************/
38 RtlCaptureUnicodeString(PUNICODE_STRING Dest
,
39 PUNICODE_STRING UnsafeSrc
)
45 * Copy the source string structure to kernel space.
47 Status
= MmCopyFromCaller(&Src
, UnsafeSrc
, sizeof(UNICODE_STRING
));
48 if (!NT_SUCCESS(Status
))
54 * Initialize the destination string.
56 Dest
->Length
= Src
->Length
;
57 Dest
->MaximumLength
= Src
->MaximumLength
;
58 Dest
->Buffer
= ExAllocatePool(NonPagedPool
, Dest
->MaximumLength
);
59 if (Dest
->Buffer
== NULL
)
61 return(STATUS_NO_MEMORY
);
65 * Copy the source string to kernel space.
67 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
->Buffer
, Dest
->Length
);
68 if (!NT_SUCCESS(Status
))
70 ExFreePool(Dest
->Buffer
);
74 return(STATUS_SUCCESS
);
78 RtlCaptureAnsiString(PANSI_STRING Dest
,
79 PANSI_STRING UnsafeSrc
)
85 * Copy the source string structure to kernel space.
87 Status
= MmCopyFromCaller(&Src
, UnsafeSrc
, sizeof(ANSI_STRING
));
88 if (!NT_SUCCESS(Status
))
94 * Initialize the destination string.
96 Dest
->Length
= Src
->Length
;
97 Dest
->MaximumLength
= Src
->MaximumLength
;
98 Dest
->Buffer
= ExAllocatePool(NonPagedPool
, Dest
->MaximumLength
);
99 if (Dest
->Buffer
== NULL
)
105 * Copy the source string to kernel space.
107 Status
= MmCopyFromCaller(Dest
->Buffer
, Src
->Buffer
, Dest
->Length
);
108 if (!NT_SUCCESS(Status
))
110 ExFreePool(Dest
->Buffer
);
114 return(STATUS_SUCCESS
);
123 OUT PCONTEXT ContextRecord
134 RtlCaptureStackBackTrace (
135 IN ULONG FramesToSkip
,
136 IN ULONG FramesToCapture
,
137 OUT PVOID
*BackTrace
,
138 OUT PULONG BackTraceHash OPTIONAL