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.

120 lines
2.4 KiB

  1. #include "precomp.h"
  2. //
  3. // OSI.CPP
  4. // OS Isolation layer, NT version in HOOK
  5. //
  6. // Copyright(c) Microsoft 1997-
  7. //
  8. #include <osi.h>
  9. #include <version.h>
  10. #include <ndcgver.h>
  11. //
  12. // OSI_SetDriverName()
  13. // This saves or clears the driver name so in OSI_FunctionRequest we can
  14. // create a DC to communicate with our display driver. On NT4.x this is a
  15. // display DC; on NT5 this is a direct DC to our driver.
  16. //
  17. void OSI_SetDriverName(LPCSTR szDriverName)
  18. {
  19. DebugEntry(OSI_SetDriverName);
  20. if (!szDriverName)
  21. {
  22. // Clear it
  23. g_osiDriverName[0] = 0;
  24. }
  25. else
  26. {
  27. // Set it
  28. ASSERT(!g_osiDriverName[0]);
  29. lstrcpy(g_osiDriverName, szDriverName);
  30. }
  31. DebugExitVOID(OSI_SetDriverName);
  32. }
  33. //
  34. // OSI_FunctionRequest - see osi.h
  35. //
  36. BOOL OSI_FunctionRequest
  37. (
  38. DWORD escapeFn,
  39. LPOSI_ESCAPE_HEADER pRequest,
  40. DWORD requestLen
  41. )
  42. {
  43. BOOL rc = FALSE;
  44. ULONG iEsc;
  45. HDC hdc;
  46. DebugEntry(OSI_FunctionRequest);
  47. if (!g_osiDriverName[0])
  48. {
  49. // NT 4.x case
  50. TRACE_OUT(("OSI_FunctionRequest: Creating %s driver DC",
  51. s_osiDisplayName));
  52. hdc = CreateDC(s_osiDisplayName, NULL, NULL, NULL);
  53. }
  54. else
  55. {
  56. // NT 5 case
  57. TRACE_OUT(("OSI_FunctionRequest: Creating %s driver DC",
  58. g_osiDriverName));
  59. hdc = CreateDC(NULL, g_osiDriverName, NULL, NULL);
  60. }
  61. if (!hdc)
  62. {
  63. ERROR_OUT(("Failed to create DC to talk to driver '%s'", g_osiDriverName));
  64. DC_QUIT;
  65. }
  66. TRACE_OUT(("OSI_FunctionRequest: Created %s driver DC %08x",
  67. g_osiDriverName, hdc));
  68. //
  69. // Pass the request on to the display driver.
  70. //
  71. pRequest->padding = 0;
  72. pRequest->identifier = OSI_ESCAPE_IDENTIFIER;
  73. pRequest->escapeFn = escapeFn;
  74. pRequest->version = DCS_MAKE_VERSION();
  75. if ((escapeFn >= OSI_HET_WO_ESC_FIRST) && (escapeFn <= OSI_HET_WO_ESC_LAST))
  76. {
  77. iEsc = WNDOBJ_SETUP;
  78. }
  79. else
  80. {
  81. iEsc = OSI_ESC_CODE;
  82. }
  83. if (0 >= ExtEscape(hdc, iEsc, requestLen, (LPCSTR)pRequest,
  84. requestLen, (LPSTR)pRequest))
  85. {
  86. WARNING_OUT(("ExtEscape %x code %d failed", iEsc, escapeFn));
  87. }
  88. else
  89. {
  90. rc = TRUE;
  91. }
  92. DC_EXIT_POINT:
  93. if (hdc)
  94. {
  95. DeleteDC(hdc);
  96. }
  97. DebugExitDWORD(OSI_FunctionRequest, rc);
  98. return(rc);
  99. }