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.

205 lines
5.9 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1997
  4. *
  5. * TITLE: Helpers.h
  6. *
  7. * VERSION: 2.0
  8. *
  9. * AUTHOR: ReedB
  10. *
  11. * DATE: 12 Mar, 1999
  12. *
  13. * DESCRIPTION:
  14. * Declarations and definitions for WIA device manager object helpers.
  15. *
  16. *******************************************************************************/
  17. #pragma once
  18. class CWiaDrvItem;
  19. //
  20. // Helper functions to build/destroy DEVICE_INFO structs
  21. //
  22. DEVICE_INFO* CreateDevInfoFromHKey(HKEY hKeyDev, DWORD dwDeviceState, SP_DEVINFO_DATA *pspDevInfoData, SP_DEVICE_INTERFACE_DATA *pspDevInterfaceData = NULL);
  23. DEVICE_INFO* CreateDevInfoForFSDriver(WCHAR *wszMountPoint);
  24. DEVICE_INFO* CreateDevInfoForRemoteDevice(HKEY hKeyDev);
  25. BOOL RefreshDevInfoFromHKey(DEVICE_INFO *pDeviceInfo,HKEY hKeyDev, DWORD dwDeviceState, SP_DEVINFO_DATA *pspDevInfoData, SP_DEVICE_INTERFACE_DATA *pspDevInterfaceData);
  26. BOOL RefreshDevInfoFromMountPoint(DEVICE_INFO *pDeviceInfo, WCHAR *wszMountPoint);
  27. VOID DestroyDevInfo(DEVICE_INFO *pInfo);
  28. VOID DumpDevInfo(DEVICE_INFO *pInfo);
  29. IWiaPropertyStorage* CreateDevInfoStg(DEVICE_INFO *pInfo);
  30. WCHAR* AllocCopyString(WCHAR* wszString);
  31. WCHAR* AllocCatString(WCHAR* wszString1, WCHAR* wszString2);
  32. HRESULT AllocReadRegistryString(HKEY hKey, WCHAR *wszValueName, WCHAR **pwszReturnValue);
  33. HRESULT ReadRegistryDWORD(HKEY hKey, WCHAR *wszValueName, DWORD *pdwReturnValue);
  34. BOOL GetDriverDLLVersion(DEVICE_INFO *pDeviceInfo, WCHAR *wszVersion, UINT uiSize);
  35. //
  36. // Exception handling covers for mini-driver entry points.
  37. //
  38. HRESULT _stdcall LockWiaDevice(IWiaItem*);
  39. HRESULT _stdcall UnLockWiaDevice(IWiaItem*);
  40. //
  41. // Validation helper functions.
  42. //
  43. HRESULT _stdcall ValidateWiaItem(IWiaItem*);
  44. HRESULT _stdcall ValidateWiaDrvItemAccess(CWiaDrvItem*);
  45. //
  46. // Error reporting helper functions.
  47. //
  48. LPOLESTR GetNameFromWiaPropId(PROPID propid);
  49. void _stdcall ReportReadWriteMultipleError(HRESULT, LPSTR, LPSTR, BOOL, ULONG, const PROPSPEC[]);
  50. //
  51. // Item navigation helpers
  52. //
  53. HRESULT _stdcall GetParentItem(CWiaItem *pItem, CWiaItem **ppParent);
  54. //
  55. // Property heplers
  56. //
  57. HRESULT _stdcall ReadPropStr(PROPID propid, IPropertyStorage *pIPropStg, BSTR *pbstr);
  58. HRESULT _stdcall ReadPropStr(PROPID propid, IWiaPropertyStorage *pIWiaPropStg, BSTR *pbstr);
  59. HRESULT _stdcall ReadPropStr(IUnknown *pDevice, PROPID propid, BSTR *pbstr);
  60. HRESULT _stdcall ReadPropLong(PROPID propid, IPropertyStorage *pIPropStg, LONG *plval);
  61. HRESULT _stdcall ReadPropLong(IUnknown *pDevice, PROPID propid, LONG *plval);
  62. HRESULT _stdcall WritePropStr(PROPID propid, IPropertyStorage *pIPropStg, BSTR bstr);
  63. HRESULT _stdcall WritePropStr(IUnknown *pDevice, PROPID propid, BSTR bstr);
  64. HRESULT _stdcall WritePropLong(PROPID propid, IPropertyStorage *pIPropStg, LONG lval);
  65. HRESULT _stdcall WritePropLong(IUnknown *pDevice, PROPID propid, LONG lval);
  66. HRESULT _stdcall GetPropertyAttributesHelper(IWiaItem*, LONG, PROPSPEC*, ULONG*, PROPVARIANT*);
  67. HRESULT _stdcall CheckXResAndUpdate(BYTE*, WIA_PROPERTY_CONTEXT*, LONG);
  68. HRESULT _stdcall CheckYResAndUpdate(BYTE*, WIA_PROPERTY_CONTEXT*, LONG);
  69. BOOL _stdcall AreWiaInitializedProps(ULONG, PROPSPEC*);
  70. HRESULT _stdcall FillICMPropertyFromRegistry(IWiaPropertyStorage *pDevInfoProps, IWiaItem *pIWiaItem);
  71. HRESULT _stdcall GetBufferValues(CWiaItem*, PWIA_EXTENDED_TRANSFER_INFO);
  72. HRESULT _stdcall BQADScale(BYTE* pSrcBuffer,
  73. LONG lSrcWidth,
  74. LONG lSrcHeight,
  75. LONG lSrcDepth,
  76. BYTE* pDestBuffer,
  77. LONG lDestWidth,
  78. LONG lDestHeight);
  79. HANDLE GetUserTokenForConsoleSession();
  80. BOOL IsMassStorageCamera(WCHAR *wszMountPoint);
  81. HRESULT GetMountPointLabel(WCHAR *wszMountPoint, LPTSTR pszLabel, DWORD cchLabel);
  82. HRESULT CreateMSCRegEntries(HKEY hDevRegKey, WCHAR *wszMountPoint);
  83. //
  84. // Mini driver context helper functions.
  85. //
  86. HRESULT _stdcall InitMiniDrvContext(IWiaItem*, PMINIDRV_TRANSFER_CONTEXT );
  87. //
  88. // COM helper functions
  89. //
  90. #define SESSION_MONIKER TEXT("Session:Console!clsid:")
  91. HRESULT _CoCreateInstanceInConsoleSession(REFCLSID rclsid,
  92. IUnknown* punkOuter,
  93. DWORD dwClsContext,
  94. REFIID riid,
  95. void** ppv);
  96. #ifndef __WAITCURS_H_INCLUDED
  97. #define __WAITCURS_H_INCLUDED
  98. class CWaitCursor
  99. {
  100. private:
  101. HCURSOR m_hCurOld;
  102. public:
  103. CWaitCursor(void)
  104. {
  105. m_hCurOld = SetCursor( LoadCursor( NULL, IDC_WAIT ) );
  106. }
  107. ~CWaitCursor(void)
  108. {
  109. SetCursor(m_hCurOld);
  110. }
  111. };
  112. #endif
  113. extern CRITICAL_SECTION g_semDeviceMan;
  114. /**************************************************************************\
  115. * class CWiaCritSect
  116. *
  117. * Dev Manager auto-exiting critical section
  118. *
  119. * Arguments:
  120. *
  121. *
  122. *
  123. * Return Value:
  124. *
  125. * Status
  126. *
  127. * History:
  128. *
  129. * 4/8/1999 Original Version
  130. *
  131. \**************************************************************************/
  132. class CWiaCritSect {
  133. private:
  134. CRITICAL_SECTION *m_pSect;
  135. BOOL bSucceeded;
  136. public:
  137. CWiaCritSect(CRITICAL_SECTION* pSect) {
  138. bSucceeded = FALSE;
  139. m_pSect = pSect;
  140. _try {
  141. EnterCriticalSection(m_pSect);
  142. }
  143. _except (EXCEPTION_EXECUTE_HANDLER) {
  144. #ifdef DEBUG
  145. OutputDebugString(TEXT("CWiaCritSect, could not grab critical section!!!!\n"));
  146. #endif
  147. return;
  148. }
  149. bSucceeded = TRUE;
  150. }
  151. ~CWiaCritSect() {
  152. if (bSucceeded) {
  153. LeaveCriticalSection(m_pSect);
  154. }
  155. }
  156. inline BOOL Succeeded() {
  157. return bSucceeded;
  158. }
  159. };