1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
7 * The contents of this file are subject to the SciTech MGL Public
8 * License Version 1.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.scitechsoft.com/mgl-license.txt
12 * Software distributed under the License is distributed on an
13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
25 * Environment: 32-bit Windows NT driver
27 * Description: C library compatible stdlib.h functions for use within a
30 ****************************************************************************/
35 /*------------------------ Main Code Implementation -----------------------*/
37 /****************************************************************************
39 PM_malloc override function for Nucleus drivers loaded in NT drivers's.
40 ****************************************************************************/
44 return PM_mallocShared(size);
47 /****************************************************************************
49 calloc library function for Nucleus drivers loaded in NT drivers's.
50 ****************************************************************************/
55 void *p = PM_mallocShared(nelem * size);
57 memset(p,0,nelem * size);
61 /****************************************************************************
63 PM_realloc override function for Nucleus drivers loaded in VxD's.
64 ****************************************************************************/
69 void *p = PM_mallocShared(size);
77 /****************************************************************************
79 PM_free override function for Nucleus drivers loaded in VxD's.
80 ****************************************************************************/
87 /****************************************************************************
89 cstr - C style ANSI string to convert
92 Pointer to the UniCode string structure or NULL on failure to allocate memory
95 Converts a C style string to a UniCode string structure that can be passed
96 directly to NT kernel functions.
97 ****************************************************************************/
98 UNICODE_STRING *_PM_CStringToUnicodeString(
103 UNICODE_STRING *uniStr;
105 /* Allocate memory for the string structure */
106 if ((uniStr = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING))) == NULL)
109 /* Allocate memory for the wide string itself */
110 length = (strlen(cstr) * sizeof(WCHAR)) + sizeof(WCHAR);
111 if ((uniStr->Buffer = ExAllocatePool(NonPagedPool, length)) == NULL) {
115 RtlZeroMemory(uniStr->Buffer, length);
117 uniStr->MaximumLength = (USHORT)length;
119 /* Convert filename string to ansi string and then to UniCode string */
120 RtlInitAnsiString(&ansiStr, cstr);
121 RtlAnsiStringToUnicodeString(uniStr, &ansiStr, FALSE);
125 /****************************************************************************
127 uniStr - UniCode string structure to free
130 Frees a string allocated by the above _PM_CStringToUnicodeString function.
131 ****************************************************************************/
132 void _PM_FreeUnicodeString(
133 UNICODE_STRING *uniStr)
136 ExFreePool(uniStr->Buffer);