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.

134 lines
2.7 KiB

  1. #include "pch.h"
  2. CMICRO::CMICRO(TCHAR *pszMicroDriver)
  3. {
  4. m_hModule = NULL;
  5. m_pMicroEntry = NULL;
  6. m_pScan = NULL;
  7. m_pSetPixelWindow = NULL;
  8. m_bDisabled = FALSE;
  9. //
  10. // Load Micro driver
  11. //
  12. m_hModule = LoadLibrary(pszMicroDriver);
  13. if (m_hModule != NULL) {
  14. //
  15. // Get entry point
  16. //
  17. m_pMicroEntry = (FPMICROENTRY)GetProcAddress(m_hModule,"MicroEntry");
  18. if (m_pMicroEntry != NULL) {
  19. //
  20. // Get Scan entry point
  21. //
  22. m_pScan = (FPSCANENTRY)GetProcAddress(m_hModule,"Scan");
  23. if (m_pScan != NULL) {
  24. //
  25. // Get SetPixelWindow entry point
  26. //
  27. m_pSetPixelWindow = (FPSETPIXELWINDOWENTRY)GetProcAddress(m_hModule,"SetPixelWindow");
  28. if (m_pSetPixelWindow != NULL) {
  29. //
  30. // we are GO!
  31. //
  32. }
  33. }
  34. }
  35. }
  36. }
  37. CMICRO::~CMICRO()
  38. {
  39. if (m_hModule != NULL) {
  40. FreeLibrary(m_hModule);
  41. }
  42. }
  43. HRESULT CMICRO::MicroEntry(LONG lCommand, PVAL pValue)
  44. {
  45. HRESULT hr = E_FAIL;
  46. if (m_pMicroEntry != NULL) {
  47. //
  48. // call Micro driver's entry point
  49. //
  50. hr = m_pMicroEntry(lCommand, pValue);
  51. }
  52. return hr;
  53. }
  54. HRESULT CMICRO::Scan(PSCANINFO pScanInfo, LONG lPhase, PBYTE pBuffer, LONG lLength, PLONG plRecieved)
  55. {
  56. HRESULT hr = E_FAIL;
  57. if (m_pMicroEntry != NULL) {
  58. if (!m_bDisabled) {
  59. //
  60. // call Micro driver's scan entry point
  61. //
  62. hr = m_pScan(pScanInfo, lPhase, pBuffer, lLength, plRecieved);
  63. } else {
  64. UnInitialize(pScanInfo);
  65. }
  66. }
  67. return hr;
  68. }
  69. HRESULT CMICRO::SetPixelWindow(PSCANINFO pScanInfo, LONG x, LONG y, LONG xExtent, LONG yExtent)
  70. {
  71. HRESULT hr = E_FAIL;
  72. if (m_pSetPixelWindow != NULL) {
  73. //
  74. // call Micro driver's SetPixelWindow entry point
  75. //
  76. hr = m_pSetPixelWindow(pScanInfo,x,y,xExtent,yExtent);
  77. }
  78. return hr;
  79. }
  80. HRESULT CMICRO::Disable()
  81. {
  82. HRESULT hr = S_OK;
  83. m_bDisabled = TRUE;
  84. return hr;
  85. }
  86. HRESULT CMICRO::UnInitialize(PSCANINFO pScanInfo)
  87. {
  88. HRESULT hr = E_FAIL;
  89. if ((m_pMicroEntry != NULL)) {
  90. //
  91. // call Micro driver's entry point to UnInitalize
  92. //
  93. VAL Val;
  94. memset(&Val, 0, sizeof(Val));
  95. Val.pScanInfo = pScanInfo;
  96. hr = m_pMicroEntry(CMD_UNINITIALIZE,&Val);
  97. m_pMicroEntry = NULL;
  98. }
  99. return hr;
  100. }