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.

233 lines
6.8 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: device.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: KeisukeT
  10. *
  11. * DATE: 27 Mar, 2000
  12. *
  13. * DESCRIPTION:
  14. * Class to handle device un/installation for WIA class installer.
  15. *
  16. *******************************************************************************/
  17. #ifndef _DEVICE_H_
  18. #define _DEVICE_H_
  19. //
  20. // Include
  21. //
  22. #include "sti_ci.h"
  23. #include "exports.h"
  24. //
  25. // Define
  26. //
  27. #ifndef StiDeviceTypeStreamingVideo
  28. #define StiDeviceTypeStreamingVideo 3
  29. #endif
  30. typedef BOOL (CALLBACK FAR * DEVNODESELCALLBACK)(LPTSTR szPortName, HDEVINFO *phDevInfo, PSP_DEVINFO_DATA pspDevInfoData);
  31. //
  32. // Class
  33. //
  34. class CDevice {
  35. // Mutex for unique DeviceID/FriendlName creation.
  36. HANDLE m_hMutex;
  37. // // These members are set in constructor.
  38. // HDEVINFO m_hDevInfo;
  39. // PSP_DEVINFO_DATA m_pspDevInfoData;
  40. CString m_csInf; // INF filename.
  41. CString m_csInstallSection; // INF section name.
  42. // These members are set during installation process.
  43. CString m_csPort; // Port name.
  44. DEVNODESELCALLBACK m_pfnDevnodeSelCallback;// Callback for devnode selection.
  45. HKEY m_hkInterfaceRegistry; // RegKey to created interface.
  46. CString m_csWiaSection; // WIA Section nane.
  47. CString m_csSubClass; // Subclass.
  48. CString m_csConnection; // Connection type.
  49. CString m_csVendor; // Vendor name.
  50. CString m_csFriendlyName; // Friendly name.
  51. CString m_csPdoDescription; // Device Desc. of Devnode..
  52. CString m_csDriverDescription; // Driver Description.
  53. CString m_csUninstallSection; // UninstallSection.
  54. CString m_csPropPages; // VendorPropertyPage.
  55. CString m_csVendorSetup; // Vendor setup extention.
  56. CString m_csDataSection; // DeviceDataSection name.
  57. CString m_csEventSection; // EventSection name.
  58. CString m_csIcmProfile; // ICM Profile.
  59. CString m_csUSDClass; // USD Class GUID.
  60. CString m_csDeviceID; // Unique device ID.
  61. CString m_csSymbolicLink; // Symbolic link to the PDO.
  62. CString m_csPortSelect; // Indicate needs of port selection page..
  63. CStringArray m_csaAllNames; // Array to keep all device FriendlyName.
  64. CStringArray m_csaAllId; // Array to keep all device ID.
  65. DWORD m_dwCapabilities; // Capabilities.
  66. DWORD m_dwDeviceType; // DeviceType.
  67. DWORD m_dwDeviceSubType; // DeviceSubType.
  68. DWORD m_dwNumberOfWiaDevice; // Number of WIA device.
  69. DWORD m_dwNumberOfStiDevice; // Number of STI device.
  70. DWORD m_dwInterfaceIndex; // Index of interface.
  71. BOOL m_bVideoDevice; // Flag to indicate video device.
  72. BOOL m_bIsPnP; // Flag to indicate PnP device.
  73. BOOL m_bDefaultDevice; //
  74. BOOL m_bInfProceeded; // Flag to indicate INF is proceeded.
  75. BOOL m_bInterfaceOnly; // Flag to indicate Interface-onle device.
  76. BOOL m_bIsMigration; // Flag to indicate migration.
  77. PPARAM_LIST m_pExtraDeviceData; // DeviceData migrated from Win9x.
  78. BOOL GetInfInforamtion();
  79. VOID ProcessEventsSection(HINF hInf, HKEY hkDrv);
  80. VOID ProcessDataSection(HINF hInf, HKEY hkDrv);
  81. VOID ProcessICMProfiles();
  82. VOID ProcessVendorSetupExtension();
  83. VOID ProcessVideoDevice(HKEY hkDrv);
  84. BOOL HandleFilesInstallation();
  85. BOOL IsInterfaceOnlyDevice(){ return m_bInterfaceOnly; };
  86. BOOL IsPnpDevice(){ return m_bIsPnP; };
  87. BOOL IsFeatureInstallation(){ return ( m_bIsPnP && m_bInterfaceOnly); };
  88. BOOL CreateDeviceInterfaceAndInstall();
  89. BOOL IsMigration(){return m_bIsMigration;};
  90. public:
  91. // These members are set in constructor. These really should be in private.
  92. HDEVINFO m_hDevInfo;
  93. PSP_DEVINFO_DATA m_pspDevInfoData;
  94. CDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoSet, BOOL bIsPnP);
  95. CDevice(HDEVINFO hDevInfo, DWORD dwDeviceIndex);
  96. CDevice(PDEVICE_INFO pMigratingDevice);
  97. CDevice::~CDevice();
  98. BOOL CollectNames();
  99. BOOL IsDefault() const { return m_bDefaultDevice; }
  100. VOID Default(BOOL bNew) { m_bDefaultDevice = bNew; }
  101. DWORD GetCapabilities(){ return m_dwCapabilities; };
  102. LPTSTR GetConnection(){ return m_csConnection; };
  103. LPTSTR GetFriendlyName(){ return m_csFriendlyName; };
  104. VOID SetPort (LPTSTR szPortName);
  105. VOID SetDevnodeSelectCallback (DEVNODESELCALLBACK pfnDevnodeSelCallback);
  106. VOID SetFriendlyName(LPTSTR szFriendlyName);
  107. BOOL IsDeviceIdUnique(LPTSTR szDeviceId);
  108. BOOL IsFriendlyNameUnique(LPTSTR szFriendlyName);
  109. BOOL IsSameDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoSet);
  110. BOOL NameDefaultUniqueName();
  111. BOOL GenerateUniqueDeviceId();
  112. BOOL Install();
  113. DWORD Remove(PSP_REMOVEDEVICE_PARAMS lprdp);
  114. BOOL PreInstall();
  115. BOOL PostInstall(BOOL bSucceeded);
  116. BOOL PreprocessInf();
  117. BOOL UpdateDeviceRegistry();
  118. DWORD GetPortSelectMode(VOID);
  119. DWORD AcquireInstallerMutex(DWORD dwTimeout);
  120. VOID ReleaseInstallerMutex();
  121. };
  122. //
  123. // Prototype
  124. //
  125. // from device.cpp
  126. VOID
  127. GetDeviceCount(
  128. DWORD *pdwWiaCount,
  129. DWORD *pdwStiCount
  130. );
  131. BOOL
  132. ExecCommandLine(
  133. LPTSTR szCommandLine
  134. );
  135. // from service.cpp
  136. DWORD
  137. WINAPI
  138. StiServiceRemove(
  139. VOID
  140. );
  141. DWORD
  142. WINAPI
  143. StiServiceInstall(
  144. BOOL UseLocalSystem,
  145. BOOL DemandStart,
  146. LPTSTR lpszUserName,
  147. LPTSTR lpszUserPassword
  148. );
  149. BOOL
  150. SetServiceStart(
  151. LPTSTR ServiceName,
  152. DWORD StartType
  153. );
  154. BOOL
  155. StartWiaService(
  156. VOID
  157. );
  158. BOOL
  159. StopWiaService(
  160. VOID
  161. );
  162. //PSP_FILE_CALLBACK StiInstallCallback;
  163. //PSP_FILE_CALLBACK StiUninstallCallback;
  164. UINT
  165. CALLBACK
  166. StiInstallCallback (
  167. PVOID Context,
  168. UINT Notification,
  169. UINT_PTR Param1,
  170. UINT_PTR Param2
  171. );
  172. UINT
  173. CALLBACK
  174. StiUninstallCallback (
  175. PVOID Context,
  176. UINT Notification,
  177. UINT_PTR Param1,
  178. UINT_PTR Param2
  179. );
  180. HANDLE
  181. GetDeviceInterfaceIndex(
  182. LPSTR pszLocalName,
  183. DWORD *pdwIndex
  184. );
  185. PPARAM_LIST
  186. MigrateDeviceData(
  187. HKEY hkDeviceData,
  188. PPARAM_LIST pExtraDeviceData,
  189. LPSTR pszKeyName
  190. );
  191. #endif // _DEVICE_H_