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.

77 lines
1.9 KiB

  1. /*
  2. Astub.cpp
  3. */
  4. #include "windows.h"
  5. #include "shlwapi.h"
  6. #include "badstrfunctions.h"
  7. #define ARRAYSIZE(_exp_) (sizeof(_exp_) / sizeof(_exp_[0]))
  8. static LPCTSTR c_rgszEXEList[] =
  9. {
  10. TEXT("internal.exe\" /Q"),
  11. TEXT("wabinst.exe\" /R:N /Q"),
  12. TEXT("setup50.exe\" /app:oe /install /prompt"),
  13. #if defined(_X86_)
  14. TEXT("polmod.exe\" /R:N /Q"),
  15. #endif
  16. };
  17. BOOL CreateProcessAndWait(LPTSTR pszExe, DWORD *pdwRetValue)
  18. {
  19. BOOL fOK = FALSE;
  20. PROCESS_INFORMATION pi;
  21. STARTUPINFO sti;
  22. // Initialize
  23. ZeroMemory(&sti, sizeof(sti));
  24. sti.cb = sizeof(sti);
  25. *pdwRetValue = 0;
  26. if (CreateProcess(NULL, pszExe, NULL, NULL, FALSE, 0, NULL, NULL, &sti, &pi))
  27. {
  28. WaitForSingleObject(pi.hProcess, INFINITE);
  29. GetExitCodeProcess(pi.hProcess, pdwRetValue);
  30. CloseHandle(pi.hThread);
  31. CloseHandle(pi.hProcess);
  32. fOK = TRUE;
  33. }
  34. return fOK;
  35. }
  36. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  37. {
  38. TCHAR szExe[MAX_PATH];
  39. int iEnd, i;
  40. DWORD dw;
  41. BOOL fNeedReboot = FALSE;
  42. // Figure out the dir we are running from
  43. // Start with a quote so we can wrap the filename to deal with spaces
  44. // Trailing quote is embedded in the string to run.
  45. szExe[0] = TEXT('\"');
  46. GetModuleFileName(NULL, &szExe[1], ARRAYSIZE(szExe) - 1);
  47. PathRemoveFileSpec(&szExe[1]);
  48. iEnd = lstrlen(szExe);
  49. szExe[iEnd++] = '\\';
  50. // Run each package sequentially
  51. for (i = 0; i < ARRAYSIZE(c_rgszEXEList); i++)
  52. {
  53. // Append exe name and args to dir path
  54. StrCpyN(&szExe[iEnd], c_rgszEXEList[i], ARRAYSIZE(szExe)-iEnd);
  55. CreateProcessAndWait(szExe, &dw);
  56. if (ERROR_SUCCESS_REBOOT_REQUIRED == dw)
  57. fNeedReboot = TRUE;
  58. }
  59. return (fNeedReboot ? ERROR_SUCCESS_REBOOT_REQUIRED : S_OK);
  60. }