CDCNTRL.H 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Renegade Setup/Autorun/CDCNTRL.H $*
  25. * *
  26. * $Author:: Maria_l $*
  27. * *
  28. * $Modtime:: 4/20/01 2:07p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #pragma once
  36. #ifndef _CDCNTRL
  37. #define _CDCNTRL
  38. //#include "always.h"
  39. //#include <winmin.h>
  40. #define STRICT
  41. #include <windows.h>
  42. #include <windowsx.h>
  43. #include <ctype.h>
  44. class CDControlClass {
  45. public:
  46. CDControlClass(void);
  47. ~CDControlClass(void);
  48. /*
  49. ** Force the CD tray to open on the specified drive.
  50. */
  51. void Force_CD_Eject(int drive);
  52. /*
  53. ** Prevent the user from ejecting the CD in the specified drive.
  54. */
  55. bool Lock_CD_Tray(int drive);
  56. /*
  57. ** Allow the user to eject the CD in the specified drive.
  58. */
  59. bool Unlock_CD_Tray(int drive);
  60. private:
  61. /*
  62. ** NT functions.
  63. */
  64. bool Eject_CD(char drive);
  65. HANDLE Open_Removable_Volume(char drive);
  66. bool Lock_Volume(HANDLE volume);
  67. bool Unlock_Volume(HANDLE volume);
  68. bool Dismount_Volume(HANDLE volume);
  69. bool Prevent_Removal_Of_Volume(HANDLE volume, bool prevent);
  70. bool Auto_Eject_Volume(HANDLE volume);
  71. bool Close_Removable_Volume(HANDLE volume);
  72. bool Lock_CD_Drive(char drive);
  73. bool Unlock_CD_Drive(char drive);
  74. /*
  75. ** Win9x functions.
  76. */
  77. HANDLE WINAPI Open_VWin32 (void);
  78. bool WINAPI Close_VWin32 (HANDLE vwin32);
  79. bool WINAPI Unlock_Logical_Volume (HANDLE vwin32, char drive);
  80. bool WINAPI Lock_Logical_Volume (HANDLE vwin32, char drive, char lock_level, short permissions);
  81. bool Lock_Volume_95 (HANDLE vwin32, char drive);
  82. bool Unlock_Volume_95 (HANDLE vwin32, char drive);
  83. bool Auto_Eject_Volume_95 (HANDLE vwin32, char drive);
  84. void Eject_CD_Win95 (char drive);
  85. bool Lock_CD_Drive_95(char drive);
  86. bool Unlock_CD_Drive_95(char drive);
  87. };
  88. extern CDControlClass CDControl;
  89. #define LOCK_TIMEOUT 2000 // 2 Seconds
  90. #define LOCK_RETRIES 2 // 2 times
  91. /*
  92. ** Low level structures for Win9x.
  93. **
  94. ** DeviceIoControl infrastructure
  95. */
  96. #if !defined (VWIN32_DIOC_DOS_IOCTL)
  97. #define VWIN32_DIOC_DOS_IOCTL 1
  98. typedef struct _DIOC_REGISTERS {
  99. DWORD reg_EBX;
  100. DWORD reg_EDX;
  101. DWORD reg_ECX;
  102. DWORD reg_EAX;
  103. DWORD reg_EDI;
  104. DWORD reg_ESI;
  105. DWORD reg_Flags;
  106. } DIOC_REGISTERS, *PDIOC_REGISTERS;
  107. #endif
  108. /*
  109. ** Intel x86 processor status flags
  110. */
  111. #define CARRY_FLAG 0x0001
  112. /*
  113. ** DOS IOCTL function support
  114. */
  115. #pragma pack(1)
  116. /*
  117. ** Parameters for locking/unlocking removable media
  118. */
  119. typedef struct _PARAMBLOCK {
  120. BYTE bOperation;
  121. BYTE bNumLocks;
  122. } PARAMBLOCK, *PPARAMBLOCK;
  123. #pragma pack()
  124. #endif //_CDCNTRL