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.

101 lines
2.5 KiB

  1. #include "stdafx.h"
  2. /*
  3. #include <nt.h>
  4. #include <ntrtl.h>
  5. #include <nturtl.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <windows.h>
  10. #include <tchar.h>
  11. */
  12. #include <shellapi.h>
  13. #include <shlobj.h>
  14. //#include "..\setup\inc\logmsg.h"
  15. #include "..\setup\inc\registry.h"
  16. LPCTSTR RUN_KEY = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  17. LPCTSTR HELP_POPUPRUN_VALUE = _T("TerminalServerInstalled");
  18. LPCTSTR HELP_PUPUP_COMMAND = _T("rundll32.exe %windir%\\system32\\tscc.dll, TSCheckList");
  19. BOOL IsCallerAdmin( VOID )
  20. {
  21. BOOL bFoundAdmin = FALSE;
  22. PSID pSid;
  23. //
  24. // If the admin sid didn't initialize, the service would not have started.
  25. //
  26. SID_IDENTIFIER_AUTHORITY SidAuthority = SECURITY_NT_AUTHORITY;
  27. if (AllocateAndInitializeSid(
  28. &SidAuthority,
  29. 2,
  30. SECURITY_BUILTIN_DOMAIN_RID,
  31. DOMAIN_ALIAS_RID_ADMINS,
  32. 0, 0, 0, 0, 0, 0,
  33. &pSid
  34. ))
  35. {
  36. ASSERT(pSid != NULL);
  37. if (!CheckTokenMembership(NULL, pSid, &bFoundAdmin))
  38. {
  39. bFoundAdmin = FALSE;
  40. }
  41. FreeSid(pSid);
  42. }
  43. return bFoundAdmin;
  44. }
  45. void TSCheckList()
  46. {
  47. if (!IsCallerAdmin())
  48. {
  49. return;
  50. }
  51. const TCHAR szHelpDir[] = _T("%windir%\\Help");
  52. const TCHAR szHelpCommand[] = _T("ms-its:%windir%\\help\\termsrv.chm::/ts_checklist_top.htm");
  53. TCHAR szHelpDirEx[MAX_PATH];
  54. if (!ExpandEnvironmentStrings(
  55. szHelpDir,
  56. szHelpDirEx,
  57. sizeof(szHelpDirEx)/sizeof(szHelpDirEx[0])))
  58. {
  59. return;
  60. }
  61. TCHAR szHelpCommandEx[1024];
  62. if (!ExpandEnvironmentStrings(
  63. szHelpCommand,
  64. szHelpCommandEx,
  65. sizeof(szHelpCommandEx)/sizeof(szHelpCommandEx[0])))
  66. {
  67. return;
  68. }
  69. //
  70. // now delete the Run registry entry, and execute the command stored in it.
  71. //
  72. CRegistry oReg;
  73. DWORD dwError = oReg.OpenKey(HKEY_LOCAL_MACHINE, RUN_KEY);
  74. if (dwError == ERROR_SUCCESS)
  75. {
  76. dwError = oReg.DeleteValue(HELP_POPUPRUN_VALUE);
  77. if (dwError == ERROR_SUCCESS)
  78. {
  79. ShellExecute(NULL,
  80. TEXT("open"),
  81. _T("hh.exe"),
  82. szHelpCommandEx,
  83. szHelpDirEx,
  84. SW_SHOW);
  85. }
  86. }
  87. }