Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. misc.c
  5. Abstract: Miscellaneous functions.
  6. Environment:
  7. Kernel mode
  8. Author:
  9. Michael Tsang (MikeTs) 13-Apr-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, RtlUnpackPartialDesc)
  15. #endif //ifdef ALLOC_PRAGMA
  16. /*****************************************************************************
  17. *
  18. * @doc EXTERNAL
  19. *
  20. * @func PCM_PARTIAL_RESOURCE_DESCRIPTOR | RtlUnpackPartialDesc |
  21. * Pulls out a pointer to the partial descriptor you are interested
  22. * in.
  23. *
  24. * @parm IN UCHAR | ResType | Specifies the resource type we are interested
  25. * in.
  26. * @parm IN PCM_RESOURCE_LIST | ResList | Points to the resource list to
  27. * search.
  28. * @parm IN OUT PULONG | Count | Points to the index of the partial
  29. * descriptor you are looking for, gets incremented if found.
  30. * i.e. starts with *Count = 0, then subsequent calls will find the
  31. * next partial descriptor.
  32. *
  33. * @rvalue SUCCESS | returns pointer to the partial descriptor found.
  34. * @rvalue FAILURE | returns NULL.
  35. *
  36. *****************************************************************************/
  37. PCM_PARTIAL_RESOURCE_DESCRIPTOR INTERNAL
  38. RtlUnpackPartialDesc(
  39. IN UCHAR ResType,
  40. IN PCM_RESOURCE_LIST ResList,
  41. IN OUT PULONG Count
  42. )
  43. {
  44. PROCNAME("RtlUnpackPartialDesc")
  45. ULONG i, j, hit = 0;
  46. PAGED_CODE();
  47. ENTER(2, ("(ResType=%x,ResList=%p,Count=%d)\n", ResType, ResList, *Count));
  48. for (i = 0; i < ResList->Count; ++i)
  49. {
  50. for (j = 0; j < ResList->List[i].PartialResourceList.Count; ++j)
  51. {
  52. if (ResList->List[i].PartialResourceList.PartialDescriptors[j].Type
  53. == ResType)
  54. {
  55. if (hit == *Count)
  56. {
  57. (*Count)++;
  58. EXIT(2, ("=%p (Count=%d)\n",
  59. &ResList->List[i].PartialResourceList.PartialDescriptors[j],
  60. *Count));
  61. return &ResList->List[i].PartialResourceList.PartialDescriptors[j];
  62. }
  63. else
  64. {
  65. hit++;
  66. }
  67. }
  68. }
  69. }
  70. EXIT(2, ("=NULL (Count=%d)\n", *Count));
  71. return NULL;
  72. } //RtlUnpackPartialDesc