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.

259 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. Generic.c
  5. Abstract:
  6. generic function to used as a filler for unimplemented functions or
  7. a template for new functions
  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. // define action codes here. They are only meaningful in the
  16. // context of this module.
  17. #define AC_GENERIC_MAKE_C2 1
  18. #define AC_GENERIC_MAKE_NOTC2 2
  19. // use this line for security items not required by the C2 doc
  20. #define SECURE C2DLL_SECURE
  21. // use this line for security items required by the C2 doc
  22. // #define SECURE C2DLL_C2
  23. LONG
  24. C2QueryGeneric (
  25. IN LPARAM lParam
  26. )
  27. /*++
  28. Routine Description:
  29. Function called to find out the current state of this configuration
  30. item. This function reads the current state of the item and
  31. sets the C2 Compliance flag and the Status string to reflect
  32. the current value of the configuration item.
  33. Arguments:
  34. Pointer to the Dll data block passed as an LPARAM.
  35. INPUTS:
  36. lActionCode = 0
  37. lActionValue = 0
  38. hWnd = window handle to main app window
  39. lC2Compliance = C2DLL_NOT_SECURE;
  40. szItemName = ItemName as read from C2CONFIG.INF file
  41. szStatusName = Empty String (all null chars) on first
  42. call, previous status on all subsequent
  43. calls
  44. OUTPUTS:
  45. lActionCode = (not used)
  46. lActionValue = (not used)
  47. hWnd = (not changed)
  48. lC2Compliance = Current compliance value
  49. szItemName = (not changed)
  50. szStatusName = string describing current status of this
  51. item
  52. ReturnValue:
  53. ERROR_SUCCESS if the function succeeds otherwise a
  54. WIN32 error is returned if an error occurs
  55. --*/
  56. {
  57. PC2DLL_DATA pC2Data;
  58. if (lParam != 0) {
  59. pC2Data = (PC2DLL_DATA)lParam;
  60. // return message based on flag for now
  61. if (pC2Data->lC2Compliance == SECURE) {
  62. lstrcpy (pC2Data->szStatusName, TEXT("C2 Compliant"));
  63. } else {
  64. lstrcpy (pC2Data->szStatusName, TEXT("NOT C2 Compliant"));
  65. }
  66. } else {
  67. return ERROR_BAD_ARGUMENTS;
  68. }
  69. return ERROR_SUCCESS;
  70. }
  71. LONG
  72. C2SetGeneric (
  73. IN LPARAM lParam
  74. )
  75. /*++
  76. Routine Description:
  77. Function called to change the current state of this configuration
  78. item based on an action code passed in the DLL data block. If
  79. this function successfully sets the state of the configuration
  80. item, then the C2 Compliance flag and the Status string to reflect
  81. the new value of the configuration item.
  82. Arguments:
  83. Pointer to the Dll data block passed as an LPARAM.
  84. INPUTS:
  85. lActionCode = code describing action to take in order to
  86. perform task selected by user.
  87. 0 == no change or no action
  88. lActionValue = value to be used, if necessary, if the
  89. lActionCode is not 0
  90. hWnd = (not changed)
  91. lC2Compliance = (not changed)
  92. szItemName = (not changed)
  93. szStatusName = (not changed)
  94. OUTPUTS:
  95. lActionCode = set to 0
  96. lActionValue = set to 0
  97. hWnd = (not changed)
  98. lC2Compliance = set to the current state (as a result of
  99. the change)
  100. szItemName = (not changed)
  101. szStatusName = set to the current state (as a result of
  102. the change)
  103. ReturnValue:
  104. ERROR_SUCCESS if the function succeeds otherwise a
  105. WIN32 error is returned if an error occurs
  106. --*/
  107. {
  108. PC2DLL_DATA pC2Data;
  109. if (lParam != 0) {
  110. // detect action to take based on action code value
  111. pC2Data = (PC2DLL_DATA)lParam;
  112. switch (pC2Data->lActionCode ) {
  113. case AC_GENERIC_MAKE_C2:
  114. // update data fields to show new state
  115. pC2Data->lC2Compliance = SECURE;
  116. lstrcpy (pC2Data->szStatusName, TEXT("C2 Compliant"));
  117. break;
  118. case AC_GENERIC_MAKE_NOTC2:
  119. // update data fields to show new state
  120. pC2Data->lC2Compliance = C2DLL_NOT_SECURE;
  121. lstrcpy (pC2Data->szStatusName, TEXT("NOT C2 Compliant"));
  122. break;
  123. default:
  124. // no change;
  125. break;
  126. }
  127. } else {
  128. return ERROR_BAD_ARGUMENTS;
  129. }
  130. return ERROR_SUCCESS;
  131. }
  132. LONG
  133. C2DisplayGeneric (
  134. IN LPARAM lParam
  135. )
  136. /*++
  137. Routine Description:
  138. Function called to display more information on the configuration
  139. item and provide the user with the option to change the current
  140. setting (if appropriate). If the User "OK's" out of the UI,
  141. then the action code field in the DLL data block is set to the
  142. appropriate (and configuration item-specific) action code so the
  143. "Set" function can be called to perform the desired action. If
  144. the user Cancels out of the UI, then the Action code field is
  145. set to 0 (no action) and no action is performed.
  146. Arguments:
  147. Pointer to the Dll data block passed as an LPARAM.
  148. INPUTS:
  149. lActionCode = 0
  150. lActionValue = 0
  151. hWnd = the window handle of the main app. window
  152. lC2Compliance = the current compliance value as returned by
  153. the last GetStatusFunction call.
  154. szItemName = the name string for this item as read from
  155. the C2CONFIG.INF file
  156. szStatusName = the string describing the current status of
  157. this item as returned by the last call to
  158. the GetStatusFunction.
  159. OUTPUTS:
  160. lActionCode = code describing action to take in order to
  161. perform task selected by user.
  162. 0 == no change or no action
  163. lActionValue = value to be used, if necessary, if the
  164. lActionCode is not 0
  165. hWnd = (not changed)
  166. lC2Compliance = (not changed)
  167. szItemName = (not changed)
  168. szStatusName = (not changed)
  169. ReturnValue:
  170. ERROR_SUCCESS if the function succeeds otherwise a
  171. WIN32 error is returned if an error occurs
  172. --*/
  173. {
  174. PC2DLL_DATA pC2Data;
  175. TCHAR szMessage[MAX_PATH];
  176. INT nMbResult;
  177. INT nMbOptions;
  178. if (lParam != 0) {
  179. pC2Data = (PC2DLL_DATA)lParam;
  180. } else {
  181. return ERROR_BAD_ARGUMENTS;
  182. }
  183. // configure UI for display
  184. _stprintf (szMessage, GetStringResource (GetDllInstance(), IDS_MAKE_C2_COMPLIANT),
  185. pC2Data->szItemName,
  186. pC2Data->szStatusName,
  187. (pC2Data->lC2Compliance == SECURE ? GetStringResource (GetDllInstance(), IDS_IS_C2_COMPLIANT) : GetStringResource (GetDllInstance(), IDS_IS_NOT_C2_COMPLIANT)));
  188. // configure MessageBox button configuration and defaults
  189. nMbOptions = MB_ICONQUESTION | MB_YESNO | MB_TASKMODAL;
  190. if (pC2Data->lC2Compliance == SECURE ) nMbOptions |= MB_DEFBUTTON2;
  191. // display UI
  192. nMbResult = MessageBox (
  193. pC2Data->hWnd,
  194. szMessage,
  195. "C2 Configuration -- Generic",
  196. nMbOptions);
  197. // set action code for subsequent processing here.
  198. if (nMbResult == IDYES){
  199. pC2Data->lActionCode = AC_GENERIC_MAKE_C2;
  200. } else if (nMbResult == IDNO) {
  201. pC2Data->lActionCode = AC_GENERIC_MAKE_NOTC2;
  202. } else {
  203. pC2Data->lActionCode = 0;
  204. }
  205. return ERROR_SUCCESS;
  206. }