[APPCOMPAT] Various fixes.
authorMark Jansen <mark.jansen@reactos.org>
Fri, 14 Jul 2017 19:29:34 +0000 (19:29 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Fri, 14 Jul 2017 19:29:34 +0000 (19:29 +0000)
- Simplify shimdbg output as suggested by Thomas
- Simplify media/sdb/sysmain.xml
- Fix some warnings + a debug print

svn path=/trunk/; revision=75340

reactos/dll/appcompat/apphelp/hsdb.c
reactos/dll/appcompat/apphelp/layer.c
reactos/media/sdb/sysmain.xml
rosapps/applications/devutils/shimdbg/shimdbg.c

index 63ba796..cf74d1b 100644 (file)
@@ -577,7 +577,7 @@ BOOL WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size)
 
     if (!default_dir)
     {
-        WCHAR* tmp = NULL;
+        WCHAR* tmp;
         UINT len = GetSystemWindowsDirectoryW(NULL, 0) + lstrlenW(szAppPatch);
         tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
         if (tmp)
@@ -706,7 +706,7 @@ BOOL WINAPI SdbPackAppCompatData(HSDB hsdb, PSDBQUERYRESULT pQueryResult, PVOID*
     pData->unknown = 0;
     pData->szLayer[0] = UNICODE_NULL;   /* TODO */
 
-    SHIM_INFO("\ndwFlags    0x%x\ndwMagic    0x%x\ntrExe      0x%x\ntrLayer    0x%x",
+    SHIM_INFO("\ndwFlags    0x%x\ndwMagic    0x%x\ntrExe      0x%x\ntrLayer    0x%x\n",
               pData->Query.dwFlags, pData->dwMagic, pData->Query.atrExes[0], pData->Query.atrLayers[0]);
 
     /* Database List */
index afe1ca3..5ae7405 100644 (file)
@@ -159,7 +159,7 @@ BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
             FindClose(FindHandle);
             SdbpResizeTempStr(LongPath, (LongPath->Str.Length >> 1) + 20);
             StringCbPrintfW(LongPath->Str.Buffer, LongPath->Str.MaximumLength, SIGN_MEDIA_FMT, SignMedia, Scratch.Str.Buffer + 3);
-            LongPath->Str.Length = wcslen(LongPath->Str.Buffer) * sizeof(WCHAR);
+            LongPath->Str.Length = (USHORT)wcslen(LongPath->Str.Buffer) * sizeof(WCHAR);
             SdbpFreeTempStr(&Scratch);
             return TRUE;
         }
@@ -217,7 +217,7 @@ NTSTATUS SdbpOpenKey(PUNICODE_STRING FullPath, BOOL bMachine, ACCESS_MASK Access
             return Status;
         }
     }
-    FullPath->MaximumLength = BasePath.Length + (wcslen(LayersKey) + 1) * sizeof(WCHAR);
+    FullPath->MaximumLength = (USHORT)(BasePath.Length + (wcslen(LayersKey) + 1) * sizeof(WCHAR));
     FullPath->Buffer = SdbAlloc(FullPath->MaximumLength);
     FullPath->Length = 0;
     RtlAppendUnicodeStringToString(FullPath, &BasePath);
index f653f7f..90410a9 100644 (file)
 
             <!-- Version lie shims -->
 
-            <SHIM>
-                <NAME>Win95VersionLie</NAME>
+            <SHIM NAME="Win95VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win98VersionLie</NAME>
+            <SHIM NAME="Win98VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>WinNT4SP5VersionLie</NAME>
+            <SHIM NAME="WinNT4SP5VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2000VersionLie</NAME>
+            <SHIM NAME="Win2000VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2000SP1VersionLie</NAME>
+            <SHIM NAME="Win2000SP1VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2000SP2VersionLie</NAME>
+            <SHIM NAME="Win2000SP2VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2000SP3VersionLie</NAME>
+            <SHIM NAME="Win2000SP3VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>WinXPVersionLie</NAME>
+            <SHIM NAME="WinXPVersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>WinXPSP1VersionLie</NAME>
+            <SHIM NAME="WinXPSP1VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>WinXPSP2VersionLie</NAME>
+            <SHIM NAME="WinXPSP2VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>WinXPSP3VersionLie</NAME>
+            <SHIM NAME="WinXPSP3VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2k3RTMVersionLie</NAME>
+            <SHIM NAME="Win2k3RTMVersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2k3SP1VersionLie</NAME>
+            <SHIM NAME="Win2k3SP1VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win2k3SP2VersionLie</NAME>
+            <SHIM NAME="Win2k3SP2VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>VistaRTMVersionLie</NAME>
+            <SHIM NAME="VistaRTMVersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>VistaSP1VersionLie</NAME>
+            <SHIM NAME="VistaSP1VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>VistaSP2VersionLie</NAME>
+            <SHIM NAME="VistaSP2VersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Win7RTMVersionLie</NAME>
+            <SHIM NAME="Win7RTMVersionLie">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
 
             <!-- Display mode shims -->
 
-            <SHIM>
-                <NAME>Force640x480</NAME>
+            <SHIM NAME="Force640x480">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
-            <SHIM>
-                <NAME>Force8BitColor</NAME>
+            <SHIM NAME="Force8BitColor">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
 
             <!-- misc shims -->
 
-            <SHIM>
-                <NAME>DisableThemes</NAME>
+            <SHIM NAME="DisableThemes">
                 <DLLFILE>acgenral.dll</DLLFILE>
             </SHIM>
 
+            <SHIM NAME="HideShimEnv">
+                <DLLFILE>aclayers.dll</DLLFILE>
+            </SHIM>
+
         </LIBRARY>
 
         <!-- Backwards compatibility layers, incomplete! -->
 
-        <LAYER>
-            <NAME>WIN95</NAME>
+        <LAYER NAME="WIN95">
             <SHIM_REF NAME="Win95VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN98</NAME>
+        <LAYER NAME="WIN98">
             <SHIM_REF NAME="Win98VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>NT4SP5</NAME>
+        <LAYER NAME="NT4SP5">
             <SHIM_REF NAME="WinNT4SP5VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN2000</NAME>
+        <LAYER NAME="WIN2000">
             <SHIM_REF NAME="Win2000VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN2000SP1</NAME>
+        <LAYER NAME="WIN2000SP1">
             <SHIM_REF NAME="Win2000SP1VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN2000SP2</NAME>
+        <LAYER NAME="WIN2000SP2">
             <SHIM_REF NAME="Win2000SP2VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN2000SP3</NAME>
+        <LAYER NAME="WIN2000SP3">
             <SHIM_REF NAME="Win2000SP3VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINXP</NAME>
+        <LAYER NAME="WINXP">
             <SHIM_REF NAME="WinXPVersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINXPSP1</NAME>
+        <LAYER NAME="WINXPSP1">
             <SHIM_REF NAME="WinXPSP1VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINXPSP2</NAME>
+        <LAYER NAME="WINXPSP2">
             <SHIM_REF NAME="WinXPSP2VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINXPSP3</NAME>
+        <LAYER NAME="WINXPSP3">
             <SHIM_REF NAME="WinXPSP3VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV03RTM</NAME>
+        <LAYER NAME="WINSRV03RTM">
             <SHIM_REF NAME="Win2k3RTMVersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV03SP1</NAME>
+        <LAYER NAME="WINSRV03SP1">
             <SHIM_REF NAME="Win2k3SP1VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV03SP2</NAME>
+        <LAYER NAME="WINSRV03SP2">
             <SHIM_REF NAME="Win2k3SP2VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>VISTARTM</NAME>
+        <LAYER NAME="VISTARTM">
             <SHIM_REF NAME="VistaRTMVersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>VISTASP1</NAME>
+        <LAYER NAME="VISTASP1">
             <SHIM_REF NAME="VistaSP1VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>VISTASP2</NAME>
+        <LAYER NAME="VISTASP2">
             <SHIM_REF NAME="VistaSP2VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV08</NAME>
+        <LAYER NAME="WINSRV08">
             <SHIM_REF NAME="VistaRTMVersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV08SP1</NAME>
+        <LAYER NAME="WINSRV08SP1">
             <SHIM_REF NAME="VistaSP1VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WINSRV08SP2</NAME>
+        <LAYER NAME="WINSRV08SP2">
             <SHIM_REF NAME="VistaSP2VersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
-        <LAYER>
-            <NAME>WIN7RTM</NAME>
+        <LAYER NAME="WIN7RTM">
             <SHIM_REF NAME="Win7RTMVersionLie" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
 
         <!-- Display mode layers -->
 
-        <LAYER>
-            <NAME>256Color</NAME>
+        <LAYER NAME="256Color">
             <SHIM_REF NAME="DisableThemes" />
             <SHIM_REF NAME="Force8BitColor" />
         </LAYER>
-        <LAYER>
-            <NAME>640X480</NAME>
+        <LAYER NAME="640X480">
             <SHIM_REF NAME="Force640x480" />
         </LAYER>
 
 
         <!-- misc layers -->
 
-        <LAYER>
-            <NAME>DisableThemes</NAME>
+        <LAYER NAME="DisableThemes">
             <SHIM_REF NAME="DisableThemes" />
         </LAYER>
 
index 3bceef8..fbb0b86 100644 (file)
 #include <ctype.h>
 #include <ntndk.h>
 
-void __stdcall OutputDebugStringA(PCSTR);
+NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap);
+#define DPFLTR_ERROR_LEVEL 0
 
 void xprintf(const char *fmt, ...)
 {
     va_list ap;
-    int length;
-    char *buf;
 
     va_start(ap, fmt);
-    length = _vscprintf(fmt, ap);
-    buf = malloc(length + 1);
-    vsprintf(buf, fmt, ap);
-    buf[length] = '\0';
-    va_end(ap);
-
-    fputs(buf, stdout);
-    OutputDebugStringA(buf);
+    vprintf(fmt, ap);
+    vDbgPrintEx(-1, DPFLTR_ERROR_LEVEL, fmt, ap);
 }