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.

219 lines
5.6 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. rconflist.c
  5. Abstract:
  6. This module contains the server-side conflict list reporting APIs.
  7. PNP_QueryResConfList
  8. Author:
  9. Paula Tomlinson (paulat) 9-27-1995
  10. Environment:
  11. User-mode only.
  12. Revision History:
  13. 27-Sept-1995 paulat
  14. Creation and initial implementation.
  15. --*/
  16. //
  17. // includes
  18. //
  19. #include "precomp.h"
  20. #pragma hdrstop
  21. #include "umpnpi.h"
  22. //
  23. // private prototypes
  24. //
  25. CONFIGRET
  26. ResDesToNtResource(
  27. IN PCVOID ResourceData,
  28. IN RESOURCEID ResourceID,
  29. IN ULONG ResourceLen,
  30. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR pResDes,
  31. IN ULONG ulTag,
  32. IN ULONG ulFlags
  33. );
  34. ULONG
  35. GetResDesSize(
  36. IN ULONG ResourceID,
  37. IN ULONG ulFlags
  38. );
  39. CONFIGRET
  40. PNP_QueryResConfList(
  41. IN handle_t hBinding,
  42. IN LPWSTR pDeviceID,
  43. IN RESOURCEID ResourceID,
  44. IN LPBYTE ResourceData,
  45. IN ULONG ResourceLen,
  46. OUT LPBYTE clBuffer,
  47. IN ULONG clBufferLen,
  48. IN ULONG ulFlags
  49. )
  50. /*++
  51. Routine Description:
  52. This the server-side of an RPC remote call. This routine retrieves
  53. conflict information for a specified resource.
  54. Arguments:
  55. hBinding RPC binding handle.
  56. pDeviceID Null-terminated device instance id string.
  57. ResourceID Type of resource, ResType_xxxx
  58. ResourceData Resource specific data
  59. ResourceLen length of ResourceData
  60. clBuffer Buffer filled with conflict list
  61. clBufferLen Size of clBuffer
  62. ulFlags Specifies the width of certain variable-size resource
  63. descriptor structure fields, where applicable.
  64. Currently, the following flags are defined:
  65. CM_RESDES_WIDTH_32 or
  66. CM_RESDES_WIDTH_64
  67. If no flags are specified, the width of the variable-sized
  68. resource data supplied is assumed to be that native to the
  69. platform of the caller.
  70. Return Value:
  71. If the specified device instance is valid, it returns CR_SUCCESS,
  72. otherwise it returns CR_ error code.
  73. --*/
  74. {
  75. CONFIGRET Status = CR_SUCCESS;
  76. NTSTATUS NtStatus = STATUS_SUCCESS;
  77. PLUGPLAY_CONTROL_CONFLICT_DATA ControlData;
  78. PPLUGPLAY_CONTROL_CONFLICT_LIST pConflicts;
  79. CM_RESOURCE_LIST NtResourceList;
  80. UNREFERENCED_PARAMETER(hBinding);
  81. try {
  82. //
  83. // validate parameters
  84. //
  85. if (INVALID_FLAGS(ulFlags, CM_RESDES_WIDTH_BITS)) {
  86. Status = CR_INVALID_FLAG;
  87. goto Clean0;
  88. }
  89. //
  90. // validate res des size
  91. //
  92. if (ResourceLen < GetResDesSize(ResourceID, ulFlags)) {
  93. Status = CR_INVALID_DATA;
  94. goto Clean0;
  95. }
  96. if (!IsLegalDeviceId(pDeviceID)) {
  97. Status = CR_INVALID_DEVNODE;
  98. goto Clean0;
  99. }
  100. //
  101. // make sure original caller didn't specify root devnode
  102. //
  103. if (IsRootDeviceID(pDeviceID)) {
  104. Status = CR_INVALID_LOG_CONF;
  105. goto Clean0;
  106. }
  107. //
  108. // look at buffer we need to fill in
  109. // validate parameters passed in buffer
  110. // buffer should always be big enough to hold header
  111. //
  112. if(clBufferLen < sizeof(PPLUGPLAY_CONTROL_CONFLICT_LIST)) {
  113. Status = CR_INVALID_STRUCTURE_SIZE;
  114. goto Clean0;
  115. }
  116. pConflicts = (PPLUGPLAY_CONTROL_CONFLICT_LIST)clBuffer;
  117. //
  118. // Convert the user-mode version of the resource list to an
  119. // NT CM_RESOURCE_LIST structure.
  120. //
  121. // we'll sort out InterfaceType and BusNumber in kernel
  122. //
  123. NtResourceList.Count = 1;
  124. NtResourceList.List[0].InterfaceType = InterfaceTypeUndefined;
  125. NtResourceList.List[0].BusNumber = 0;
  126. NtResourceList.List[0].PartialResourceList.Version = NT_RESLIST_VERSION;
  127. NtResourceList.List[0].PartialResourceList.Revision = NT_RESLIST_REVISION;
  128. NtResourceList.List[0].PartialResourceList.Count = 1;
  129. Status = ResDesToNtResource(ResourceData, ResourceID, ResourceLen,
  130. &NtResourceList.List[0].PartialResourceList.PartialDescriptors[0], 0, ulFlags);
  131. if (Status != CR_SUCCESS) {
  132. goto Clean0;
  133. }
  134. //
  135. // now fill in ControlData
  136. //
  137. RtlInitUnicodeString(&ControlData.DeviceInstance, pDeviceID);
  138. ControlData.ResourceList = &NtResourceList;
  139. ControlData.ResourceListSize = sizeof(NtResourceList);
  140. ControlData.ConflictBuffer = pConflicts;
  141. ControlData.ConflictBufferSize = clBufferLen;
  142. ControlData.Flags = ulFlags;
  143. ControlData.Status = STATUS_SUCCESS;
  144. NtStatus = NtPlugPlayControl(PlugPlayControlQueryConflictList,
  145. &ControlData,
  146. sizeof(ControlData));
  147. if (NtStatus == STATUS_SUCCESS) {
  148. Status = CR_SUCCESS;
  149. } else {
  150. Status = MapNtStatusToCmError(NtStatus);
  151. }
  152. Clean0:
  153. NOTHING;
  154. } except(EXCEPTION_EXECUTE_HANDLER) {
  155. //
  156. // unspecified failure
  157. //
  158. Status = CR_FAILURE;
  159. }
  160. return Status;
  161. } // PNP_QueryResConfList