Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: userstub.cpp
  7. //
  8. // Contents: exe to load webcheck
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 12-12/96 rayen (Raymond Endres) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #define _SHELL32_ // We delayload shell32
  18. #include <windows.h>
  19. #include <debug.h>
  20. #include <docobj.h>
  21. #include <webcheck.h>
  22. #include <shlguid.h>
  23. #include <shlobj.h>
  24. #include <shellp.h>
  25. #include <shlwapi.h>
  26. // if inststub.h is used in userstub, use LoadString() OW use MLLoadString()
  27. #define USERSTUB 1
  28. //
  29. // NOTE: ActiveSetup relies on our window name and class name
  30. // to shut us down properly in softboot. Do not change it.
  31. //
  32. //const TCHAR c_szClassName[] = TEXT("userstub");
  33. //const TCHAR c_szWebCheck[] = TEXT("WebCheck");
  34. //const TCHAR c_szWebCheckWindow[] = TEXT("MS_WebcheckMonitor");
  35. //const TCHAR c_szShellReg[] = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad");
  36. //const TCHAR c_szWebcheckKey[] = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Webcheck");
  37. typedef struct {
  38. HINSTANCE hInstance; // handle to current instance
  39. BOOL fUninstallOnly; // TRUE -> run uninstall stubs only, then quit
  40. } GLOBALS;
  41. GLOBALS g;
  42. //
  43. // The caller should always GetProcAddress("DllGetVersion"), not
  44. // implicitly link to it.
  45. //
  46. typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
  47. // Code to run install/uninstall stubs, from shell\inc.
  48. #define HINST_THISDLL g.hInstance
  49. #include "resource.h"
  50. #include <inststub.h>
  51. // need to do this so we can since inststub.h #includes <runonce.c>
  52. BOOL g_fCleanBoot = FALSE;
  53. BOOL g_fEndSession = FALSE;
  54. int WINAPI WinMainT(HINSTANCE, HINSTANCE, LPSTR, int);
  55. BOOL bParseCommandLine(LPSTR lpCmdLine, int nCmdShow);
  56. //----------------------------------------------------------------------------
  57. // ModuleEntry
  58. //----------------------------------------------------------------------------
  59. extern "C" int _stdcall ModuleEntry(void)
  60. {
  61. int i;
  62. STARTUPINFOA si;
  63. LPTSTR pszCmdLine;
  64. pszCmdLine = GetCommandLine();
  65. // g_hProcessHeap = GetProcessHeap();
  66. //
  67. // We don't want the "No disk in drive X:" requesters, so we set
  68. // the critical error mask such that calls will just silently fail
  69. //
  70. SetErrorMode(SEM_FAILCRITICALERRORS);
  71. if ( *pszCmdLine == TEXT('\"') ) {
  72. /*
  73. * Scan, and skip over, subsequent characters until
  74. * another double-quote or a null is encountered.
  75. */
  76. while ( *++pszCmdLine && (*pszCmdLine
  77. != TEXT('\"')) );
  78. /*
  79. * If we stopped on a double-quote (usual case), skip
  80. * over it.
  81. */
  82. if ( *pszCmdLine == TEXT('\"') )
  83. pszCmdLine++;
  84. }
  85. else {
  86. while (*pszCmdLine > TEXT(' '))
  87. pszCmdLine++;
  88. }
  89. /*
  90. * Skip past any white space preceeding the second token.
  91. */
  92. while (*pszCmdLine && (*pszCmdLine <= TEXT(' '))) {
  93. pszCmdLine++;
  94. }
  95. si.dwFlags = 0;
  96. GetStartupInfoA(&si);
  97. i = WinMainT(GetModuleHandle(NULL), NULL, pszCmdLine,
  98. si.dwFlags & STARTF_USESHOWWINDOW ? si.wShowWindow : SW_SHOWDEFAULT);
  99. // Since we now have a way for an extension to tell us when it is finished,
  100. // we will terminate all processes when the main thread goes away.
  101. ExitProcess(i);
  102. // DebugMsg(DM_TRACE, TEXT("c.me: Cabinet main thread exiting without ExitProcess."));
  103. return i;
  104. }
  105. //----------------------------------------------------------------------------
  106. // WinMain
  107. //----------------------------------------------------------------------------
  108. int WINAPI WinMainT(
  109. HINSTANCE hInstance, // handle to current instance
  110. HINSTANCE hPrevInstance, // handle to previous instance
  111. LPSTR lpCmdLine, // pointer to command line
  112. int nCmdShow // show state of window
  113. )
  114. {
  115. // Save the globals
  116. g.hInstance = hInstance;
  117. g.fUninstallOnly = FALSE;
  118. // Parse the command line, for DEBUG options and for uninstall-only switch.
  119. if (!bParseCommandLine(lpCmdLine, nCmdShow))
  120. return 0;
  121. // Run all install/uninstall stubs for browser-only mode.
  122. // If IE4 has been uninstalled, we'll be run with the -u switch; this
  123. // means to run install/uninstall stubs only, no webcheck stuff.
  124. RunInstallUninstallStubs2(NULL);
  125. // Return the exit code to Windows
  126. return 0;
  127. }
  128. //----------------------------------------------------------------------------
  129. // bParseCmdLine
  130. //
  131. // Parse the command line
  132. // -u run install/uninstall stubs only, then quit
  133. // DEBUG options:
  134. // -v visible window (easy to shutdown)
  135. // -a add webcheck to shell service object
  136. // -r remove webcheck from shell service object
  137. // -s fix shell folders only
  138. // -? these options
  139. //----------------------------------------------------------------------------
  140. BOOL bParseCommandLine(LPSTR lpCmdLine, int nCmdShow)
  141. {
  142. if (!lpCmdLine)
  143. return TRUE;
  144. CharUpper(lpCmdLine); /* easier to parse */
  145. while (*lpCmdLine)
  146. {
  147. if (*lpCmdLine != '-' && *lpCmdLine != '/')
  148. break;
  149. lpCmdLine++;
  150. switch (*(lpCmdLine++))
  151. {
  152. case 'U':
  153. g.fUninstallOnly = TRUE;
  154. break;
  155. }
  156. while (*lpCmdLine == ' ' || *lpCmdLine == '\t') {
  157. lpCmdLine++;
  158. }
  159. }
  160. return TRUE;
  161. }