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.

284 lines
3.8 KiB

  1. /*
  2. * valid.c - Validation functions module.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.h"
  7. #pragma hdrstop
  8. /****************************** Public Functions *****************************/
  9. /*
  10. ** IsValidHANDLE()
  11. **
  12. **
  13. **
  14. ** Arguments:
  15. **
  16. ** Returns:
  17. **
  18. ** Side Effects: none
  19. */
  20. PUBLIC_CODE BOOL IsValidHANDLE(HANDLE hnd)
  21. {
  22. return(EVAL(hnd != INVALID_HANDLE_VALUE));
  23. }
  24. /*
  25. ** IsValidHFILE()
  26. **
  27. **
  28. **
  29. ** Arguments:
  30. **
  31. ** Returns:
  32. **
  33. ** Side Effects: none
  34. */
  35. PUBLIC_CODE BOOL IsValidHFILE(HANDLE hf)
  36. {
  37. return(IsValidHANDLE(hf));
  38. }
  39. /*
  40. ** IsValidHWND()
  41. **
  42. **
  43. **
  44. ** Arguments:
  45. **
  46. ** Returns:
  47. **
  48. ** Side Effects: none
  49. */
  50. PUBLIC_CODE BOOL IsValidHWND(HWND hwnd)
  51. {
  52. /* Ask User if this is a valid window. */
  53. return(IsWindow(hwnd));
  54. }
  55. #if defined(DEBUG) || defined(VSTF)
  56. /*
  57. ** IsValidPCSECURITY_ATTRIBUTES()
  58. **
  59. **
  60. **
  61. ** Arguments:
  62. **
  63. ** Returns:
  64. **
  65. ** Side Effects: none
  66. */
  67. PUBLIC_CODE BOOL IsValidPCSECURITY_ATTRIBUTES(PCSECURITY_ATTRIBUTES pcsa)
  68. {
  69. return(IS_VALID_READ_PTR(pcsa, CSECURITY_ATTRIBUTES));
  70. }
  71. /*
  72. ** IsValidFileCreationMode()
  73. **
  74. **
  75. **
  76. ** Arguments:
  77. **
  78. ** Returns:
  79. **
  80. ** Side Effects: none
  81. */
  82. PUBLIC_CODE BOOL IsValidFileCreationMode(DWORD dwMode)
  83. {
  84. BOOL bResult;
  85. switch (dwMode)
  86. {
  87. case CREATE_NEW:
  88. case CREATE_ALWAYS:
  89. case OPEN_EXISTING:
  90. case OPEN_ALWAYS:
  91. case TRUNCATE_EXISTING:
  92. bResult = TRUE;
  93. break;
  94. default:
  95. bResult = FALSE;
  96. ERROR_OUT((TEXT("IsValidFileCreationMode(): Invalid file creation mode %#lx."),
  97. dwMode));
  98. break;
  99. }
  100. return(bResult);
  101. }
  102. /*
  103. ** IsValidHTEMPLATEFILE()
  104. **
  105. **
  106. **
  107. ** Arguments:
  108. **
  109. ** Returns:
  110. **
  111. ** Side Effects: none
  112. */
  113. PUBLIC_CODE BOOL IsValidHTEMPLATEFILE(HANDLE htf)
  114. {
  115. return(IsValidHANDLE(htf));
  116. }
  117. /*
  118. ** IsValidPCFILETIME()
  119. **
  120. **
  121. **
  122. ** Arguments:
  123. **
  124. ** Returns:
  125. **
  126. ** Side Effects: none
  127. */
  128. PUBLIC_CODE BOOL IsValidPCFILETIME(PCFILETIME pcft)
  129. {
  130. return(IS_VALID_READ_PTR(pcft, CFILETIME));
  131. }
  132. #endif
  133. #ifdef DEBUG
  134. /*
  135. ** IsValidHINSTANCE()
  136. **
  137. **
  138. **
  139. ** Arguments:
  140. **
  141. ** Returns:
  142. **
  143. ** Side Effects: none
  144. */
  145. PUBLIC_CODE BOOL IsValidHINSTANCE(HINSTANCE hinst)
  146. {
  147. return(EVAL(hinst));
  148. }
  149. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  150. /*
  151. ** IsValidHICON()
  152. **
  153. **
  154. **
  155. ** Arguments:
  156. **
  157. ** Returns:
  158. **
  159. ** Side Effects: none
  160. */
  161. PUBLIC_CODE BOOL IsValidHICON(HICON hicon)
  162. {
  163. /* Any value is a valid HICON. */
  164. return(TRUE);
  165. }
  166. /*
  167. ** IsValidHKEY()
  168. **
  169. **
  170. **
  171. ** Arguments:
  172. **
  173. ** Returns:
  174. **
  175. ** Side Effects: none
  176. */
  177. PUBLIC_CODE BOOL IsValidHKEY(HKEY hkey)
  178. {
  179. /* Any value is a valid HKEY. */
  180. return(TRUE);
  181. }
  182. /*
  183. ** IsValidHMODULE()
  184. **
  185. **
  186. **
  187. ** Arguments:
  188. **
  189. ** Returns:
  190. **
  191. ** Side Effects: none
  192. */
  193. PUBLIC_CODE BOOL IsValidHMODULE(HMODULE hmod)
  194. {
  195. /* Any non-NULL value is a valid HMODULE. */
  196. return(hmod != NULL);
  197. }
  198. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */
  199. /*
  200. ** IsValidShowWindowCmd()
  201. **
  202. **
  203. **
  204. ** Arguments:
  205. **
  206. ** Returns:
  207. **
  208. ** Side Effects: none
  209. */
  210. PUBLIC_CODE BOOL IsValidShowWindowCmd(int nShow)
  211. {
  212. BOOL bResult;
  213. switch (nShow)
  214. {
  215. case SW_HIDE:
  216. case SW_SHOWNORMAL:
  217. case SW_SHOWMINIMIZED:
  218. case SW_SHOWMAXIMIZED:
  219. case SW_SHOWNOACTIVATE:
  220. case SW_SHOW:
  221. case SW_MINIMIZE:
  222. case SW_SHOWMINNOACTIVE:
  223. case SW_SHOWNA:
  224. case SW_RESTORE:
  225. case SW_SHOWDEFAULT:
  226. bResult = TRUE;
  227. break;
  228. default:
  229. bResult = FALSE;
  230. ERROR_OUT((TEXT("IsValidShowWindowCmd(): Invalid file creation mode %d."),
  231. nShow));
  232. break;
  233. }
  234. return(bResult);
  235. }
  236. #endif