ReactOS  0.4.15-dev-313-g8fde48b
pnpres.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for pnpres.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

FORCEINLINE PIO_RESOURCE_LIST IopGetNextResourceList (_In_ const IO_RESOURCE_LIST *ResourceList)
 
static BOOLEAN IopCheckDescriptorForConflict (PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
 
static BOOLEAN IopFindBusNumberResource (IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 
static BOOLEAN IopFindMemoryResource (IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 
static BOOLEAN IopFindPortResource (IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 
static BOOLEAN IopFindDmaResource (IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 
static BOOLEAN IopFindInterruptResource (IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 
NTSTATUS NTAPI IopFixupResourceListWithRequirements (IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, OUT PCM_RESOURCE_LIST *ResourceList)
 
static BOOLEAN IopCheckResourceDescriptor (IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
 
static NTSTATUS IopUpdateControlKeyWithResources (IN PDEVICE_NODE DeviceNode)
 
static NTSTATUS IopFilterResourceRequirements (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS IopUpdateResourceMap (IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key)
 
NTSTATUS IopUpdateResourceMapForPnPDevice (IN PDEVICE_NODE DeviceNode)
 
static NTSTATUS IopTranslateDeviceResources (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopAssignDeviceResources (IN PDEVICE_NODE DeviceNode)
 
static BOOLEAN IopCheckForResourceConflict (IN PCM_RESOURCE_LIST ResourceList1, IN PCM_RESOURCE_LIST ResourceList2, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
 
NTSTATUS NTAPI IopDetectResourceConflict (IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file pnpres.c.

Function Documentation

◆ IopAssignDeviceResources()

NTSTATUS NTAPI IopAssignDeviceResources ( IN PDEVICE_NODE  DeviceNode)

Definition at line 1105 of file pnpres.c.

1107 {
1108  NTSTATUS Status;
1109  ULONG ListSize;
1110 
1112 
1114  if (!NT_SUCCESS(Status))
1115  goto ByeBye;
1116 
1117  if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements)
1118  {
1121 
1122  /* No resource needed for this device */
1123  DeviceNode->ResourceList = NULL;
1124  DeviceNode->ResourceListTranslated = NULL;
1125 
1126  return STATUS_SUCCESS;
1127  }
1128 
1129  if (DeviceNode->BootResources)
1130  {
1131  ListSize = PnpDetermineResourceListSize(DeviceNode->BootResources);
1132 
1133  DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize);
1134  if (!DeviceNode->ResourceList)
1135  {
1137  goto ByeBye;
1138  }
1139 
1140  RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, ListSize);
1141 
1143  if (!NT_SUCCESS(Status))
1144  {
1145  DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath);
1146  ExFreePool(DeviceNode->ResourceList);
1147  DeviceNode->ResourceList = NULL;
1148  }
1149  }
1150  else
1151  {
1152  /* We'll make this from the requirements */
1153  DeviceNode->ResourceList = NULL;
1154  }
1155 
1156  /* No resources requirements */
1157  if (!DeviceNode->ResourceRequirements)
1158  goto Finish;
1159 
1160  /* Call HAL to fixup our resource requirements list */
1161  HalAdjustResourceList(&DeviceNode->ResourceRequirements);
1162 
1163  /* Add resource requirements that aren't in the list we already got */
1164  Status = IopFixupResourceListWithRequirements(DeviceNode->ResourceRequirements,
1165  &DeviceNode->ResourceList);
1166  if (!NT_SUCCESS(Status))
1167  {
1168  DPRINT1("Failed to fixup a resource list from supplied resources for %wZ\n", &DeviceNode->InstancePath);
1170  goto ByeBye;
1171  }
1172 
1173  /* IopFixupResourceListWithRequirements should NEVER give us a conflicting list */
1175 
1176 Finish:
1178  if (!NT_SUCCESS(Status))
1179  {
1181  DPRINT1("Failed to translate resources for %wZ\n", &DeviceNode->InstancePath);
1182  goto ByeBye;
1183  }
1184 
1186  if (!NT_SUCCESS(Status))
1187  goto ByeBye;
1188 
1190  if (!NT_SUCCESS(Status))
1191  goto ByeBye;
1192 
1194 
1196 
1197  return STATUS_SUCCESS;
1198 
1199 ByeBye:
1200  if (DeviceNode->ResourceList)
1201  {
1202  ExFreePool(DeviceNode->ResourceList);
1203  DeviceNode->ResourceList = NULL;
1204  }
1205 
1206  DeviceNode->ResourceListTranslated = NULL;
1207 
1209 
1210  return Status;
1211 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1251
#define DNF_NO_RESOURCE_REQUIRED
Definition: iotypes.h:174
#define DNF_RESOURCE_ASSIGNED
Definition: iotypes.h:176
static NTSTATUS IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:763
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4155
#define IopDeviceNodeSetFlag(DeviceNode, Flag)
Definition: io.h:142
smooth NULL
Definition: ftsmooth.c:416
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
NTSTATUS NTAPI HalAdjustResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST *ResourceList)
Definition: bus.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_PROB_TRANSLATION_FAILED
Definition: cfg.h:63
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:706
static NTSTATUS IopTranslateDeviceResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:959
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
NTSTATUS IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:951
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define DNF_ASSIGNING_RESOURCES
Definition: iotypes.h:192
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define IopDeviceNodeClearFlag(DeviceNode, Flag)
Definition: io.h:151
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS NTAPI IopFixupResourceListWithRequirements(IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, OUT PCM_RESOURCE_LIST *ResourceList)
Definition: pnpres.c:219

Referenced by IopStartDevice(), and IoReportDetectedDevice().

◆ IopCheckDescriptorForConflict()

static BOOLEAN IopCheckDescriptorForConflict ( PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc,
OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)
static

Definition at line 27 of file pnpres.c.

30 {
31  CM_RESOURCE_LIST CmList;
33 
34  CmList.Count = 1;
36  CmList.List[0].BusNumber = 0;
37  CmList.List[0].PartialResourceList.Version = 1;
38  CmList.List[0].PartialResourceList.Revision = 1;
39  CmList.List[0].PartialResourceList.Count = 1;
40  CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc;
41 
42  Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor);
44  return TRUE;
45 
46  return FALSE;
47 }
#define TRUE
Definition: types.h:120
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1251
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Status
Definition: gdiplustypes.h:24
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247

Referenced by IopFindBusNumberResource(), IopFindDmaResource(), IopFindInterruptResource(), IopFindMemoryResource(), and IopFindPortResource().

◆ IopCheckForResourceConflict()

static BOOLEAN IopCheckForResourceConflict ( IN PCM_RESOURCE_LIST  ResourceList1,
IN PCM_RESOURCE_LIST  ResourceList2,
IN BOOLEAN  Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)
static

Definition at line 1215 of file pnpres.c.

1220 {
1221  ULONG i, ii;
1222  BOOLEAN Result = FALSE;
1223  PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
1224 
1225  FullDescriptor = &ResourceList1->List[0];
1226  for (i = 0; i < ResourceList1->Count; i++)
1227  {
1228  PCM_PARTIAL_RESOURCE_LIST ResList = &FullDescriptor->PartialResourceList;
1229  FullDescriptor = CmiGetNextResourceDescriptor(FullDescriptor);
1230 
1231  for (ii = 0; ii < ResList->Count; ii++)
1232  {
1233  /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
1234  but only one is allowed and it must be the last one in the list! */
1235  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc = &ResList->PartialDescriptors[ii];
1236 
1238  ResourceList2,
1239  Silent,
1240  ConflictingDescriptor);
1241  if (Result) goto ByeBye;
1242  }
1243  }
1244 
1245 ByeBye:
1246 
1247  return Result;
1248 }
static BOOLEAN IopCheckResourceDescriptor(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:559
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
FORCEINLINE PCM_FULL_RESOURCE_DESCRIPTOR CmiGetNextResourceDescriptor(_In_ const CM_FULL_RESOURCE_DESCRIPTOR *ResourceDescriptor)
Definition: cmreslist.h:54
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
unsigned int ULONG
Definition: retypes.h:1

Referenced by IopDetectResourceConflict().

◆ IopCheckResourceDescriptor()

static BOOLEAN IopCheckResourceDescriptor ( IN PCM_PARTIAL_RESOURCE_DESCRIPTOR  ResDesc,
IN PCM_RESOURCE_LIST  ResourceList,
IN BOOLEAN  Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)
static

Definition at line 559 of file pnpres.c.

564 {
565  ULONG i, ii;
566  BOOLEAN Result = FALSE;
567  PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
568 
569  FullDescriptor = &ResourceList->List[0];
570  for (i = 0; i < ResourceList->Count; i++)
571  {
572  PCM_PARTIAL_RESOURCE_LIST ResList = &FullDescriptor->PartialResourceList;
573  FullDescriptor = CmiGetNextResourceDescriptor(FullDescriptor);
574 
575  for (ii = 0; ii < ResList->Count; ii++)
576  {
577  /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
578  but only one is allowed and it must be the last one in the list! */
579  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii];
580 
581  /* We don't care about shared resources */
582  if (ResDesc->ShareDisposition == CmResourceShareShared &&
584  continue;
585 
586  /* Make sure we're comparing the same types */
587  if (ResDesc->Type != ResDesc2->Type)
588  continue;
589 
590  switch (ResDesc->Type)
591  {
593  if (((ULONGLONG)ResDesc->u.Memory.Start.QuadPart < (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart &&
594  (ULONGLONG)ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length >
595  (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Memory.Start.QuadPart <
596  (ULONGLONG)ResDesc->u.Memory.Start.QuadPart && (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart +
597  ResDesc2->u.Memory.Length > (ULONGLONG)ResDesc->u.Memory.Start.QuadPart))
598  {
599  if (!Silent)
600  {
601  DPRINT1("Resource conflict: Memory (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n",
602  ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart +
603  ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart,
604  ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length);
605  }
606 
607  Result = TRUE;
608 
609  goto ByeBye;
610  }
611  break;
612 
613  case CmResourceTypePort:
614  if (((ULONGLONG)ResDesc->u.Port.Start.QuadPart < (ULONGLONG)ResDesc2->u.Port.Start.QuadPart &&
615  (ULONGLONG)ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length >
616  (ULONGLONG)ResDesc2->u.Port.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Port.Start.QuadPart <
617  (ULONGLONG)ResDesc->u.Port.Start.QuadPart && (ULONGLONG)ResDesc2->u.Port.Start.QuadPart +
618  ResDesc2->u.Port.Length > (ULONGLONG)ResDesc->u.Port.Start.QuadPart))
619  {
620  if (!Silent)
621  {
622  DPRINT1("Resource conflict: Port (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n",
623  ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart +
624  ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart,
625  ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length);
626  }
627 
628  Result = TRUE;
629 
630  goto ByeBye;
631  }
632  break;
633 
635  if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector)
636  {
637  if (!Silent)
638  {
639  DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n",
640  ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level,
641  ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level);
642  }
643 
644  Result = TRUE;
645 
646  goto ByeBye;
647  }
648  break;
649 
651  if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start &&
652  ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length >
653  ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start <
654  ResDesc->u.BusNumber.Start && ResDesc2->u.BusNumber.Start +
655  ResDesc2->u.BusNumber.Length > ResDesc->u.BusNumber.Start))
656  {
657  if (!Silent)
658  {
659  DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n",
660  ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start +
661  ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start,
662  ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length);
663  }
664 
665  Result = TRUE;
666 
667  goto ByeBye;
668  }
669  break;
670 
671  case CmResourceTypeDma:
672  if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel)
673  {
674  if (!Silent)
675  {
676  DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n",
677  ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port,
678  ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port);
679  }
680 
681  Result = TRUE;
682 
683  goto ByeBye;
684  }
685  break;
686  }
687  }
688  }
689 
690 ByeBye:
691 
692  if (Result && ConflictingDescriptor)
693  {
694  RtlCopyMemory(ConflictingDescriptor,
695  ResDesc,
697  }
698 
699  // Hacked, because after fixing resource list parsing
700  // we actually detect resource conflicts
701  return Silent ? Result : FALSE; // Result;
702 }
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@381 Port
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@384 Memory
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@382 Interrupt
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@385 Dma
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
uint64_t ULONGLONG
Definition: typedefs.h:66
FORCEINLINE PCM_FULL_RESOURCE_DESCRIPTOR CmiGetNextResourceDescriptor(_In_ const CM_FULL_RESOURCE_DESCRIPTOR *ResourceDescriptor)
Definition: cmreslist.h:54
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@387 BusNumber
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by IopCheckForResourceConflict().

◆ IopDetectResourceConflict()

NTSTATUS NTAPI IopDetectResourceConflict ( IN PCM_RESOURCE_LIST  ResourceList,
IN BOOLEAN  Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)

Definition at line 1251 of file pnpres.c.

1255 {
1258  HANDLE ResourceMapKey = NULL, ChildKey2 = NULL, ChildKey3 = NULL;
1259  ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength;
1260  PKEY_BASIC_INFORMATION KeyInformation;
1261  PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
1263  ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0;
1264  NTSTATUS Status;
1265 
1266  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
1268  &KeyName,
1270  NULL,
1271  NULL);
1272  Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
1273  if (!NT_SUCCESS(Status))
1274  {
1275  /* The key is missing which means we are the first device */
1276  return STATUS_SUCCESS;
1277  }
1278 
1279  while (TRUE)
1280  {
1281  Status = ZwEnumerateKey(ResourceMapKey,
1282  ChildKeyIndex1,
1284  NULL,
1285  0,
1286  &RequiredLength);
1288  break;
1290  {
1291  KeyInformationLength = RequiredLength;
1292  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1293  KeyInformationLength,
1294  TAG_IO);
1295  if (!KeyInformation)
1296  {
1298  goto cleanup;
1299  }
1300 
1301  Status = ZwEnumerateKey(ResourceMapKey,
1302  ChildKeyIndex1,
1304  KeyInformation,
1305  KeyInformationLength,
1306  &RequiredLength);
1307  }
1308  else
1309  goto cleanup;
1310  ChildKeyIndex1++;
1311  if (!NT_SUCCESS(Status))
1312  {
1313  ExFreePoolWithTag(KeyInformation, TAG_IO);
1314  goto cleanup;
1315  }
1316 
1317  KeyName.Buffer = KeyInformation->Name;
1318  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1320  &KeyName,
1322  ResourceMapKey,
1323  NULL);
1324  Status = ZwOpenKey(&ChildKey2,
1326  &ObjectAttributes);
1327  ExFreePoolWithTag(KeyInformation, TAG_IO);
1328  if (!NT_SUCCESS(Status))
1329  goto cleanup;
1330 
1331  while (TRUE)
1332  {
1333  Status = ZwEnumerateKey(ChildKey2,
1334  ChildKeyIndex2,
1336  NULL,
1337  0,
1338  &RequiredLength);
1340  break;
1341  else if (Status == STATUS_BUFFER_TOO_SMALL)
1342  {
1343  KeyInformationLength = RequiredLength;
1344  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1345  KeyInformationLength,
1346  TAG_IO);
1347  if (!KeyInformation)
1348  {
1350  goto cleanup;
1351  }
1352 
1353  Status = ZwEnumerateKey(ChildKey2,
1354  ChildKeyIndex2,
1356  KeyInformation,
1357  KeyInformationLength,
1358  &RequiredLength);
1359  }
1360  else
1361  goto cleanup;
1362  ChildKeyIndex2++;
1363  if (!NT_SUCCESS(Status))
1364  {
1365  ExFreePoolWithTag(KeyInformation, TAG_IO);
1366  goto cleanup;
1367  }
1368 
1369  KeyName.Buffer = KeyInformation->Name;
1370  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1372  &KeyName,
1374  ChildKey2,
1375  NULL);
1376  Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes);
1377  ExFreePoolWithTag(KeyInformation, TAG_IO);
1378  if (!NT_SUCCESS(Status))
1379  goto cleanup;
1380 
1381  while (TRUE)
1382  {
1383  Status = ZwEnumerateValueKey(ChildKey3,
1384  ChildKeyIndex3,
1386  NULL,
1387  0,
1388  &RequiredLength);
1390  break;
1391  else if (Status == STATUS_BUFFER_TOO_SMALL)
1392  {
1393  KeyValueInformationLength = RequiredLength;
1394  KeyValueInformation = ExAllocatePoolWithTag(PagedPool,
1395  KeyValueInformationLength,
1396  TAG_IO);
1397  if (!KeyValueInformation)
1398  {
1400  goto cleanup;
1401  }
1402 
1403  Status = ZwEnumerateValueKey(ChildKey3,
1404  ChildKeyIndex3,
1406  KeyValueInformation,
1407  KeyValueInformationLength,
1408  &RequiredLength);
1409  }
1410  else
1411  goto cleanup;
1412  if (!NT_SUCCESS(Status))
1413  {
1414  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1415  goto cleanup;
1416  }
1417 
1418  Status = ZwEnumerateValueKey(ChildKey3,
1419  ChildKeyIndex3,
1421  NULL,
1422  0,
1423  &RequiredLength);
1425  {
1426  KeyNameInformationLength = RequiredLength;
1428  KeyNameInformationLength + sizeof(WCHAR),
1429  TAG_IO);
1430  if (!KeyNameInformation)
1431  {
1433  goto cleanup;
1434  }
1435 
1436  Status = ZwEnumerateValueKey(ChildKey3,
1437  ChildKeyIndex3,
1440  KeyNameInformationLength,
1441  &RequiredLength);
1442  }
1443  else
1444  goto cleanup;
1445  ChildKeyIndex3++;
1446  if (!NT_SUCCESS(Status))
1447  {
1449  goto cleanup;
1450  }
1451 
1452  KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
1453 
1454  /* Skip translated entries */
1455  if (wcsstr(KeyNameInformation->Name, L".Translated"))
1456  {
1458  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1459  continue;
1460  }
1461 
1463 
1465  (PCM_RESOURCE_LIST)KeyValueInformation->Data,
1466  Silent,
1467  ConflictingDescriptor))
1468  {
1469  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1471  goto cleanup;
1472  }
1473 
1474  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1475  }
1476  }
1477  }
1478 
1479 cleanup:
1480  if (ResourceMapKey != NULL)
1481  ObCloseHandle(ResourceMapKey, KernelMode);
1482  if (ChildKey2 != NULL)
1483  ObCloseHandle(ChildKey2, KernelMode);
1484  if (ChildKey3 != NULL)
1485  ObCloseHandle(ChildKey3, KernelMode);
1486 
1489 
1490  return Status;
1491 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO
Definition: tag.h:69
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
static BOOLEAN IopCheckForResourceConflict(IN PCM_RESOURCE_LIST ResourceList1, IN PCM_RESOURCE_LIST ResourceList2, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1215
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by IopAssignDeviceResources(), IopCheckDescriptorForConflict(), IoReportResourceForDetection(), and IoReportResourceUsage().

◆ IopFilterResourceRequirements()

static NTSTATUS IopFilterResourceRequirements ( IN PDEVICE_NODE  DeviceNode)
static

Definition at line 763 of file pnpres.c.

765 {
766  IO_STACK_LOCATION Stack;
769 
770  DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n");
771 
772  Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements;
773  Status = IopInitiatePnpIrp(DeviceNode->PhysicalDeviceObject,
774  &IoStatusBlock,
776  &Stack);
778  {
779  DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n");
780  return Status;
781  }
783  {
785  }
786 
787  return STATUS_SUCCESS;
788 }
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
struct _IO_RESOURCE_REQUIREMENTS_LIST * PIO_RESOURCE_REQUIREMENTS_LIST
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: Node.h:9
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)

Referenced by IopAssignDeviceResources().

◆ IopFindBusNumberResource()

static BOOLEAN IopFindBusNumberResource ( IN PIO_RESOURCE_DESCRIPTOR  IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc 
)
static

Definition at line 51 of file pnpres.c.

54 {
55  ULONG Start;
56  CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
57 
58  ASSERT(IoDesc->Type == CmDesc->Type);
59  ASSERT(IoDesc->Type == CmResourceTypeBusNumber);
60 
61  for (Start = IoDesc->u.BusNumber.MinBusNumber;
62  Start <= IoDesc->u.BusNumber.MaxBusNumber - IoDesc->u.BusNumber.Length + 1;
63  Start++)
64  {
65  CmDesc->u.BusNumber.Length = IoDesc->u.BusNumber.Length;
66  CmDesc->u.BusNumber.Start = Start;
67 
68  if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc))
69  {
70  Start += ConflictingDesc.u.BusNumber.Start + ConflictingDesc.u.BusNumber.Length;
71  }
72  else
73  {
74  DPRINT1("Satisfying bus number requirement with 0x%x (length: 0x%x)\n", Start, CmDesc->u.BusNumber.Length);
75  return TRUE;
76  }
77  }
78 
79  return FALSE;
80 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@387 BusNumber
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
static BOOLEAN IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:27
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128

Referenced by IopFixupResourceListWithRequirements().

◆ IopFindDmaResource()

static BOOLEAN IopFindDmaResource ( IN PIO_RESOURCE_DESCRIPTOR  IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc 
)
static

Definition at line 160 of file pnpres.c.

163 {
164  ULONG Channel;
165 
166  ASSERT(IoDesc->Type == CmDesc->Type);
167  ASSERT(IoDesc->Type == CmResourceTypeDma);
168 
169  for (Channel = IoDesc->u.Dma.MinimumChannel;
170  Channel <= IoDesc->u.Dma.MaximumChannel;
171  Channel++)
172  {
173  CmDesc->u.Dma.Channel = Channel;
174  CmDesc->u.Dma.Port = 0;
175 
176  if (!IopCheckDescriptorForConflict(CmDesc, NULL))
177  {
178  DPRINT1("Satisfying DMA requirement with channel 0x%x\n", Channel);
179  return TRUE;
180  }
181  }
182 
183  return FALSE;
184 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static BOOLEAN IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:27
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by IopFixupResourceListWithRequirements().

◆ IopFindInterruptResource()

static BOOLEAN IopFindInterruptResource ( IN PIO_RESOURCE_DESCRIPTOR  IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc 
)
static

Definition at line 188 of file pnpres.c.

191 {
192  ULONG Vector;
193 
194  ASSERT(IoDesc->Type == CmDesc->Type);
195  ASSERT(IoDesc->Type == CmResourceTypeInterrupt);
196 
197  for (Vector = IoDesc->u.Interrupt.MinimumVector;
198  Vector <= IoDesc->u.Interrupt.MaximumVector;
199  Vector++)
200  {
201  CmDesc->u.Interrupt.Vector = Vector;
202  CmDesc->u.Interrupt.Level = Vector;
203  CmDesc->u.Interrupt.Affinity = (KAFFINITY)-1;
204 
205  if (!IopCheckDescriptorForConflict(CmDesc, NULL))
206  {
207  DPRINT1("Satisfying interrupt requirement with IRQ 0x%x\n", Vector);
208  return TRUE;
209  }
210  }
211 
212  DPRINT1("Failed to satisfy interrupt requirement with IRQ 0x%x-0x%x\n",
213  IoDesc->u.Interrupt.MinimumVector,
214  IoDesc->u.Interrupt.MaximumVector);
215  return FALSE;
216 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static BOOLEAN IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:27
ULONG_PTR KAFFINITY
Definition: compat.h:75
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

Referenced by IopFixupResourceListWithRequirements().

◆ IopFindMemoryResource()

static BOOLEAN IopFindMemoryResource ( IN PIO_RESOURCE_DESCRIPTOR  IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc 
)
static

Definition at line 84 of file pnpres.c.

87 {
89  CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
90 
91  ASSERT(IoDesc->Type == CmDesc->Type);
92  ASSERT(IoDesc->Type == CmResourceTypeMemory);
93 
94  /* HACK */
95  if (IoDesc->u.Memory.Alignment == 0)
96  IoDesc->u.Memory.Alignment = 1;
97 
98  for (Start = (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart;
99  Start <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart - IoDesc->u.Memory.Length + 1;
100  Start += IoDesc->u.Memory.Alignment)
101  {
102  CmDesc->u.Memory.Length = IoDesc->u.Memory.Length;
103  CmDesc->u.Memory.Start.QuadPart = (LONGLONG)Start;
104 
105  if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc))
106  {
107  Start += (ULONGLONG)ConflictingDesc.u.Memory.Start.QuadPart +
108  ConflictingDesc.u.Memory.Length;
109  }
110  else
111  {
112  DPRINT1("Satisfying memory requirement with 0x%I64x (length: 0x%x)\n", Start, CmDesc->u.Memory.Length);
113  return TRUE;
114  }
115  }
116 
117  return FALSE;
118 }
#define TRUE
Definition: types.h:120
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@384 Memory
int64_t LONGLONG
Definition: typedefs.h:67
uint64_t ULONGLONG
Definition: typedefs.h:66
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
static BOOLEAN IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:27
#define DPRINT1
Definition: precomp.h:8
#define CmResourceTypeMemory
Definition: hwresource.cpp:125

Referenced by IopFixupResourceListWithRequirements().

◆ IopFindPortResource()

static BOOLEAN IopFindPortResource ( IN PIO_RESOURCE_DESCRIPTOR  IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmDesc 
)
static

Definition at line 122 of file pnpres.c.

125 {
127  CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
128 
129  ASSERT(IoDesc->Type == CmDesc->Type);
130  ASSERT(IoDesc->Type == CmResourceTypePort);
131 
132  /* HACK */
133  if (IoDesc->u.Port.Alignment == 0)
134  IoDesc->u.Port.Alignment = 1;
135 
136  for (Start = (ULONGLONG)IoDesc->u.Port.MinimumAddress.QuadPart;
137  Start <= (ULONGLONG)IoDesc->u.Port.MaximumAddress.QuadPart - IoDesc->u.Port.Length + 1;
138  Start += IoDesc->u.Port.Alignment)
139  {
140  CmDesc->u.Port.Length = IoDesc->u.Port.Length;
141  CmDesc->u.Port.Start.QuadPart = (LONGLONG)Start;
142 
143  if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc))
144  {
145  Start += (ULONGLONG)ConflictingDesc.u.Port.Start.QuadPart + ConflictingDesc.u.Port.Length;
146  }
147  else
148  {
149  DPRINT("Satisfying port requirement with 0x%I64x (length: 0x%x)\n", Start, CmDesc->u.Port.Length);
150  return TRUE;
151  }
152  }
153 
154  DPRINT1("IopFindPortResource failed!\n");
155  return FALSE;
156 }
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@381 Port
#define TRUE
Definition: types.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
void DPRINT(...)
Definition: polytest.cpp:61
int64_t LONGLONG
Definition: typedefs.h:67
uint64_t ULONGLONG
Definition: typedefs.h:66
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
static BOOLEAN IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:27
#define DPRINT1
Definition: precomp.h:8

Referenced by IopFixupResourceListWithRequirements().

◆ IopFixupResourceListWithRequirements()

NTSTATUS NTAPI IopFixupResourceListWithRequirements ( IN PIO_RESOURCE_REQUIREMENTS_LIST  RequirementsList,
OUT PCM_RESOURCE_LIST ResourceList 
)

Definition at line 219 of file pnpres.c.

222 {
223  ULONG i, OldCount;
224  BOOLEAN AlternateRequired = FALSE;
225  PIO_RESOURCE_LIST ResList;
226 
227  /* Save the initial resource count when we got here so we can restore if an alternate fails */
228  if (*ResourceList != NULL)
229  OldCount = (*ResourceList)->List[0].PartialResourceList.Count;
230  else
231  OldCount = 0;
232 
233  ResList = &RequirementsList->List[0];
234  for (i = 0; i < RequirementsList->AlternativeLists; i++, ResList = IopGetNextResourceList(ResList))
235  {
236  ULONG ii;
237 
238  /* We need to get back to where we were before processing the last alternative list */
239  if (OldCount == 0 && *ResourceList != NULL)
240  {
241  /* Just free it and kill the pointer */
243  *ResourceList = NULL;
244  }
245  else if (OldCount != 0)
246  {
247  PCM_RESOURCE_LIST NewList;
248 
249  /* Let's resize it */
250  (*ResourceList)->List[0].PartialResourceList.Count = OldCount;
251 
252  /* Allocate the new smaller list */
254  if (!NewList)
255  return STATUS_NO_MEMORY;
256 
257  /* Copy the old stuff back */
259 
260  /* Free the old one */
262 
263  /* Store the pointer to the new one */
264  *ResourceList = NewList;
265  }
266 
267  for (ii = 0; ii < ResList->Count; ii++)
268  {
269  ULONG iii;
270  PCM_PARTIAL_RESOURCE_LIST PartialList = (*ResourceList) ? &(*ResourceList)->List[0].PartialResourceList : NULL;
271  PIO_RESOURCE_DESCRIPTOR IoDesc = &ResList->Descriptors[ii];
272  BOOLEAN Matched = FALSE;
273 
274  /* Skip alternates if we don't need one */
275  if (!AlternateRequired && (IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
276  {
277  DPRINT("Skipping unneeded alternate\n");
278  continue;
279  }
280 
281  /* Check if we couldn't satsify a requirement or its alternates */
282  if (AlternateRequired && !(IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
283  {
284  DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i);
285 
286  /* Break out of this loop and try the next list */
287  break;
288  }
289 
290  for (iii = 0; PartialList && iii < PartialList->Count && !Matched; iii++)
291  {
292  /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
293  but only one is allowed and it must be the last one in the list! */
294  PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc = &PartialList->PartialDescriptors[iii];
295 
296  /* First check types */
297  if (IoDesc->Type != CmDesc->Type)
298  continue;
299 
300  switch (IoDesc->Type)
301  {
303  /* Make sure it satisfies our vector range */
304  if (CmDesc->u.Interrupt.Vector >= IoDesc->u.Interrupt.MinimumVector &&
305  CmDesc->u.Interrupt.Vector <= IoDesc->u.Interrupt.MaximumVector)
306  {
307  /* Found it */
308  Matched = TRUE;
309  }
310  else
311  {
312  DPRINT("Interrupt - Not a match! 0x%x not inside 0x%x to 0x%x\n",
313  CmDesc->u.Interrupt.Vector,
314  IoDesc->u.Interrupt.MinimumVector,
315  IoDesc->u.Interrupt.MaximumVector);
316  }
317  break;
318 
320  case CmResourceTypePort:
321  /* Make sure the length matches and it satisfies our address range */
322  if (CmDesc->u.Memory.Length == IoDesc->u.Memory.Length &&
323  (ULONGLONG)CmDesc->u.Memory.Start.QuadPart >= (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart &&
324  (ULONGLONG)CmDesc->u.Memory.Start.QuadPart + CmDesc->u.Memory.Length - 1 <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart)
325  {
326  /* Found it */
327  Matched = TRUE;
328  }
329  else
330  {
331  DPRINT("Memory/Port - Not a match! 0x%I64x with length 0x%x not inside 0x%I64x to 0x%I64x with length 0x%x\n",
332  CmDesc->u.Memory.Start.QuadPart,
333  CmDesc->u.Memory.Length,
334  IoDesc->u.Memory.MinimumAddress.QuadPart,
335  IoDesc->u.Memory.MaximumAddress.QuadPart,
336  IoDesc->u.Memory.Length);
337  }
338  break;
339 
341  /* Make sure the length matches and it satisfies our bus number range */
342  if (CmDesc->u.BusNumber.Length == IoDesc->u.BusNumber.Length &&
343  CmDesc->u.BusNumber.Start >= IoDesc->u.BusNumber.MinBusNumber &&
344  CmDesc->u.BusNumber.Start + CmDesc->u.BusNumber.Length - 1 <= IoDesc->u.BusNumber.MaxBusNumber)
345  {
346  /* Found it */
347  Matched = TRUE;
348  }
349  else
350  {
351  DPRINT("Bus Number - Not a match! 0x%x with length 0x%x not inside 0x%x to 0x%x with length 0x%x\n",
352  CmDesc->u.BusNumber.Start,
353  CmDesc->u.BusNumber.Length,
354  IoDesc->u.BusNumber.MinBusNumber,
355  IoDesc->u.BusNumber.MaxBusNumber,
356  IoDesc->u.BusNumber.Length);
357  }
358  break;
359 
360  case CmResourceTypeDma:
361  /* Make sure it fits in our channel range */
362  if (CmDesc->u.Dma.Channel >= IoDesc->u.Dma.MinimumChannel &&
363  CmDesc->u.Dma.Channel <= IoDesc->u.Dma.MaximumChannel)
364  {
365  /* Found it */
366  Matched = TRUE;
367  }
368  else
369  {
370  DPRINT("DMA - Not a match! 0x%x not inside 0x%x to 0x%x\n",
371  CmDesc->u.Dma.Channel,
372  IoDesc->u.Dma.MinimumChannel,
373  IoDesc->u.Dma.MaximumChannel);
374  }
375  break;
376 
377  default:
378  /* Other stuff is fine */
379  Matched = TRUE;
380  break;
381  }
382  }
383 
384  /* Check if we found a matching descriptor */
385  if (!Matched)
386  {
387  PCM_RESOURCE_LIST NewList;
390  BOOLEAN FoundResource = TRUE;
391 
392  /* Setup the new CM descriptor */
393  NewDesc.Type = IoDesc->Type;
394  NewDesc.Flags = IoDesc->Flags;
395  NewDesc.ShareDisposition = IoDesc->ShareDisposition;
396 
397  /* Let'se see if we can find a resource to satisfy this */
398  switch (IoDesc->Type)
399  {
401  /* Find an available interrupt */
402  if (!IopFindInterruptResource(IoDesc, &NewDesc))
403  {
404  DPRINT1("Failed to find an available interrupt resource (0x%x to 0x%x)\n",
405  IoDesc->u.Interrupt.MinimumVector, IoDesc->u.Interrupt.MaximumVector);
406 
407  FoundResource = FALSE;
408  }
409  break;
410 
411  case CmResourceTypePort:
412  /* Find an available port range */
413  if (!IopFindPortResource(IoDesc, &NewDesc))
414  {
415  DPRINT1("Failed to find an available port resource (0x%I64x to 0x%I64x length: 0x%x)\n",
416  IoDesc->u.Port.MinimumAddress.QuadPart, IoDesc->u.Port.MaximumAddress.QuadPart,
417  IoDesc->u.Port.Length);
418 
419  FoundResource = FALSE;
420  }
421  break;
422 
424  /* Find an available memory range */
425  if (!IopFindMemoryResource(IoDesc, &NewDesc))
426  {
427  DPRINT1("Failed to find an available memory resource (0x%I64x to 0x%I64x length: 0x%x)\n",
428  IoDesc->u.Memory.MinimumAddress.QuadPart, IoDesc->u.Memory.MaximumAddress.QuadPart,
429  IoDesc->u.Memory.Length);
430 
431  FoundResource = FALSE;
432  }
433  break;
434 
436  /* Find an available bus address range */
437  if (!IopFindBusNumberResource(IoDesc, &NewDesc))
438  {
439  DPRINT1("Failed to find an available bus number resource (0x%x to 0x%x length: 0x%x)\n",
440  IoDesc->u.BusNumber.MinBusNumber, IoDesc->u.BusNumber.MaxBusNumber,
441  IoDesc->u.BusNumber.Length);
442 
443  FoundResource = FALSE;
444  }
445  break;
446 
447  case CmResourceTypeDma:
448  /* Find an available DMA channel */
449  if (!IopFindDmaResource(IoDesc, &NewDesc))
450  {
451  DPRINT1("Failed to find an available dma resource (0x%x to 0x%x)\n",
452  IoDesc->u.Dma.MinimumChannel, IoDesc->u.Dma.MaximumChannel);
453 
454  FoundResource = FALSE;
455  }
456  break;
457 
458  default:
459  DPRINT1("Unsupported resource type: %x\n", IoDesc->Type);
460  FoundResource = FALSE;
461  break;
462  }
463 
464  /* Check if it's missing and required */
465  if (!FoundResource && IoDesc->Option == 0)
466  {
467  /* Break out of this loop and try the next list */
468  DPRINT1("Unable to satisfy required resource in list %lu\n", i);
469  break;
470  }
471  else if (!FoundResource)
472  {
473  /* Try an alternate for this preferred descriptor */
474  AlternateRequired = TRUE;
475  continue;
476  }
477  else
478  {
479  /* Move on to the next preferred or required descriptor after this one */
480  AlternateRequired = FALSE;
481  }
482 
483  /* Figure out what we need */
484  if (PartialList == NULL)
485  {
486  /* We need a new list */
487  NewList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST));
488  if (!NewList)
489  return STATUS_NO_MEMORY;
490 
491  /* Set it up */
492  NewList->Count = 1;
493  NewList->List[0].InterfaceType = RequirementsList->InterfaceType;
494  NewList->List[0].BusNumber = RequirementsList->BusNumber;
495  NewList->List[0].PartialResourceList.Version = 1;
496  NewList->List[0].PartialResourceList.Revision = 1;
497  NewList->List[0].PartialResourceList.Count = 1;
498 
499  /* Set our pointer */
500  DescPtr = &NewList->List[0].PartialResourceList.PartialDescriptors[0];
501  }
502  else
503  {
504  /* Allocate the new larger list */
506  if (!NewList)
507  return STATUS_NO_MEMORY;
508 
509  /* Copy the old stuff back */
511 
512  /* Set our pointer */
513  DescPtr = &NewList->List[0].PartialResourceList.PartialDescriptors[NewList->List[0].PartialResourceList.Count];
514 
515  /* Increment the descriptor count */
516  NewList->List[0].PartialResourceList.Count++;
517 
518  /* Free the old list */
520  }
521 
522  /* Copy the descriptor in */
523  *DescPtr = NewDesc;
524 
525  /* Store the new list */
526  *ResourceList = NewList;
527  }
528  }
529 
530  /* Check if we need an alternate with no resources left */
531  if (AlternateRequired)
532  {
533  DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i);
534 
535  /* Try the next alternate list */
536  continue;
537  }
538 
539  /* We're done because we satisfied one of the alternate lists */
540  return STATUS_SUCCESS;
541  }
542 
543  /* We ran out of alternates */
544  DPRINT1("Out of alternate lists!\n");
545 
546  /* Free the list */
547  if (*ResourceList)
548  {
550  *ResourceList = NULL;
551  }
552 
553  /* Fail */
555 }
struct _IO_RESOURCE_DESCRIPTOR::@1568::@1570 Memory
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@384 Memory
static BOOLEAN IopFindMemoryResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:84
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@382 Interrupt
struct _IO_RESOURCE_DESCRIPTOR::@1568::@1569 Port
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static BOOLEAN IopFindInterruptResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:188
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4155
static BOOLEAN IopFindBusNumberResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:51
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@385 Dma
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
uint64_t ULONGLONG
Definition: typedefs.h:66
static BOOLEAN IopFindPortResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:122
struct _IO_RESOURCE_DESCRIPTOR::@1568::@1572 Dma
#define IO_RESOURCE_ALTERNATIVE
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@387 BusNumber
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
static BOOLEAN IopFindDmaResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:160
struct _IO_RESOURCE_DESCRIPTOR::@1568::@1575 BusNumber
struct _IO_RESOURCE_DESCRIPTOR::@1568::@1571 Interrupt
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
FORCEINLINE PIO_RESOURCE_LIST IopGetNextResourceList(_In_ const IO_RESOURCE_LIST *ResourceList)
Definition: pnpres.c:17
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
return STATUS_SUCCESS
Definition: btrfs.c:3014
union _IO_RESOURCE_DESCRIPTOR::@1568 u
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by IopAssignDeviceResources(), and IopLegacyResourceAllocation().

◆ IopGetNextResourceList()

FORCEINLINE PIO_RESOURCE_LIST IopGetNextResourceList ( _In_ const IO_RESOURCE_LIST ResourceList)

Definition at line 17 of file pnpres.c.

19 {
20  ASSERT((ResourceList->Count > 0) && (ResourceList->Count < 1000));
21  return (PIO_RESOURCE_LIST)(
22  &ResourceList->Descriptors[ResourceList->Count]);
23 }
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by IopFixupResourceListWithRequirements().

◆ IopTranslateDeviceResources()

static NTSTATUS IopTranslateDeviceResources ( IN PDEVICE_NODE  DeviceNode)
static

Definition at line 959 of file pnpres.c.

961 {
962  PCM_PARTIAL_RESOURCE_LIST pPartialResourceList;
963  PCM_PARTIAL_RESOURCE_DESCRIPTOR DescriptorRaw, DescriptorTranslated;
964  PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
965  ULONG i, j, ListSize;
967 
968  if (!DeviceNode->ResourceList)
969  {
970  DeviceNode->ResourceListTranslated = NULL;
971  return STATUS_SUCCESS;
972  }
973 
974  /* That's easy to translate a resource list. Just copy the
975  * untranslated one and change few fields in the copy
976  */
977  ListSize = PnpDetermineResourceListSize(DeviceNode->ResourceList);
978 
979  DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool, ListSize);
980  if (!DeviceNode->ResourceListTranslated)
981  {
983  goto cleanup;
984  }
985  RtlCopyMemory(DeviceNode->ResourceListTranslated, DeviceNode->ResourceList, ListSize);
986 
987  FullDescriptor = &DeviceNode->ResourceList->List[0];
988  for (i = 0; i < DeviceNode->ResourceList->Count; i++)
989  {
990  pPartialResourceList = &FullDescriptor->PartialResourceList;
991  FullDescriptor = CmiGetNextResourceDescriptor(FullDescriptor);
992 
993  for (j = 0; j < pPartialResourceList->Count; j++)
994  {
995  /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
996  but only one is allowed and it must be the last one in the list! */
997  DescriptorRaw = &pPartialResourceList->PartialDescriptors[j];
998 
999  /* Calculate the location of the translated resource descriptor */
1000  DescriptorTranslated = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)(
1001  (PUCHAR)DeviceNode->ResourceListTranslated +
1002  ((PUCHAR)DescriptorRaw - (PUCHAR)DeviceNode->ResourceList));
1003 
1004  switch (DescriptorRaw->Type)
1005  {
1006  case CmResourceTypePort:
1007  {
1008  ULONG AddressSpace = 1; /* IO space */
1010  DeviceNode->ResourceList->List[i].InterfaceType,
1011  DeviceNode->ResourceList->List[i].BusNumber,
1012  DescriptorRaw->u.Port.Start,
1013  &AddressSpace,
1014  &DescriptorTranslated->u.Port.Start))
1015  {
1017  DPRINT1("Failed to translate port resource (Start: 0x%I64x)\n", DescriptorRaw->u.Port.Start.QuadPart);
1018  goto cleanup;
1019  }
1020 
1021  if (AddressSpace == 0)
1022  {
1023  DPRINT1("Guessed incorrect address space: 1 -> 0\n");
1024 
1025  /* FIXME: I think all other CM_RESOURCE_PORT_XXX flags are
1026  * invalid for this state but I'm not 100% sure */
1027  DescriptorRaw->Flags =
1028  DescriptorTranslated->Flags = CM_RESOURCE_PORT_MEMORY;
1029  }
1030  break;
1031  }
1033  {
1034  KIRQL Irql;
1035  DescriptorTranslated->u.Interrupt.Vector = HalGetInterruptVector(
1036  DeviceNode->ResourceList->List[i].InterfaceType,
1037  DeviceNode->ResourceList->List[i].BusNumber,
1038  DescriptorRaw->u.Interrupt.Level,
1039  DescriptorRaw->u.Interrupt.Vector,
1040  &Irql,
1041  &DescriptorTranslated->u.Interrupt.Affinity);
1042  DescriptorTranslated->u.Interrupt.Level = Irql;
1043  if (!DescriptorTranslated->u.Interrupt.Vector)
1044  {
1046  DPRINT1("Failed to translate interrupt resource (Vector: 0x%x | Level: 0x%x)\n", DescriptorRaw->u.Interrupt.Vector,
1047  DescriptorRaw->u.Interrupt.Level);
1048  goto cleanup;
1049  }
1050  break;
1051  }
1052  case CmResourceTypeMemory:
1053  {
1054  ULONG AddressSpace = 0; /* Memory space */
1056  DeviceNode->ResourceList->List[i].InterfaceType,
1057  DeviceNode->ResourceList->List[i].BusNumber,
1058  DescriptorRaw->u.Memory.Start,
1059  &AddressSpace,
1060  &DescriptorTranslated->u.Memory.Start))
1061  {
1063  DPRINT1("Failed to translate memory resource (Start: 0x%I64x)\n", DescriptorRaw->u.Memory.Start.QuadPart);
1064  goto cleanup;
1065  }
1066 
1067  if (AddressSpace != 0)
1068  {
1069  DPRINT1("Guessed incorrect address space: 0 -> 1\n");
1070 
1071  /* This should never happen for memory space */
1072  ASSERT(FALSE);
1073  }
1074  }
1075 
1076  case CmResourceTypeDma:
1079  /* Nothing to do */
1080  break;
1081  default:
1082  DPRINT1("Unknown resource descriptor type 0x%x\n", DescriptorRaw->Type);
1084  goto cleanup;
1085  }
1086  }
1087  }
1088  return STATUS_SUCCESS;
1089 
1090 cleanup:
1091  /* Yes! Also delete ResourceList because ResourceList and
1092  * ResourceListTranslated should be a pair! */
1093  ExFreePool(DeviceNode->ResourceList);
1094  DeviceNode->ResourceList = NULL;
1095  if (DeviceNode->ResourceListTranslated)
1096  {
1097  ExFreePool(DeviceNode->ResourceListTranslated);
1098  DeviceNode->ResourceList = NULL;
1099  }
1100  return Status;
1101 }
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@381 Port
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR * PCM_PARTIAL_RESOURCE_DESCRIPTOR
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@384 Memory
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
unsigned char * PUCHAR
Definition: retypes.h:3
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379::@382 Interrupt
LONG NTSTATUS
Definition: precomp.h:26
_Out_ PKIRQL Irql
Definition: csq.h:179
#define CmResourceTypePort
Definition: hwresource.cpp:123
UCHAR KIRQL
Definition: env_spec_w32.h:591
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4155
smooth NULL
Definition: ftsmooth.c:416
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
FORCEINLINE PCM_FULL_RESOURCE_DESCRIPTOR CmiGetNextResourceDescriptor(_In_ const CM_FULL_RESOURCE_DESCRIPTOR *ResourceDescriptor)
Definition: cmreslist.h:54
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@379 u
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
Status
Definition: gdiplustypes.h:24
#define CM_RESOURCE_PORT_MEMORY
Definition: cmtypes.h:108
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by IopAssignDeviceResources().

◆ IopUpdateControlKeyWithResources()

static NTSTATUS IopUpdateControlKeyWithResources ( IN PDEVICE_NODE  DeviceNode)
static

Definition at line 706 of file pnpres.c.

708 {
712  HANDLE EnumKey, InstanceKey, ControlKey;
715 
716  /* Open the Enum key */
718  if (!NT_SUCCESS(Status))
719  return Status;
720 
721  /* Open the instance key (eg. Root\PNP0A03) */
722  Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey, &DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS);
723  ZwClose(EnumKey);
724 
725  if (!NT_SUCCESS(Status))
726  return Status;
727 
728  /* Create/Open the Control key */
730  &Control,
732  InstanceKey,
733  NULL);
734  Status = ZwCreateKey(&ControlKey,
737  0,
738  NULL,
740  NULL);
741  ZwClose(InstanceKey);
742 
743  if (!NT_SUCCESS(Status))
744  return Status;
745 
746  /* Write the resource list */
747  Status = ZwSetValueKey(ControlKey,
748  &ValueName,
749  0,
751  DeviceNode->ResourceList,
753  ZwClose(ControlKey);
754 
755  if (!NT_SUCCESS(Status))
756  return Status;
757 
758  return STATUS_SUCCESS;
759 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4155
smooth NULL
Definition: ftsmooth.c:416
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static LONG WINAPI EnumKey(HANDLE hcKey, DWORD dwIndex, LPWSTR pszName, PDWORD pcchName, PFILETIME pftLastWriteTime, HANDLE hSpooler)
Definition: localmon.c:169
#define ENUM_ROOT
Definition: io.h:53
Definition: Node.h:9
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Control[]
Definition: interface.c:27
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI IopOpenRegistryKeyEx(PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
Definition: pnpmgr.c:3760
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IopAssignDeviceResources().

◆ IopUpdateResourceMap()

NTSTATUS IopUpdateResourceMap ( IN PDEVICE_NODE  DeviceNode,
PWCHAR  Level1Key,
PWCHAR  Level2Key 
)

Definition at line 792 of file pnpres.c.

796 {
799  HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey;
802 
804  L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
806  &KeyName,
808  NULL,
809  NULL);
810  Status = ZwCreateKey(&ResourceMapKey,
813  0,
814  NULL,
816  &Disposition);
817  if (!NT_SUCCESS(Status))
818  return Status;
819 
820  RtlInitUnicodeString(&KeyName, Level1Key);
822  &KeyName,
824  ResourceMapKey,
825  NULL);
826  Status = ZwCreateKey(&PnpMgrLevel1,
829  0,
830  NULL,
832  &Disposition);
833  ZwClose(ResourceMapKey);
834  if (!NT_SUCCESS(Status))
835  return Status;
836 
837  RtlInitUnicodeString(&KeyName, Level2Key);
839  &KeyName,
841  PnpMgrLevel1,
842  NULL);
843  Status = ZwCreateKey(&PnpMgrLevel2,
846  0,
847  NULL,
849  &Disposition);
850  ZwClose(PnpMgrLevel1);
851  if (!NT_SUCCESS(Status))
852  return Status;
853 
854  if (DeviceNode->ResourceList)
855  {
856  UNICODE_STRING NameU;
857  UNICODE_STRING RawSuffix, TranslatedSuffix;
858  ULONG OldLength = 0;
859 
860  ASSERT(DeviceNode->ResourceListTranslated);
861 
862  RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
863  RtlInitUnicodeString(&RawSuffix, L".Raw");
864 
865  Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
867  0,
868  NULL,
869  &OldLength);
871  {
872  ASSERT(OldLength);
873 
874  NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length);
875  if (!NameU.Buffer)
876  {
877  ZwClose(PnpMgrLevel2);
879  }
880 
881  NameU.Length = 0;
882  NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
883 
884  Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
886  NameU.MaximumLength,
887  NameU.Buffer,
888  &OldLength);
889  if (!NT_SUCCESS(Status))
890  {
891  ZwClose(PnpMgrLevel2);
892  ExFreePool(NameU.Buffer);
893  return Status;
894  }
895  }
896  else if (!NT_SUCCESS(Status))
897  {
898  /* Some failure */
899  ZwClose(PnpMgrLevel2);
900  return Status;
901  }
902  else
903  {
904  /* This should never happen */
905  ASSERT(FALSE);
906  }
907 
908  NameU.Length = (USHORT)OldLength;
909 
910  RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
911 
912  Status = ZwSetValueKey(PnpMgrLevel2,
913  &NameU,
914  0,
916  DeviceNode->ResourceList,
918  if (!NT_SUCCESS(Status))
919  {
920  ZwClose(PnpMgrLevel2);
921  ExFreePool(NameU.Buffer);
922  return Status;
923  }
924 
925  /* "Remove" the suffix by setting the length back to what it used to be */
926  NameU.Length = (USHORT)OldLength;
927 
928  RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
929 
930  Status = ZwSetValueKey(PnpMgrLevel2,
931  &NameU,
932  0,
934  DeviceNode->ResourceListTranslated,
935  PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
936  ZwClose(PnpMgrLevel2);
937  ExFreePool(NameU.Buffer);
938 
939  if (!NT_SUCCESS(Status))
940  return Status;
941  }
942  else
943  {
944  ZwClose(PnpMgrLevel2);
945  }
946 
947  return STATUS_SUCCESS;
948 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
#define OBJ_OPENIF
Definition: winternl.h:229
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4155
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4300
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopUpdateResourceMapForPnPDevice().

◆ IopUpdateResourceMapForPnPDevice()

NTSTATUS IopUpdateResourceMapForPnPDevice ( IN PDEVICE_NODE  DeviceNode)

Definition at line 951 of file pnpres.c.

953 {
954  return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager");
955 }
NTSTATUS IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key)
Definition: pnpres.c:792
Definition: Node.h:9
static const WCHAR L[]
Definition: oid.c:1250

Referenced by IopAssignDeviceResources().