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.

337 lines
9.5 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. OS2SS.C
  5. Abstract:
  6. functions to used to determine if the OS/2 subsystem is present
  7. on the current system.
  8. Author:
  9. Bob Watson (a-robw)
  10. Revision History:
  11. 23 Dec 94
  12. --*/
  13. #include <windows.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <c2dll.h>
  17. #include <c2inc.h>
  18. #include <c2utils.h>
  19. #include "c2funcs.h"
  20. #include "c2funres.h"
  21. // define action codes here. They are only meaningful in the
  22. // context of this module.
  23. #define SECURE C2DLL_C2
  24. static
  25. BOOL
  26. IsOs2OnSystem (
  27. )
  28. {
  29. BOOL bFileFound;
  30. LPCTSTR szFileToCheck;
  31. TCHAR szOs2Path[MAX_PATH];
  32. SET_WAIT_CURSOR;
  33. // check for OS2SS.EXE
  34. szFileToCheck = GetStringResource(GetDllInstance(), IDS_OS2SS_FILE);
  35. GetExpandedFileName (
  36. (LPTSTR)szFileToCheck,
  37. MAX_PATH,
  38. szOs2Path,
  39. NULL);
  40. bFileFound = FileExists(szOs2Path);
  41. if (bFileFound) {
  42. // check to see if it's really there
  43. if (GetFileSizeFromPath(szOs2Path) == 0) {
  44. // just a name so reset flag
  45. bFileFound = FALSE;
  46. }
  47. }
  48. if (!bFileFound) {
  49. // check for OS2.EXE
  50. szFileToCheck = GetStringResource(GetDllInstance(), IDS_OS2_FILE);
  51. GetExpandedFileName (
  52. (LPTSTR)szFileToCheck,
  53. MAX_PATH,
  54. szOs2Path,
  55. NULL);
  56. bFileFound = FileExists(szOs2Path);
  57. if (bFileFound) {
  58. // check to see if it's really there
  59. if (GetFileSizeFromPath(szOs2Path) == 0) {
  60. // just a name so reset flag
  61. bFileFound = FALSE;
  62. }
  63. }
  64. }
  65. SET_ARROW_CURSOR;
  66. return bFileFound;
  67. }
  68. LONG
  69. C2QueryOs2ss (
  70. IN LPARAM lParam
  71. )
  72. /*++
  73. Routine Description:
  74. Function called to find out if the OS/2 subsystem is installed
  75. on the system. For C2 compliance, OS/2 must not be
  76. allowed on the system.
  77. Arguments:
  78. Pointer to the Dll data block passed as an LPARAM.
  79. ReturnValue:
  80. ERROR_SUCCESS if the function succeeds otherwise a
  81. WIN32 error is returned if an error occurs
  82. --*/
  83. {
  84. PC2DLL_DATA pC2Data;
  85. if (lParam != 0) {
  86. pC2Data = (PC2DLL_DATA)lParam;
  87. pC2Data->lC2Compliance = SECURE; // assume true for now
  88. // check for DOS files found on system
  89. if (IsOs2OnSystem()) {
  90. pC2Data->lC2Compliance = C2DLL_NOT_SECURE;
  91. lstrcpy (pC2Data->szStatusName,
  92. GetStringResource (GetDllInstance(), IDS_OS2_ON_SYSTEM));
  93. }
  94. if (pC2Data->lC2Compliance == SECURE) {
  95. lstrcpy (pC2Data->szStatusName,
  96. GetStringResource (GetDllInstance(), IDS_OS2_NOT_ON_SYSTEM));
  97. }
  98. } else {
  99. return ERROR_BAD_ARGUMENTS;
  100. }
  101. return ERROR_SUCCESS;
  102. }
  103. LONG
  104. C2SetOs2ss (
  105. IN LPARAM lParam
  106. )
  107. /*++
  108. Routine Description:
  109. Function called to change the current state of this configuration
  110. item based on an action code passed in the DLL data block. If
  111. this function successfully sets the state of the configuration
  112. item, then the C2 Compliance flag and the Status string to reflect
  113. the new value of the configuration item.
  114. Arguments:
  115. Pointer to the Dll data block passed as an LPARAM.
  116. ReturnValue:
  117. ERROR_SUCCESS if the function succeeds otherwise a
  118. WIN32 error is returned if an error occurs
  119. --*/
  120. {
  121. PC2DLL_DATA pC2Data;
  122. LPCTSTR szFileToCheck;
  123. TCHAR szOldPath[MAX_PATH];
  124. TCHAR szNewPath[MAX_PATH];
  125. int nMbReturn = 0;
  126. BOOL bReturn;
  127. BOOL bDisplayMessageBox = TRUE;
  128. LONG lReturn = ERROR_SUCCESS;
  129. if (lParam != 0) {
  130. pC2Data = (PC2DLL_DATA)lParam;
  131. if (pC2Data->lActionCode == 1) {
  132. while (bDisplayMessageBox) {
  133. nMbReturn = DisplayDllMessageBox (
  134. pC2Data->hWnd,
  135. IDS_OS2_CONFIRM,
  136. IDS_OS2_CAPTION,
  137. MBOKCANCEL_EXCLAIM |
  138. /* WinVer >= 4.0 only
  139. MB_HELP |
  140. */
  141. MB_DEFBUTTON2);
  142. switch (nMbReturn) {
  143. case IDOK:
  144. SET_WAIT_CURSOR;
  145. szFileToCheck = GetStringResource(
  146. GetDllInstance(), IDS_OS2SS_FILE);
  147. GetExpandedFileName (
  148. (LPTSTR)szFileToCheck,
  149. MAX_PATH,
  150. szOldPath,
  151. NULL);
  152. if (FileExists (szOldPath)) {
  153. szFileToCheck = GetStringResource(
  154. GetDllInstance(), IDS_NEW_OS2SS_FILE);
  155. GetExpandedFileName (
  156. (LPTSTR)szFileToCheck,
  157. MAX_PATH,
  158. szNewPath,
  159. NULL);
  160. bReturn = DeleteFile (szOldPath);
  161. } else {
  162. // if the file does not exist, then that's ok too.
  163. bReturn = TRUE;
  164. }
  165. if (bReturn) {
  166. // then all went OK so change the other file now
  167. szFileToCheck = GetStringResource(
  168. GetDllInstance(), IDS_OS2_FILE);
  169. GetExpandedFileName (
  170. (LPTSTR)szFileToCheck,
  171. MAX_PATH,
  172. szOldPath,
  173. NULL);
  174. if (FileExists (szOldPath)) {
  175. szFileToCheck = GetStringResource(
  176. GetDllInstance(), IDS_NEW_OS2_FILE);
  177. GetExpandedFileName (
  178. (LPTSTR)szFileToCheck,
  179. MAX_PATH,
  180. szNewPath,
  181. NULL);
  182. bReturn = DeleteFile (szOldPath);
  183. } else {
  184. // if the file does not exist, then that's ok too.
  185. bReturn = TRUE;
  186. }
  187. }
  188. if (bReturn) {
  189. // then all files have been renamed so update message
  190. pC2Data->lC2Compliance = SECURE;
  191. lstrcpy (pC2Data->szStatusName,
  192. GetStringResource (GetDllInstance(),
  193. IDS_OS2_NOT_ON_SYSTEM));
  194. lReturn = ERROR_SUCCESS;
  195. } else {
  196. DisplayDllMessageBox (
  197. pC2Data->hWnd,
  198. IDS_OS2_ERROR_MOVING,
  199. IDS_OS2_CAPTION,
  200. MBOK_EXCLAIM);
  201. lReturn = ERROR_CAN_NOT_COMPLETE;
  202. }
  203. SET_ARROW_CURSOR;
  204. bDisplayMessageBox = FALSE;
  205. break;
  206. case IDCANCEL:
  207. bDisplayMessageBox = FALSE;
  208. break;
  209. /* WinVer >= 4.00 only
  210. case IDHELP:
  211. PostMessage (pC2Data->hWnd, UM_SHOW_CONTEXT_HELP, 0, 0);
  212. break;
  213. */
  214. }
  215. pC2Data->lActionCode = 0;
  216. } // end while Show Message Box
  217. }
  218. } else {
  219. lReturn = ERROR_BAD_ARGUMENTS;
  220. }
  221. return lReturn;
  222. }
  223. LONG
  224. C2DisplayOs2ss (
  225. IN LPARAM lParam
  226. )
  227. /*++
  228. Routine Description:
  229. Function called to display more information on the configuration
  230. item and provide the user with the option to change the current
  231. setting (if appropriate). If the User "OK's" out of the UI,
  232. then the action code field in the DLL data block is set to the
  233. appropriate (and configuration item-specific) action code so the
  234. "Set" function can be called to perform the desired action. If
  235. the user Cancels out of the UI, then the Action code field is
  236. set to 0 (no action) and no action is performed.
  237. Arguments:
  238. Pointer to the Dll data block passed as an LPARAM.
  239. ReturnValue:
  240. ERROR_SUCCESS if the function succeeds otherwise a
  241. WIN32 error is returned if an error occurs
  242. --*/
  243. {
  244. PC2DLL_DATA pC2Data;
  245. if (lParam != 0) {
  246. pC2Data = (PC2DLL_DATA)lParam;
  247. // check the C2 Compliance flag to see if the list box or
  248. // message box should be displayed
  249. if (pC2Data->lC2Compliance == SECURE) {
  250. // all volumes are OK so just pop a message box
  251. DisplayDllMessageBox (
  252. pC2Data->hWnd,
  253. IDS_OS2_NOT_ON_SYSTEM,
  254. IDS_OS2_CAPTION,
  255. MBOK_INFO);
  256. pC2Data->lActionCode = 0;
  257. } else {
  258. if (DisplayDllMessageBox (
  259. pC2Data->hWnd,
  260. IDS_OS2_DISPLAY_MESSAGE,
  261. IDS_OS2_CAPTION,
  262. MBOKCANCEL_EXCLAIM) == IDOK) {
  263. pC2Data->lActionCode = 1;
  264. } else {
  265. pC2Data->lActionCode = 0;
  266. }
  267. }
  268. } else {
  269. return ERROR_BAD_ARGUMENTS;
  270. }
  271. return ERROR_SUCCESS;
  272. }
  273. 
  274.