ReactOS 0.4.15-dev-7924-g5949c20
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 */
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
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 {
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
82{
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
98 OUT PLARGE_INTEGER CurrentTime)
99{
100 CurrentTime->QuadPart = 0;
101}
102
107{
108 return (PVOID) malloc(NumberOfBytes);
109}
110
113 IN PVOID p)
114{
115 free(p);
116}
117
118ULONG
121 IN CHAR *Format,
122 IN ...)
123{
124 va_list ap;
126 vprintf(Format, ap);
127 va_end(ap);
128
129 return 0;
130}
131
132VOID
133NTAPI
134RtlAssert(IN PVOID FailedAssertion,
138{
139 if (Message != NULL)
140 {
141 DbgPrint("Assertion \'%s\' failed at %s line %u: %s\n",
142 (PCHAR)FailedAssertion,
145 Message);
146 }
147 else
148 {
149 DbgPrint("Assertion \'%s\' failed at %s line %u\n",
150 (PCHAR)FailedAssertion,
152 LineNumber);
153 }
154
155 //DbgBreakPoint();
156}
157
158// FIXME: DECLSPEC_NORETURN
159VOID
160NTAPI
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
177unsigned 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
188unsigned 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}
unsigned char BOOLEAN
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
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:1220
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static const WCHAR Message[]
Definition: register.c:74
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
unsigned int Mask
Definition: fpcontrol.c:82
#define printf
Definition: freeldr.h:93
GLfloat GLfloat p
Definition: glext.h:8902
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
#define DbgPrint
Definition: hal.h:12
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define BitScanReverse
Definition: interlocked.h:6
#define BitScanForward
Definition: interlocked.h:5
#define ASSERT(a)
Definition: mode.c:44
static USHORT
Definition: rtl.c:96
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ const STRING * String2
Definition: rtlfuncs.h:2357
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1910
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2390
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1909
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define strlenW(s)
Definition: unicode.h:28
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
WCHAR NTAPI RtlUpcaseUnicodeChar(IN WCHAR Source)
Definition: rtl.c:80
LONG NTAPI RtlCompareUnicodeString(IN PCUNICODE_STRING String1, IN PCUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
Definition: rtl.c:49
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: rtl.c:134
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
const uint16_t * PCWSTR
Definition: typedefs.h:57
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175