- mkhive's "registry.c" used wcsncmp for comparing two strings. But this function...
authorColin Finck <colin@reactos.org>
Sun, 19 Aug 2007 19:37:47 +0000 (19:37 +0000)
committerColin Finck <colin@reactos.org>
Sun, 19 Aug 2007 19:37:47 +0000 (19:37 +0000)
  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
reactos/include/psdk/winnt.h
reactos/lib/cmlib/cmlib.mak
reactos/tools/mkhive/mkhive.h
reactos/tools/mkhive/mkhive.sln [new file with mode: 0644]
reactos/tools/mkhive/mkhive.vcproj [new file with mode: 0644]
reactos/tools/mkhive/reginf.c
reactos/tools/mkhive/registry.c

index 8afd420..e154e32 100644 (file)
@@ -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 {
index d840980..af8a032 100644 (file)
@@ -4017,6 +4017,7 @@ typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX;
 ULONGLONG WINAPI VerSetConditionMask(ULONGLONG,DWORD,BYTE);
 #endif
 
+NTSYSAPI
 SIZE_T
 STDCALL
 RtlCompareMemory (
index 57b06e0..c947a31 100644 (file)
@@ -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)
index c2efa96..3887c34 100644 (file)
@@ -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 (file)
index 0000000..7618731
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual C++ Express 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mkhive", "mkhive.vcproj", "{4D03FFD1-EB34-41A1-908B-F8F7350118A7}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Debug|Win32.Build.0 = Debug|Win32\r
+               {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Release|Win32.ActiveCfg = Release|Win32\r
+               {4D03FFD1-EB34-41A1-908B-F8F7350118A7}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/reactos/tools/mkhive/mkhive.vcproj b/reactos/tools/mkhive/mkhive.vcproj
new file mode 100644 (file)
index 0000000..4d69557
--- /dev/null
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8,00"\r
+       Name="mkhive"\r
+       ProjectGUID="{4D03FFD1-EB34-41a1-908B-F8F7350118A7}"\r
+       RootNamespace="mkhive"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="0"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               UseUnicodeResponseFiles="true"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../include/ddk;../../include/psdk;../../include/reactos;../../lib/cmlib;../../lib/inflib;../../lib/rtl"\r
+                               PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="kernel32.lib ../../obj-i386/lib/cmlib/cmlib.a ../../obj-i386/lib/inflib_host/infcore.o ../../obj-i386/lib/inflib_host/infget.o ../../obj-i386/lib/inflib_host/infhostgen.o ../../obj-i386/lib/inflib_host/infhostget.o ../../obj-i386/lib/inflib_host/infhostglue.o ../../obj-i386/lib/inflib_host/infhostput.o ../../obj-i386/lib/inflib_host/infput.o ../../obj-i386/lib/rtl/rtl.a $(NOINHERIT)"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=""\r
+                               PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="kernel32.lib $(NOINHERIT)"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\binhive.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\cmi.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\mkhive.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\reginf.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\registry.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\rtl.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\binhive.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\cmi.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\mkhive.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\reginf.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\registry.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index da801ae..117e550 100644 (file)
@@ -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);
index c224b47..ef9a015 100644 (file)
@@ -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);