MONOD.CPP 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. ** Command & Conquer Red Alert(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. #include "monod.h"
  19. MonoD::MonoD(void)
  20. {
  21. #ifdef _WIN32
  22. unsigned long retval;
  23. handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL,
  24. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  25. if (handle != INVALID_HANDLE_VALUE)
  26. {
  27. DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0,
  28. &retval,0);
  29. }
  30. #endif
  31. }
  32. MonoD::~MonoD()
  33. {
  34. #ifdef _WIN32
  35. CloseHandle(handle);
  36. handle=NULL;
  37. #endif
  38. }
  39. int MonoD::print(const char *str, int len)
  40. {
  41. #ifdef _WIN32
  42. unsigned long retval;
  43. WriteFile(handle, str, len, &retval, NULL);
  44. //DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, NULL, 0,
  45. // &retval,0);
  46. return(len);
  47. #else
  48. for (int i=0; i<len; i++)
  49. fprintf(stderr,"%c",str[i]);
  50. return(len);
  51. #endif
  52. }