1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS hive maker
3 * FILE: tools/mkhive/rtl.c
4 * PURPOSE: Runtime Library
13 SIZE_T
xwcslen( PCWSTR String
) {
16 for( i
= 0; String
[i
]; i
++ );
21 PWSTR
xwcschr( PWSTR String
, WCHAR Char
)
25 for( i
= 0; String
[i
] && String
[i
] != Char
; i
++ );
27 if( String
[i
] ) return &String
[i
];
31 int xwcsncmp(PCWSTR s1
, PCWSTR s2
, size_t n
)
52 * If source is NULL the length of source is assumed to be 0.
56 IN OUT PANSI_STRING DestinationString
,
57 IN PCSTR SourceString
)
63 DestSize
= strlen(SourceString
);
64 DestinationString
->Length
= (USHORT
)DestSize
;
65 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(CHAR
);
69 DestinationString
->Length
= 0;
70 DestinationString
->MaximumLength
= 0;
73 DestinationString
->Buffer
= (PCHAR
)SourceString
;
80 * If source is NULL the length of source is assumed to be 0.
84 IN OUT PUNICODE_STRING DestinationString
,
85 IN PCWSTR SourceString
)
91 DestSize
= xwcslen(SourceString
) * sizeof(WCHAR
);
92 DestinationString
->Length
= (USHORT
)DestSize
;
93 DestinationString
->MaximumLength
= (USHORT
)DestSize
+ sizeof(WCHAR
);
97 DestinationString
->Length
= 0;
98 DestinationString
->MaximumLength
= 0;
101 DestinationString
->Buffer
= (PWCHAR
)SourceString
;
105 RtlAnsiStringToUnicodeString(
106 IN OUT PUNICODE_STRING UniDest
,
107 IN PANSI_STRING AnsiSource
,
108 IN BOOLEAN AllocateDestinationString
)
114 Length
= AnsiSource
->Length
* sizeof(WCHAR
);
115 if (Length
> MAXUSHORT
) return STATUS_INVALID_PARAMETER_2
;
116 UniDest
->Length
= (USHORT
)Length
;
118 if (AllocateDestinationString
)
120 UniDest
->MaximumLength
= (USHORT
)Length
+ sizeof(WCHAR
);
121 UniDest
->Buffer
= (PWSTR
) malloc(UniDest
->MaximumLength
);
122 if (!UniDest
->Buffer
)
123 return STATUS_NO_MEMORY
;
125 else if (UniDest
->Length
>= UniDest
->MaximumLength
)
127 return STATUS_BUFFER_OVERFLOW
;
130 WideString
= (PUCHAR
)UniDest
->Buffer
;
131 for (i
= 0; i
<= AnsiSource
->Length
; i
++)
133 WideString
[2 * i
+ 0] = AnsiSource
->Buffer
[i
];
134 WideString
[2 * i
+ 1] = 0;
136 return STATUS_SUCCESS
;
140 RtlUpcaseUnicodeChar(
149 return (Source
- ('a' - 'A'));
153 return Source
+ (SHORT
)Offset
;
158 OUT PLARGE_INTEGER CurrentTime
)
160 CurrentTime
->QuadPart
= 0;
165 IN POOL_TYPE PoolType
,
166 IN SIZE_T NumberOfBytes
)
168 return (PVOID
) malloc(NumberOfBytes
);
185 va_start(ap
, Format
);
194 RtlAssert(PVOID FailedAssertion
,
201 DbgPrint("Assertion \'%s\' failed at %s line %d: %s\n",
202 (PCHAR
)FailedAssertion
,
209 DbgPrint("Assertion \'%s\' failed at %s line %d\n",
210 (PCHAR
)FailedAssertion
,