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.

303 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. Other.c
  5. Abstract:
  6. Displays a dialog box of items that are required but not detectable
  7. from the program
  8. Revision History:
  9. 23 Dec 94 Created
  10. --*/
  11. #include <windows.h> // standard Windows includes
  12. #include <tchar.h> // for UNICODE/ANSI compatiblity
  13. #include <stdio.h> // text formatting & display functions
  14. #include <c2dll.h> // DLL interface definitions
  15. #include "c2funcs.h" // local functions & definitions
  16. #include "c2funres.h" // local resources
  17. #include "c2utils.h" // local utilities
  18. // define action codes here. They are only meaningful in the
  19. // context of this module.
  20. #define AC_OTHER_NO_ACTION 0
  21. #define AC_OTHER_MAKE_C2 1
  22. #define AC_OTHER_MAKE_NOTC2 2
  23. // use this line for security items not required by the C2 doc
  24. //#define SECURE C2DLL_SECURE
  25. // use this line for security items required by the C2 doc
  26. #define SECURE C2DLL_C2
  27. BOOL CALLBACK
  28. C2OtherItemsDlgProc(
  29. IN HWND hDlg, // window handle of the dialog box
  30. IN UINT message, // type of message
  31. IN WPARAM wParam,
  32. IN LPARAM lParam
  33. )
  34. /*++
  35. Routine Description:
  36. Dialog procedure for Other Security Items dialog box
  37. Arguments:
  38. Standard DlgProc arguments
  39. ReturnValue:
  40. TRUE the message was handled by this routine
  41. FALSE DefDialogProc should handle the message
  42. --*/
  43. {
  44. static LPDWORD lpdwNewValue;
  45. DWORD dwLogSetting = 0;
  46. switch (message) {
  47. case WM_INITDIALOG:
  48. // save the pointer to the new value
  49. lpdwNewValue = (LPDWORD)lParam;
  50. SetFocus (GetDlgItem (hDlg, IDOK)); // set focus to OK Button
  51. return FALSE; // we don't want Windows to set the focus
  52. case WM_COMMAND:
  53. switch (LOWORD(wParam)){
  54. case IDOK:
  55. if (HIWORD(wParam) == BN_CLICKED) {
  56. // exit and return button that caused exit
  57. *lpdwNewValue = 0; // clear value
  58. EndDialog (hDlg, (int)LOWORD(wParam));
  59. return TRUE;
  60. } else {
  61. return FALSE;
  62. }
  63. case IDCANCEL:
  64. if (HIWORD(wParam) == BN_CLICKED) {
  65. // exit and return button that caused exit
  66. *lpdwNewValue = 0;
  67. EndDialog (hDlg, (int)LOWORD(wParam));
  68. return TRUE;
  69. } else {
  70. return FALSE;
  71. }
  72. case IDC_HELP:
  73. PostMessage (GetParent(hDlg), UM_SHOW_CONTEXT_HELP, 0, 0);
  74. return TRUE;
  75. default:
  76. return FALSE;
  77. }
  78. default:
  79. return (FALSE); // Didn't process the message
  80. }
  81. }
  82. LONG
  83. C2QueryOtherItems (
  84. IN LPARAM lParam
  85. )
  86. /*++
  87. Routine Description:
  88. Function called to find out the current state of this configuration
  89. item. This function reads the current state of the item and
  90. sets the C2 Compliance flag and the Status string to reflect
  91. the current value of the configuration item.
  92. Arguments:
  93. Pointer to the Dll data block passed as an LPARAM.
  94. INPUTS:
  95. lActionCode = 0
  96. lActionValue = 0
  97. hWnd = window handle to main app window
  98. lC2Compliance = C2DLL_NOT_SECURE;
  99. szItemName = ItemName as read from C2CONFIG.INF file
  100. szStatusName = Empty String (all null chars) on first
  101. call, previous status on all subsequent
  102. calls
  103. OUTPUTS:
  104. lActionCode = (not used)
  105. lActionValue = (not used)
  106. hWnd = (not changed)
  107. lC2Compliance = Current compliance value
  108. szItemName = (not changed)
  109. szStatusName = string describing current status of this
  110. item
  111. ReturnValue:
  112. ERROR_SUCCESS if the function succeeds otherwise a
  113. WIN32 error is returned if an error occurs
  114. --*/
  115. {
  116. PC2DLL_DATA pC2Data;
  117. if (lParam != 0) {
  118. pC2Data = (PC2DLL_DATA)lParam;
  119. pC2Data->lC2Compliance = C2DLL_UNKNOWN;
  120. lstrcpy (pC2Data->szStatusName,
  121. GetStringResource (GetDllInstance(),IDS_UNABLE_READ));
  122. } else {
  123. return ERROR_BAD_ARGUMENTS;
  124. }
  125. return ERROR_SUCCESS;
  126. }
  127. LONG
  128. C2SetOtherItems (
  129. IN LPARAM lParam
  130. )
  131. /*++
  132. Routine Description:
  133. Function called to change the current state of this configuration
  134. item based on an action code passed in the DLL data block. If
  135. this function successfully sets the state of the configuration
  136. item, then the C2 Compliance flag and the Status string to reflect
  137. the new value of the configuration item.
  138. Arguments:
  139. Pointer to the Dll data block passed as an LPARAM.
  140. INPUTS:
  141. lActionCode = code describing action to take in order to
  142. perform task selected by user.
  143. 0 == no change or no action
  144. lActionValue = value to be used, if necessary, if the
  145. lActionCode is not 0
  146. hWnd = (not changed)
  147. lC2Compliance = (not changed)
  148. szItemName = (not changed)
  149. szStatusName = (not changed)
  150. OUTPUTS:
  151. lActionCode = set to 0
  152. lActionValue = set to 0
  153. hWnd = (not changed)
  154. lC2Compliance = set to the current state (as a result of
  155. the change)
  156. szItemName = (not changed)
  157. szStatusName = set to the current state (as a result of
  158. the change)
  159. ReturnValue:
  160. ERROR_SUCCESS if the function succeeds otherwise a
  161. WIN32 error is returned if an error occurs
  162. --*/
  163. {
  164. PC2DLL_DATA pC2Data;
  165. if (lParam != 0) {
  166. // detect action to take based on action code value
  167. pC2Data = (PC2DLL_DATA)lParam;
  168. // this function NEVER changes anything
  169. pC2Data->lC2Compliance = C2DLL_UNKNOWN;
  170. lstrcpy (pC2Data->szStatusName,
  171. GetStringResource (GetDllInstance(),IDS_UNABLE_READ));
  172. } else {
  173. return ERROR_BAD_ARGUMENTS;
  174. }
  175. return ERROR_SUCCESS;
  176. }
  177. LONG
  178. C2DisplayOtherItems (
  179. IN LPARAM lParam
  180. )
  181. /*++
  182. Routine Description:
  183. Function called to display more information on the configuration
  184. item and provide the user with the option to change the current
  185. setting (if appropriate). If the User "OK's" out of the UI,
  186. then the action code field in the DLL data block is set to the
  187. appropriate (and configuration item-specific) action code so the
  188. "Set" function can be called to perform the desired action. If
  189. the user Cancels out of the UI, then the Action code field is
  190. set to 0 (no action) and no action is performed.
  191. Arguments:
  192. Pointer to the Dll data block passed as an LPARAM.
  193. INPUTS:
  194. lActionCode = 0
  195. lActionValue = 0
  196. hWnd = the window handle of the main app. window
  197. lC2Compliance = the current compliance value as returned by
  198. the last GetStatusFunction call.
  199. szItemName = the name string for this item as read from
  200. the C2CONFIG.INF file
  201. szStatusName = the string describing the current status of
  202. this item as returned by the last call to
  203. the GetStatusFunction.
  204. OUTPUTS:
  205. lActionCode = code describing action to take in order to
  206. perform task selected by user.
  207. 0 == no change or no action
  208. lActionValue = value to be used, if necessary, if the
  209. lActionCode is not 0
  210. hWnd = (not changed)
  211. lC2Compliance = (not changed)
  212. szItemName = (not changed)
  213. szStatusName = (not changed)
  214. ReturnValue:
  215. ERROR_SUCCESS if the function succeeds otherwise a
  216. WIN32 error is returned if an error occurs
  217. --*/
  218. {
  219. PC2DLL_DATA pC2Data;
  220. TCHAR szMessage[MAX_PATH];
  221. INT nMbResult;
  222. INT nMbOptions;
  223. DWORD dwNewValue = 0;
  224. if (lParam != 0) {
  225. pC2Data = (PC2DLL_DATA)lParam;
  226. if (DialogBoxParam (
  227. GetDllInstance(),
  228. MAKEINTRESOURCE (IDD_OTHER_ITEMS),
  229. pC2Data->hWnd,
  230. C2OtherItemsDlgProc,
  231. (LPARAM)&dwNewValue) == IDOK) {
  232. // this dialog does not change anything.
  233. pC2Data->lActionCode = AC_OTHER_NO_ACTION;
  234. } else {
  235. // no action
  236. pC2Data->lActionCode = AC_OTHER_NO_ACTION;
  237. }
  238. pC2Data->lActionValue = 0;
  239. } else {
  240. return ERROR_BAD_ARGUMENTS;
  241. }
  242. return ERROR_SUCCESS;
  243. }
  244.