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.

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