[ros-diffs] [hpoussin] 31656: Add traces

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Mon Jan 7 22:43:00 CET 2008


Author: hpoussin
Date: Tue Jan  8 00:42:59 2008
New Revision: 31656

URL: http://svn.reactos.org/svn/reactos?rev=31656&view=rev
Log:
Add traces

Modified:
    trunk/reactos/base/system/userinit/userinit.c
    trunk/reactos/base/system/userinit/userinit.rbuild

Modified: trunk/reactos/base/system/userinit/userinit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/userinit/userinit.c?rev=31656&r1=31655&r2=31656&view=diff
==============================================================================
--- trunk/reactos/base/system/userinit/userinit.c (original)
+++ trunk/reactos/base/system/userinit/userinit.c Tue Jan  8 00:42:59 2008
@@ -29,6 +29,9 @@
 #include <shlobj.h>
 #include <shlwapi.h>
 #include "resource.h"
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(userinit);
 
 #define CMP_MAGIC  0x01234567
 
@@ -47,17 +50,29 @@
     DWORD cbData = 0;
     LPWSTR Value;
 
+    TRACE("(%p, %s, %p)\n", hKey, debugstr_w(pszKey), pValue);
+
     rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
     if (rc != ERROR_SUCCESS)
+    {
+        WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
         return rc;
+    }
     if (dwType != REG_SZ)
+    {
+        WARN("Wrong registry data type (%u vs %u)\n", dwType, REG_SZ);
         return ERROR_FILE_NOT_FOUND;
+    }
     Value = (WCHAR*) HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
     if (!Value)
+    {
+        WARN("No memory\n");
         return ERROR_NOT_ENOUGH_MEMORY;
+    }
     rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
     if (rc != ERROR_SUCCESS)
     {
+        WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
         HeapFree(GetProcessHeap(), 0, Value);
         return rc;
     }
@@ -76,6 +91,8 @@
     LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
     LONG rc;
     BOOL ret = FALSE;
+
+    TRACE("()\n");
 
     rc = RegOpenKeyEx(
         HKEY_LOCAL_MACHINE,
@@ -83,10 +100,18 @@
         0,
         KEY_QUERY_VALUE,
         &ControlKey);
+    if (rc != ERROR_SUCCESS)
+    {
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
+        goto cleanup;
+    }
 
     rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
     if (rc != ERROR_SUCCESS)
+    {
+        WARN("ReadRegSzKey() failed with error %lu\n", rc);
         goto cleanup;
+    }
 
     /* Check for CONSOLE in SystemStartOptions */
     CurrentOption = SystemStartOptions;
@@ -97,6 +122,7 @@
             *NextOption = L'\0';
         if (wcsicmp(CurrentOption, L"CONSOLE") == 0)
         {
+            TRACE("Found 'CONSOLE' boot option\n");
             ret = TRUE;
             goto cleanup;
         }
@@ -120,26 +146,38 @@
     WCHAR Shell[MAX_PATH];
     BOOL Ret = FALSE;
     BOOL ConsoleShell = IsConsoleShell();
-
-    if (RegOpenKeyEx(hRootKey, REGSTR_PATH_WINLOGON,
-                     0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+    LONG rc;
+
+    TRACE("(%p, %p)\n", CommandLine, hRootKey);
+
+    rc = RegOpenKeyEx(hRootKey, REGSTR_PATH_WINLOGON,
+                      0, KEY_QUERY_VALUE, &hKey);
+    if (rc == ERROR_SUCCESS)
     {
         Size = MAX_PATH * sizeof(WCHAR);
-        if (RegQueryValueEx(hKey,
-                            ConsoleShell ? L"ConsoleShell" : L"Shell",
-                            NULL,
-                            &Type,
-                            (LPBYTE)Shell,
-                            &Size) == ERROR_SUCCESS)
+        rc = RegQueryValueEx(hKey,
+                             ConsoleShell ? L"ConsoleShell" : L"Shell",
+                             NULL,
+                             &Type,
+                             (LPBYTE)Shell,
+                             &Size);
+        if (rc == ERROR_SUCCESS)
         {
             if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
             {
+                TRACE("Found command line %s\n", debugstr_w(Shell));
                 wcscpy(CommandLine, Shell);
                 Ret = TRUE;
             }
+            else
+                WARN("Wrong type %lu (expected %u or %u)\n", Type, REG_SZ, REG_EXPAND_SZ);
         }
+        else
+            WARN("RegQueryValueEx() failed with error %lu\n", rc);
         RegCloseKey(hKey);
     }
+    else
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
 
     return Ret;
 }
@@ -155,10 +193,13 @@
     SHELLEXECUTEINFOW ExecInfo;
     size_t len;
 
+    TRACE("(%d)\n", clsid);
+
     hResult = SHGetFolderPathW(NULL, clsid, NULL, SHGFP_TYPE_CURRENT, szPath);
     len = wcslen(szPath);
     if (!SUCCEEDED(hResult) || len == 0)
     {
+        WARN("SHGetFolderPath() failed with error %lu\n", GetLastError());
         return;
     }
 
@@ -166,6 +207,7 @@
     hFind = FindFirstFileW(szPath, &findData);
     if (hFind == INVALID_HANDLE_VALUE)
     {
+        WARN("FindFirstFile(%s) failed with error %lu\n", debugstr_w(szPath), GetLastError());
         return;
     }
     szPath[len] = L'\0';
@@ -179,6 +221,8 @@
             ExecInfo.lpVerb = L"open";
             ExecInfo.lpFile = findData.cFileName;
             ExecInfo.lpDirectory = szPath;
+            TRACE("Executing %s in directory %s\n",
+                debugstr_w(findData.cFileName), debugstr_w(szPath));
             ShellExecuteExW(&ExecInfo);
         }
     } while (FindNextFileW(hFind, &findData));
@@ -192,6 +236,8 @@
     STARTUPINFO si;
     PROCESS_INFORMATION pi;
     WCHAR ExpandedShell[MAX_PATH];
+
+    TRACE("(%s)\n", debugstr_w(Shell));
 
     ZeroMemory(&si, sizeof(STARTUPINFO));
     si.cb = sizeof(STARTUPINFO);
@@ -210,6 +256,7 @@
                       &si,
                       &pi))
     {
+        WARN("CreateProcess() failed with error %lu\n", GetLastError());
         return FALSE;
     }
 
@@ -227,15 +274,19 @@
     WCHAR Shell[MAX_PATH];
     TCHAR szMsg[RC_STRING_MAX_SIZE];
 
+    TRACE("()\n");
+
     /* Try to run shell in user key */
     if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell))
     {
+        TRACE("Failed to start a shell from HKEY_CURRENT_USER\n");
         return;
     }
 
     /* Try to run shell in local machine key */
     if (GetShell(Shell, HKEY_LOCAL_MACHINE) && TryToStartShell(Shell))
     {
+        TRACE("Failed to start a shell from HKEY_LOCAL_MACHINE\n");
         return;
     }
 
@@ -256,12 +307,13 @@
     }
     if (!TryToStartShell(Shell))
     {
+        WARN("Failed to start default shell %s\n", debugstr_w(Shell));
         LoadString( GetModuleHandle(NULL), STRING_USERINIT_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
         MessageBox(0, szMsg, NULL, 0);
     }
 }
 
-WCHAR g_RegColorNames[][32] = {
+const WCHAR g_RegColorNames[][32] = {
     L"Scrollbar",             /* 00 = COLOR_SCROLLBAR */
     L"Background",            /* 01 = COLOR_DESKTOP */
     L"ActiveTitle",           /* 02 = COLOR_ACTIVECAPTION  */
@@ -302,6 +354,8 @@
 {
     BYTE rgb[3];
 
+    TRACE("(%s)\n", debugstr_w(lpszCol));
+
     rgb[0] = StrToIntW(lpszCol);
     lpszCol = StrChrW(lpszCol, L' ') + 1;
     rgb[1] = StrToIntW(lpszCol);
@@ -318,25 +372,32 @@
     WCHAR szColor[20];
     DWORD Type, Size;
     COLORREF crColor;
-
-    if (!RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_COLORS,
-                      0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
-    {
+    LONG rc;
+
+    TRACE("()\n");
+
+    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_COLORS,
+                      0, KEY_QUERY_VALUE, &hKey);
+    if (rc != ERROR_SUCCESS)
+    {
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
         return;
     }
     for(i = 0; i < NUM_SYSCOLORS; i++)
     {
         Size = sizeof(szColor);
-        if (RegQueryValueEx(hKey, g_RegColorNames[i], NULL, &Type,
-                            (LPBYTE)szColor, &Size) == ERROR_SUCCESS &&
-            Type == REG_SZ)
+        rc = RegQueryValueEx(hKey, g_RegColorNames[i], NULL, &Type,
+                             (LPBYTE)szColor, &Size);
+        if (rc == ERROR_SUCCESS && Type == REG_SZ)
         {
             crColor = StrToColorref(szColor);
             SetSysColors(1, &i, &crColor);
         }
+        else
+            WARN("RegQueryValueEx(%s) failed with error %lu\n",
+                debugstr_w(g_RegColorNames[i]), rc);
     }
     RegCloseKey(hKey);
-    return;
 }
 
 static
@@ -347,17 +408,22 @@
     HKEY hKey;
     LOGFONTW lfTemp;
     DWORD Type, Size;
-    INT error;
+    LONG rc;
+
+    TRACE("(%s, %p)\n", debugstr_w(lpValueName), pFont);
 
     Size = sizeof(LOGFONTW);
-    if (!RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
-                      0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
-    {
-        return;
-    }
-    error = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&lfTemp, &Size);
-    if ((error != ERROR_SUCCESS) || (Type != REG_BINARY))
-    {
+    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
+                      0, KEY_QUERY_VALUE, &hKey);
+    if (rc != ERROR_SUCCESS)
+    {
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
+        return;
+    }
+    rc = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&lfTemp, &Size);
+    if (rc != ERROR_SUCCESS || Type != REG_BINARY)
+    {
+        WARN("RegQueryValueEx() failed with error %lu\n", rc);
         return;
     }
     RegCloseKey(hKey);
@@ -372,18 +438,23 @@
 {
     HKEY hKey;
     DWORD Type, Size;
-    INT ret;
     WCHAR strValue[8];
+    LONG rc;
+
+    TRACE("(%s, %p)\n", debugstr_w(lpValueName), pValue);
 
     Size = sizeof(strValue);
-    if (!RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
-                      0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
-    {
-        return;
-    }
-    ret = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&strValue, &Size);
-    if ((ret != ERROR_SUCCESS) || (Type != REG_SZ))
-    {
+    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_METRICS,
+                      0, KEY_QUERY_VALUE, &hKey);
+    if (rc != ERROR_SUCCESS)
+    {
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
+        return;
+    }
+    rc = RegQueryValueEx(hKey, lpValueName, NULL, &Type, (LPBYTE)&strValue, &Size);
+    if (rc != ERROR_SUCCESS || Type != REG_SZ)
+    {
+        WARN("RegQueryValueEx() failed with error %lu\n", rc);
         return;
     }
     RegCloseKey(hKey);
@@ -395,6 +466,8 @@
 {
     NONCLIENTMETRICSW ncmetrics;
     MINIMIZEDMETRICS mmmetrics;
+
+    TRACE("()\n");
 
     ncmetrics.cbSize = sizeof(NONCLIENTMETRICSW);
     mmmetrics.cbSize = sizeof(MINIMIZEDMETRICS);
@@ -427,20 +500,25 @@
     HKEY hKey;
     DWORD Type, Size;
     WCHAR szWallpaper[MAX_PATH + 1];
-
-    if (RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_DESKTOP,
-                     0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+    LONG rc;
+
+    TRACE("()\n");
+
+    rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_DESKTOP,
+                      0, KEY_QUERY_VALUE, &hKey);
+    if (rc == ERROR_SUCCESS)
     {
         Size = sizeof(szWallpaper);
-        if (RegQueryValueEx(hKey,
-                            L"Wallpaper",
-                            NULL,
-                            &Type,
-                            (LPBYTE)szWallpaper,
-                            &Size) == ERROR_SUCCESS &&
-            Type == REG_SZ)
+        rc = RegQueryValueEx(hKey,
+                             L"Wallpaper",
+                             NULL,
+                             &Type,
+                             (LPBYTE)szWallpaper,
+                             &Size);
+        if (rc == ERROR_SUCCESS && Type == REG_SZ)
         {
             ExpandEnvironmentStrings(szWallpaper, szWallpaper, MAX_PATH);
+            TRACE("Using wallpaper %s\n", debugstr_w(szWallpaper));
 
             /* Load and change the wallpaper */
             SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szWallpaper, SPIF_SENDCHANGE);
@@ -448,15 +526,20 @@
         else
         {
             /* remove the wallpaper */
+            TRACE("No wallpaper set in registry (error %lu)\n", rc);
             SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
         }
         RegCloseKey(hKey);
     }
+    else
+        WARN("RegOpenKeyEx() failed with error %lu\n", rc);
 }
 
 static
 VOID SetUserSettings(VOID)
 {
+    TRACE("()\n");
+
     SetUserSysColors();
     SetUserMetrics();
     SetUserWallpaper();
@@ -470,15 +553,21 @@
     HINSTANCE hModule;
     PCMP_REPORT_LOGON CMP_Report_LogOn;
 
+    TRACE("()\n");
+
     hModule = LoadLibrary(L"setupapi.dll");
     if (hModule)
     {
         CMP_Report_LogOn = (PCMP_REPORT_LOGON)GetProcAddress(hModule, "CMP_Report_LogOn");
         if (CMP_Report_LogOn)
             CMP_Report_LogOn(CMP_MAGIC, GetCurrentProcessId());
+        else
+            WARN("GetProcAddress() failed\n");
 
         FreeLibrary(hModule);
     }
+    else
+        WARN("LoadLibrary() failed with error %lu\n", GetLastError());
 }
 
 #ifdef _MSC_VER

Modified: trunk/reactos/base/system/userinit/userinit.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/userinit/userinit.rbuild?rev=31656&r1=31655&r2=31656&view=diff
==============================================================================
--- trunk/reactos/base/system/userinit/userinit.rbuild (original)
+++ trunk/reactos/base/system/userinit/userinit.rbuild Tue Jan  8 00:42:59 2008
@@ -1,9 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="userinit" type="win32gui" installbase="system32" installname="userinit.exe">
+<module name="userinit" type="win32gui" installbase="system32" installname="userinit.exe" unicode="yes">
 	<include base="userinit">.</include>
-	<define name="UNICODE" />
-	<define name="_UNICODE" />
 	<library>ntdll</library>
 	<library>kernel32</library>
 	<library>user32</library>




More information about the Ros-diffs mailing list