Leaked source code of windows server 2003
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.

157 lines
4.3 KiB

  1. #include <windows.h>
  2. #include <shellapi.h>
  3. //-------------------------------------------------------------------------
  4. //
  5. // P A T H R E M O V E F I L E S P E C
  6. //
  7. //
  8. // Removes the file name from a path
  9. //-------------------------------------------------------------------------
  10. BOOL _PathRemoveFileSpec(LPSTR pFile)
  11. {
  12. LPSTR pT;
  13. LPSTR pT2 = pFile;
  14. for (pT = pT2; *pT2; pT2 = CharNext(pT2)) {
  15. if (*pT2 == '\\')
  16. pT = pT2; // last "\" found, (we will strip here)
  17. else if (*pT2 == ':') { // skip ":\" so we don't
  18. if (pT2[1] =='\\') // strip the "\" from "C:\"
  19. pT2++;
  20. pT = pT2 + 1;
  21. }
  22. }
  23. if (*pT == 0)
  24. return FALSE; // didn't strip anything
  25. //
  26. // handle the \foo case
  27. //
  28. else if ((pT == pFile) && (*pT == '\\')) {
  29. // Is it just a '\'?
  30. if (*(pT+1) != '\0') {
  31. // Nope.
  32. *(pT+1) = '\0';
  33. return TRUE; // stripped something
  34. }
  35. else {
  36. // Yep.
  37. return FALSE;
  38. }
  39. }
  40. else {
  41. *pT = 0;
  42. return TRUE; // stripped something
  43. }
  44. }
  45. //-------------------------------------------------------------------------
  46. //
  47. // E X E C A P P
  48. //
  49. //
  50. // Executes and application and returns the process handle
  51. //-------------------------------------------------------------------------
  52. HANDLE ExecApp( char *command, char *params, char *dir, int nWinState )
  53. {
  54. SHELLEXECUTEINFO sei;
  55. sei.fMask = SEE_MASK_NOCLOSEPROCESS;
  56. sei.hwnd = NULL;
  57. sei.lpVerb = "Open";
  58. sei.lpFile = command;
  59. sei.lpParameters = params;
  60. sei.lpDirectory = dir;
  61. sei.nShow = nWinState;
  62. sei.cbSize = sizeof(sei);
  63. if( ShellExecuteEx(&sei) )
  64. return sei.hProcess;
  65. return NULL;
  66. }
  67. int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
  68. {
  69. HKEY hkRegKey;
  70. DWORD dwType;
  71. DWORD dwLength=MAX_PATH;
  72. char szIEPath[MAX_PATH];
  73. char szDir[MAX_PATH];
  74. char szParams[MAX_PATH];
  75. HANDLE hProcess;
  76. if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", 0, KEY_ALL_ACCESS, &hkRegKey ) != ERROR_SUCCESS)
  77. //we're toast
  78. goto get_out;
  79. RegQueryValueEx( hkRegKey, "", NULL, &dwType, szIEPath, &dwLength );
  80. RegCloseKey( hkRegKey );
  81. _PathRemoveFileSpec( szIEPath );
  82. lstrcat( szIEPath, "\\signup" );
  83. lstrcpy( szDir, szIEPath );
  84. lstrcat( szIEPath, "\\signup.htm" );
  85. wsprintf( szParams, "-h %s", szIEPath );
  86. hProcess = ExecApp( "ISIGNUP.EXE", szParams, szDir, SW_SHOWNORMAL );
  87. if( hProcess )
  88. {
  89. DWORD dwResult;
  90. while((dwResult=MsgWaitForMultipleObjects(1, &hProcess, FALSE, INFINITE, QS_ALLINPUT))==(WAIT_OBJECT_0 + 1))
  91. {
  92. MSG msg;
  93. // read all of the messages in this next loop
  94. // removing each message as we read it
  95. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  96. {
  97. if( msg.message == WM_QUIT )
  98. goto get_out;
  99. DefWindowProc( msg.hwnd, msg.message, msg.wParam, msg.lParam );
  100. }
  101. }
  102. }
  103. get_out:
  104. return 0;
  105. }
  106. int _stdcall ModuleEntry(void)
  107. {
  108. int i;
  109. STARTUPINFO si;
  110. LPSTR pszCmdLine = GetCommandLine();
  111. if ( *pszCmdLine == '\"' ) {
  112. /*
  113. * Scan, and skip over, subsequent characters until
  114. * another double-quote or a null is encountered.
  115. */
  116. while ( *++pszCmdLine && (*pszCmdLine != '\"') )
  117. ;
  118. /*
  119. * If we stopped on a double-quote (usual case), skip
  120. * over it.
  121. */
  122. if ( *pszCmdLine == '\"' )
  123. pszCmdLine++;
  124. }
  125. else {
  126. while (*pszCmdLine > ' ')
  127. pszCmdLine++;
  128. }
  129. /*
  130. * Skip past any white space preceeding the second token.
  131. */
  132. while (*pszCmdLine && (*pszCmdLine <= ' ')) {
  133. pszCmdLine++;
  134. }
  135. si.dwFlags = 0;
  136. GetStartupInfoA(&si);
  137. i = WinMain(GetModuleHandle(NULL), NULL, pszCmdLine,
  138. si.dwFlags & STARTF_USESHOWWINDOW ? si.wShowWindow : SW_SHOWDEFAULT);
  139. ExitProcess(i);
  140. return i; // We never comes here.
  141. }