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.

118 lines
2.8 KiB

  1. /* Copyright (c) 1998 Microsoft Corporation */
  2. /*
  3. * @Doc DMusic16
  4. *
  5. * @module locks.c - Manage page-locking the code which will be accessed via callbacks from MMSYSTEM |
  6. *
  7. */
  8. #include <windows.h>
  9. #include <mmsystem.h>
  10. #include "dmusic16.h"
  11. #include "debug.h"
  12. #define SINTEXT __segname("FIX_IN_TEXT")
  13. #define SOUTTEXT __segname("FIX_OUT_TEXT")
  14. #define SCOMMTEXT __segname("FIX_COMM_TEXT")
  15. #define SDATA __segname("_DATA")
  16. static VOID PASCAL NEAR
  17. ForcePresent(
  18. WORD wSegment)
  19. {
  20. LPBYTE lpb = (LPBYTE)MAKELP(wSegment, 0);
  21. _asm
  22. {
  23. les bx, [lpb]
  24. mov al, es:[bx]
  25. }
  26. }
  27. /* @func Page lock needed segments
  28. *
  29. */
  30. VOID PASCAL
  31. LockCode(
  32. WORD wFlags) /* @parm What to lock: Any combination of: */
  33. /* @flag LOCK_F_INPUT | To lock the MIDI input code segments */
  34. /* @flag LOCK_F_OUTPUT | To lock the MIDI output code segments */
  35. /* @flag LOCK_F_COMMON | To lock the common code segments */
  36. {
  37. if (wFlags & LOCK_F_INPUT)
  38. {
  39. ForcePresent(SINTEXT);
  40. if (!GlobalSmartPageLock(SINTEXT))
  41. {
  42. DPF(0, "Could not lock input text");
  43. }
  44. }
  45. if (wFlags & LOCK_F_OUTPUT)
  46. {
  47. ForcePresent(SOUTTEXT);
  48. if (!GlobalSmartPageLock(SOUTTEXT))
  49. {
  50. DPF(0, "Could not lock output text");
  51. }
  52. }
  53. if (wFlags & LOCK_F_COMMON)
  54. {
  55. ForcePresent(SCOMMTEXT);
  56. if (!GlobalSmartPageLock(SCOMMTEXT))
  57. {
  58. DPF(0, "Could not lock common text");
  59. }
  60. ForcePresent(SDATA);
  61. if (!GlobalSmartPageLock(SDATA))
  62. {
  63. DPF(0, "Could not lock data segment");
  64. }
  65. }
  66. }
  67. /* @func Page unlock needed segments
  68. *
  69. * @comm
  70. */
  71. VOID PASCAL
  72. UnlockCode(
  73. WORD wFlags) /* @parm What to unlock: Any combination of: */
  74. /* @flag LOCK_F_INPUT | To unlock the MIDI input code segments */
  75. /* @flag LOCK_F_OUTPUT | To unlock the MIDI output code segments */
  76. /* @flag LOCK_F_COMMON | To unlock the common code segments */
  77. {
  78. if (wFlags & LOCK_F_INPUT)
  79. {
  80. if (!GlobalSmartPageUnlock(SINTEXT))
  81. {
  82. DPF(0, "Could not unlock input text");
  83. }
  84. }
  85. if (wFlags & LOCK_F_OUTPUT)
  86. {
  87. if (!GlobalSmartPageUnlock(SOUTTEXT))
  88. {
  89. DPF(0, "Could not unlock output text");
  90. }
  91. }
  92. if (wFlags & LOCK_F_COMMON)
  93. {
  94. if (!GlobalSmartPageUnlock(SCOMMTEXT))
  95. {
  96. DPF(0, "Could not unlock common text");
  97. }
  98. if (!GlobalSmartPageUnlock(SDATA))
  99. {
  100. DPF(0, "Could not unlock data");
  101. }
  102. }
  103. }