1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS hive maker
3 * FILE: tools/mkhive/rtl.c
4 * PURPOSE: Runtime Library
11 #define NTOS_MODE_USER
12 #define WIN32_NO_STATUS
16 SIZE_T
xwcslen( PCWSTR String
) {
19 for( i
= 0; String
[i
]; i
++ );
24 PWSTR
xwcschr( PWSTR String
, WCHAR Char
)
28 for( i
= 0; String
[i
] && String
[i
] != Char
; i
++ );
30 if( String
[i
] ) return &String
[i
];
38 * If source is NULL the length of source is assumed to be 0.
42 IN OUT PANSI_STRING DestinationString
,
43 IN PCSTR SourceString
)
49 DestSize
= strlen(SourceString
);
50 DestinationString
->Length
= (USHORT
)DestSize
;
51 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(CHAR
);
55 DestinationString
->Length
= 0;
56 DestinationString
->MaximumLength
= 0;
59 DestinationString
->Buffer
= (PCHAR
)SourceString
;
66 * If source is NULL the length of source is assumed to be 0.
70 IN OUT PUNICODE_STRING DestinationString
,
71 IN PCWSTR SourceString
)
77 DestSize
= xwcslen(SourceString
) * sizeof(WCHAR
);
78 DestinationString
->Length
= (USHORT
)DestSize
;
79 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(WCHAR
);
83 DestinationString
->Length
= 0;
84 DestinationString
->MaximumLength
= 0;
87 DestinationString
->Buffer
= (PWCHAR
)SourceString
;
91 RtlAnsiStringToUnicodeString(
92 IN OUT PUNICODE_STRING UniDest
,
93 IN PANSI_STRING AnsiSource
,
94 IN BOOLEAN AllocateDestinationString
)
100 Length
= AnsiSource
->Length
* sizeof(WCHAR
);
101 if (Length
> MAXUSHORT
) return STATUS_INVALID_PARAMETER_2
;
102 UniDest
->Length
= (USHORT
)Length
;
104 if (AllocateDestinationString
)
106 UniDest
->MaximumLength
= (USHORT
)Length
+ sizeof(WCHAR
);
107 UniDest
->Buffer
= (PWSTR
) malloc(UniDest
->MaximumLength
);
108 if (!UniDest
->Buffer
)
109 return STATUS_NO_MEMORY
;
111 else if (UniDest
->Length
>= UniDest
->MaximumLength
)
113 return STATUS_BUFFER_OVERFLOW
;
116 WideString
= (PUCHAR
)UniDest
->Buffer
;
117 for (i
= 0; i
<= AnsiSource
->Length
; i
++)
119 WideString
[2 * i
+ 0] = AnsiSource
->Buffer
[i
];
120 WideString
[2 * i
+ 1] = 0;
122 return STATUS_SUCCESS
;
126 RtlUpcaseUnicodeChar(
135 return (Source
- ('a' - 'A'));
139 return Source
+ (SHORT
)Offset
;
144 OUT PLARGE_INTEGER CurrentTime
)
146 DPRINT1("KeQuerySystemTime() unimplemented\n");
151 IN POOL_TYPE PoolType
,
152 IN SIZE_T NumberOfBytes
)
154 return (PVOID
) malloc(NumberOfBytes
);