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.

224 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1995-2001 Microsoft Corporation
  3. Module Name:
  4. umpnplib.h
  5. Abstract:
  6. This module contains the private prototype defintions for routines contained
  7. in the statically linked library that is shared by both the Configuration
  8. Manager client DLL and User-Mode Plug and Play manager server DLL.
  9. Author:
  10. Jim Cavalaris (jamesca) 02/27/2001
  11. Environment:
  12. User mode only.
  13. Revision History:
  14. 27-February-2001 jamesca
  15. Creation and initial implementation.
  16. --*/
  17. #ifndef _UMPNPLIB_H_
  18. #define _UMPNPLIB_H_
  19. //-------------------------------------------------------------------
  20. // Common private utility routines (used by client and server)
  21. //-------------------------------------------------------------------
  22. BOOL
  23. IsLegalDeviceId(
  24. IN LPCWSTR pszDeviceInstance
  25. );
  26. BOOL
  27. SplitDeviceInstanceString(
  28. IN LPCWSTR pszDeviceInstance,
  29. OUT LPWSTR pszBase,
  30. OUT LPWSTR pszDeviceID,
  31. OUT LPWSTR pszInstanceID
  32. );
  33. CONFIGRET
  34. DeletePrivateKey(
  35. IN HKEY hBranchKey,
  36. IN LPCWSTR pszParentKey,
  37. IN LPCWSTR pszChildKey
  38. );
  39. BOOL
  40. RegDeleteNode(
  41. IN HKEY hParentKey,
  42. IN LPCWSTR szKey
  43. );
  44. BOOL
  45. Split1(
  46. IN LPCWSTR pszString,
  47. OUT LPWSTR pszString1,
  48. OUT LPWSTR pszString2
  49. );
  50. BOOL
  51. Split2(
  52. IN LPCWSTR pszString,
  53. OUT LPWSTR pszString1,
  54. OUT LPWSTR pszString2
  55. );
  56. CONFIGRET
  57. GetDevNodeKeyPath(
  58. IN handle_t hBinding,
  59. IN LPCWSTR pDeviceID,
  60. IN ULONG ulFlags,
  61. IN ULONG ulHardwareProfile,
  62. OUT LPWSTR pszBaesKey,
  63. OUT LPWSTR pszPrivateKey
  64. );
  65. CONFIGRET
  66. MapRpcExceptionToCR(
  67. ULONG ulRpcExceptionCode
  68. );
  69. //-------------------------------------------------------------------
  70. // Generic (private) locking support
  71. //-------------------------------------------------------------------
  72. //
  73. // Locking functions. These functions are used to make various parts of
  74. // the DLL multithread-safe. The basic idea is to have a mutex and an event.
  75. // The mutex is used to synchronize access to the structure being guarded.
  76. // The event is only signalled when the structure being guarded is destroyed.
  77. // To gain access to the guarded structure, a routine waits on both the mutex
  78. // and the event. If the event gets signalled, then the structure was destroyed.
  79. // If the mutex gets signalled, then the thread has access to the structure.
  80. //
  81. #define DESTROYED_EVENT 0
  82. #define ACCESS_MUTEX 1
  83. typedef struct _LOCKINFO {
  84. //
  85. // DESTROYED_EVENT, ACCESS_MUTEX
  86. //
  87. HANDLE LockHandles[2];
  88. } LOCKINFO, *PLOCKINFO;
  89. BOOL
  90. InitPrivateResource(
  91. OUT PLOCKINFO Lock
  92. );
  93. VOID
  94. DestroyPrivateResource(
  95. IN OUT PLOCKINFO Lock
  96. );
  97. BOOL
  98. __inline
  99. LockPrivateResource(
  100. IN PLOCKINFO Lock
  101. )
  102. {
  103. DWORD d = WaitForMultipleObjects(2,
  104. Lock->LockHandles,
  105. FALSE,
  106. INFINITE);
  107. //
  108. // Success if the mutex object satisfied the wait;
  109. // Failure if the table destroyed event satisified the wait, or
  110. // the mutex was abandoned, etc.
  111. //
  112. return ((d - WAIT_OBJECT_0) == ACCESS_MUTEX);
  113. }
  114. VOID
  115. __inline
  116. UnlockPrivateResource(
  117. IN PLOCKINFO Lock
  118. )
  119. {
  120. ReleaseMutex(Lock->LockHandles[ACCESS_MUTEX]);
  121. }
  122. //-------------------------------------------------------------------
  123. // Defines and typedefs needed for logconf routines
  124. //-------------------------------------------------------------------
  125. #include "pshpack1.h" // set to 1-byte packing
  126. //
  127. // DEFINES REQUIRED FOR PARTIAL (SUR) IMPLEMENTATION OF LOG_CONF and RES_DES
  128. //
  129. // We only allow one logical config (the BOOT_LOG_CONF) for SUR so no need
  130. // to keep track of multiple log confs, this will all change for Cairo.
  131. //
  132. typedef struct Private_Log_Conf_Handle_s {
  133. ULONG LC_Signature; // CM_PRIVATE_LOGCONF_HANDLE
  134. DEVINST LC_DevInst;
  135. ULONG LC_LogConfType;
  136. ULONG LC_LogConfTag; //LC_LogConfIndex;
  137. } Private_Log_Conf_Handle, *PPrivate_Log_Conf_Handle;
  138. typedef struct Private_Res_Des_Handle_s {
  139. ULONG RD_Signature; // CM_PRIVATE_RESDES_HANDLE
  140. DEVINST RD_DevInst;
  141. ULONG RD_LogConfType;
  142. ULONG RD_LogConfTag; //RD_LogConfIndex;
  143. RESOURCEID RD_ResourceType;
  144. ULONG RD_ResDesTag; //RD_ResDesIndex;
  145. } Private_Res_Des_Handle, *PPrivate_Res_Des_Handle;
  146. typedef struct Generic_Des_s {
  147. DWORD GENERIC_Count;
  148. DWORD GENERIC_Type;
  149. } GENERIC_DES, *PGENERIC_DES;
  150. typedef struct Generic_Resource_S {
  151. GENERIC_DES GENERIC_Header;
  152. } GENERIC_RESOURCE, *PGENERIC_RESOURCE;
  153. typedef struct Private_Log_Conf_s {
  154. ULONG LC_Flags; // Type of log conf
  155. ULONG LC_Priority; // Priority of log conf
  156. CS_RESOURCE LC_CS; // First and only res-des, class-specific
  157. } Private_Log_Conf, *PPrivate_Log_Conf;
  158. #include "poppack.h" // restore to default packing
  159. //-------------------------------------------------------------------
  160. // Defines and typedefs needed for range routines
  161. //-------------------------------------------------------------------
  162. typedef struct Range_Element_s {
  163. ULONG_PTR RL_Next;
  164. ULONG_PTR RL_Header;
  165. DWORDLONG RL_Start;
  166. DWORDLONG RL_End;
  167. } Range_Element, *PRange_Element;
  168. typedef struct Range_List_Hdr_s {
  169. ULONG_PTR RLH_Head;
  170. ULONG_PTR RLH_Header;
  171. ULONG RLH_Signature;
  172. LOCKINFO RLH_Lock;
  173. } Range_List_Hdr, *PRange_List_Hdr;
  174. #define Range_List_Signature 0x5959574D
  175. #endif // _UMPNPLIB_H_