* PURPOSE: Runtime Library
*/
-#define RTL_H
+#include <stdlib.h>
+#include <stdarg.h>
-#define NTOS_MODE_USER
-#define WIN32_NO_STATUS
-#include <ntddk.h>
+/* gcc defaults to cdecl */
+#if defined(__GNUC__)
+#undef __cdecl
+#define __cdecl
+#endif
+
+#include "mkhive.h"
#include <bitmap.c>
/*
if(SourceString)
{
- DestSize = wcslen(SourceString) * sizeof(WCHAR);
+ DestSize = utf16_wcslen(SourceString) * sizeof(WCHAR);
DestinationString->Length = (USHORT)DestSize;
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
}
if (AllocateDestinationString)
{
UniDest->MaximumLength = (USHORT)Length + sizeof(WCHAR);
- UniDest->Buffer = malloc(UniDest->MaximumLength);
+ UniDest->Buffer = (PWSTR) malloc(UniDest->MaximumLength);
if (!UniDest->Buffer)
return STATUS_NO_MEMORY;
}
KeQuerySystemTime(
OUT PLARGE_INTEGER CurrentTime)
{
- DPRINT1("KeQuerySystemTime() unimplemented\n");
+ CurrentTime->QuadPart = 0;
}
PVOID NTAPI
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes)
{
- return malloc(NumberOfBytes);
+ return (PVOID) malloc(NumberOfBytes);
}
VOID NTAPI
free(p);
}
+ULONG
+__cdecl
+DbgPrint(
+ IN CHAR *Format,
+ IN ...)
+{
+ va_list ap;
+ va_start(ap, Format);
+ vprintf(Format, ap);
+ va_end(ap);
+
+ return 0;
+}
+
+VOID
+NTAPI
+RtlAssert(PVOID FailedAssertion,
+ PVOID FileName,
+ ULONG LineNumber,
+ PCHAR Message)
+{
+ if (NULL != Message)
+ {
+ DbgPrint("Assertion \'%s\' failed at %s line %d: %s\n",
+ (PCHAR)FailedAssertion,
+ (PCHAR)FileName,
+ LineNumber,
+ Message);
+ }
+ else
+ {
+ DbgPrint("Assertion \'%s\' failed at %s line %d\n",
+ (PCHAR)FailedAssertion,
+ (PCHAR)FileName,
+ LineNumber);
+ }
+
+ //DbgBreakPoint();
+}
+
+unsigned char BitScanForward(ULONG * Index, unsigned long Mask)
+{
+ *Index = 0;
+ while (Mask && ((Mask & 1) == 0))
+ {
+ Mask >>= 1;
+ ++(*Index);
+ }
+ return Mask ? 1 : 0;
+}
+
+unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask)
+{
+ *Index = 0;
+ while (Mask && ((Mask & (1 << 31)) == 0))
+ {
+ Mask <<= 1;
+ ++(*Index);
+ }
+ return Mask ? 1 : 0;
+}
+
+#undef tolower
+WCHAR towlower(WCHAR ch)
+{
+ if (ch < L'A')
+ {
+ return ch;
+ }
+ else if (ch <= L'Z')
+ {
+ return ch + (L'a' - L'A');
+ }
+
+ return ch;
+}
+
+int _wcsicmp(PCWSTR cs, PCWSTR ct)
+{
+ while (towlower(*cs) == towlower(*ct))
+ {
+ if (*cs == 0)
+ return 0;
+
+ cs++;
+ ct++;
+ }
+
+ return towlower(*cs) - towlower(*ct);
+}