From 82f18756f0afb8133937ba1cfd1a84cd2d20ede1 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Sun, 19 Aug 2007 19:37:47 +0000 Subject: [PATCH] - mkhive's "registry.c" used wcsncmp for comparing two strings. But this function seems to work different on different hosts (probably due to different handling of wchar_t's or whatever). To avoid this problem, use memcmp now to compare the strings as it's done two lines later. This fixes the Live-CD on Linux/Unix hosts. (For the first time, Live-CDs created by our 64-Bit Debug Buildslave are usable :-) - Change __volatile to volatile in "winddk.h". This fixes compilation problems under MSVC. - Make the prototype of RtlCompareMemory in "winnt.h" similar to the one in "winddk.h". Fixes a compilation problem in MSVC. - Define the prototype for xwcschr in "mkhive.h". Silences a warning in MSVC. - Add some casts to "reginf.c" to silence some warnings in MSVC. - Add a MSVC 2005 project file for mkhive. mkhive can be compiled under MSVC with this project file, when cmlib and inflib_host are compiled. - Remove the duplicate definition of CMLIB_HOST in "cmlib.mak". svn path=/trunk/; revision=28425 --- reactos/include/ddk/winddk.h | 28 ++-- reactos/include/psdk/winnt.h | 1 + reactos/lib/cmlib/cmlib.mak | 2 +- reactos/tools/mkhive/mkhive.h | 7 + reactos/tools/mkhive/mkhive.sln | 20 +++ reactos/tools/mkhive/mkhive.vcproj | 234 +++++++++++++++++++++++++++++ reactos/tools/mkhive/reginf.c | 8 +- reactos/tools/mkhive/registry.c | 4 +- 8 files changed, 283 insertions(+), 21 deletions(-) create mode 100644 reactos/tools/mkhive/mkhive.sln create mode 100644 reactos/tools/mkhive/mkhive.vcproj diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index 8afd4209797..e154e326f5e 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -1266,8 +1266,8 @@ typedef struct _EX_RUNDOWN_REF { union { - __volatile ULONG_PTR Count; - __volatile PVOID Ptr; + volatile ULONG_PTR Count; + volatile PVOID Ptr; }; } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; @@ -1362,7 +1362,7 @@ typedef struct _IRP { ULONG Flags; union { struct _IRP *MasterIrp; - __volatile LONG IrpCount; + volatile LONG IrpCount; PVOID SystemBuffer; } AssociatedIrp; LIST_ENTRY ThreadListEntry; @@ -1384,7 +1384,7 @@ typedef struct _IRP { } AsynchronousParameters; LARGE_INTEGER AllocationSize; } Overlay; - __volatile PDRIVER_CANCEL CancelRoutine; + volatile PDRIVER_CANCEL CancelRoutine; PVOID UserBuffer; union { struct { @@ -2187,7 +2187,7 @@ typedef struct _DEVICE_OBJECT { PIO_TIMER Timer; ULONG Flags; ULONG Characteristics; - __volatile PVPB Vpb; + volatile PVPB Vpb; PVOID DeviceExtension; DEVICE_TYPE DeviceType; CCHAR StackSize; @@ -3147,8 +3147,8 @@ typedef struct _ERESOURCE { POWNER_ENTRY OwnerTable; SHORT ActiveCount; USHORT Flag; - __volatile PKSEMAPHORE SharedWaiters; - __volatile PKEVENT ExclusiveWaiters; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; OWNER_ENTRY OwnerThreads[2]; ULONG ContentionCount; USHORT NumberOfSharedWaiters; @@ -3479,15 +3479,15 @@ typedef struct _FILE_OBJECT ULONG Flags; UNICODE_STRING FileName; LARGE_INTEGER CurrentByteOffset; - __volatile ULONG Waiters; - __volatile ULONG Busy; + volatile ULONG Waiters; + volatile ULONG Busy; PVOID LastLock; KEVENT Lock; KEVENT Event; - __volatile PIO_COMPLETION_CONTEXT CompletionContext; + volatile PIO_COMPLETION_CONTEXT CompletionContext; KSPIN_LOCK IrpListLock; LIST_ENTRY IrpList; - __volatile PVOID FileObjectExtension; + volatile PVOID FileObjectExtension; } FILE_OBJECT; typedef struct _FILE_OBJECT *PFILE_OBJECT; @@ -4467,7 +4467,7 @@ typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { BOOLEAN Removed; BOOLEAN Reserved[3]; - __volatile LONG IoCount; + volatile LONG IoCount; KEVENT RemoveEvent; } IO_REMOVE_LOCK_COMMON_BLOCK; @@ -4478,7 +4478,7 @@ typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { LONG AllocateTag; LIST_ENTRY LockList; KSPIN_LOCK Spin; - __volatile LONG LowMemoryCount; + volatile LONG LowMemoryCount; ULONG Reserved1[4]; PVOID Reserved2; PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; @@ -4651,7 +4651,7 @@ typedef VOID typedef struct _WORK_QUEUE_ITEM { LIST_ENTRY List; PWORKER_THREAD_ROUTINE WorkerRoutine; - __volatile PVOID Parameter; + volatile PVOID Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; typedef enum _KBUGCHECK_CALLBACK_REASON { diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index d840980501b..af8a03249f1 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -4017,6 +4017,7 @@ typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX; ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE); #endif +NTSYSAPI SIZE_T STDCALL RtlCompareMemory ( diff --git a/reactos/lib/cmlib/cmlib.mak b/reactos/lib/cmlib/cmlib.mak index 57b06e0358d..c947a310c95 100644 --- a/reactos/lib/cmlib/cmlib.mak +++ b/reactos/lib/cmlib/cmlib.mak @@ -33,7 +33,7 @@ CMLIB_HOST_OBJECTS = \ CMLIB_HOST_CFLAGS = -O3 -Wall -Wwrite-strings -Wpointer-arith \ -D_X86_ -D__i386__ -D_REACTOS_ -D_NTOSKRNL_ -D_NTSYSTEM_ \ -DCMLIB_HOST -D_M_IX86 -I$(CMLIB_BASE) -Iinclude/reactos -Iinclude/psdk -Iinclude/ddk -Iinclude/crt \ - -D__NO_CTYPE_INLINES -DCMLIB_HOST + -D__NO_CTYPE_INLINES $(CMLIB_HOST_TARGET): $(CMLIB_HOST_OBJECTS) | $(CMLIB_OUT) $(ECHO_AR) diff --git a/reactos/tools/mkhive/mkhive.h b/reactos/tools/mkhive/mkhive.h index c2efa96aa92..3887c340d27 100644 --- a/reactos/tools/mkhive/mkhive.h +++ b/reactos/tools/mkhive/mkhive.h @@ -101,6 +101,13 @@ static void DPRINT ( const char* fmt, ... ) #define GCC_PACKED __attribute__((packed)) #endif//_MSC_VER +/* rtl.c */ +PWSTR +xwcschr( + PWSTR String, + WCHAR Char +); + #endif /* __MKHIVE_H__ */ /* EOF */ diff --git a/reactos/tools/mkhive/mkhive.sln b/reactos/tools/mkhive/mkhive.sln new file mode 100644 index 00000000000..7618731db43 --- /dev/null +++ b/reactos/tools/mkhive/mkhive.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mkhive", "mkhive.vcproj", "{4D03FFD1-EB34-41A1-908B-F8F7350118A7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Debug|Win32.ActiveCfg = Debug|Win32 + {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Debug|Win32.Build.0 = Debug|Win32 + {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Release|Win32.ActiveCfg = Release|Win32 + {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/reactos/tools/mkhive/mkhive.vcproj b/reactos/tools/mkhive/mkhive.vcproj new file mode 100644 index 00000000000..4d69557ba3a --- /dev/null +++ b/reactos/tools/mkhive/mkhive.vcproj @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reactos/tools/mkhive/reginf.c b/reactos/tools/mkhive/reginf.c index da801aed086..117e5507b87 100644 --- a/reactos/tools/mkhive/reginf.c +++ b/reactos/tools/mkhive/reginf.c @@ -262,7 +262,7 @@ do_reg_operation(HKEY KeyHandle, if (Str == NULL) return FALSE; - InfHostGetMultiSzField (Context, 5, Str, Size, NULL); + InfHostGetMultiSzField (Context, 5, Str, (ULONG)Size, NULL); } if (Flags & FLG_ADDREG_APPEND) @@ -291,7 +291,7 @@ do_reg_operation(HKEY KeyHandle, if (Str == NULL) return FALSE; - InfHostGetStringField (Context, 5, Str, Size, NULL); + InfHostGetStringField (Context, 5, Str, (ULONG)Size, NULL); } } @@ -347,7 +347,7 @@ do_reg_operation(HKEY KeyHandle, return FALSE; DPRINT("setting binary data %s len %lu\n", ValueName, Size); - InfHostGetBinaryField (Context, 5, Data, Size, NULL); + InfHostGetBinaryField (Context, 5, Data, (ULONG)Size, NULL); } RegSetValueExA (KeyHandle, @@ -396,7 +396,7 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete) /* get key */ Length = strlen (Buffer); - if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL) != 0) + if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - (ULONG)Length, NULL) != 0) *Buffer = 0; DPRINT("KeyName: <%s>\n", Buffer); diff --git a/reactos/tools/mkhive/registry.c b/reactos/tools/mkhive/registry.c index c224b475dbf..ef9a015a352 100644 --- a/reactos/tools/mkhive/registry.c +++ b/reactos/tools/mkhive/registry.c @@ -133,7 +133,7 @@ RegpOpenOrCreateKey( RtlInitUnicodeString(&KeyString, LocalKeyName); /* Redirect from 'CurrentControlSet' to 'ControlSet001' */ - if (!wcsncmp(LocalKeyName, L"CurrentControlSet", 17) && + if (!memcmp(LocalKeyName, L"CurrentControlSet", 34) && ParentKey->NameSize == 12 && !memcmp(ParentKey->Name, L"SYSTEM", 12)) RtlInitUnicodeString(&KeyString, L"ControlSet001"); @@ -624,7 +624,7 @@ RegInitializeRegistry(VOID) { UNICODE_STRING RootKeyName = RTL_CONSTANT_STRING(L"\\"); NTSTATUS Status; - HKEY ControlSetKey, LinkKey; + HKEY ControlSetKey; InitializeListHead(&CmiHiveListHead);