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.

325 lines
12 KiB

  1. /* DRIVERS.H
  2. **
  3. ** Copyright (C) Microsoft, 1990, All Rights Reserved.
  4. **
  5. **
  6. ** Multimedia Control Panel Drivers Applet.
  7. **
  8. ** Display a list of all installed drivers, allow user to configure
  9. ** existing or install new ones.
  10. **
  11. */
  12. #include "dlgs.h"
  13. #include "commdlg.h"
  14. #include <multimed.h>
  15. #include <commctrl.h>
  16. #include "mmcpl.h"
  17. #include <setupapi.h>
  18. #define SECTION 512 // Maximum size of section
  19. #define MAXSTR 256
  20. #define DLG_BROWSE 38
  21. #define UNLIST_LINE 1
  22. #define NO_UNLIST_LINE 0
  23. #define WEC_RESTART 0x42
  24. #define DESC_SYS 3
  25. #define DESC_INF 2
  26. #define DESC_EXE 1
  27. #define DESC_NOFILE 0
  28. #define dwStatusHASSERVICE 0x00000001 // bit set if driver has service
  29. #define dwStatusSvcENABLED 0x00000002 // bit set if has -enabled- service
  30. #define dwStatusSvcSTARTED 0x00000004 // bit set if has now-running service
  31. #define dwStatusDRIVEROK 0x00000008 // bit set if !svc and can open driver
  32. #define dwStatusMAPPABLE 0x00000010 // bit set if doesn't have Mappable=0
  33. #ifndef cchRESOURCE
  34. #define cchRESOURCE 256
  35. #endif
  36. typedef struct _IDRIVER
  37. {
  38. WCHAR wszSection[MAXSTR];
  39. WCHAR wszAlias[MAXSTR];
  40. WCHAR wszFile[MAX_PATH];
  41. TCHAR szSection[MAXSTR];
  42. TCHAR szAlias[MAXSTR];
  43. TCHAR szFile[MAX_PATH];
  44. TCHAR szDesc[MAXSTR];
  45. struct _IDRIVER *related;
  46. BOOL bRelated;
  47. TCHAR szRelated[MAXSTR];
  48. TCHAR szRemove[MAXSTR];
  49. int fQueryable; // 0 -> can't, 1 -> can, -1 -> need to check
  50. BOOL bInstall; // 0 -> no, 1 -> yes
  51. BOOL KernelDriver; // If TRUE this is a kernel driver, not an
  52. // 'installable' driver so it can't be opened,
  53. // process messages etc.
  54. #ifdef INFFILE
  55. BOOL infFileProcessing;
  56. #endif // INFFILE
  57. LPARAM lp;
  58. } IDRIVER, *PIDRIVER;
  59. typedef enum // DriverClass (in no particular order)
  60. {
  61. dcINVALID = -1,
  62. dcAUX = 0, // Aux devices
  63. dcMIDI, // MIDi devices, MIDI mapper
  64. dcMIXER, // Mixer devices
  65. dcWAVE, // Wave audio devices, Wave mapper
  66. dcACODEC, // Audio codecs
  67. dcVCODEC, // Video codecs
  68. dcMCI, // MCI devices
  69. dcVIDCAP, // Video capture devices
  70. dcJOY, // Joystick devices
  71. dcLEGACY, // Legacy Devices for wave, midi and mixer
  72. dcOTHER // Any unknown device
  73. } DriverClass;
  74. typedef struct _DevTreeNode // legacy from win95 devpropsheet code
  75. {
  76. HWND hwndTree;
  77. LPARAM lParam;
  78. } DEVTREENODE, * PDEVTREENODE;
  79. extern HANDLE myInstance;
  80. extern TCHAR szNULL[];
  81. extern TCHAR szDrivers[];
  82. extern TCHAR szBoot[];
  83. extern TCHAR szDriversHlp[];
  84. extern TCHAR szAppName[];
  85. extern TCHAR szUnlisted[];
  86. extern TCHAR szFullPath[];
  87. extern TCHAR szOemInf[];
  88. extern TCHAR szDirOfSrc[];
  89. extern TCHAR szUserDrivers[];
  90. extern TCHAR szControlIni[];
  91. extern TCHAR szDriversDesc[];
  92. extern TCHAR szSetupInf[];
  93. extern TCHAR szSysIni[];
  94. extern TCHAR szMCI[];
  95. extern TCHAR szRestartDrv[];
  96. extern TCHAR szRelated[];
  97. extern TCHAR szNULL[];
  98. extern TCHAR szBackslash[];
  99. extern TCHAR szOutOfRemoveSpace[];
  100. extern TCHAR szKnown[];
  101. extern TCHAR szRelatedDesc[];
  102. extern TCHAR szDrv[];
  103. extern TCHAR szRemove[];
  104. extern TCHAR szSystem[];
  105. extern TCHAR szSystemDrivers[];
  106. extern int iRestartMessage;
  107. extern UINT wHelpMessage;
  108. extern DWORD dwContext;
  109. extern BOOL bCopyVxD;
  110. extern BOOL bVxd;
  111. extern BOOL bInstallBootLine;
  112. extern BOOL bFindOEM;
  113. extern BOOL bRestart;
  114. extern BOOL bCopyingRelated;
  115. extern BOOL bRelated;
  116. extern HWND hAdvDlgTree;
  117. extern BOOL IniFileReadAllowed;
  118. extern BOOL IniFileWriteAllowed;
  119. //------------------------------------------------------------------------
  120. //
  121. // Public routines
  122. //
  123. //------------------------------------------------------------------------
  124. extern void RemoveDriverEntry (LPTSTR, LPTSTR, LPTSTR, BOOL);
  125. extern int FileNameCmp (TCHAR *, TCHAR *);
  126. extern void OpenDriverError (HWND, LPTSTR, LPTSTR);
  127. extern void RemoveSpaces (LPTSTR, LPTSTR);
  128. extern INT_PTR RestartDlg (HWND, unsigned, WPARAM, LPARAM);
  129. extern INT_PTR AddDriversDlg (HWND, unsigned, WPARAM, LPARAM);
  130. extern INT_PTR AddUnlistedDlg (HWND, unsigned, WPARAM, LPARAM);
  131. extern BOOL mmAddNewDriver (LPTSTR, LPTSTR, PIDRIVER);
  132. extern LONG_PTR PostRemove (PIDRIVER, BOOL);
  133. extern BOOL RemoveService (LPTSTR);
  134. extern BOOL CopyToSysDir (void);
  135. extern BOOL InstallDrivers (HWND, HWND, LPTSTR);
  136. extern void InitDrvConfigInfo (LPDRVCONFIGINFO, PIDRIVER);
  137. extern BOOL AddIDriverToArray (PIDRIVER);
  138. extern BOOL FillTreeInAdvDlg (HWND, PIDRIVER);
  139. extern PIDRIVER FindIDriverByName (LPTSTR);
  140. extern void RemoveIDriver (HWND, PIDRIVER, BOOL);
  141. extern BOOL IsConfigurable (PIDRIVER, HWND);
  142. extern void BrowseDlg (HWND, int);
  143. extern int LoadDescFromFile (PIDRIVER, LPTSTR, LPTSTR);
  144. extern BOOL wsInfParseInit (void);
  145. extern void wsStartWait (void);
  146. extern void wsEndWait (void);
  147. extern UINT wsCopySingleStatus (int, DWORD_PTR, LPTSTR);
  148. extern BOOL QueryRemoveDrivers (HWND, LPTSTR, LPTSTR);
  149. #ifdef FIX_BUG_15451
  150. extern void ConfigureDriver (HWND, LPTSTR);
  151. extern BOOL fDeviceHasMixers (LPTSTR);
  152. extern BOOL WaitForNewCPLWindow (HWND);
  153. extern void GetTreeItemNodeDesc (LPTSTR, PIRESOURCE);
  154. extern void GetTreeItemNodeID (LPTSTR, PIRESOURCE);
  155. #endif // FIX_BUG_15451
  156. extern void RefreshAdvDlgTree (void);
  157. extern DWORD InstallDriversForPnPDevice (HWND, HDEVINFO, PSP_DEVINFO_DATA);
  158. // From drivers.c
  159. extern void lsplitpath (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR);
  160. // From remove.c
  161. LPTSTR mystrtok(LPTSTR SrcString, LPCTSTR Seps, LPTSTR FAR *State);
  162. extern DWORD Media_RemoveDevice(IN HDEVINFO DeviceInfoSet,
  163. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  164. );
  165. extern BOOL RemoveDriver (HDEVINFO, PSP_DEVINFO_DATA);
  166. #ifdef _WIN64
  167. extern void mmWOW64ThunkMediaClassInstaller(DWORD dwInstallationFlag, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData);
  168. #endif //_WIN64
  169. // From install.c
  170. extern BOOL FilterOutNonNTInfs(IN HDEVINFO DeviceInfoSet,
  171. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
  172. IN DWORD DriverType
  173. );
  174. extern DWORD Media_SelectBestCompatDrv(IN HDEVINFO DeviceInfoSet,
  175. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  176. );
  177. extern DWORD Media_AllowInstall(IN HDEVINFO DeviceInfoSet,
  178. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  179. );
  180. extern DWORD Media_InstallDevice(IN HDEVINFO DeviceInfoSet,
  181. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  182. );
  183. // From legcyinf.c
  184. extern DWORD Media_SelectDevice(IN HDEVINFO DeviceInfoSet,
  185. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  186. );
  187. extern DWORD Media_MigrateLegacy(IN HDEVINFO DeviceInfoSet,
  188. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  189. );
  190. #define IS_MS_MMMCI 1
  191. #define IS_MS_MMVID 2
  192. #define IS_MS_MMACM 3
  193. #define IS_MS_MMVCD 4
  194. #define IS_MS_MMDRV 5
  195. extern int IsSpecialDriver(IN HDEVINFO DeviceInfoSet,
  196. IN PSP_DEVINFO_DATA DeviceInfoData
  197. );
  198. extern BOOL IsPnPDriver(IN PTSTR szName);
  199. void acmDeleteCodec (WORD, WORD); // (from MSACMCPL.C)
  200. #ifdef FIX_BUG_15451
  201. extern TCHAR szDriverWhichNeedsSettings[MAX_PATH]; // See MMCPL.C
  202. #endif // FIX_BUG_15451
  203. void FreeIResource (PIRESOURCE);
  204. INT_PTR CALLBACK DevPropDlg (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  205. BOOL DriverClassToClassNode (PCLASSNODE, DriverClass);
  206. int DriverClassToOldClassID (DriverClass);
  207. DWORD GetDriverStatus (PIDRIVER);
  208. BOOL InitInstalled (HWND, LPTSTR);
  209. /* Resource IDs */
  210. #define IDOK 1
  211. #define IDCANCEL 2
  212. #define ID_IGNORE 3
  213. #define ID_CURRENT 4
  214. #define ID_RETRY 5
  215. #define ID_NEW 6
  216. #define ID_DISK 101
  217. #define ID_ADV_ADD 102
  218. #define ID_EDIT 105
  219. #define ID_TEXT 106
  220. #define ID_DIR 202
  221. #define ID_FILE_LIST 203
  222. #define ID_DIR_LIST 204
  223. #define ID_TYPE 205
  224. #define LB_AVAILABLE 301
  225. #define ID_DRV 302
  226. #define ID_LIST 303
  227. #define ID_DRVSTRING 304
  228. #define LB_UNLISTED 306
  229. #define ID_ADV_PROP 307
  230. #define ID_ADV_TSHOOT 308
  231. #define ADVDLG 1001
  232. #define DLG_UPDATE 1002
  233. #define DLG_KNOWN 1003
  234. #define DLG_RESTART 1004
  235. #define DLG_EXISTS 1005
  236. #define DLG_INSERTDISK 1006
  237. #define DLG_COPYERR 1007
  238. #define ID_STATUS2 1008
  239. #define DLG_DM_ADVDLG 1009
  240. #define DLG_DM_LEGACY_RESOURCES 1010
  241. #define IDS_NOINF 2003
  242. #define IDS_DEFDRIVE 2004
  243. #define IDS_OUTOFDISK 2005
  244. #define IDS_DISKS 2006
  245. #define IDS_INSTALLDRIVERS 2007
  246. #define IDS_INSTALLDRIVERS32 2067
  247. #define IDS_DRIVERDESC 2008
  248. #define IDS_OUT_OF_REMOVE_SPACE 2009
  249. #define IDS_AVAILABLE_DRIVERS_DEFAULT 2010
  250. #define IDS_ERROR 2011
  251. #define IDS_INSTALLING_DRIVERS 2012
  252. #define IDS_NO_DESCRIPTION 2013
  253. #define IDS_ERRORBOX 2014
  254. #define IDS_RESTARTTEXT 2015
  255. #define IDS_CONFIGURE_DRIVER 2016
  256. #define IDS_TOO_MANY_DRIVERS 2017
  257. #define IDS_CANNOT_FIND 2018
  258. #define IDS_APPNAME 2019
  259. #define IDS_DRIVERS 2020
  260. #define IDS_SETUPINF 2021
  261. #define IDS_CONTROLINI 2022
  262. #define IDS_SYSINI 2023
  263. #define IDS_MCI 2024
  264. #define IDS_CONTROL_INI 2025
  265. #define IDS_WIN 2027
  266. #define IDS_DOS 2028
  267. #define IDS_BROWSE 2029
  268. #define IDS_UPDATED 2031
  269. #define IDS_CLOSE 2032
  270. #define IDS_REMOVEORNOT 2033
  271. #define IDS_UNLISTED 2034
  272. #define IDS_KNOWN 2035
  273. #define IDS_REMOVE 2036
  274. #define IDS_REMOVEORNOTSTRICT 2037
  275. #define IDS_USERINSTALLDRIVERS 2038
  276. #define IDS_OEMSETUP 2044
  277. #define IDS_SYSTEM 2045
  278. #define IDS_FILE_ERROR 2046
  279. #define IDS_UNABLE_TOINSTALL 2049
  280. #define IDS_BOOT 2050
  281. #define IDS_RESTART_ADD 2051
  282. #define IDS_RESTART_REM 2052
  283. #define IDS_FILEINUSEADD 2053
  284. #define IDS_OEMDISKS 2054
  285. #define IDS_FILEINUSEREM 2055
  286. #define IDS_LASTQUERY 2056
  287. #define IDS_RELATEDDESC 2057
  288. #define IDS_DRIVER_EXISTS 2058
  289. #define IDS_SYSTEM_DRIVERS 2060
  290. #define IDS_INSUFFICIENT_PRIVILEGE 2061
  291. #define IDS_CANNOT_RESTART_PRIVILEGE 2062
  292. #define IDS_CANNOT_RESTART_UNKNOWN 2063
  293. #define IDS_DRIVER_CONFIG_ERROR 2064
  294. #define IDS_CANTADD 2065
  295. #define IDS_CONTROL_HLP_FILE 2066
  296. #define IDS_TSHOOT 2068