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.

161 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. vxd.c
  5. Abstract:
  6. This module contains misc dpmi functions for risc.
  7. Revision History:
  8. Neil Sandlin (neilsa) Nov. 1, 95 - split off from "misc" source
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #include "softpc.h"
  13. #define W386_VCD_ID 0xe
  14. VOID
  15. GetVxDApiHandler(
  16. USHORT VxdId
  17. )
  18. {
  19. DECLARE_LocalVdmContext;
  20. if (VxdId == W386_VCD_ID) {
  21. setES(HIWORD(DosxVcdPmSvcCall));
  22. setDI(LOWORD(DosxVcdPmSvcCall));
  23. } else {
  24. setES(0);
  25. setDI(0);
  26. }
  27. }
  28. LONG
  29. VcdPmGetPortArray(
  30. VOID
  31. )
  32. /*++
  33. Routine Description:
  34. Use the registry enteries in HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM
  35. to simulate the Virtual Comm Device API: VCD_PM_Get_Port_Array. See VCD.ASM
  36. in the Win 3.1 DDK.
  37. Arguments:
  38. None
  39. Return Value:
  40. Port Array in LOWORD. Bit array of valid ports:
  41. Bit Set -> Port valid
  42. Bit clear -> Port invalid
  43. Bit 0 -> COM1, Bit 1 -> COM2, Bit 2 -> COM3...
  44. --*/
  45. {
  46. HKEY hSerialCommKey;
  47. DWORD dwPortArray;
  48. DWORD dwPortNum;
  49. DWORD cbPortName;
  50. DWORD cbPortValue;
  51. CHAR szPortName[64];
  52. CHAR szPortValue[64];
  53. LONG iPort;
  54. LONG iStatus;
  55. dwPortArray = 0;
  56. if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  57. "HARDWARE\\DEVICEMAP\\SERIALCOMM",
  58. 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
  59. &hSerialCommKey) == ERROR_SUCCESS){
  60. cbPortName = sizeof(szPortName);
  61. cbPortValue = sizeof(szPortValue);
  62. for (iPort = 0;
  63. (iStatus = RegEnumValue(hSerialCommKey,
  64. iPort, szPortName, &cbPortName,
  65. NULL, NULL, szPortValue,
  66. &cbPortValue)) != ERROR_NO_MORE_ITEMS;
  67. iPort++)
  68. {
  69. if ((iStatus == ERROR_SUCCESS) && (cbPortValue > 3)) {
  70. if (NT_SUCCESS(RtlCharToInteger(szPortValue+3,10,&dwPortNum))) {
  71. dwPortArray |= (1 << (dwPortNum - 1));
  72. }
  73. }
  74. cbPortName = sizeof(szPortName);
  75. cbPortValue = sizeof(szPortValue);
  76. }
  77. // WOW only supports 9 ports. See WU32OPENCOM in WUCOMM.C.
  78. dwPortArray &= 0x1FF;
  79. RegCloseKey(hSerialCommKey);
  80. }
  81. return(dwPortArray);
  82. }
  83. // The following values taken from Win 3.1 DDK VCD.ASM:
  84. #define VCD_PM_Get_Version 0
  85. #define VCD_PM_Get_Port_Array 1
  86. #define VCD_PM_Get_Port_Behavior 2
  87. #define VCD_PM_Set_Port_Behavior 3
  88. #define VCD_PM_Acquire_Port 4
  89. #define VCD_PM_Free_Port 5
  90. #define VCD_PM_Steal_Port 6
  91. VOID
  92. DpmiVcdPmSvcCall32(
  93. VOID
  94. )
  95. /*++
  96. Routine Description:
  97. Dispatch VCD API requests to the correct API.
  98. Arguments:
  99. Client DX contains API function id.
  100. Return Value:
  101. Depends on API.
  102. --*/
  103. {
  104. DECLARE_LocalVdmContext;
  105. switch (getDX()) {
  106. case VCD_PM_Get_Version:
  107. setAX(0x30A);
  108. break;
  109. case VCD_PM_Get_Port_Array:
  110. setAX((WORD)VcdPmGetPortArray());
  111. break;
  112. default :
  113. ASSERT(0);
  114. setCF(1);
  115. }
  116. }