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.

109 lines
3.5 KiB

  1. #include "isignup.h"
  2. #include "icw.h"
  3. #include "appdefs.h"
  4. BOOL UseICWForIEAK(TCHAR* szIEAKFileName)
  5. {
  6. TCHAR szUseICW[2] = TEXT("\0");
  7. //If we can't find this section it the isp file we'll assume "no".
  8. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_USEICW, TEXT("0"), szUseICW, 2, szIEAKFileName);
  9. return (BOOL)_ttoi(szUseICW);
  10. }
  11. void LocateICWFromReigistry(TCHAR* pszICWLocation, size_t size)
  12. {
  13. HKEY hKey = NULL;
  14. TCHAR szICWPath[MAX_PATH] = TEXT("");
  15. DWORD dwcbPath = sizeof(szICWPath);
  16. //Look fo the ICW in the app paths
  17. if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, ICW50_PATHKEY, 0, KEY_QUERY_VALUE, &hKey)) == ERROR_SUCCESS)
  18. {
  19. //get the default for the key
  20. RegQueryValueEx(hKey, NULL , NULL, NULL, (BYTE *)szICWPath, (DWORD *)&dwcbPath);
  21. }
  22. if (hKey)
  23. RegCloseKey(hKey);
  24. lstrcpyn(pszICWLocation, szICWPath, size / sizeof(pszICWLocation[0]));
  25. }
  26. void RunICWinIEAKMode(TCHAR* pszIEAKFileName)
  27. {
  28. //this must be big enough to hold the path to the icw as well as
  29. //the ieak file
  30. TCHAR szCmdLine[MAX_PATH * 4 + 8];
  31. TCHAR szICWPath[MAX_PATH + 1] = TEXT("");
  32. STARTUPINFO si;
  33. PROCESS_INFORMATION pi;
  34. MSG msg;
  35. DWORD iWaitResult = 0;
  36. BOOL bRetVal = FALSE;
  37. memset(&pi, 0, sizeof(pi));
  38. memset(&si, 0, sizeof(si));
  39. //Get the path to the icw
  40. LocateICWFromReigistry(szICWPath, sizeof(szICWPath));
  41. if (szICWPath[0] != TEXT('\0'))
  42. {
  43. if ((szICWPath[0] != TEXT('\"')) ||
  44. (szICWPath[lstrlen(szICWPath) - 1] != TEXT('\"')))
  45. {
  46. //use quotes in case there are spaces
  47. lstrcpy(szCmdLine, TEXT("\""));
  48. lstrcat(szCmdLine, szICWPath);
  49. lstrcat(szCmdLine, TEXT("\" "));
  50. }
  51. else
  52. {
  53. lstrcpy(szCmdLine, szICWPath);
  54. lstrcat(szCmdLine, TEXT(" "));
  55. }
  56. //set the IEAK switch, pass in the path to the file
  57. //used to invoke isign32
  58. lstrcat(szCmdLine, ICW_IEAK_CMD);
  59. lstrcat(szCmdLine, TEXT(" \""));
  60. lstrcat(szCmdLine, pszIEAKFileName);
  61. lstrcat(szCmdLine, TEXT("\""));
  62. if(CreateProcess(NULL,
  63. szCmdLine,
  64. NULL,
  65. NULL,
  66. TRUE,
  67. 0,
  68. NULL,
  69. NULL,
  70. &si,
  71. &pi))
  72. {
  73. // wait for event or msgs. Dispatch msgs. Exit when event is signalled.
  74. while((iWaitResult=MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLINPUT))==(WAIT_OBJECT_0 + 1))
  75. {
  76. // read all of the messages in this next loop
  77. // removing each message as we read it
  78. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  79. {
  80. // how to handle quit message?
  81. if (msg.message == WM_QUIT)
  82. {
  83. CloseHandle(pi.hThread);
  84. CloseHandle(pi.hProcess);
  85. }
  86. else
  87. DispatchMessage(&msg);
  88. }
  89. }
  90. CloseHandle(pi.hThread);
  91. CloseHandle(pi.hProcess);
  92. }
  93. }
  94. }