ReactOS  0.4.14-dev-556-g4c5b21f
rtl.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS hive maker
4  * FILE: tools/mkhive/rtl.c
5  * PURPOSE: Runtime Library
6  */
7 
8 #include <stdlib.h>
9 #include <stdarg.h>
10 
11 /* gcc defaults to cdecl */
12 #if defined(__GNUC__)
13 #undef __cdecl
14 #define __cdecl
15 #endif
16 
17 #include "mkhive.h"
18 #include <bitmap.c>
19 
20 /*
21  * @implemented
22  *
23  * NOTES
24  * If source is NULL the length of source is assumed to be 0.
25  */
26 VOID NTAPI
30 {
31  SIZE_T DestSize;
32 
33  if(SourceString)
34  {
35  DestSize = strlenW(SourceString) * sizeof(WCHAR);
36  DestinationString->Length = (USHORT)DestSize;
37  DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
38  }
39  else
40  {
43  }
44 
46 }
47 
48 LONG NTAPI
50  IN PCUNICODE_STRING String1,
53 {
54  USHORT i;
55  WCHAR c1, c2;
56 
57  for (i = 0; i <= String1->Length / sizeof(WCHAR) && i <= String2->Length / sizeof(WCHAR); i++)
58  {
59  if (CaseInSensitive)
60  {
61  c1 = RtlUpcaseUnicodeChar(String1->Buffer[i]);
62  c2 = RtlUpcaseUnicodeChar(String2->Buffer[i]);
63  }
64  else
65  {
66  c1 = String1->Buffer[i];
67  c2 = String2->Buffer[i];
68  }
69 
70  if (c1 < c2)
71  return -1;
72  else if (c1 > c2)
73  return 1;
74  }
75 
76  return 0;
77 }
78 
81  IN WCHAR Source)
82 {
83  USHORT Offset;
84 
85  if (Source < 'a')
86  return Source;
87 
88  if (Source <= 'z')
89  return (Source - ('a' - 'A'));
90 
91  Offset = 0;
92 
93  return Source + (SHORT)Offset;
94 }
95 
96 VOID NTAPI
98  OUT PLARGE_INTEGER CurrentTime)
99 {
100  CurrentTime->QuadPart = 0;
101 }
102 
103 PVOID NTAPI
107 {
108  return (PVOID) malloc(NumberOfBytes);
109 }
110 
111 VOID NTAPI
113  IN PVOID p)
114 {
115  free(p);
116 }
117 
118 ULONG
119 __cdecl
121  IN CHAR *Format,
122  IN ...)
123 {
124  va_list ap;
125  va_start(ap, Format);
126  vprintf(Format, ap);
127  va_end(ap);
128 
129  return 0;
130 }
131 
132 VOID
133 NTAPI
134 RtlAssert(IN PVOID FailedAssertion,
135  IN PVOID FileName,
138 {
139  if (Message != NULL)
140  {
141  DbgPrint("Assertion \'%s\' failed at %s line %u: %s\n",
142  (PCHAR)FailedAssertion,
143  (PCHAR)FileName,
144  LineNumber,
145  Message);
146  }
147  else
148  {
149  DbgPrint("Assertion \'%s\' failed at %s line %u\n",
150  (PCHAR)FailedAssertion,
151  (PCHAR)FileName,
152  LineNumber);
153  }
154 
155  //DbgBreakPoint();
156 }
157 
158 // DECLSPEC_NORETURN
159 VOID
160 NTAPI
162  IN ULONG BugCheckCode,
163  IN ULONG_PTR BugCheckParameter1,
164  IN ULONG_PTR BugCheckParameter2,
165  IN ULONG_PTR BugCheckParameter3,
166  IN ULONG_PTR BugCheckParameter4)
167 {
168  printf("*** STOP: 0x%08X (0x%p,0x%p,0x%p,0x%p)",
169  BugCheckCode,
170  (PVOID)BugCheckParameter1,
171  (PVOID)BugCheckParameter2,
172  (PVOID)BugCheckParameter3,
173  (PVOID)BugCheckParameter4);
174  ASSERT(FALSE);
175 }
176 
177 unsigned char BitScanForward(ULONG * Index, unsigned long Mask)
178 {
179  *Index = 0;
180  while (Mask && ((Mask & 1) == 0))
181  {
182  Mask >>= 1;
183  ++(*Index);
184  }
185  return Mask ? 1 : 0;
186 }
187 
188 unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask)
189 {
190  *Index = 0;
191  while (Mask && ((Mask & (1 << 31)) == 0))
192  {
193  Mask <<= 1;
194  ++(*Index);
195  }
196  return Mask ? 1 : 0;
197 }
signed char * PCHAR
Definition: retypes.h:7
static USHORT
Definition: rtl.c:96
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
unsigned char BitScanForward(ULONG *Index, unsigned long Mask)
Definition: rtl.c:177
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define __cdecl
Definition: accygwin.h:79
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
unsigned short Length
Definition: sprintf.c:451
uint16_t * PWCHAR
Definition: typedefs.h:54
ULONG __cdecl DbgPrint(IN CHAR *Format, IN ...)
Definition: rtl.c:120
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void * Buffer
Definition: sprintf.c:453
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define va_end(ap)
Definition: acmsvcex.h:90
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
WCHAR NTAPI RtlUpcaseUnicodeChar(IN WCHAR Source)
Definition: rtl.c:80
short SHORT
Definition: pedump.c:59
unsigned char BOOLEAN
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: rtl.c:161
char * va_list
Definition: acmsvcex.h:78
PVOID NTAPI ExAllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: rtl.c:104
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: rtl.c:134
unsigned char BitScanReverse(ULONG *const Index, unsigned long Mask)
Definition: rtl.c:188
VOID NTAPI RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString)
Definition: rtl.c:27
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT POOL_TYPE
Definition: typedefs.h:76
VOID NTAPI KeQuerySystemTime(OUT PLARGE_INTEGER CurrentTime)
Definition: rtl.c:97
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CHAR Message[80]
Definition: alive.c:5
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
LONG NTAPI RtlCompareUnicodeString(IN PCUNICODE_STRING String1, IN PCUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
Definition: rtl.c:49
ULONG_PTR SIZE_T
Definition: typedefs.h:78
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1212
unsigned short USHORT
Definition: pedump.c:61
#define va_start(ap, A)
Definition: acmsvcex.h:91
_In_ const STRING * String2
Definition: rtlfuncs.h:2261
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define OUT
Definition: typedefs.h:39
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:998
unsigned int ULONG
Definition: retypes.h:1
#define malloc
Definition: debug_ros.c:4
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
GLfloat GLfloat p
Definition: glext.h:8902
unsigned short MaximumLength
Definition: sprintf.c:452
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
VOID NTAPI ExFreePool(IN PVOID p)
Definition: rtl.c:112
#define printf
Definition: config.h:203
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68