Windows NT 4.0 source code leak
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.

413 lines
8.0 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. rmisc.c
  5. Abstract:
  6. This module contains the server-side misc configuration manager routines.
  7. Author:
  8. Paula Tomlinson (paulat) 6-28-1995
  9. Environment:
  10. User-mode only.
  11. Revision History:
  12. 28-June-1995 paulat
  13. Creation and initial implementation.
  14. --*/
  15. //
  16. // includes
  17. //
  18. #include "precomp.h"
  19. #include "umpnpdat.h"
  20. //
  21. // private prototypes
  22. //
  23. //
  24. // global data
  25. //
  26. CONFIGRET
  27. PNP_GetVersion(
  28. IN handle_t hBinding,
  29. IN OUT WORD * pVersion
  30. )
  31. /*++
  32. Routine Description:
  33. This is the RPC server entry point, it returns the version
  34. number for the server-side component.
  35. Arguments:
  36. hBinding Not used.
  37. Return Value:
  38. Return the version number, with the major version in the high byte and
  39. the minor version number in the low byte.
  40. --*/
  41. {
  42. CONFIGRET Status = CR_SUCCESS;
  43. UNREFERENCED_PARAMETER(hBinding);
  44. try {
  45. *pVersion = (WORD)PNP_VERSION;
  46. } except(EXCEPTION_EXECUTE_HANDLER) {
  47. Status = CR_FAILURE;
  48. }
  49. return Status;
  50. } // PNP_GetVersion
  51. CONFIGRET
  52. PNP_GetGlobalState(
  53. IN handle_t hBinding,
  54. OUT PULONG pulState,
  55. IN ULONG ulFlags
  56. )
  57. /*++
  58. Routine Description:
  59. This is the RPC server entry point, it returns the Global State of the
  60. Configuration Manager.
  61. Arguments:
  62. hBinding Not used.
  63. pulState Returns the current global state.
  64. ulFlags Not used.
  65. Return Value:
  66. Return CR_SUCCESS if the function succeeds, otherwise it returns one
  67. of the CR_* errors.
  68. --*/
  69. {
  70. CONFIGRET Status = CR_SUCCESS;
  71. UNREFERENCED_PARAMETER(hBinding);
  72. UNREFERENCED_PARAMETER(ulFlags);
  73. try {
  74. //
  75. // BUGBUG: For Cairo this will be dynamic
  76. //
  77. *pulState =
  78. CM_GLOBAL_STATE_CAN_DO_UI |
  79. CM_GLOBAL_STATE_SERVICES_AVAILABLE;
  80. } except(EXCEPTION_EXECUTE_HANDLER) {
  81. Status = CR_FAILURE;
  82. }
  83. return Status;
  84. } // PNP_GetGlobalState
  85. CONFIGRET
  86. PNP_SetActiveService(
  87. IN handle_t hBinding,
  88. IN LPCWSTR pszService,
  89. IN ULONG ulFlags
  90. )
  91. /*++
  92. Routine Description:
  93. This routine is currently not an rpc routine, it is called directly
  94. and privately by the service controller.
  95. Arguments:
  96. hBinding Not used.
  97. pszService Specifies the service name.
  98. ulFlags Either PNP_SERVICE_STARTED or PNP_SERVICE_STOPPED.
  99. Return Value:
  100. Return CR_SUCCESS if the function succeeds, otherwise it returns one
  101. of the CR_* errors.
  102. --*/
  103. {
  104. CONFIGRET Status = CR_SUCCESS;
  105. ULONG ulSize = 0, ulStatus = 0;
  106. LPWSTR pDeviceList = NULL, pszDevice = NULL;
  107. HKEY hKey = NULL, hControlKey = NULL;
  108. WCHAR RegStr[MAX_PATH];
  109. UNREFERENCED_PARAMETER(hBinding);
  110. try {
  111. //
  112. // validate parameters
  113. //
  114. if (pszService == NULL) {
  115. Status = CR_INVALID_POINTER;
  116. goto Clean0;
  117. }
  118. if (ulFlags != PNP_SERVICE_STOPPED && ulFlags != PNP_SERVICE_STARTED) {
  119. Status = CR_INVALID_FLAG;
  120. goto Clean0;
  121. }
  122. //
  123. // not handling stops right now, everything beyond here assumes
  124. // the service is starting (or at least it attempted to start)
  125. //
  126. if (ulFlags == PNP_SERVICE_STOPPED) {
  127. goto Clean0; // not handling this right now
  128. }
  129. //
  130. // retreive the list of devices that this service is controlling
  131. //
  132. Status = PNP_GetDeviceListSize(NULL, pszService, &ulSize,
  133. CM_GETIDLIST_FILTER_SERVICE);
  134. if (Status != CR_SUCCESS) {
  135. goto Clean0;
  136. }
  137. pDeviceList = malloc(ulSize * sizeof(WCHAR));
  138. if (pDeviceList == NULL) {
  139. Status = CR_OUT_OF_MEMORY;
  140. goto Clean0;
  141. }
  142. Status = PNP_GetDeviceList(NULL, pszService, pDeviceList, &ulSize,
  143. CM_GETIDLIST_FILTER_SERVICE);
  144. if (Status != CR_SUCCESS) {
  145. goto Clean0;
  146. }
  147. //
  148. // set the ActiveService value for each device
  149. //
  150. for (pszDevice = pDeviceList;
  151. *pszDevice;
  152. pszDevice += lstrlen(pszDevice) + 1) {
  153. wsprintf(RegStr, TEXT("%s\\%s"),
  154. pszRegPathEnum,
  155. pszDevice);
  156. //
  157. // open the device instance key
  158. //
  159. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegStr, 0, KEY_ALL_ACCESS,
  160. &hKey) == ERROR_SUCCESS) {
  161. //
  162. // open/create the volatile Control key
  163. //
  164. if (RegCreateKeyEx(hKey, pszRegKeyDeviceControl, 0, NULL,
  165. REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL,
  166. &hControlKey, NULL) == ERROR_SUCCESS) {
  167. RegSetValueEx(hControlKey, pszRegValueActiveService,
  168. 0, REG_SZ, (LPBYTE)pszService,
  169. (lstrlen(pszService) + 1) * sizeof(WCHAR));
  170. //
  171. // set the statusflag to DN_STARTED
  172. //
  173. ulSize = sizeof(DWORD);
  174. if (RegQueryValueEx(hKey, pszRegValueStatusFlags,
  175. NULL, NULL, (LPBYTE)&ulStatus,
  176. &ulSize) != ERROR_SUCCESS) {
  177. ulStatus = 0;
  178. }
  179. SET_FLAG(ulStatus, DN_STARTED);
  180. RegSetValueEx(hKey, pszRegValueStatusFlags, 0, REG_DWORD,
  181. (LPBYTE)&ulStatus, sizeof(DWORD));
  182. RegCloseKey(hControlKey);
  183. hControlKey = NULL;
  184. }
  185. RegCloseKey(hKey);
  186. hKey = NULL;
  187. }
  188. }
  189. Clean0:
  190. ;
  191. } except(EXCEPTION_EXECUTE_HANDLER) {
  192. Status = CR_FAILURE;
  193. }
  194. if (pDeviceList != NULL) {
  195. free(pDeviceList);
  196. }
  197. if (hKey != NULL) {
  198. RegCloseKey(hKey);
  199. }
  200. return Status;
  201. } // PNP_SetActiveService
  202. //--------------------------------------------------------------------
  203. // Stub server side CM routines - not implemented yet
  204. //--------------------------------------------------------------------
  205. CONFIGRET
  206. PNP_SetHwProf(
  207. IN handle_t hBinding,
  208. IN ULONG ulHardwareProfile,
  209. IN ULONG ulFlags
  210. )
  211. {
  212. UNREFERENCED_PARAMETER(hBinding);
  213. UNREFERENCED_PARAMETER(ulHardwareProfile);
  214. UNREFERENCED_PARAMETER(ulFlags);
  215. return CR_CALL_NOT_IMPLEMENTED;
  216. }
  217. CONFIGRET
  218. PNP_QueryArbitratorFreeData(
  219. IN handle_t hBinding,
  220. OUT LPBYTE pData,
  221. IN ULONG ulDataLen,
  222. IN LPCWSTR pszDeviceID,
  223. IN RESOURCEID ResourceID,
  224. IN ULONG ulFlags
  225. )
  226. {
  227. UNREFERENCED_PARAMETER(hBinding);
  228. UNREFERENCED_PARAMETER(pData);
  229. UNREFERENCED_PARAMETER(ulDataLen);
  230. UNREFERENCED_PARAMETER(pszDeviceID);
  231. UNREFERENCED_PARAMETER(ResourceID);
  232. UNREFERENCED_PARAMETER(ulFlags);
  233. return CR_CALL_NOT_IMPLEMENTED;
  234. }
  235. CONFIGRET
  236. PNP_QueryArbitratorFreeSize(
  237. IN handle_t hBinding,
  238. OUT PULONG pulSize,
  239. IN LPCWSTR pszDeviceID,
  240. IN RESOURCEID ResourceID,
  241. IN ULONG ulFlags
  242. )
  243. {
  244. UNREFERENCED_PARAMETER(hBinding);
  245. UNREFERENCED_PARAMETER(pulSize);
  246. UNREFERENCED_PARAMETER(pszDeviceID);
  247. UNREFERENCED_PARAMETER(ResourceID);
  248. UNREFERENCED_PARAMETER(ulFlags);
  249. return CR_CALL_NOT_IMPLEMENTED;
  250. }
  251. CONFIGRET
  252. PNP_RunDetection(
  253. IN handle_t hBinding,
  254. IN ULONG ulFlags
  255. )
  256. {
  257. UNREFERENCED_PARAMETER(hBinding);
  258. UNREFERENCED_PARAMETER(ulFlags);
  259. return CR_CALL_NOT_IMPLEMENTED;
  260. }
  261. CONFIGRET
  262. PNP_Connect(
  263. IN PNP_HANDLE UNCServerName
  264. )
  265. {
  266. UNREFERENCED_PARAMETER(UNCServerName);
  267. return CR_SUCCESS;
  268. }
  269. CONFIGRET
  270. PNP_Disconnect(
  271. IN PNP_HANDLE UNCServerName
  272. )
  273. {
  274. UNREFERENCED_PARAMETER(UNCServerName);
  275. return CR_SUCCESS;
  276. }