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.

296 lines
6.9 KiB

  1. /*
  2. * MMDEVLDR.H - The main include file for the DevLoader
  3. *
  4. * Version 4.00
  5. *
  6. * Copyright (C) 1994-1995 Microsoft Corporation. All Rights Reserved.
  7. *
  8. */
  9. #ifdef _WIN32 /* ;BeginInternal */
  10. #define MMDEVLDR_IOCTL_GETVERSION 0
  11. #define MMDEVLDR_IOCTL_LINPAGELOCK 1
  12. #define MMDEVLDR_IOCTL_LINPAGEUNLOCK 2
  13. #define MMDEVLDR_IOCTL_RING0THREADHANDLE 3
  14. #define MMDEVLDR_IOCTL_QUEUEAPC 4
  15. #define MMDEVLDR_IOCTL_GETCHANGENOTIFYPTR 5
  16. #define MMDEVLDR_IOCTL_CLOSEVXDHANDLE 6
  17. #define MMDEVLDR_IOCTL_PAGEALLOCATE 7
  18. #define MMDEVLDR_IOCTL_PAGEFREE 8
  19. #define MMDEVLDR_IOCTL_GETDEVICESTATUS 9
  20. #define MM_DEVSTATUS_ERROR 0
  21. #define MM_DEVSTATUS_STARTED 1
  22. #define MM_DEVSTATUS_UNKNOWNPROB 2
  23. #define MM_DEVSTATUS_DISABLED 3
  24. typedef struct tagLOCKUNLOCKPARMS
  25. {
  26. DWORD dwStartPage;
  27. DWORD dwPageCount;
  28. DWORD fdwOperation;
  29. } LOCKUNLOCKPARMS;
  30. typedef struct tagQUEUEAPCPARMS
  31. {
  32. DWORD fnCallback;
  33. DWORD dwUser;
  34. DWORD hRing0Thd;
  35. } QUEUEAPCPARMS;
  36. typedef struct tagPAGEALLOCATEPARMS
  37. {
  38. DWORD dwFlags;
  39. DWORD dwPageCount;
  40. } PAGEALLOCATEPARMS;
  41. typedef struct tagPAGEALLOCATERETURN
  42. {
  43. VOID * lpvBase;
  44. DWORD hMem;
  45. DWORD dwPageCount;
  46. DWORD dwPhysBase;
  47. } PAGEALLOCATERETURN;
  48. #endif
  49. #ifdef MMDEVLDR_VXD
  50. #define MM_STOP 0
  51. #define MM_START 1
  52. #define MM_MMDEVLDR_UP 3
  53. #define CONFIG_QUERYSTART 0x01000
  54. #define MAXLEN 256
  55. typedef struct tagMMDEVNODE
  56. {
  57. DEVNODE dn ;
  58. DWORD dwDevStatus ;
  59. VMMLIST hlDrivers ;
  60. } MMDEVNODE, *PMMDEVNODE ;
  61. typedef struct tagMMDRVNODE
  62. {
  63. CMCONFIGHANDLER pConfigHandler ;
  64. DWORD dwRefData ;
  65. } MMDRVNODE, *PMMDRVNODE ;
  66. //
  67. // macros
  68. //
  69. #define SIZEOF_ARRAY(ar) (sizeof(ar)/sizeof((ar)[0]))
  70. #if defined(DEBUG_RETAIL) || defined(DEBUG)
  71. #define DBG_TRACE(strings) {\
  72. _Debug_Printf_Service( "MMDEVLDR: "); \
  73. _Debug_Printf_Service##strings; \
  74. _Debug_Printf_Service("\n");}
  75. #ifdef DEBUG
  76. #define DBG_ERROR(strings) {\
  77. _Debug_Printf_Service( "MMDEVLDR ERROR: "); \
  78. _Debug_Printf_Service##strings; \
  79. _Debug_Printf_Service("\n");\
  80. {_asm int 3}}
  81. #else
  82. #define DBG_ERROR(strings) {\
  83. _Debug_Printf_Service( "MMDEVLDR ERROR: "); \
  84. _Debug_Printf_Service##strings; \
  85. _Debug_Printf_Service("\n");}
  86. #endif
  87. #else
  88. #define DBG_TRACE(strings)
  89. #define DBG_ERROR(strings)
  90. #endif
  91. #ifdef DEBUG
  92. #define DPF( strings ) _Debug_Printf_Service##strings;
  93. #else
  94. #define DPF( strings )
  95. #endif
  96. #define QUOTE(x) #x
  97. #define QQUOTE(y) QUOTE(y)
  98. #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) ") : " str
  99. //
  100. // internal function prototypes
  101. //
  102. void MMDEVLDR_Call_MMSystem(DEVNODE dnDevNode, DWORD fLoad);
  103. void MMDEVLDR_CheckForMMSystem(void);
  104. DWORD StringLen(PCHAR psz);
  105. PCHAR StringCopy(PCHAR pszDst, PCHAR pszSrc);
  106. PCHAR StringCat(PCHAR pszDst, PCHAR pszSrc);
  107. #pragma warning (disable:4035) // turn off no return code warning
  108. PSTR VXDINLINE Get_Environment_String
  109. (
  110. PSTR pszName
  111. )
  112. {
  113. _asm push esi
  114. _asm mov esi, pszName
  115. VMMCall( Get_Environment_String ) ;
  116. _asm mov eax, edx
  117. _asm pop esi
  118. }
  119. #pragma warning (default:4035) // turn on no return code warning
  120. BOOL _InitGlobalEnvironment() ;
  121. VOID MMDEVLDR_SetEnvironmentString
  122. (
  123. PSTR pszName,
  124. PSTR pszValue
  125. ) ;
  126. BOOL MMDEVLDR_GetEnvironmentString
  127. (
  128. PSTR pszName,
  129. PSTR pszValue,
  130. UINT uBufSize
  131. ) ;
  132. VOID MMDEVLDR_RemoveEnvironmentString
  133. (
  134. PSTR pszName
  135. ) ;
  136. VOID MMDEVLDR_AddEnvironmentString
  137. (
  138. PSTR pszName,
  139. PSTR pszValue
  140. ) ;
  141. #else /* ;EndInternal */
  142. #define Multimedia_OEM_ID 0x0440 // ; MS Reserved OEM # 34
  143. #define MMDEVLDR_DEVICE_ID Multimedia_OEM_ID + 10 //;MMDEVLDR's device ID
  144. #ifdef Begin_Service_Table // define only if vmm.h is included
  145. #define MMDEVLDR_Service Declare_Service
  146. #pragma warning (disable:4003) // turn off not enough params warning
  147. //MACROS
  148. Begin_Service_Table(MMDEVLDR)
  149. MMDEVLDR_Service (MMDEVLDR_Register_Device_Driver, LOCAL)
  150. MMDEVLDR_Service (MMDEVLDR_SetDevicePresence)
  151. MMDEVLDR_Service (MMDEVLDR_SetEnvironmentString)
  152. MMDEVLDR_Service (MMDEVLDR_GetEnvironmentString)
  153. MMDEVLDR_Service (MMDEVLDR_RemoveEnvironmentString)
  154. MMDEVLDR_Service (MMDEVLDR_AddEnvironmentString)
  155. End_Service_Table(MMDEVLDR)
  156. //ENDMACROS
  157. #pragma warning (default:4003) // turn on not enough params warning
  158. #pragma warning (disable:4035) // turn off no return code warning
  159. VOID VXDINLINE MMDEVLDR_Register_Device_Driver
  160. (
  161. DEVNODE dnDevNode,
  162. DWORD fnConfigHandler,
  163. DWORD dwUserData
  164. )
  165. {
  166. _asm push ebx
  167. _asm mov eax,dnDevNode
  168. _asm mov ebx,fnConfigHandler
  169. _asm mov ecx,dwUserData
  170. VxDCall(MMDEVLDR_Register_Device_Driver);
  171. _asm pop ebx
  172. }
  173. VOID VXDINLINE MMDEVLDR_SetDevicePresence
  174. (
  175. DEVNODE dn,
  176. PCHAR pszReg,
  177. BOOL fPresent
  178. )
  179. {
  180. _asm push fPresent
  181. _asm push pszReg
  182. _asm push dn
  183. Touch_Register(eax)
  184. Touch_Register(ecx)
  185. Touch_Register(edx)
  186. VxDCall(MMDEVLDR_SetDevicePresence);
  187. _asm add esp, 3*4
  188. } ;
  189. VOID VXDINLINE MMDEVLDR_SetEnvironmentString
  190. (
  191. PCHAR pszName,
  192. PCHAR pszValue
  193. )
  194. {
  195. _asm push pszValue
  196. _asm push pszName
  197. Touch_Register(eax)
  198. Touch_Register(ecx)
  199. Touch_Register(edx)
  200. VxDCall(MMDEVLDR_SetEnvironmentString);
  201. _asm add esp, 2*4
  202. } ;
  203. BOOL VXDINLINE MMDEVLDR_GetEnvironmentString
  204. (
  205. PCHAR pszName,
  206. PCHAR pszValue,
  207. UINT uBufSize
  208. )
  209. {
  210. _asm push uBufSize
  211. _asm push pszValue
  212. _asm push pszName
  213. Touch_Register(eax)
  214. Touch_Register(ecx)
  215. Touch_Register(edx)
  216. VxDCall(MMDEVLDR_GetEnvironmentString);
  217. _asm add esp, 3*4
  218. } ;
  219. VOID VXDINLINE MMDEVLDR_RemoveEnvironmentString
  220. (
  221. PCHAR pszName
  222. )
  223. {
  224. _asm push pszName
  225. Touch_Register(eax)
  226. Touch_Register(ecx)
  227. Touch_Register(edx)
  228. VxDCall(MMDEVLDR_RemoveEnvironmentString);
  229. _asm add esp, 4
  230. } ;
  231. VOID VXDINLINE MMDEVLDR_AddEnvironmentString
  232. (
  233. PCHAR pszName,
  234. PCHAR pszValue
  235. )
  236. {
  237. _asm push pszValue
  238. _asm push pszName
  239. Touch_Register(eax)
  240. Touch_Register(ecx)
  241. Touch_Register(edx)
  242. VxDCall(MMDEVLDR_AddEnvironmentString);
  243. _asm add esp, 2*4
  244. } ;
  245. #pragma warning (disable:4035) // turn on no return code warning
  246. #endif // Begin_Service_Table
  247. #endif /* ;Internal */