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 ******************************************************************/
31 #include <ddk/ntddk.h>
32 #include <internal/safe.h>
35 #include <internal/debug.h>
37 /* FUNCTIONS *****************************************************************/
40 RtlCaptureUnicodeString(PUNICODE_STRING Dest,
41 PUNICODE_STRING UnsafeSrc)
47 * Copy the source string structure to kernel space.
49 Status = MmCopyFromCaller(&Src, UnsafeSrc, sizeof(UNICODE_STRING));
50 if (!NT_SUCCESS(Status))
56 * Initialize the destination string.
58 Dest->Length = Src->Length;
59 Dest->MaximumLength = Src->MaximumLength;
60 Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
61 if (Dest->Buffer == NULL)
63 return(STATUS_NO_MEMORY);
67 * Copy the source string to kernel space.
69 Status = MmCopyFromCaller(Dest->Buffer, Src->Buffer, Dest->Length);
70 if (!NT_SUCCESS(Status))
72 ExFreePool(Dest->Buffer);
76 return(STATUS_SUCCESS);
80 RtlCaptureAnsiString(PANSI_STRING Dest,
81 PANSI_STRING UnsafeSrc)
87 * Copy the source string structure to kernel space.
89 Status = MmCopyFromCaller(&Src, UnsafeSrc, sizeof(ANSI_STRING));
90 if (!NT_SUCCESS(Status))
96 * Initialize the destination string.
98 Dest->Length = Src->Length;
99 Dest->MaximumLength = Src->MaximumLength;
100 Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
101 if (Dest->Buffer == NULL)
107 * Copy the source string to kernel space.
109 Status = MmCopyFromCaller(Dest->Buffer, Src->Buffer, Dest->Length);
110 if (!NT_SUCCESS(Status))
112 ExFreePool(Dest->Buffer);
116 return(STATUS_SUCCESS);