From f26f546a70ce686f2e8d3a26b535a1f1b80c734e Mon Sep 17 00:00:00 2001 From: lace <> Date: Thu, 31 Oct 2002 14:41:55 +0000 Subject: [PATCH] bootstrap --- .vimrc | 2 ++ drivers/bus/acpi/include/platform/types.h | 4 +++- include/ddk/cmtypes.h | 14 ++++++++++++++ include/ddk/ntddk.h | 6 ++++++ include/ddk/rtl.h | 7 ++++++- include/ntos/types.h | 7 ++++++- ntoskrnl/include/internal/kd.h | 2 +- ntoskrnl/include/internal/ke.h | 2 +- ntoskrnl/io/device.c | 5 +++++ ntoskrnl/io/iomgr.c | 31 +++++++++++++++++++++++++++++-- ntoskrnl/io/shutdown.c | 4 ++++ ntoskrnl/io/vpb.c | 3 +++ ntoskrnl/ke/kqueue.c | 8 ++++++++ ntoskrnl/ldr/loader.c | 29 ++++++++++++++++++++++++----- ntoskrnl/ldr/rtl.c | 3 +++ ntoskrnl/ob/handle.c | 8 +++++++- ntoskrnl/ob/namespc.c | 11 +++++++---- ntoskrnl/ob/object.c | 7 +++++++ ntoskrnl/ps/create.c | 13 +++++++++++++ ntoskrnl/ps/process.c | 30 +++++++++++++++++++++++++++++- ntoskrnl/ps/thread.c | 28 ++++++++++++++++++++++++++-- ntoskrnl/rtl/mem.c | 10 ++++++++-- ntoskrnl/rtl/nls.c | 6 ++++++ ntoskrnl/rtl/sprintf.c | 2 +- ntoskrnl/rtl/unicode.c | 4 ++-- ntoskrnl/rtl/wstring.c | 12 ++++++++++++ 26 files changed, 233 insertions(+), 25 deletions(-) create mode 100644 .vimrc diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..6751a10 --- /dev/null +++ b/.vimrc @@ -0,0 +1,2 @@ +set ts=8 +set sw=2 diff --git a/drivers/bus/acpi/include/platform/types.h b/drivers/bus/acpi/include/platform/types.h index 6326448..ef4b439 100644 --- a/drivers/bus/acpi/include/platform/types.h +++ b/drivers/bus/acpi/include/platform/types.h @@ -86,6 +86,7 @@ typedef unsigned long long DWORD64, *PDWORD64; typedef unsigned char UCHAR; #endif typedef unsigned short USHORT; +/* Yes, W32 uses 16-bit wchar_t requiring GCC -fshort-wchar option */ typedef unsigned short WCHAR; typedef unsigned short WORD; typedef int BOOL; @@ -137,7 +138,7 @@ typedef CCHAR *PCCHAR; typedef const unsigned short *PCWSTR; -typedef char* PCSZ; +typedef const char* PCSZ; typedef union _LARGE_INTEGER { @@ -455,6 +456,7 @@ typedef unsigned char UCHAR; typedef unsigned int UINT; typedef unsigned long ULONG; typedef unsigned short USHORT; +/* Yes, W32 uses 16-bit wchar_t requiring GCC -fshort-wchar option */ typedef unsigned short WCHAR; typedef unsigned short WORD; typedef int BOOL; diff --git a/include/ddk/cmtypes.h b/include/ddk/cmtypes.h index a9af321..fc87506 100644 --- a/include/ddk/cmtypes.h +++ b/include/ddk/cmtypes.h @@ -1,3 +1,11 @@ +#ifndef __DDK_CMTYPES_H +#define __DDK_CMTYPES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + /* * Object Manager structures and typedefs @@ -98,3 +106,9 @@ typedef struct _KEY_VALUE_ENTRY ULONG Type; } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; + +#ifdef __cplusplus +}; +#endif + +#endif /* __DDK_CMTYPES_H */ diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h index fd8d199..8dcac67 100644 --- a/include/ddk/ntddk.h +++ b/include/ddk/ntddk.h @@ -19,10 +19,16 @@ extern "C" /* INCLUDES ***************************************************************/ +#ifndef FASTCALL #define FASTCALL __attribute__((fastcall)) +#endif #define STATIC static +#ifndef REACTOS_UCS2 +#define REACTOS_UCS2(string_ucs2) (string_ucs2) +#endif + #ifndef _GNU_H_WINDOWS_H /* NASTY HACK! Our msvcrt are messed up, causing msvcrt.dll to crash when * the headers are mixed with MinGW msvcrt headers. Not including stdlib.h diff --git a/include/ddk/rtl.h b/include/ddk/rtl.h index 178977d..d600c76 100644 --- a/include/ddk/rtl.h +++ b/include/ddk/rtl.h @@ -1097,12 +1097,17 @@ RtlInitUnicodeStringFromLiteral ( */ +/* Prevent hide of the inappropriate passed type by our + * de"const" of the string in the macro below. + */ +static inline const WCHAR *_RtlInitUnicodeStringFromLiteral_typecheck(const WCHAR *s) { return s; } + #define RtlInitUnicodeStringFromLiteral(__PDEST_STRING__,__SOURCE_STRING__) \ InitializeUnicodeString( \ (__PDEST_STRING__), \ sizeof(__SOURCE_STRING__) - sizeof(WCHAR), \ sizeof(__SOURCE_STRING__), \ - (__SOURCE_STRING__) \ + (WCHAR * /* de"const" the string here */ )_RtlInitUnicodeStringFromLiteral_typecheck((__SOURCE_STRING__)) \ ) /* diff --git a/include/ntos/types.h b/include/ntos/types.h index ebdf60f..1375aea 100644 --- a/include/ntos/types.h +++ b/include/ntos/types.h @@ -80,6 +80,7 @@ typedef unsigned long long DWORD64, *PDWORD64; typedef unsigned char UCHAR; typedef unsigned short USHORT; +/* Yes, W32 uses 16-bit wchar_t requiring GCC -fshort-wchar option */ typedef unsigned short WCHAR; typedef unsigned short WORD; typedef int BOOL; @@ -115,8 +116,12 @@ typedef char CCHAR; typedef CCHAR *PCCHAR; +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE 1 +#endif #ifndef NULL #ifdef __cplusplus @@ -128,7 +133,7 @@ typedef CCHAR *PCCHAR; typedef const unsigned short *PCWSTR; -typedef char* PCSZ; +typedef const char* PCSZ; typedef union _LARGE_INTEGER { diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/include/internal/kd.h index 06d525d..e08f3f1 100644 --- a/ntoskrnl/include/internal/kd.h +++ b/ntoskrnl/include/internal/kd.h @@ -54,7 +54,7 @@ UCHAR KdGetChar(VOID); VOID -KdGdbStubInit(); +KdGdbStubInit(VOID); VOID KdGdbDebugPrint (LPSTR Message); diff --git a/ntoskrnl/include/internal/ke.h b/ntoskrnl/include/internal/ke.h index 102b9c5..9fb0d10 100644 --- a/ntoskrnl/include/internal/ke.h +++ b/ntoskrnl/include/internal/ke.h @@ -86,7 +86,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, VOID KeTrapFrameToContext(PKTRAP_FRAME TrapFrame, PCONTEXT Context); VOID -KeApplicationProcessorInit(); +KeApplicationProcessorInit(VOID); VOID KePrepareForApplicationProcessorInit(ULONG id); ULONG diff --git a/ntoskrnl/io/device.c b/ntoskrnl/io/device.c index a2ebf77..36b4a09 100644 --- a/ntoskrnl/io/device.c +++ b/ntoskrnl/io/device.c @@ -35,6 +35,8 @@ /* FUNCTIONS ***************************************************************/ +#ifndef LIBCAPTIVE + NTSTATUS STDCALL IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice) @@ -580,6 +582,7 @@ IopCreateDevice(PVOID ObjectBody, return(STATUS_SUCCESS); } +#endif /* LIBCAPTIVE */ NTSTATUS STDCALL IoCreateDevice(PDRIVER_OBJECT DriverObject, @@ -706,6 +709,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE NTSTATUS STDCALL @@ -733,5 +737,6 @@ IoQueryDeviceEnumInfo ( return 0; } +#endif /* LIBCAPTIVE */ /* EOF */ diff --git a/ntoskrnl/io/iomgr.c b/ntoskrnl/io/iomgr.c index 4c5a358..be4bf54 100644 --- a/ntoskrnl/io/iomgr.c +++ b/ntoskrnl/io/iomgr.c @@ -30,11 +30,13 @@ POBJECT_TYPE EXPORTED IoDeviceObjectType = NULL; POBJECT_TYPE EXPORTED IoFileObjectType = NULL; +#ifndef LIBCAPTIVE ULONG EXPORTED IoReadOperationCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoReadTransferCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoWriteOperationCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoWriteTransferCount = 0; /* FIXME: unknown type */ ULONG EXPORTED IoStatisticsLock = 0; /* FIXME: unknown type */ +#endif /* LIBCAPTIVE */ static GENERIC_MAPPING IopFileMapping = {FILE_GENERIC_READ, FILE_GENERIC_WRITE, @@ -43,6 +45,8 @@ static GENERIC_MAPPING IopFileMapping = {FILE_GENERIC_READ, /* FUNCTIONS ****************************************************************/ +#ifndef LIBCAPTIVE + VOID STDCALL IopCloseFile(PVOID ObjectBody, ULONG HandleCount) @@ -111,15 +115,18 @@ IopDeleteFile(PVOID ObjectBody) } } +#endif /* LIBCAPTIVE */ VOID IoInit (VOID) { +#ifndef LIBCAPTIVE OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING DirName; UNICODE_STRING LinkName; HANDLE Handle; IopInitDriverImplementation(); +#endif /* LIBCAPTIVE */ /* * Register iomgr types: DeviceObjectType @@ -143,10 +150,14 @@ VOID IoInit (VOID) IoDeviceObjectType->Security = NULL; IoDeviceObjectType->QueryName = NULL; IoDeviceObjectType->OkayToClose = NULL; +#ifndef LIBCAPTIVE IoDeviceObjectType->Create = IopCreateDevice; +#else /* !LIBCAPTIVE */ + IoDeviceObjectType->Create = NULL; +#endif /* !LIBCAPTIVE */ IoDeviceObjectType->DuplicationNotify = NULL; - RtlInitUnicodeStringFromLiteral(&IoDeviceObjectType->TypeName, L"Device"); + RtlInitUnicodeStringFromLiteral(&IoDeviceObjectType->TypeName, REACTOS_UCS2(L"Device")); /* * Register iomgr types: FileObjectType @@ -164,17 +175,27 @@ VOID IoInit (VOID) IoFileObjectType->Mapping = &IopFileMapping; IoFileObjectType->Dump = NULL; IoFileObjectType->Open = NULL; +#ifndef LIBCAPTIVE IoFileObjectType->Close = IopCloseFile; IoFileObjectType->Delete = IopDeleteFile; +#else /* !LIBCAPTIVE */ + IoFileObjectType->Close = NULL; + IoFileObjectType->Delete = NULL; +#endif /* !LIBCAPTIVE */ IoFileObjectType->Parse = NULL; IoFileObjectType->Security = NULL; IoFileObjectType->QueryName = NULL; IoFileObjectType->OkayToClose = NULL; +#ifndef LIBCAPTIVE IoFileObjectType->Create = IopCreateFile; +#else /* !LIBCAPTIVE */ + IoFileObjectType->Create = NULL; +#endif /* !LIBCAPTIVE */ IoFileObjectType->DuplicationNotify = NULL; - RtlInitUnicodeStringFromLiteral(&IoFileObjectType->TypeName, L"File"); + RtlInitUnicodeStringFromLiteral(&IoFileObjectType->TypeName, REACTOS_UCS2(L"File")); +#ifndef LIBCAPTIVE /* * Create the '\Driver' object directory */ @@ -250,12 +271,14 @@ VOID IoInit (VOID) IoInitCancelHandling(); IoInitSymbolicLinkImplementation(); IoInitFileSystemImplementation(); +#endif /* LIBCAPTIVE */ IoInitVpbImplementation(); IoInitShutdownNotification(); /* * Create link from '\DosDevices' to '\??' directory */ +#ifndef LIBCAPTIVE RtlInitUnicodeStringFromLiteral(&LinkName, L"\\DosDevices"); RtlInitUnicodeStringFromLiteral(&DirName, @@ -267,8 +290,10 @@ VOID IoInit (VOID) * Initialize PnP manager */ PnpInit(); +#endif /* LIBCAPTIVE */ } +#ifndef LIBCAPTIVE PGENERIC_MAPPING STDCALL IoGetFileObjectGenericMapping(VOID) @@ -276,4 +301,6 @@ IoGetFileObjectGenericMapping(VOID) return(&IopFileMapping); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/io/shutdown.c b/ntoskrnl/io/shutdown.c index ef369b7..1023deb 100644 --- a/ntoskrnl/io/shutdown.c +++ b/ntoskrnl/io/shutdown.c @@ -38,6 +38,8 @@ VOID IoInitShutdownNotification (VOID) KeInitializeSpinLock(&ShutdownListLock); } +#ifndef LIBCAPTIVE + VOID IoShutdownRegisteredDevices(VOID) { PSHUTDOWN_ENTRY ShutdownEntry; @@ -79,6 +81,8 @@ VOID IoShutdownRegisteredDevices(VOID) } } +#endif /* LIBCAPTIVE */ + NTSTATUS STDCALL IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject) { PSHUTDOWN_ENTRY Entry; diff --git a/ntoskrnl/io/vpb.c b/ntoskrnl/io/vpb.c index 72744a5..09b7ab8 100644 --- a/ntoskrnl/io/vpb.c +++ b/ntoskrnl/io/vpb.c @@ -64,6 +64,7 @@ IoAttachVpb(PDEVICE_OBJECT DeviceObject) return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE NTSTATUS STDCALL NtQueryVolumeInformationFile(IN HANDLE FileHandle, @@ -362,4 +363,6 @@ IoReleaseVpbSpinLock(IN KIRQL Irql) Irql); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ke/kqueue.c b/ntoskrnl/ke/kqueue.c index 6c8d685..859a01e 100644 --- a/ntoskrnl/ke/kqueue.c +++ b/ntoskrnl/ke/kqueue.c @@ -17,6 +17,8 @@ /* FUNCTIONS *****************************************************************/ +#ifndef LIBCAPTIVE + VOID InsertBeforeEntryInList(PLIST_ENTRY Head, PLIST_ENTRY After, PLIST_ENTRY Entry) { @@ -137,6 +139,8 @@ KeRemoveDeviceQueue ( return(entry); } +#endif /* LIBCAPTIVE */ + VOID STDCALL KeInitializeDeviceQueue ( @@ -154,6 +158,8 @@ KeInitializeDeviceQueue ( KeInitializeSpinLock(&DeviceQueue->Lock); } +#ifndef LIBCAPTIVE + BOOLEAN STDCALL KeInsertDeviceQueue ( @@ -196,3 +202,5 @@ KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue, UNIMPLEMENTED; return(FALSE); } + +#endif /* LIBCAPTIVE */ diff --git a/ntoskrnl/ldr/loader.c b/ntoskrnl/ldr/loader.c index eba5f27..cf2b120 100644 --- a/ntoskrnl/ldr/loader.c +++ b/ntoskrnl/ldr/loader.c @@ -52,8 +52,10 @@ LIST_ENTRY ModuleListHead; KSPIN_LOCK ModuleListLock; LIST_ENTRY ModuleTextListHead; +#ifndef LIBCAPTIVE STATIC MODULE_TEXT_SECTION NtoskrnlTextSection; STATIC MODULE_TEXT_SECTION LdrHalTextSection; +#endif /* LIBCAPTIVE */ ULONG_PTR LdrHalBase; #define TAG_DRIVER_MEM TAG('D', 'R', 'V', 'M') @@ -88,10 +90,12 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject, PCHAR Name, USHORT Hint); +#ifndef LIBCAPTIVE static PVOID LdrSafePEGetExportAddress(PVOID ImportModuleBase, PCHAR Name, USHORT Hint); +#endif /* LIBCAPTIVE */ static PVOID LdrPEFixupForward(PCHAR ForwardName); @@ -99,6 +103,8 @@ LdrPEFixupForward(PCHAR ForwardName); /* FUNCTIONS *****************************************************************/ +#ifndef LIBCAPTIVE + VOID LdrInitDebug(PLOADER_MODULE Module, PWCH Name) { @@ -418,6 +424,7 @@ LdrLoadModule(PUNICODE_STRING Filename, return(STATUS_SUCCESS); } +#endif /* LIBCAPTIVE */ NTSTATUS LdrUnloadModule(PMODULE_OBJECT ModuleObject) @@ -449,6 +456,7 @@ LdrUnloadModule(PMODULE_OBJECT ModuleObject) return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE NTSTATUS LdrInitializeBootStartDriver(PVOID ModuleLoadBase, @@ -546,6 +554,7 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase, return(Status); } +#endif /* LIBCAPTIVE */ NTSTATUS LdrProcessModule(PVOID ModuleLoadBase, @@ -583,6 +592,7 @@ LdrGetExportAddress(PMODULE_OBJECT ModuleObject, } } +#ifndef LIBCAPTIVE NTSTATUS LdrpQueryModuleInformation(PVOID Buffer, @@ -663,6 +673,7 @@ LdrpQueryModuleInformation(PVOID Buffer, return(STATUS_SUCCESS); } +#endif /* LIBCAPTIVE */ static VOID LdrpBuildModuleBaseName(PUNICODE_STRING BaseName, @@ -970,10 +981,10 @@ LdrPEProcessModule(PVOID ModuleLoadBase, { NumRelocs = (RelocDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) / sizeof(WORD); -/* DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n", + DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n", RelocDir, RelocDir->VirtualAddress, - NumRelocs);*/ + NumRelocs); RelocEntry = (PRELOCATION_ENTRY) ((DWORD)RelocDir + sizeof(RELOCATION_DIRECTORY)); for (Idx = 0; Idx < NumRelocs; Idx++) @@ -986,12 +997,12 @@ LdrPEProcessModule(PVOID ModuleLoadBase, Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf; RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress + Offset); -/* DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n", + DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n", RelocItem, Type, Type ? "HIGHLOW" : "ABS", *RelocItem, - (*RelocItem) + RelocDelta); */ + (*RelocItem) + RelocDelta); if (Type == 3) { (*RelocItem) += RelocDelta; @@ -1034,7 +1045,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, if (LibraryModuleObject == NULL) { CPRINT("Module '%wZ' not loaded yet\n", &ModuleName); - wcscpy(NameBuffer, L"\\SystemRoot\\system32\\drivers\\"); + wcscpy(NameBuffer, REACTOS_UCS2(L"\\SystemRoot\\system32\\drivers\\")); wcscat(NameBuffer, ModuleName.Buffer); RtlInitUnicodeString(&NameString, NameBuffer); Status = LdrLoadModule(&NameString, &LibraryModuleObject); @@ -1195,6 +1206,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, return STATUS_SUCCESS; } +#ifndef LIBCAPTIVE PVOID LdrSafePEProcessModule(PVOID ModuleLoadBase, @@ -1435,6 +1447,7 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase, return(0); } +#endif /* LIBCAPTIVE */ static PVOID LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject, @@ -1494,8 +1507,12 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject, } else /* use hint */ { +#ifndef LIBCAPTIVE ExportAddress = (PVOID) ((DWORD)ModuleObject->Base + FunctionList[Hint - ExportDir->Base]); +#else /* !LIBCAPTIVE */ + /* Ordinals not supported by libcaptive */ +#endif /* !LIBCAPTIVE */ } if (ExportAddress == NULL) @@ -1509,6 +1526,7 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject, return(ExportAddress); } +#ifndef LIBCAPTIVE static PVOID LdrSafePEGetExportAddress(PVOID ImportModuleBase, @@ -1570,6 +1588,7 @@ LdrSafePEGetExportAddress(PVOID ImportModuleBase, return ExportAddress; } +#endif /* LIBCAPTIVE */ static PVOID LdrPEFixupForward(PCHAR ForwardName) diff --git a/ntoskrnl/ldr/rtl.c b/ntoskrnl/ldr/rtl.c index 4427372..5112306 100644 --- a/ntoskrnl/ldr/rtl.c +++ b/ntoskrnl/ldr/rtl.c @@ -82,6 +82,7 @@ RtlImageDirectoryEntryToData (IN PVOID BaseAddress, return NULL; } +#ifndef LIBCAPTIVE PIMAGE_SECTION_HEADER STDCALL @@ -232,4 +233,6 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, return STATUS_PROCEDURE_NOT_FOUND; } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ob/handle.c b/ntoskrnl/ob/handle.c index 8d3b679..db493f8 100644 --- a/ntoskrnl/ob/handle.c +++ b/ntoskrnl/ob/handle.c @@ -105,6 +105,8 @@ static PHANDLE_REP ObpGetObjectByHandle(PHANDLE_TABLE HandleTable, HANDLE h) return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES])); } +#ifndef LIBCAPTIVE + NTSTATUS ObDuplicateObject(PEPROCESS SourceProcess, PEPROCESS TargetProcess, @@ -362,6 +364,7 @@ VOID ObDeleteHandleTable(PEPROCESS Process) } } +#endif /* LIBCAPTIVE */ VOID ObCreateHandleTable(PEPROCESS Parent, BOOLEAN Inherit, @@ -693,7 +696,6 @@ ObReferenceObjectByHandle(HANDLE Handle, return(STATUS_SUCCESS); } - /********************************************************************** * NAME EXPORTED * NtClose @@ -731,6 +733,8 @@ NTSTATUS STDCALL NtClose(HANDLE Handle) return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE + NTSTATUS STDCALL ObInsertObject(PVOID Object, PACCESS_STATE PassedAccessState, @@ -746,4 +750,6 @@ ObInsertObject(PVOID Object, Handle)); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ob/namespc.c b/ntoskrnl/ob/namespc.c index de66216..dfc6f58 100644 --- a/ntoskrnl/ob/namespc.c +++ b/ntoskrnl/ob/namespc.c @@ -41,6 +41,8 @@ static GENERIC_MAPPING ObpTypeMapping = { /* FUNCTIONS **************************************************************/ +#ifndef LIBCAPTIVE + NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath, ULONG Attributes, @@ -155,6 +157,7 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, return Status; } +#endif /* LIBCAPTIVE */ VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent, @@ -355,7 +358,7 @@ ObInit(VOID) ObDirectoryType->DuplicationNotify = NULL; RtlInitUnicodeStringFromLiteral(&ObDirectoryType->TypeName, - L"Directory"); + REACTOS_UCS2(L"Directory")); /* create 'type' object type*/ ObTypeObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); @@ -380,7 +383,7 @@ ObInit(VOID) ObTypeObjectType->DuplicationNotify = NULL; RtlInitUnicodeStringFromLiteral(&ObTypeObjectType->TypeName, - L"ObjectType"); + REACTOS_UCS2(L"ObjectType")); /* create root directory */ ObCreateObject(NULL, @@ -391,7 +394,7 @@ ObInit(VOID) /* create '\ObjectTypes' directory */ RtlInitUnicodeStringFromLiteral(&Name, - L"\\ObjectTypes"); + REACTOS_UCS2(L"\\ObjectTypes")); InitializeObjectAttributes(&ObjectAttributes, &Name, OBJ_PERMANENT, @@ -418,7 +421,7 @@ ObpCreateTypeObject(POBJECT_TYPE ObjectType) NTSTATUS Status; DPRINT("ObjectType: %wZ\n", &ObjectType->TypeName); - wcscpy(NameString, L"\\ObjectTypes\\"); + wcscpy(NameString, REACTOS_UCS2(L"\\ObjectTypes\\")); wcscat(NameString, ObjectType->TypeName.Buffer); RtlInitUnicodeString(&Name, NameString); diff --git a/ntoskrnl/ob/object.c b/ntoskrnl/ob/object.c index 7ac9996..04fb364 100644 --- a/ntoskrnl/ob/object.c +++ b/ntoskrnl/ob/object.c @@ -389,6 +389,7 @@ ObReferenceObjectByPointer(IN PVOID Object, return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE NTSTATUS STDCALL ObOpenObjectByPointer(IN POBJECT Object, @@ -423,6 +424,7 @@ ObOpenObjectByPointer(IN POBJECT Object, return STATUS_SUCCESS; } +#endif /* LIBCAPTIVE */ static NTSTATUS ObpPerformRetentionChecks(POBJECT_HEADER Header) @@ -469,6 +471,7 @@ ObpPerformRetentionChecks(POBJECT_HEADER Header) return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE /********************************************************************** * NAME EXPORTED @@ -502,6 +505,7 @@ ObfReferenceObject(IN PVOID Object) ObpPerformRetentionChecks(Header); } +#endif /* LIBCAPTIVE */ /********************************************************************** * NAME EXPORTED @@ -545,6 +549,7 @@ ObfDereferenceObject(IN PVOID Object) ObpPerformRetentionChecks(Header); } +#ifndef LIBCAPTIVE /********************************************************************** * NAME EXPORTED @@ -595,4 +600,6 @@ ObGetObjectHandleCount(PVOID Object) return(Header->HandleCount); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ps/create.c b/ntoskrnl/ps/create.c index 72fa987..ae92739 100644 --- a/ntoskrnl/ps/create.c +++ b/ntoskrnl/ps/create.c @@ -41,14 +41,18 @@ extern ULONG PiNrThreads; extern LIST_ENTRY PiThreadListHead; +#ifndef LIBCAPTIVE #define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8 static ULONG PiThreadNotifyRoutineCount = 0; static PCREATE_THREAD_NOTIFY_ROUTINE PiThreadNotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT]; +#endif /* LIBCAPTIVE */ /* FUNCTIONS ***************************************************************/ +#ifndef LIBCAPTIVE + NTSTATUS STDCALL PsAssignImpersonationToken(PETHREAD Thread, HANDLE TokenHandle) @@ -301,6 +305,8 @@ PiDeleteThread(PVOID ObjectBody) DPRINT("PiDeleteThread() finished\n"); } +#endif /* LIBCAPTIVE */ + NTSTATUS PsInitializeThread(HANDLE ProcessHandle, PETHREAD* ThreadPtr, @@ -313,7 +319,9 @@ PsInitializeThread(HANDLE ProcessHandle, NTSTATUS Status; KIRQL oldIrql; PEPROCESS Process; +#ifndef LIBCAPTIVE ULONG i; +#endif /* LIBCAPTIVE */ /* * Reference process @@ -385,16 +393,19 @@ PsInitializeThread(HANDLE ProcessHandle, Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority; Thread->Tcb.Priority = Thread->Tcb.BasePriority; +#ifndef LIBCAPTIVE for (i = 0; i < PiThreadNotifyRoutineCount; i++) { PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess, Thread->Cid.UniqueThread, TRUE); } +#endif /* LIBCAPTIVE */ return(STATUS_SUCCESS); } +#ifndef LIBCAPTIVE static NTSTATUS PsCreateTeb(HANDLE ProcessHandle, @@ -686,4 +697,6 @@ PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine) return(STATUS_SUCCESS); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ps/process.c b/ntoskrnl/ps/process.c index c0b094c..751e534 100644 --- a/ntoskrnl/ps/process.c +++ b/ntoskrnl/ps/process.c @@ -50,12 +50,15 @@ static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ, #define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8 +#ifndef LIBCAPTIVE static ULONG PiProcessNotifyRoutineCount = 0; static PCREATE_PROCESS_NOTIFY_ROUTINE PiProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT]; +#endif /* LIBCAPTIVE */ /* FUNCTIONS *****************************************************************/ +#ifndef LIBCAPTIVE PEPROCESS PsGetNextProcess(PEPROCESS OldProcess) @@ -191,6 +194,7 @@ PiKillMostProcesses(VOID) KeReleaseSpinLock(&PsProcessListLock, oldIrql); } +#endif /* LIBCAPTIVE */ VOID PsInitProcessManagment(VOID) @@ -216,7 +220,11 @@ PsInitProcessManagment(VOID) PsProcessType->Dump = NULL; PsProcessType->Open = NULL; PsProcessType->Close = NULL; +#ifndef LIBCAPTIVE PsProcessType->Delete = PiDeleteProcess; +#else + PsProcessType->Delete = NULL; /* never Delete PsInitialSystemProcess */ +#endif /* LIBCAPTIVE */ PsProcessType->Parse = NULL; PsProcessType->Security = NULL; PsProcessType->QueryName = NULL; @@ -224,7 +232,7 @@ PsInitProcessManagment(VOID) PsProcessType->Create = NULL; PsProcessType->DuplicationNotify = NULL; - RtlInitUnicodeStringFromLiteral(&PsProcessType->TypeName, L"Process"); + RtlInitUnicodeStringFromLiteral(&PsProcessType->TypeName, REACTOS_UCS2(L"Process")); InitializeListHead(&PsProcessListHead); KeInitializeSpinLock(&PsProcessListLock); @@ -245,17 +253,23 @@ PsInitProcessManagment(VOID) /* System threads may run on any processor. */ PsInitialSystemProcess->Pcb.Affinity = 0xFFFFFFFF; PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL; +#ifndef LIBCAPTIVE KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader, InternalProcessType, sizeof(EPROCESS), FALSE); +#endif /* LIBCAPTIVE */ KProcess = &PsInitialSystemProcess->Pcb; +#ifndef LIBCAPTIVE MmInitializeAddressSpace(PsInitialSystemProcess, &PsInitialSystemProcess->AddressSpace); +#endif /* LIBCAPTIVE */ ObCreateHandleTable(NULL,FALSE,PsInitialSystemProcess); +#ifndef LIBCAPTIVE KProcess->DirectoryTableBase = (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory(); +#endif /* LIBCAPTIVE */ PsInitialSystemProcess->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId); PsInitialSystemProcess->Win32WindowStation = (HANDLE)0; @@ -269,7 +283,9 @@ PsInitProcessManagment(VOID) strcpy(PsInitialSystemProcess->ImageFileName, "SYSTEM"); +#ifndef LIBCAPTIVE SepCreateSystemProcessToken(PsInitialSystemProcess); +#endif /* LIBCAPTIVE */ ObCreateHandle(PsInitialSystemProcess, PsInitialSystemProcess, @@ -278,6 +294,8 @@ PsInitProcessManagment(VOID) &SystemProcessHandle); } +#ifndef LIBCAPTIVE + VOID STDCALL PiDeleteProcess(PVOID ObjectBody) { @@ -364,23 +382,31 @@ PsGetCurrentProcessId(VOID) return((HANDLE)PsGetCurrentProcess()->UniqueProcessId); } +#endif /* LIBCAPTIVE */ + /* * FUNCTION: Returns a pointer to the current process */ PEPROCESS STDCALL PsGetCurrentProcess(VOID) { +#ifndef LIBCAPTIVE if (PsGetCurrentThread() == NULL || PsGetCurrentThread()->ThreadsProcess == NULL) { +#endif /* LIBCAPTIVE */ return(PsInitialSystemProcess); +#ifndef LIBCAPTIVE } else { return(PsGetCurrentThread()->ThreadsProcess); } +#endif /* LIBCAPTIVE */ } +#ifndef LIBCAPTIVE + PEPROCESS STDCALL IoGetCurrentProcess(VOID) { @@ -1245,4 +1271,6 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, return(STATUS_SUCCESS); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/ps/thread.c b/ntoskrnl/ps/thread.c index c4da6f3..a4b53c7 100644 --- a/ntoskrnl/ps/thread.c +++ b/ntoskrnl/ps/thread.c @@ -43,16 +43,20 @@ KSPIN_LOCK PiThreadListLock; /* * PURPOSE: List of threads associated with each priority level */ -LIST_ENTRY PiThreadListHead; static LIST_ENTRY PriorityListHead[MAXIMUM_PRIORITY]; static BOOLEAN DoneInitYet = FALSE; +LIST_ENTRY PiThreadListHead; +#ifndef LIBCAPTIVE static PETHREAD IdleThreads[MAXIMUM_PROCESSORS]; +#endif /* LIBCAPTIVE */ ULONG PiNrThreads = 0; +#ifndef LIBCAPTIVE ULONG PiNrReadyThreads = 0; static HANDLE PiReaperThreadHandle; static KEVENT PiReaperThreadEvent; static BOOL PiReaperThreadShouldTerminate = FALSE; ULONG PiNrThreadsAwaitingReaping = 0; +#endif /* LIBCAPTIVE */ static GENERIC_MAPPING PiThreadMapping = {THREAD_READ, THREAD_WRITE, @@ -61,17 +65,23 @@ static GENERIC_MAPPING PiThreadMapping = {THREAD_READ, /* FUNCTIONS ***************************************************************/ +#ifndef LIBCAPTIVE + PKTHREAD STDCALL KeGetCurrentThread(VOID) { return(KeGetCurrentKPCR()->CurrentThread); } +#endif /* LIBCAPTIVE */ + PETHREAD STDCALL PsGetCurrentThread(VOID) { PKTHREAD CurrentThread = KeGetCurrentKPCR()->CurrentThread; return(CONTAINING_RECORD(CurrentThread, ETHREAD, Tcb)); } +#ifndef LIBCAPTIVE + HANDLE STDCALL PsGetCurrentThreadId(VOID) { return(PsGetCurrentThread()->Cid.UniqueThread); @@ -393,6 +403,8 @@ PsPrepareForApplicationProcessorInit(ULONG Id) Id, IdleThread->Cid.UniqueThread); } +#endif /* LIBCAPTIVE */ + VOID PsInitThreadManagment(VOID) /* @@ -402,7 +414,9 @@ PsInitThreadManagment(VOID) PETHREAD FirstThread; ULONG i; HANDLE FirstThreadHandle; +#ifndef LIBCAPTIVE NTSTATUS Status; +#endif /* LIBCAPTIVE */ KeInitializeSpinLock(&PiThreadListLock); for (i=0; i < MAXIMUM_PRIORITY; i++) @@ -414,7 +428,7 @@ PsInitThreadManagment(VOID) PsThreadType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); - RtlInitUnicodeStringFromLiteral(&PsThreadType->TypeName, L"Thread"); + RtlInitUnicodeStringFromLiteral(&PsThreadType->TypeName, REACTOS_UCS2(L"Thread")); PsThreadType->Tag = TAG('T', 'H', 'R', 'T'); PsThreadType->TotalObjects = 0; @@ -427,7 +441,11 @@ PsInitThreadManagment(VOID) PsThreadType->Dump = NULL; PsThreadType->Open = NULL; PsThreadType->Close = NULL; +#ifndef LIBCAPTIVE PsThreadType->Delete = PiDeleteThread; +#else /* !LIBCAPTIVE */ + PsThreadType->Delete = NULL; +#endif /* !LIBCAPTIVE */ PsThreadType->Parse = NULL; PsThreadType->Security = NULL; PsThreadType->QueryName = NULL; @@ -446,6 +464,7 @@ PsInitThreadManagment(VOID) DoneInitYet = TRUE; +#ifndef LIBCAPTIVE /* * Create the reaper thread */ @@ -462,8 +481,11 @@ PsInitThreadManagment(VOID) DPRINT1("PS: Failed to create reaper thread.\n"); KeBugCheck(0); } +#endif /* LIBCAPTIVE */ } +#ifndef LIBCAPTIVE + LONG STDCALL KeSetBasePriorityThread (PKTHREAD Thread, LONG Increment) @@ -647,4 +669,6 @@ PsLookupThreadByThreadId(IN PVOID ThreadId, return(STATUS_INVALID_PARAMETER); } +#endif /* LIBCAPTIVE */ + /* EOF */ diff --git a/ntoskrnl/rtl/mem.c b/ntoskrnl/rtl/mem.c index dfdbdd7..5f73fbf 100644 --- a/ntoskrnl/rtl/mem.c +++ b/ntoskrnl/rtl/mem.c @@ -19,6 +19,8 @@ /* FUNCTIONS *****************************************************************/ +#ifndef LIBCAPTIVE + NTSTATUS STDCALL MmCopyToCaller(PVOID Dest, PVOID Src, ULONG NumberOfBytes) { @@ -78,7 +80,7 @@ RtlCompareMemory ( * RETURNS: Number of equal bytes */ { - int i,total; + ULONG i,total; for (i=0,total=0;i"; + sw = REACTOS_UCS2(L""); len = 6; } else diff --git a/ntoskrnl/rtl/unicode.c b/ntoskrnl/rtl/unicode.c index 705e7cc..e4797e1 100644 --- a/ntoskrnl/rtl/unicode.c +++ b/ntoskrnl/rtl/unicode.c @@ -11,7 +11,7 @@ #include //#include -#include +#include /* does not need to define isw*() */ #include #include @@ -735,7 +735,7 @@ RtlIntegerToChar(IN ULONG Value, tp++; } - if (tp - temp >= Length) + if ((ULONG)(tp - temp) >= Length) return STATUS_BUFFER_TOO_SMALL; sp = String; diff --git a/ntoskrnl/rtl/wstring.c b/ntoskrnl/rtl/wstring.c index ee59a51..f449ca9 100644 --- a/ntoskrnl/rtl/wstring.c +++ b/ntoskrnl/rtl/wstring.c @@ -29,6 +29,8 @@ int _wcsicmp (const wchar_t* cs, const wchar_t* ct) return *cs - *ct; } +#ifndef LIBCAPTIVE + wchar_t *_wcslwr (wchar_t *x) { wchar_t *y=x; @@ -101,6 +103,7 @@ wchar_t *_wcsupr(wchar_t *x) return x; } +#endif /* LIBCAPTIVE */ wchar_t * wcscat(wchar_t *dest, const wchar_t *src) { @@ -131,6 +134,7 @@ wchar_t * wcschr(const wchar_t *str, wchar_t ch) return NULL; } +#ifndef LIBCAPTIVE int wcscmp(const wchar_t *cs, const wchar_t *ct) { @@ -142,6 +146,7 @@ int wcscmp(const wchar_t *cs, const wchar_t *ct) return *cs - *ct; } +#endif /* LIBCAPTIVE */ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2) { @@ -157,6 +162,7 @@ wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2) return(str1); } +#ifndef LIBCAPTIVE size_t wcscspn(const wchar_t *str,const wchar_t *reject) { @@ -177,6 +183,7 @@ size_t wcscspn(const wchar_t *str,const wchar_t *reject) return s-str; /* nr of wchars */ } +#endif /* LIBCAPTIVE */ size_t wcslen(const wchar_t *s) { @@ -190,6 +197,7 @@ size_t wcslen(const wchar_t *s) return len; } +#ifndef LIBCAPTIVE wchar_t * wcsncat(wchar_t *dest, const wchar_t *src, size_t count) { @@ -239,6 +247,7 @@ wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count) return dest; } +#endif /* LIBCAPTIVE */ wchar_t *wcsrchr(const wchar_t *str, wchar_t ch) { @@ -259,6 +268,7 @@ wchar_t *wcsrchr(const wchar_t *str, wchar_t ch) return NULL; } +#ifndef LIBCAPTIVE size_t wcsspn(const wchar_t *str,const wchar_t *accept) { @@ -306,3 +316,5 @@ wchar_t *wcsstr(const wchar_t *s,const wchar_t *b) } return NULL; } + +#endif /* LIBCAPTIVE */ -- 1.8.3.1