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.

224 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 ProcessVideoDevice(HKEY hkDrv);
  83. BOOL HandleFilesInstallation();
  84. BOOL IsInterfaceOnlyDevice(){ return m_bInterfaceOnly; };
  85. BOOL IsPnpDevice(){ return m_bIsPnP; };
  86. BOOL IsFeatureInstallation(){ return ( m_bIsPnP && m_bInterfaceOnly); };
  87. BOOL CreateDeviceInterfaceAndInstall();
  88. BOOL IsMigration(){return m_bIsMigration;};
  89. public:
  90. // These members are set in constructor. These really should be in private.
  91. HDEVINFO m_hDevInfo;
  92. PSP_DEVINFO_DATA m_pspDevInfoData;
  93. CDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoSet, BOOL bIsPnP);
  94. CDevice(HDEVINFO hDevInfo, DWORD dwDeviceIndex);
  95. CDevice(PDEVICE_INFO pMigratingDevice);
  96. CDevice::~CDevice();
  97. BOOL CollectNames();
  98. BOOL IsDefault() const { return m_bDefaultDevice; }
  99. VOID Default(BOOL bNew) { m_bDefaultDevice = bNew; }
  100. DWORD GetCapabilities(){ return m_dwCapabilities; };
  101. LPTSTR GetConnection(){ return m_csConnection; };
  102. LPTSTR GetFriendlyName(){ return m_csFriendlyName; };
  103. VOID SetPort (LPTSTR szPortName);
  104. VOID SetDevnodeSelectCallback (DEVNODESELCALLBACK pfnDevnodeSelCallback);
  105. VOID SetFriendlyName(LPTSTR szFriendlyName);
  106. BOOL IsDeviceIdUnique(LPTSTR szDeviceId);
  107. BOOL IsFriendlyNameUnique(LPTSTR szFriendlyName);
  108. BOOL IsSameDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoSet);
  109. BOOL NameDefaultUniqueName();
  110. BOOL GenerateUniqueDeviceId();
  111. BOOL Install();
  112. DWORD Remove(PSP_REMOVEDEVICE_PARAMS lprdp);
  113. BOOL PreInstall();
  114. BOOL PostInstall(BOOL bSucceeded);
  115. BOOL PreprocessInf();
  116. BOOL UpdateDeviceRegistry();
  117. DWORD GetPortSelectMode(VOID);
  118. DWORD AcquireInstallerMutex(DWORD dwTimeout);
  119. VOID ReleaseInstallerMutex();
  120. };
  121. //
  122. // Prototype
  123. //
  124. // from device.cpp
  125. VOID
  126. GetDeviceCount(
  127. DWORD *pdwWiaCount,
  128. DWORD *pdwStiCount
  129. );
  130. HANDLE
  131. ExecCommandLine(
  132. LPTSTR szCommandLine,
  133. DWORD dwDirectory
  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. HANDLE
  173. GetDeviceInterfaceIndex(
  174. LPSTR pszLocalName,
  175. DWORD *pdwIndex
  176. );
  177. PPARAM_LIST
  178. MigrateDeviceData(
  179. HKEY hkDeviceData,
  180. PPARAM_LIST pExtraDeviceData,
  181. LPSTR pszKeyName
  182. );
  183. #endif // _DEVICE_H_