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.

297 lines
6.5 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_PTR 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_PTR dwUserData
  164. )
  165. {
  166. _asm push ebx
  167. _asm mov eax,dnDevNode
  168. _asm mov ebx,fnConfigHandler
  169. _asm mov ecx,dwUserData
  170. Touch_Register(edx)
  171. VxDCall(MMDEVLDR_Register_Device_Driver);
  172. _asm pop ebx
  173. }
  174. VOID VXDINLINE MMDEVLDR_SetDevicePresence
  175. (
  176. DEVNODE dn,
  177. PCHAR pszReg,
  178. BOOL fPresent
  179. )
  180. {
  181. _asm push fPresent
  182. _asm push pszReg
  183. _asm push dn
  184. Touch_Register(eax)
  185. Touch_Register(ecx)
  186. Touch_Register(edx)
  187. VxDCall(MMDEVLDR_SetDevicePresence);
  188. _asm add esp, 3*4
  189. } ;
  190. VOID VXDINLINE MMDEVLDR_SetEnvironmentString
  191. (
  192. PCHAR pszName,
  193. PCHAR pszValue
  194. )
  195. {
  196. _asm push pszValue
  197. _asm push pszName
  198. Touch_Register(eax)
  199. Touch_Register(ecx)
  200. Touch_Register(edx)
  201. VxDCall(MMDEVLDR_SetEnvironmentString);
  202. _asm add esp, 2*4
  203. } ;
  204. BOOL VXDINLINE MMDEVLDR_GetEnvironmentString
  205. (
  206. PCHAR pszName,
  207. PCHAR pszValue,
  208. UINT uBufSize
  209. )
  210. {
  211. _asm push uBufSize
  212. _asm push pszValue
  213. _asm push pszName
  214. Touch_Register(eax)
  215. Touch_Register(ecx)
  216. Touch_Register(edx)
  217. VxDCall(MMDEVLDR_GetEnvironmentString);
  218. _asm add esp, 3*4
  219. } ;
  220. VOID VXDINLINE MMDEVLDR_RemoveEnvironmentString
  221. (
  222. PCHAR pszName
  223. )
  224. {
  225. _asm push pszName
  226. Touch_Register(eax)
  227. Touch_Register(ecx)
  228. Touch_Register(edx)
  229. VxDCall(MMDEVLDR_RemoveEnvironmentString);
  230. _asm add esp, 4
  231. } ;
  232. VOID VXDINLINE MMDEVLDR_AddEnvironmentString
  233. (
  234. PCHAR pszName,
  235. PCHAR pszValue
  236. )
  237. {
  238. _asm push pszValue
  239. _asm push pszName
  240. Touch_Register(eax)
  241. Touch_Register(ecx)
  242. Touch_Register(edx)
  243. VxDCall(MMDEVLDR_AddEnvironmentString);
  244. _asm add esp, 2*4
  245. } ;
  246. #pragma warning (disable:4035) // turn on no return code warning
  247. #endif // Begin_Service_Table
  248. #endif /* ;Internal */
  249.