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.

231 lines
6.0 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  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. SplitString(
  28. IN LPCWSTR SourceString,
  29. IN WCHAR SearchChar,
  30. IN ULONG nOccurrence,
  31. OUT LPWSTR String1,
  32. IN ULONG Length1,
  33. OUT LPWSTR String2,
  34. IN ULONG Length2
  35. );
  36. BOOL
  37. SplitDeviceInstanceString(
  38. IN LPCWSTR pszDeviceInstance,
  39. OUT LPWSTR pszBase,
  40. OUT LPWSTR pszDeviceID,
  41. OUT LPWSTR pszInstanceID
  42. );
  43. BOOL
  44. SplitClassInstanceString(
  45. IN LPCWSTR pszClassInstance,
  46. OUT LPWSTR pszClass,
  47. OUT LPWSTR pszInstance
  48. );
  49. CONFIGRET
  50. DeletePrivateKey(
  51. IN HKEY hBranchKey,
  52. IN LPCWSTR pszParentKey,
  53. IN LPCWSTR pszChildKey
  54. );
  55. BOOL
  56. RegDeleteNode(
  57. IN HKEY hParentKey,
  58. IN LPCWSTR szKey
  59. );
  60. CONFIGRET
  61. GetDevNodeKeyPath(
  62. IN handle_t hBinding,
  63. IN LPCWSTR pDeviceID,
  64. IN ULONG ulFlags,
  65. IN ULONG ulHardwareProfile,
  66. OUT LPWSTR pszBaseKey,
  67. IN ULONG ulBaseKeyLength,
  68. OUT LPWSTR pszPrivateKey,
  69. IN ULONG ulPrivateKeyLength,
  70. IN BOOL bCreateAlways
  71. );
  72. CONFIGRET
  73. MapRpcExceptionToCR(
  74. ULONG ulRpcExceptionCode
  75. );
  76. //-------------------------------------------------------------------
  77. // Generic (private) locking support
  78. //-------------------------------------------------------------------
  79. //
  80. // Locking functions. These functions are used to make various parts of
  81. // the DLL multithread-safe. The basic idea is to have a mutex and an event.
  82. // The mutex is used to synchronize access to the structure being guarded.
  83. // The event is only signalled when the structure being guarded is destroyed.
  84. // To gain access to the guarded structure, a routine waits on both the mutex
  85. // and the event. If the event gets signalled, then the structure was destroyed.
  86. // If the mutex gets signalled, then the thread has access to the structure.
  87. //
  88. #define DESTROYED_EVENT 0
  89. #define ACCESS_MUTEX 1
  90. typedef struct _LOCKINFO {
  91. //
  92. // DESTROYED_EVENT, ACCESS_MUTEX
  93. //
  94. HANDLE LockHandles[2];
  95. } LOCKINFO, *PLOCKINFO;
  96. BOOL
  97. InitPrivateResource(
  98. OUT PLOCKINFO Lock
  99. );
  100. VOID
  101. DestroyPrivateResource(
  102. IN OUT PLOCKINFO Lock
  103. );
  104. BOOL
  105. __inline
  106. LockPrivateResource(
  107. IN PLOCKINFO Lock
  108. )
  109. {
  110. DWORD d = WaitForMultipleObjects(2,
  111. Lock->LockHandles,
  112. FALSE,
  113. INFINITE);
  114. //
  115. // Success if the mutex object satisfied the wait;
  116. // Failure if the table destroyed event satisified the wait, or
  117. // the mutex was abandoned, etc.
  118. //
  119. return ((d - WAIT_OBJECT_0) == ACCESS_MUTEX);
  120. }
  121. VOID
  122. __inline
  123. UnlockPrivateResource(
  124. IN PLOCKINFO Lock
  125. )
  126. {
  127. ReleaseMutex(Lock->LockHandles[ACCESS_MUTEX]);
  128. }
  129. //-------------------------------------------------------------------
  130. // Defines and typedefs needed for logconf routines
  131. //-------------------------------------------------------------------
  132. #include "pshpack1.h" // set to 1-byte packing
  133. //
  134. // DEFINES REQUIRED FOR PARTIAL (SUR) IMPLEMENTATION OF LOG_CONF and RES_DES
  135. //
  136. // We only allow one logical config (the BOOT_LOG_CONF) for SUR so no need
  137. // to keep track of multiple log confs, this will all change for Cairo.
  138. //
  139. typedef struct Private_Log_Conf_Handle_s {
  140. ULONG LC_Signature; // CM_PRIVATE_LOGCONF_HANDLE
  141. DEVINST LC_DevInst;
  142. ULONG LC_LogConfType;
  143. ULONG LC_LogConfTag; //LC_LogConfIndex;
  144. } Private_Log_Conf_Handle, *PPrivate_Log_Conf_Handle;
  145. typedef struct Private_Res_Des_Handle_s {
  146. ULONG RD_Signature; // CM_PRIVATE_RESDES_HANDLE
  147. DEVINST RD_DevInst;
  148. ULONG RD_LogConfType;
  149. ULONG RD_LogConfTag; //RD_LogConfIndex;
  150. RESOURCEID RD_ResourceType;
  151. ULONG RD_ResDesTag; //RD_ResDesIndex;
  152. } Private_Res_Des_Handle, *PPrivate_Res_Des_Handle;
  153. typedef struct Generic_Des_s {
  154. DWORD GENERIC_Count;
  155. DWORD GENERIC_Type;
  156. } GENERIC_DES, *PGENERIC_DES;
  157. typedef struct Generic_Resource_S {
  158. GENERIC_DES GENERIC_Header;
  159. } GENERIC_RESOURCE, *PGENERIC_RESOURCE;
  160. typedef struct Private_Log_Conf_s {
  161. ULONG LC_Flags; // Type of log conf
  162. ULONG LC_Priority; // Priority of log conf
  163. CS_RESOURCE LC_CS; // First and only res-des, class-specific
  164. } Private_Log_Conf, *PPrivate_Log_Conf;
  165. #include "poppack.h" // restore to default packing
  166. //-------------------------------------------------------------------
  167. // Defines and typedefs needed for range routines
  168. //-------------------------------------------------------------------
  169. typedef struct Range_Element_s {
  170. ULONG_PTR RL_Next;
  171. ULONG_PTR RL_Header;
  172. DWORDLONG RL_Start;
  173. DWORDLONG RL_End;
  174. } Range_Element, *PRange_Element;
  175. typedef struct Range_List_Hdr_s {
  176. ULONG_PTR RLH_Head;
  177. ULONG_PTR RLH_Header;
  178. ULONG RLH_Signature;
  179. LOCKINFO RLH_Lock;
  180. } Range_List_Hdr, *PRange_List_Hdr;
  181. #define Range_List_Signature 0x5959574D
  182. #endif // _UMPNPLIB_H_