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.

270 lines
5.9 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1999
  4. *
  5. * TITLE: fstidev.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ByronC
  10. *
  11. * DATE: 7 Dec, 1999
  12. *
  13. * DESCRIPTION:
  14. * Implmentation for fake StiDevice which gets handed down to WIA
  15. * driver.
  16. *
  17. *******************************************************************************/
  18. #include "precomp.h"
  19. #include "stiexe.h"
  20. #include "device.h"
  21. #include "assert.h"
  22. #include "wiapriv.h"
  23. #include "lockmgr.h"
  24. #include "fstidev.h"
  25. //
  26. // Default constructor
  27. //
  28. FakeStiDevice::FakeStiDevice()
  29. {
  30. m_cRef = 0;
  31. m_pDevice = NULL;
  32. }
  33. //
  34. // Constructor which takes in the device name and returns a pointer to this
  35. // IStiDevice interface
  36. //
  37. FakeStiDevice::FakeStiDevice(BSTR bstrDeviceName, IStiDevice **ppStiDevice)
  38. {
  39. if (SUCCEEDED(Init(bstrDeviceName))) {
  40. QueryInterface(IID_IStiDevice, (VOID**)ppStiDevice);
  41. } else {
  42. *ppStiDevice = NULL;
  43. }
  44. }
  45. //
  46. // Destructor
  47. //
  48. FakeStiDevice::~FakeStiDevice()
  49. {
  50. m_cRef = 0;
  51. }
  52. //
  53. // Initialization methods
  54. //
  55. HRESULT FakeStiDevice::Init(ACTIVE_DEVICE *pDevice)
  56. {
  57. m_pDevice = pDevice;
  58. if (pDevice) {
  59. return S_OK;
  60. } else {
  61. return E_POINTER;
  62. }
  63. }
  64. HRESULT FakeStiDevice::Init(BSTR bstrDeviceName)
  65. {
  66. HRESULT hr = S_OK;
  67. /* This is all dead code. The Fake STI Device object implementation
  68. is no longer needed for ensuring mutually exclusive locking - it is
  69. now done automatically by the wrapper.
  70. ACTIVE_DEVICE *pDevice;
  71. USES_CONVERSION;
  72. pDevice = g_pDevMan->IsInList(DEV_MAN_IN_LIST_DEV_ID, bstrDeviceName);
  73. if(pDevice) {
  74. m_pDevice = pDevice;
  75. //
  76. // We don't need to maintain a ref count on pDevice,
  77. // since we're only used while the ACTIVE_DEVICE
  78. // lives.
  79. //
  80. pDevice->Release();
  81. } else {
  82. hr = E_FAIL;
  83. }
  84. */
  85. return hr;
  86. }
  87. //
  88. // IUnknown methods. Note: This object cannot be delegated and
  89. // does not use aggregation.
  90. //
  91. HRESULT _stdcall FakeStiDevice::QueryInterface(const IID& iid, void** ppv)
  92. {
  93. if (ppv == NULL)
  94. {
  95. return E_POINTER;
  96. }
  97. if (ppv != NULL) {
  98. *ppv = NULL;
  99. }
  100. if (iid == IID_IUnknown) {
  101. *ppv = (IUnknown*) this;
  102. } else if (iid == IID_IStiDevice) {
  103. *ppv = (IStiDevice*) this;
  104. } else {
  105. return E_NOINTERFACE;
  106. }
  107. AddRef();
  108. return S_OK;
  109. }
  110. ULONG _stdcall FakeStiDevice::AddRef(void)
  111. {
  112. InterlockedIncrement(&m_cRef);
  113. return m_cRef;
  114. }
  115. ULONG _stdcall FakeStiDevice::Release(void)
  116. {
  117. LONG cRef = m_cRef;
  118. InterlockedDecrement(&m_cRef);
  119. return cRef;
  120. }
  121. //
  122. // IStiDevice Methods. The only methods implemented are:
  123. //
  124. // LockDevice
  125. // UnLockDevice
  126. //
  127. // All other methods return E_NOTIMPL
  128. //
  129. HRESULT _stdcall FakeStiDevice::LockDevice( DWORD dwTimeOut)
  130. {
  131. HRESULT hr = S_OK;
  132. /* This is all dead code. The Fake STI Device object implementation
  133. is no longer needed for ensuring mutually exclusive locking - it is
  134. now done automatically by the wrapper.
  135. if (m_pDevice) {
  136. //
  137. // AddRef the ACTIVE_DEVICE so it doesn't attempt to
  138. // unload us while we're in use.
  139. //
  140. m_pDevice->AddRef();
  141. hr = g_pStiLockMgr->RequestLock(m_pDevice, 60000);
  142. if (FAILED(hr)) {
  143. m_pDevice->Release();
  144. }
  145. }
  146. */
  147. return hr;
  148. }
  149. HRESULT _stdcall FakeStiDevice::UnLockDevice( )
  150. {
  151. HRESULT hr = S_OK/*E_FAIL*/;
  152. /* This is all dead code. The Fake STI Device object implementation
  153. is no longer needed for ensuring mutually exclusive locking - it is
  154. now done automatically by the wrapper.
  155. if (m_pDevice) {
  156. hr = g_pStiLockMgr->RequestUnlock(m_pDevice);
  157. m_pDevice->Release();
  158. }
  159. */
  160. return hr;
  161. }
  162. HRESULT _stdcall FakeStiDevice::Initialize(HINSTANCE hinst,LPCWSTR pwszDeviceName,DWORD dwVersion,DWORD dwMode)
  163. {
  164. return E_NOTIMPL;
  165. }
  166. HRESULT _stdcall FakeStiDevice::GetCapabilities( PSTI_DEV_CAPS pDevCaps)
  167. {
  168. return E_NOTIMPL;
  169. }
  170. HRESULT _stdcall FakeStiDevice::GetStatus( PSTI_DEVICE_STATUS pDevStatus)
  171. {
  172. return E_NOTIMPL;
  173. }
  174. HRESULT _stdcall FakeStiDevice::DeviceReset( )
  175. {
  176. return E_NOTIMPL;
  177. }
  178. HRESULT _stdcall FakeStiDevice::Diagnostic( LPSTI_DIAG pBuffer)
  179. {
  180. return E_NOTIMPL;
  181. }
  182. HRESULT _stdcall FakeStiDevice::Escape( STI_RAW_CONTROL_CODE EscapeFunction,LPVOID lpInData,DWORD cbInDataSize,LPVOID pOutData,DWORD dwOutDataSize,LPDWORD pdwActualData)
  183. {
  184. return E_NOTIMPL;
  185. }
  186. HRESULT _stdcall FakeStiDevice::GetLastError( LPDWORD pdwLastDeviceError)
  187. {
  188. return E_NOTIMPL;
  189. }
  190. HRESULT _stdcall FakeStiDevice::RawReadData( LPVOID lpBuffer,LPDWORD lpdwNumberOfBytes,LPOVERLAPPED lpOverlapped)
  191. {
  192. return E_NOTIMPL;
  193. }
  194. HRESULT _stdcall FakeStiDevice::RawWriteData( LPVOID lpBuffer,DWORD nNumberOfBytes,LPOVERLAPPED lpOverlapped)
  195. {
  196. return E_NOTIMPL;
  197. }
  198. HRESULT _stdcall FakeStiDevice::RawReadCommand( LPVOID lpBuffer,LPDWORD lpdwNumberOfBytes,LPOVERLAPPED lpOverlapped)
  199. {
  200. return E_NOTIMPL;
  201. }
  202. HRESULT _stdcall FakeStiDevice::RawWriteCommand( LPVOID lpBuffer,DWORD nNumberOfBytes,LPOVERLAPPED lpOverlapped)
  203. {
  204. return E_NOTIMPL;
  205. }
  206. HRESULT _stdcall FakeStiDevice::Subscribe( LPSTISUBSCRIBE lpSubsribe)
  207. {
  208. return E_NOTIMPL;
  209. }
  210. HRESULT _stdcall FakeStiDevice::GetLastNotificationData(LPSTINOTIFY lpNotify)
  211. {
  212. return E_NOTIMPL;
  213. }
  214. HRESULT _stdcall FakeStiDevice::UnSubscribe( )
  215. {
  216. return E_NOTIMPL;
  217. }
  218. HRESULT _stdcall FakeStiDevice::GetLastErrorInfo( STI_ERROR_INFO *pLastErrorInfo)
  219. {
  220. return E_NOTIMPL;
  221. }