1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS hive maker
3 * FILE: tools/mkhive/rtl.c
4 * PURPOSE: Runtime Library
10 #define WIN32_NO_STATUS
14 SIZE_T
xwcslen( PWSTR String
) {
17 for( i
= 0; String
[i
]; i
++ );
22 PWSTR
xwcschr( PWSTR String
, WCHAR Char
)
26 for( i
= 0; String
[i
] && String
[i
] != Char
; i
++ );
28 if( String
[i
] ) return &String
[i
];
36 * If source is NULL the length of source is assumed to be 0.
40 IN OUT PANSI_STRING DestinationString
,
41 IN PCSTR SourceString
)
47 DestSize
= strlen(SourceString
);
48 DestinationString
->Length
= (USHORT
)DestSize
;
49 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(CHAR
);
53 DestinationString
->Length
= 0;
54 DestinationString
->MaximumLength
= 0;
57 DestinationString
->Buffer
= (PCHAR
)SourceString
;
64 * If source is NULL the length of source is assumed to be 0.
68 IN OUT PUNICODE_STRING DestinationString
,
69 IN PCWSTR SourceString
)
75 DestSize
= xwcslen(SourceString
) * sizeof(WCHAR
);
76 DestinationString
->Length
= (USHORT
)DestSize
;
77 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(WCHAR
);
81 DestinationString
->Length
= 0;
82 DestinationString
->MaximumLength
= 0;
85 DestinationString
->Buffer
= (PWCHAR
)SourceString
;
89 RtlAnsiStringToUnicodeString(
90 IN OUT PUNICODE_STRING UniDest
,
91 IN PANSI_STRING AnsiSource
,
92 IN BOOLEAN AllocateDestinationString
)
98 Length
= AnsiSource
->Length
* sizeof(WCHAR
);
99 if (Length
> MAXUSHORT
) return STATUS_INVALID_PARAMETER_2
;
100 UniDest
->Length
= (USHORT
)Length
;
102 if (AllocateDestinationString
)
104 UniDest
->MaximumLength
= (USHORT
)Length
+ sizeof(WCHAR
);
105 UniDest
->Buffer
= (PWSTR
) malloc(UniDest
->MaximumLength
);
106 if (!UniDest
->Buffer
)
107 return STATUS_NO_MEMORY
;
109 else if (UniDest
->Length
>= UniDest
->MaximumLength
)
111 return STATUS_BUFFER_OVERFLOW
;
114 WideString
= (PUCHAR
)UniDest
->Buffer
;
115 for (i
= 0; i
<= AnsiSource
->Length
; i
++)
117 WideString
[2 * i
+ 0] = AnsiSource
->Buffer
[i
];
118 WideString
[2 * i
+ 1] = 0;
120 return STATUS_SUCCESS
;
124 RtlUpcaseUnicodeChar(
133 return (Source
- ('a' - 'A'));
137 return Source
+ (SHORT
)Offset
;
142 OUT PLARGE_INTEGER CurrentTime
)
144 DPRINT1("KeQuerySystemTime() unimplemented\n");
149 IN POOL_TYPE PoolType
,
150 IN SIZE_T NumberOfBytes
)
152 return (PVOID
) malloc(NumberOfBytes
);