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.

129 lines
2.8 KiB

  1. /*** vxd.c - ACPITAB.VXD related functions
  2. *
  3. * Copyright (c) 1996,1997 Microsoft Corporation
  4. * Author: Michael Tsang (MikeTs)
  5. * Created: 10/09/97
  6. *
  7. * MODIFICATION HISTORY
  8. */
  9. #ifdef ___UNASM
  10. #pragma warning (disable: 4201 4214 4514)
  11. typedef unsigned __int64 ULONGLONG;
  12. #define LOCAL __cdecl
  13. #define EXPORT __cdecl
  14. #include <stdarg.h>
  15. #define _X86_
  16. #include <windef.h>
  17. #include <winbase.h>
  18. #define EXCL_BASEDEF
  19. #include "aslp.h"
  20. #include "..\acpitab\acpitab.h"
  21. /***LP OpenVxD - Open ACPITAB.VXD
  22. *
  23. * ENTRY
  24. * None
  25. *
  26. * EXIT-SUCCESS
  27. * returns VxD handle
  28. * EXIT-FAILURE
  29. * returns NULL
  30. */
  31. HANDLE LOCAL OpenVxD(VOID)
  32. {
  33. HANDLE hVxD;
  34. DWORD dwVersion;
  35. ENTER((2, "OpenVxD()\n"));
  36. if ((hVxD = CreateFile(ACPITAB_VXD_NAME, 0, 0, NULL, 0,
  37. FILE_FLAG_DELETE_ON_CLOSE, NULL)) ==
  38. INVALID_HANDLE_VALUE)
  39. {
  40. hVxD = NULL;
  41. }
  42. else if (!DeviceIoControl(hVxD, ACPITAB_DIOC_GETVERSION, NULL, 0,
  43. &dwVersion, sizeof(dwVersion), NULL, NULL) ||
  44. (dwVersion != (ACPITAB_MAJOR_VER << 8) | ACPITAB_MINOR_VER))
  45. {
  46. ERROR(("OpenVxD: version error"));
  47. CloseVxD(hVxD);
  48. hVxD = NULL;
  49. }
  50. EXIT((2, "OpenVxD=%x\n", hVxD));
  51. return hVxD;
  52. } //OpenVxD
  53. /***LP CloseVxD - Close the VxD
  54. *
  55. * ENTRY
  56. * hVxD - VxD handle
  57. *
  58. * EXIT
  59. * None
  60. */
  61. VOID LOCAL CloseVxD(HANDLE hVxD)
  62. {
  63. ENTER((2, "CloseVxD(hVxD=%x)\n", hVxD));
  64. CloseHandle(hVxD);
  65. EXIT((2, "CloseVxD!\n"));
  66. } //CloseVxD
  67. /***LP GetTable - Get table
  68. *
  69. * ENTRY
  70. * hVxD - VxD handle
  71. * dwTabSig - table signature
  72. *
  73. * EXIT-SUCCESS
  74. * returns pointer to table
  75. * EXIT-FAILURE
  76. * returns NULL
  77. */
  78. PBYTE LOCAL GetTable(HANDLE hVxD, DWORD dwTabSig)
  79. {
  80. PBYTE pb = NULL;
  81. TABINFO TabInfo;
  82. ENTER((2, "GetTable(hVxD=%x,TabSig=%x)\n", hVxD, dwTabSig));
  83. TabInfo.dwTabSig = dwTabSig;
  84. if (DeviceIoControl(hVxD, ACPITAB_DIOC_GETTABINFO, NULL, 0, &TabInfo,
  85. sizeof(TabInfo), NULL, NULL))
  86. {
  87. if ((pb = MEMALLOC(TabInfo.dh.Length)) != NULL)
  88. {
  89. if (DeviceIoControl(hVxD, ACPITAB_DIOC_GETTABLE,
  90. (PVOID)TabInfo.dwPhyAddr, 0, pb,
  91. TabInfo.dh.Length, NULL, NULL) == 0)
  92. {
  93. ERROR(("GetTable: failed to get table. (rc=%x)",
  94. GetLastError()));
  95. MEMFREE(pb);
  96. pb = NULL;
  97. }
  98. }
  99. else
  100. {
  101. ERROR(("GetTable: failed to allocate table buffer"));
  102. }
  103. }
  104. else
  105. {
  106. ERROR(("GetTable: failed to get table info. (rc=%x)", GetLastError()));
  107. }
  108. EXIT((2, "GetTable=%x\n", pb));
  109. return pb;
  110. } //GetTable
  111. #endif //ifdef __UNASM