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.

248 lines
4.1 KiB

  1. /*++
  2. *
  3. * VDD v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * VDD.C - Sample VDD for NT-MVDM
  8. *
  9. --*/
  10. #include "fax32.h"
  11. #include "vddsvc.h"
  12. USHORT Sub16CS;
  13. USHORT Sub16IP;
  14. BOOL
  15. VDDInitialize(
  16. IN PVOID DllHandle,
  17. IN ULONG Reason,
  18. IN PCONTEXT Context OPTIONAL
  19. )
  20. /*++
  21. Routine Description:
  22. Arguments:
  23. DllHandle - Not Used
  24. Reason - Attach or Detach
  25. Context - Not Used
  26. Return Value:
  27. SUCCESS - TRUE
  28. FAILURE - FALSE
  29. --*/
  30. {
  31. switch ( Reason ) {
  32. case DLL_PROCESS_ATTACH:
  33. // Allocate VDD's local heap if needed. Check that NT FAX driver
  34. // is available by opening that device.
  35. //....
  36. // Install user hook for callback service.
  37. if(!VDDInstallUserHook (DllHandle,&FAXVDDCreate, &FAXVDDTerminate,
  38. &FAXVDDBlock, &FAXVDDResume))
  39. OutputDebugString("FAX32: UserHook not installed\n");
  40. else
  41. OutputDebugString("FAX32: UserHook installed!\n");
  42. // UserHook # 2
  43. if(!VDDInstallUserHook (DllHandle,&FAXVDDCreate, NULL,
  44. NULL, &FAXVDDResume))
  45. OutputDebugString("FAX32: UserHook #2 not installed\n");
  46. else
  47. OutputDebugString("FAX32: UserHook #2 installed!\n");
  48. break;
  49. case DLL_PROCESS_DETACH:
  50. // Deallocate VDD's local heap if needed
  51. // communicate to appropriate Device driver about your departure
  52. //...
  53. // Deinstall user hook for callback service.
  54. if(!VDDDeInstallUserHook (DllHandle))
  55. OutputDebugString("FAX32: UserHook not deinstalled\n");
  56. else
  57. OutputDebugString("FAX32: UserHook deinstalled!\n");
  58. break;
  59. default:
  60. break;
  61. }
  62. return TRUE;
  63. }
  64. // Sample function
  65. VOID FAXVDDTerminate(USHORT usPDB)
  66. {
  67. USHORT uSaveCS, uSaveIP;
  68. OutputDebugString("FAX32: Terminate message\n");
  69. // VDDHostSimulate
  70. uSaveCS = getCS();
  71. uSaveIP = getIP();
  72. setCS(Sub16CS);
  73. setIP(Sub16IP);
  74. VDDSimulate16();
  75. setCS(uSaveCS);
  76. setIP(uSaveIP);
  77. }
  78. // Sample function
  79. VOID FAXVDDCreate(USHORT usPDB)
  80. {
  81. OutputDebugString("FAX32: Create Message\n");
  82. }
  83. // Sample function
  84. VOID FAXVDDBlock(VOID)
  85. {
  86. OutputDebugString("FAX32: Block Message\n");
  87. }
  88. // Sample function
  89. VOID FAXVDDResume(VOID)
  90. {
  91. OutputDebugString("FAX32: Resume Message\n");
  92. }
  93. VOID
  94. FAXVDDTerminateVDM(
  95. VOID
  96. )
  97. /*++
  98. Arguments:
  99. Return Value:
  100. SUCCESS - TRUE
  101. FAILURE - FALSE
  102. --*/
  103. {
  104. // Cleanup any resource taken for this vdm
  105. return;
  106. }
  107. VOID
  108. FAXVDDRegisterInit(
  109. VOID
  110. )
  111. /*++
  112. Arguments:
  113. Return Value:
  114. SUCCESS - TRUE
  115. FAILURE - FALSE
  116. --*/
  117. {
  118. // Save addresses for fax16
  119. Sub16CS = getDS();
  120. Sub16IP = getAX();
  121. OutputDebugString("FAX32: GET_ADD\n");
  122. // Called from the BOP manager. If VDDInitialize has done all the
  123. // checking and resources alloaction, just return success.
  124. setCF(0);
  125. return;
  126. }
  127. #define GET_A_FAX 1
  128. #define SEND_A_FAX 2
  129. VOID
  130. FAXVDDDispatch(
  131. VOID
  132. )
  133. /*++
  134. Arguments:
  135. Client (DX) = Command code
  136. 01 - get a message from NT device driver
  137. 02 - send a message through NT device driver
  138. 03 - address of 16 bit routine
  139. Client (ES:BX) = Message Buffer
  140. Client (CX) = Buffer Size
  141. Return Value:
  142. SUCCESS - Client Carry Clear and CX has the count transferred
  143. FAILURE - Client Carry Set
  144. --*/
  145. {
  146. PCHAR Buffer;
  147. USHORT cb;
  148. USHORT uCom;
  149. BOOL Success = TRUE; // In this sample operation always succeeds
  150. uCom = getDX();
  151. cb = getCX();
  152. Buffer = (PCHAR) GetVDMPointer ((ULONG)((getES() << 16)|getBX()),cb,FALSE);
  153. switch (uCom) {
  154. case GET_A_FAX:
  155. // Make a DeviceIOControl or ReadFile on NT FAX driver with
  156. // cb and Buffer.Then set CX if success.
  157. if (Success) {
  158. setCX(cb);
  159. setCF(0);
  160. }
  161. else
  162. setCF(1);
  163. break;
  164. case SEND_A_FAX:
  165. // Make a DeviceIOControl or WriteFile on NT FAX driver with
  166. // cb and Buffer.Then set CX if success.
  167. if (Success) {
  168. setCX(cb);
  169. setCF(0);
  170. }
  171. else
  172. setCF(1);
  173. break;
  174. default:
  175. setCF(1);
  176. }
  177. return;
  178. }