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.

123 lines
4.1 KiB

  1. /******************************Module*Header***********************************\
  2. * Module Name: registry.c
  3. *
  4. * Routines to initialize the registry and lookup string values.
  5. *
  6. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  7. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  8. *
  9. \******************************************************************************/
  10. #include "precomp.h"
  11. //------------------------------------------------------------------------------
  12. // BOOL bRegistryQueryUlong
  13. //
  14. // Take a string and look up its value in the registry. We assume that the
  15. // value fits into 4 bytes. Fill in the supplied DWORD pointer with the value.
  16. //
  17. // Returns:
  18. // TRUE if we found the string, FALSE if not. Note, if we failed to init
  19. // the registry the query funtion will simply fail and we act as though
  20. // the string was not defined.
  21. //
  22. //------------------------------------------------------------------------------
  23. BOOL
  24. bRegistryQueryUlong(PPDev ppdev, LPWSTR valueStr, PULONG pData)
  25. {
  26. ULONG ReturnedDataLength;
  27. ULONG inSize;
  28. ULONG outData;
  29. PWCHAR inStr;
  30. // get the string length including the NULL
  31. for (inSize = 2, inStr = valueStr; *inStr != 0; ++inStr, inSize += 2);
  32. if (EngDeviceIoControl(ppdev->hDriver,
  33. IOCTL_VIDEO_QUERY_REGISTRY_DWORD,
  34. valueStr, // input buffer
  35. inSize,
  36. &outData, // output buffer
  37. sizeof(ULONG),
  38. &ReturnedDataLength))
  39. {
  40. DBG_GDI((1, "bQueryRegistryValueUlong failed"));
  41. return(FALSE);
  42. }
  43. *pData = outData;
  44. DBG_GDI((1, "bQueryRegistryValueUlong returning 0x%x (ReturnedDataLength = %d)",
  45. *pData, ReturnedDataLength));
  46. return(TRUE);
  47. }
  48. //------------------------------------------------------------------------------
  49. // BOOL bRegistryRetrieveGammaLUT
  50. //
  51. // Look up the registry to reload the saved gamma LUT into memory.
  52. //
  53. // Returns:
  54. // TRUE if we found the string, FALSE if not. Note, if we failed to init
  55. // the registry the query funtion will simply fail and we act as though
  56. // the string was not defined.
  57. //
  58. //------------------------------------------------------------------------------
  59. BOOL
  60. bRegistryRetrieveGammaLUT(
  61. PPDev ppdev,
  62. PVIDEO_CLUT pScreenClut
  63. )
  64. {
  65. ULONG ReturnedDataLength;
  66. if (EngDeviceIoControl(ppdev->hDriver,
  67. IOCTL_VIDEO_REG_RETRIEVE_GAMMA_LUT,
  68. NULL, // input buffer
  69. 0,
  70. pScreenClut, // output buffer
  71. MAX_CLUT_SIZE,
  72. &ReturnedDataLength))
  73. {
  74. DBG_GDI((1, "IOCTL_VIDEO_REG_RETRIEVE_GAMMA_LUT failed"));
  75. return(FALSE);
  76. }
  77. return(TRUE);
  78. }
  79. //------------------------------------------------------------------------------
  80. // BOOL bRegistrySaveGammaLUT
  81. //
  82. // Save the gamma lut in the registry for later reloading.
  83. //
  84. // Returns:
  85. // TRUE if we found the string, FALSE if not. Note, if we failed to init
  86. // the registry the query funtion will simply fail and we act as though
  87. // the string was not defined.
  88. //
  89. //------------------------------------------------------------------------------
  90. BOOL
  91. bRegistrySaveGammaLUT(
  92. PPDev ppdev,
  93. PVIDEO_CLUT pScreenClut
  94. )
  95. {
  96. ULONG ReturnedDataLength;
  97. if (EngDeviceIoControl(ppdev->hDriver,
  98. IOCTL_VIDEO_REG_SAVE_GAMMA_LUT,
  99. pScreenClut, // input buffer
  100. MAX_CLUT_SIZE,
  101. NULL, // output buffer
  102. 0,
  103. &ReturnedDataLength))
  104. {
  105. DBG_GDI((1, "IOCTL_VIDEO_REG_SAVE_GAMMA_LUT failed"));
  106. return(FALSE);
  107. }
  108. return(TRUE);
  109. }