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.

111 lines
3.9 KiB

  1. /******************************************************************************
  2. *
  3. * $RCSfile: 52xHlp.cpp $
  4. * $Source: u:/si/VXP/Wdm/Encore/52x/52xHlp.cpp $
  5. * $Author: Max $
  6. * $Date: 1999/02/19 00:10:31 $
  7. * $Revision: 1.6 $
  8. *
  9. * Written by: Max Paklin
  10. * Purpose: Helper functions for 52x analog overlay hardware
  11. *
  12. *******************************************************************************
  13. *
  14. * Copyright 1998-99, AuraVision Corporation. All rights reserved.
  15. *
  16. * AuraVision Corporation makes no warranty of any kind, express or implied,
  17. * with regard to this software. In no event shall AuraVision Corporation
  18. * be liable for incidental or consequential damages in connection with or
  19. * arising from the furnishing, performance, or use of this software.
  20. *
  21. * Tab step is to be set to 4 to achive the best readability for this code.
  22. *
  23. *******************************************************************************/
  24. #include "Comwdm.h"
  25. #pragma hdrstop
  26. #include "Avwinwdm.h"
  27. extern "C"
  28. {
  29. /******************************************************************************/
  30. /*** Macrovision handler interface routines ***********************************/
  31. // The next two functions are actually sort of "exported" from here for Macrovision handler.
  32. // They provide I2C service that Macrovision license code can use to access I2C registers
  33. int __stdcall SetI2CRegister( unsigned int uID, unsigned int uIndex, unsigned int uData )
  34. {
  35. if( HW_SetExternalRegister( 2, (WORD)uID, (WORD)uIndex, (WORD)uData ) == 0 )
  36. return TRUE;
  37. return FALSE;
  38. }
  39. unsigned int __stdcall GetI2CRegister( unsigned int uID, unsigned int uIndex )
  40. {
  41. return HW_GetExternalRegister( 2, (WORD)uID, (WORD)uIndex );
  42. }
  43. /*** Macrovision handler interface routines ***********************************/
  44. /******************************************************************************/
  45. } // extern "C"
  46. /******************************************************************************/
  47. /*** Functions to be used by AvWin ********************************************/
  48. static PVOID s_hHandle = NULL;
  49. static PDEVICE_OBJECT s_pDeviceObject = NULL;
  50. extern "C" void APIENTRY AV_SetContextHandle( PVOID hHandle, PVOID pDeviceObject )
  51. {
  52. s_hHandle = hHandle;
  53. s_pDeviceObject = (PDEVICE_OBJECT)pDeviceObject;
  54. }
  55. extern "C" SINT APIENTRY AV_GetProfileString
  56. (
  57. LPCWSTR pwszSection,
  58. LPCWSTR pwszEntry,
  59. LPCWSTR pwszDefault,
  60. LPWSTR pwszBufferReturn,
  61. int nBufferReturn
  62. )
  63. {
  64. if( s_hHandle == NULL && s_pDeviceObject == NULL )
  65. return 0;
  66. CKsRegKey regKey( pwszSection, s_pDeviceObject, s_hHandle );
  67. if( !regKey.GetValue( pwszEntry, pwszBufferReturn, (USHORT)nBufferReturn, pwszDefault ) )
  68. wcsncpy( pwszBufferReturn, pwszDefault, nBufferReturn/sizeof( WCHAR ) );
  69. return wcslen( pwszBufferReturn );
  70. }
  71. extern "C" UINT APIENTRY AV_GetProfileInt( LPCWSTR pwszSection, LPCWSTR pwszEntry, int nDefault )
  72. {
  73. if( s_hHandle == NULL && s_pDeviceObject == NULL )
  74. return nDefault;
  75. CKsRegKey regKey( pwszSection, s_pDeviceObject, s_hHandle );
  76. int nValue;
  77. if( !regKey.GetValue( pwszEntry, nValue, nDefault ) )
  78. nValue = nDefault;
  79. return (UINT)nValue;
  80. }
  81. extern "C" BOOL APIENTRY AV_WriteProfileString
  82. (
  83. LPCWSTR pwszSection,
  84. LPCWSTR pwszEntry,
  85. LPCWSTR pwszString
  86. )
  87. {
  88. if( s_hHandle == NULL && s_pDeviceObject == NULL )
  89. return FALSE;
  90. CKsRegKey regKey( pwszSection, s_pDeviceObject, s_hHandle );
  91. return regKey.SetValue( pwszEntry, pwszString );
  92. }
  93. extern "C" BOOL APIENTRY AV_WriteProfileInt
  94. (
  95. LPCWSTR pwszSection,
  96. LPCWSTR pwszEntry,
  97. SINT Value
  98. )
  99. {
  100. if( s_hHandle == NULL && s_pDeviceObject == NULL )
  101. return FALSE;
  102. CKsRegKey regKey( pwszSection, s_pDeviceObject, s_hHandle );
  103. return regKey.SetValue( pwszEntry, (int)Value );
  104. }
  105. /*** Functions to be used by AvWin ********************************************/
  106. /******************************************************************************/