Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrtl.c
Go to the documentation of this file.
00001 /* COPYRIGHT: See COPYING in the top level directory 00002 * PROJECT: ReactOS hive maker 00003 * FILE: tools/mkhive/rtl.c 00004 * PURPOSE: Runtime Library 00005 */ 00006 00007 #include <stdlib.h> 00008 #include <stdarg.h> 00009 00010 /* gcc defaults to cdecl */ 00011 #if defined(__GNUC__) 00012 #undef __cdecl 00013 #define __cdecl 00014 #endif 00015 00016 #include "mkhive.h" 00017 #include <bitmap.c> 00018 00019 /* 00020 * @implemented 00021 * 00022 * NOTES 00023 * If source is NULL the length of source is assumed to be 0. 00024 */ 00025 VOID NTAPI 00026 RtlInitAnsiString( 00027 IN OUT PANSI_STRING DestinationString, 00028 IN PCSTR SourceString) 00029 { 00030 SIZE_T DestSize; 00031 00032 if(SourceString) 00033 { 00034 DestSize = strlen(SourceString); 00035 DestinationString->Length = (USHORT)DestSize; 00036 DestinationString->MaximumLength = (USHORT)DestSize + sizeof(CHAR); 00037 } 00038 else 00039 { 00040 DestinationString->Length = 0; 00041 DestinationString->MaximumLength = 0; 00042 } 00043 00044 DestinationString->Buffer = (PCHAR)SourceString; 00045 } 00046 00047 /* 00048 * @implemented 00049 * 00050 * NOTES 00051 * If source is NULL the length of source is assumed to be 0. 00052 */ 00053 VOID NTAPI 00054 RtlInitUnicodeString( 00055 IN OUT PUNICODE_STRING DestinationString, 00056 IN PCWSTR SourceString) 00057 { 00058 SIZE_T DestSize; 00059 00060 if(SourceString) 00061 { 00062 DestSize = strlenW(SourceString) * sizeof(WCHAR); 00063 DestinationString->Length = (USHORT)DestSize; 00064 DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR); 00065 } 00066 else 00067 { 00068 DestinationString->Length = 0; 00069 DestinationString->MaximumLength = 0; 00070 } 00071 00072 DestinationString->Buffer = (PWCHAR)SourceString; 00073 } 00074 00075 NTSTATUS NTAPI 00076 RtlAnsiStringToUnicodeString( 00077 IN OUT PUNICODE_STRING UniDest, 00078 IN PANSI_STRING AnsiSource, 00079 IN BOOLEAN AllocateDestinationString) 00080 { 00081 ULONG Length; 00082 PUCHAR WideString; 00083 USHORT i; 00084 00085 Length = AnsiSource->Length * sizeof(WCHAR); 00086 if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2; 00087 UniDest->Length = (USHORT)Length; 00088 00089 if (AllocateDestinationString) 00090 { 00091 UniDest->MaximumLength = (USHORT)Length + sizeof(WCHAR); 00092 UniDest->Buffer = (PWSTR) malloc(UniDest->MaximumLength); 00093 if (!UniDest->Buffer) 00094 return STATUS_NO_MEMORY; 00095 } 00096 else if (UniDest->Length >= UniDest->MaximumLength) 00097 { 00098 return STATUS_BUFFER_OVERFLOW; 00099 } 00100 00101 WideString = (PUCHAR)UniDest->Buffer; 00102 for (i = 0; i <= AnsiSource->Length; i++) 00103 { 00104 WideString[2 * i + 0] = AnsiSource->Buffer[i]; 00105 WideString[2 * i + 1] = 0; 00106 } 00107 return STATUS_SUCCESS; 00108 } 00109 00110 WCHAR NTAPI 00111 RtlUpcaseUnicodeChar( 00112 IN WCHAR Source) 00113 { 00114 USHORT Offset; 00115 00116 if (Source < 'a') 00117 return Source; 00118 00119 if (Source <= 'z') 00120 return (Source - ('a' - 'A')); 00121 00122 Offset = 0; 00123 00124 return Source + (SHORT)Offset; 00125 } 00126 00127 VOID NTAPI 00128 KeQuerySystemTime( 00129 OUT PLARGE_INTEGER CurrentTime) 00130 { 00131 CurrentTime->QuadPart = 0; 00132 } 00133 00134 PVOID NTAPI 00135 ExAllocatePool( 00136 IN POOL_TYPE PoolType, 00137 IN SIZE_T NumberOfBytes) 00138 { 00139 return (PVOID) malloc(NumberOfBytes); 00140 } 00141 00142 VOID NTAPI 00143 ExFreePool( 00144 IN PVOID p) 00145 { 00146 free(p); 00147 } 00148 00149 ULONG 00150 __cdecl 00151 DbgPrint( 00152 IN CHAR *Format, 00153 IN ...) 00154 { 00155 va_list ap; 00156 va_start(ap, Format); 00157 vprintf(Format, ap); 00158 va_end(ap); 00159 00160 return 0; 00161 } 00162 00163 VOID 00164 NTAPI 00165 RtlAssert(PVOID FailedAssertion, 00166 PVOID FileName, 00167 ULONG LineNumber, 00168 PCHAR Message) 00169 { 00170 if (NULL != Message) 00171 { 00172 DbgPrint("Assertion \'%s\' failed at %s line %d: %s\n", 00173 (PCHAR)FailedAssertion, 00174 (PCHAR)FileName, 00175 LineNumber, 00176 Message); 00177 } 00178 else 00179 { 00180 DbgPrint("Assertion \'%s\' failed at %s line %d\n", 00181 (PCHAR)FailedAssertion, 00182 (PCHAR)FileName, 00183 LineNumber); 00184 } 00185 00186 //DbgBreakPoint(); 00187 } 00188 00189 unsigned char BitScanForward(ULONG * Index, unsigned long Mask) 00190 { 00191 *Index = 0; 00192 while (Mask && ((Mask & 1) == 0)) 00193 { 00194 Mask >>= 1; 00195 ++(*Index); 00196 } 00197 return Mask ? 1 : 0; 00198 } 00199 00200 unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask) 00201 { 00202 *Index = 0; 00203 while (Mask && ((Mask & (1 << 31)) == 0)) 00204 { 00205 Mask <<= 1; 00206 ++(*Index); 00207 } 00208 return Mask ? 1 : 0; 00209 } Generated on Sun May 27 2012 04:37:46 for ReactOS by
1.7.6.1
|