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.

370 lines
12 KiB

  1. /***************************************************************************
  2. * winmmi.h
  3. *
  4. * Copyright (c) Microsoft Corporation 1990. All rights reserved
  5. *
  6. * private include file
  7. *
  8. * History
  9. *
  10. * 15 Jan 92 - Robin Speed (RobinSp) and Steve Davies (SteveDav) -
  11. * major NT update
  12. * 6 Feb 92 - LaurieGr replaced HLOCAL by HANDLE
  13. *
  14. ***************************************************************************/
  15. /***************************************************************************
  16. Useful include files for winmm component
  17. ***************************************************************************/
  18. #ifndef WINMMI_H
  19. #define WINMMI_H /* Protect against double inclusion */
  20. #include <windows.h>
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include "mmsystem.h" /* Pick up the public header */
  24. /*--------------------------------------------------------------------*\
  25. * Unicode helper macros
  26. \*--------------------------------------------------------------------*/
  27. #define SZCODE CHAR
  28. #define TSZCODE TCHAR
  29. #define WSZCODE WCHAR
  30. #define BYTE_GIVEN_CHAR(x) ( (x) * sizeof( WCHAR ) )
  31. #define CHAR_GIVEN_BYTE(x) ( (x) / sizeof( WCHAR ) )
  32. int Iwcstombs(LPTSTR lpstr, LPCWSTR lpwstr, int len);
  33. int Imbstowcs(LPWSTR lpwstr, LPCTSTR lpstr, int len);
  34. /***********************************************************************
  35. *
  36. * prototypes from "mmiomisc.c"
  37. *
  38. ***********************************************************************/
  39. PBYTE AsciiStrToUnicodeStr( PBYTE pdst, PBYTE pmax, LPCTSTR psrc );
  40. PBYTE UnicodeStrToAsciiStr( PBYTE pdst, PBYTE pmax, LPCWSTR psrc);
  41. LPWSTR AllocUnicodeStr( LPCTSTR lpSourceStr );
  42. BOOL FreeUnicodeStr( LPWSTR lpStr );
  43. LPSTR AllocAsciiStr( LPCWSTR lpSourceStr );
  44. BOOL FreeAsciiStr( LPSTR lpStr );
  45. /***********************************************************************
  46. *
  47. * prototypes from "mmio.c"
  48. *
  49. ***********************************************************************/
  50. void mmioCleanupIOProcs(HANDLE hTask);
  51. /***********************************************************************
  52. *
  53. * Timer functions
  54. *
  55. ***********************************************************************/
  56. #if 0 //BUGBUG - are timer functions required?
  57. #ifndef MMNOTIMER
  58. BOOL TimeInit(void);
  59. void TimeCleanup(DWORD ThreadId);
  60. UINT timeSetEventInternal(UINT wDelay, UINT wResolution, LPTIMECALLBACK lpFunction, DWORD dwUser, UINT wFlags, BOOL IsWOW);
  61. #endif // !MMNOTIMER
  62. #endif
  63. /***********************************************************************
  64. *
  65. * Information structure used to play sounds
  66. *
  67. ***********************************************************************/
  68. #define WAIT_FOREVER INFINITE
  69. /***************************************************************************
  70. Memory allocation using our local heap
  71. ***************************************************************************/
  72. PVOID winmmAlloc(DWORD cb);
  73. PVOID winmmReAlloc(PVOID ptr, DWORD cb);
  74. //#define winmmFree(ptr) HeapFree(hHeap, 0, (ptr))
  75. /***************************************************************************
  76. LOCKING AND UNLOCKING MEMORY
  77. ***************************************************************************/
  78. #if 0
  79. BOOL HugePageLock(LPVOID lpArea, DWORD dwLength);
  80. void HugePageUnlock(LPVOID lpArea, DWORD dwLength);
  81. #else
  82. #define HugePageLock(lpArea, dwLength) (TRUE)
  83. #define HugePageUnlock(lpArea, dwLength)
  84. #endif
  85. /**************************************************************************
  86. //
  87. //**************************************************************************/
  88. #define TYPE_UNKNOWN 0
  89. #define TYPE_WAVEOUT 1
  90. #define TYPE_WAVEIN 2
  91. #define TYPE_MIDIOUT 3
  92. #define TYPE_MIDIIN 4
  93. #define TYPE_MMIO 5
  94. #define TYPE_MCI 6
  95. #define TYPE_DRVR 7
  96. #define TYPE_MIXER 8
  97. #define TYPE_MIDISTRM 9
  98. #define TYPE_AUX 10
  99. /****************************************************************************
  100. handle apis's
  101. ****************************************************************************/
  102. /*
  103. // all MMSYSTEM handles are tagged with the following structure.
  104. //
  105. // a MMSYSTEM handle is really a fixed local memory object.
  106. //
  107. // the functions NewHandle() and FreeHandle() create and release a MMSYSTEM
  108. // handle.
  109. //
  110. */
  111. typedef struct tagHNDL {
  112. struct tagHNDL *pNext; // link to next handle
  113. UINT uType; // type of handle wave, midi, mmio, ...
  114. HANDLE hThread; // task that owns it
  115. UINT h16; // Corresponding WOW handle
  116. CRITICAL_SECTION CritSec; // Serialize access
  117. } HNDL, *PHNDL;
  118. /*************************************************************************/
  119. #define HtoPH(h) ((PHNDL)(h)-1)
  120. #define PHtoH(ph) ((ph) ? (HANDLE)((PHNDL)(ph)+1) : 0)
  121. #define HtoPT(t,h) ((t)(h))
  122. #define PTtoH(t,pt) ((t)(pt))
  123. extern PHNDL pHandleList;
  124. //
  125. // Handles can be tested for ownership and reserved at the same time
  126. //
  127. #define ENTER_MM_HANDLE(h) (EnterCriticalSection(&HtoPH(h)->CritSec))
  128. #define LEAVE_MM_HANDLE(h) ((void)LeaveCriticalSection(&HtoPH(h)->CritSec))
  129. /*
  130. // all wave and midi handles will be linked into
  131. // a global list, so we can enumerate them latter if needed.
  132. //
  133. // all handle structures start with a HNDL structure, that contain common
  134. fields
  135. //
  136. // pHandleList points to the first handle in the list
  137. //
  138. // HandleListCritSec protects the handle list
  139. //
  140. // the NewHandle() and FreeHandle() functions are used to add/remove
  141. // a handle to/from the list
  142. */
  143. //extern PHNDL pHandleList;
  144. //extern CRITICAL_SECTION HandleListCritSec;
  145. extern HANDLE NewHandle(UINT uType, UINT size);
  146. extern void FreeHandle(HANDLE h);
  147. #define GetHandleType(h) (HtoPH(h)->uType)
  148. #define GetHandleOwner(h) (HtoPH(h)->hThread)
  149. #define GetHandleFirst() (PHtoH(pHandleList))
  150. #define GetHandleNext(h) (PHtoH(HtoPH(h)->pNext))
  151. #define SetHandleOwner(h,hOwn) (HtoPH(h)->hThread = (hOwn))
  152. #define GetWOWHandle(h) (HtoPH(h)->h16)
  153. #define SetWOWHandle(h, myh16) (HtoPH(h)->h16 = (myh16))
  154. /****************************************************************************
  155. user debug support
  156. ****************************************************************************/
  157. #define DebugErr(x,y) /* BUGBUG - put in error logging later */
  158. #define DebugErr1(flags, sz, a)
  159. #ifdef DEBUG_RETAIL
  160. #define MM_GET_DEBUG DRV_USER
  161. #define MM_GET_DEBUGOUT DRV_USER+1
  162. #define MM_SET_DEBUGOUT DRV_USER+2
  163. #define MM_GET_MCI_DEBUG DRV_USER+3
  164. #define MM_SET_MCI_DEBUG DRV_USER+4
  165. #define MM_GET_MM_DEBUG DRV_USER+5
  166. #define MM_SET_MM_DEBUG DRV_USER+6
  167. #define MM_HINFO_NEXT DRV_USER+10
  168. #define MM_HINFO_TASK DRV_USER+11
  169. #define MM_HINFO_TYPE DRV_USER+12
  170. #define MM_HINFO_MCI DRV_USER+20
  171. #define MM_DRV_RESTART DRV_USER+30
  172. /*
  173. // these validation routines can be found in DEBUG.C
  174. */
  175. // The kernel validation is turned OFF because it appeared to test every page
  176. // before use and this took over a minute for soundrec with a 10MB buffer
  177. //
  178. #ifdef USE_KERNEL_VALIDATION
  179. #define ValidateReadPointer(p, len) (!IsBadReadPtr(p, len))
  180. #define ValidateWritePointer(p, len) (!IsBadWritePtr(p, len))
  181. #define ValidateString(lsz, max_len) (!IsBadStringPtrA(lsz, max_len))
  182. #define ValidateStringW(lsz, max_len) (!IsBadStringPtrW(lsz, max_len))
  183. #else
  184. BOOL ValidateReadPointer(LPVOID p, DWORD len);
  185. BOOL ValidateWritePointer(LPVOID p, DWORD len);
  186. BOOL ValidateString(LPCTSTR lsz, DWORD max_len);
  187. BOOL ValidateStringW(LPCWSTR lsz, DWORD max_len);
  188. #endif // USE_KERNEL_VALIDATION
  189. BOOL ValidateHandle(HANDLE h, UINT uType);
  190. BOOL ValidateHeader(LPVOID p, UINT uSize, UINT uType);
  191. BOOL ValidateCallbackType(DWORD dwCallback, UINT uType);
  192. /********************************************************************
  193. * When time permits we should change to using the Kernel supplied and
  194. * supported validation routines:
  195. *
  196. * BOOL WINAPI IsBadReadPtr(CONST VOID *lp, UINT ucb );
  197. * BOOL WINAPI IsBadWritePtr(LPVOID lp, UINT ucb );
  198. * BOOL WINAPI IsBadHugeReadPtr(CONST VOID *lp, UINT ucb);
  199. * BOOL WINAPI IsBadHugeWritePtr(LPVOID lp, UINT ucb);
  200. * BOOL WINAPI IsBadCodePtr(FARPROC lpfn);
  201. * BOOL WINAPI IsBadStringPtrA(LPCTSTR lpsz, UINT ucchMax);
  202. * BOOL WINAPI IsBadStringPtrW(LPCWSTR lpsz, UINT ucchMax);
  203. *
  204. * These routines can be found in * \nt\private\WINDOWS\BASE\CLIENT\PROCESS.C
  205. *
  206. ********************************************************************/
  207. #define V_HANDLE(h, t, r) { if (!ValidateHandle(h, t)) return (r); }
  208. #define BAD_HANDLE(h, t) ( !(ValidateHandle((h), (t))) )
  209. #define V_HEADER(p, w, t, r) { if (!ValidateHeader((p), (w), (t))) return (
  210. r); }
  211. #define V_RPOINTER(p, l, r) { if (!ValidateReadPointer((PVOID)(p), (l)))
  212. return (r); }
  213. #define V_RPOINTER0(p, l, r) { if ((p) && !ValidateReadPointer((PVOID)(p),
  214. (l))) return (r); }
  215. #define V_WPOINTER(p, l, r) { if (!ValidateWritePointer((PVOID)(p), (l)))
  216. return (r); }
  217. #define V_WPOINTER0(p, l, r) { if ((p) && !ValidateWritePointer((PVOID)(p)
  218. , (l))) return (r); }
  219. #define V_DCALLBACK(d, w, r) { if ((d) && !ValidateCallbackType((d), (w)))
  220. return(r); }
  221. //#define V_DCALLBACK(d, w, r) 0
  222. #define V_TCALLBACK(d, r) 0
  223. #define V_CALLBACK(f, r) { if (IsBadCodePtr((f))) return (r); }
  224. #define V_CALLBACK0(f, r) { if ((f) && IsBadCodePtr((f))) return (r); }
  225. #define V_STRING(s, l, r) { if (!ValidateString(s,l)) return (r); }
  226. #define V_STRING_W(s, l, r) { if (!ValidateStringW(s,l)) return (r); }
  227. #define V_FLAGS(t, b, f, r) { if ((t) & ~(b)) { return (r); }}
  228. #define V_DFLAGS(t, b, f, r) { if ((t) & ~(b)) {/* LogParamError(
  229. ERR_BAD_DFLAGS, (FARPROC)(f), (LPVOID)(DWORD)(t));*/ return (r); }}
  230. #define V_MMSYSERR(e, f, t, r) { /* LogParamError(e, (FARPROC)(f), (LPVOID)(
  231. DWORD)(t));*/ return (r); }
  232. #else /*ifdef DEBUG_RETAIL */
  233. #define V_HANDLE(h, t, r) { if (!(h)) return (r); }
  234. #define BAD_HANDLE(h, t) ( !(ValidateHandle((h), (t))) )
  235. #define V_HEADER(p, w, t, r) { if (!(p)) return (r); }
  236. #define V_RPOINTER(p, l, r) { if (!(p)) return (r); }
  237. #define V_RPOINTER0(p, l, r) 0
  238. #define V_WPOINTER(p, l, r) { if (!(p)) return (r); }
  239. #define V_WPOINTER0(p, l, r) 0
  240. #define V_DCALLBACK(d, w, r) { if ((d) && !ValidateCallbackType((d), (w))) return(r); }
  241. //#define V_DCALLBACK(d, w, r) 0
  242. #define V_TCALLBACK(d, r) 0
  243. #define V_CALLBACK(f, r) { if (IsBadCodePtr((f))) return (r); }
  244. #define V_CALLBACK0(f, r) { if ((f) && IsBadCodePtr((f))) return (r); }
  245. #define V_STRING(s, l, r) { if (!(s)) return (r); }
  246. #define V_STRING_W(s, l, r) { if (!(s)) return (r); }
  247. #define V_FLAGS(t, b, f, r) 0
  248. #define V_DFLAGS(t, b, f, r) { if ((t) & ~(b)) return (r); }
  249. #define V_MMSYSERR(e, f, t, r) { return (r); }
  250. #endif /* ifdef DEBUG_RETAIL */
  251. /****************************************************************************
  252. RIFF constants used to access wave files
  253. ****************************************************************************/
  254. #define FOURCC_FMT mmioFOURCC('f', 'm', 't', ' ')
  255. #define FOURCC_DATA mmioFOURCC('d', 'a', 't', 'a')
  256. #define FOURCC_WAVE mmioFOURCC('W', 'A', 'V', 'E')
  257. extern HWND hwndNotify;
  258. void FAR PASCAL WaveOutNotify(DWORD wParam, LONG lParam); // in PLAYWAV.C
  259. /*
  260. // Things not in Win32
  261. */
  262. /*
  263. // other stuff
  264. */
  265. // Maximum length, including the terminating NULL, of an Scheme entry.
  266. //
  267. #define SCH_TYPE_MAX_LENGTH 64
  268. // Maximum length, including the terminating NULL, of an Event entry.
  269. //
  270. #define EVT_TYPE_MAX_LENGTH 32
  271. // Maximum length, including the terminating NULL, of an App entry.
  272. //
  273. #define APP_TYPE_MAX_LENGTH 64
  274. // Sound event names can be a fully qualified filepath with a NULL
  275. // terminator.
  276. //
  277. #define MAX_SOUND_NAME_CHARS 144
  278. // sound atom names are composed of:
  279. // <1 char id>
  280. // <reg key name>
  281. // <1 char sep>
  282. // <filepath>
  283. //
  284. #define MAX_SOUND_ATOM_CHARS (1 + 40 + 1 + MAX_SOUND_NAME_CHARS)
  285. #endif /* WINMMI_H */