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.

606 lines
13 KiB

  1. /*++
  2. Copyright (c) 1995-2000 Microsoft Corporation
  3. Module Name:
  4. devres.c
  5. Abstract:
  6. Header for resource dialog routines
  7. Author:
  8. Paula Tomlinson (paulat) 7-Feb-1996
  9. --*/
  10. #pragma once
  11. #define MAX_MSG_LEN 512
  12. #define MAX_VAL_LEN 25
  13. #define MAX_SPINRANGE 0x7FFF
  14. #define MAX_RES_PROPERTY_PAGES 6
  15. #define DMPROP_FLAG_CHANGESSAVED 0x00000001
  16. #define DMPROP_FLAG_64BIT_RANGE 0x00000002
  17. #define DMPROP_FLAG_CLASSNAMECHANGED 0x00000100
  18. #define DMPROP_FLAG_DEVDESCCHANGED 0x00000200
  19. #define DMPROP_FLAG_DRVDESCCHANGED 0x00000400
  20. #define DMPROP_FLAG_GLOBALDISCHANGED 0x00000800
  21. #define DMPROP_FLAG_PROFILECHANGED 0x00001000
  22. #define DMPROP_FLAG_DEVREMOVED 0x00002000
  23. #define DMPROP_FLAG_VIEWONLYRES 0x00004000
  24. #define DMPROP_FLAG_DEVUSAGECHANGE 0x00008000
  25. #define DMPROP_FLAG_USESYSSETTINGS 0x00010000
  26. #define DMPROP_FLAG_FIXEDCONFIG 0x00020000
  27. #define DMPROP_FLAG_FORCEDONLY 0x00040000
  28. #define DMPROP_FLAG_HASPROBLEM 0x00800000
  29. #define DMPROP_FLAG_DISPLAY_ALLOC 0x01000000
  30. #define DMPROP_FLAG_DISPLAY_BOOT 0x02000000
  31. #define DMPROP_FLAG_DISPLAY_FORCED 0x04000000
  32. #define DMPROP_FLAG_DISPLAY_BASIC 0x08000000
  33. #define DMPROP_FLAG_DISPLAY_MASK 0x0f000000
  34. #define DMPROP_FLAG_PARTIAL_MATCH 0x10000000
  35. #define DMPROP_FLAG_MATCH_OUT_OF_ORDER 0x20000000
  36. #define DMPROP_FLAG_NO_RESOURCES 0x40000000
  37. #define DMPROP_FLAG_SINGLE_CONFIG 0x80000000
  38. #define DEVRES_HELP TEXT("devmgr.hlp")
  39. #ifdef ANSI_SETUPAPI
  40. #define DEVRES_WIDTH_FLAGS (0)
  41. #define DEVRES_PIRQ_RESOURCE PIRQ_RESOURCE
  42. #define DEVRES_IRQ_RESOURCE IRQ_RESOURCE
  43. #define DEVRES_AFFINITY ULONG32
  44. #else
  45. #define DEVRES_WIDTH_FLAGS CM_RESDES_WIDTH_64
  46. #define DEVRES_PIRQ_RESOURCE PIRQ_RESOURCE_64
  47. #define DEVRES_IRQ_RESOURCE IRQ_RESOURCE_64
  48. #define DEVRES_AFFINITY ULONG64
  49. #endif
  50. typedef struct {
  51. PROPSHEETPAGE psp;
  52. HIMAGELIST himlResourceImages;
  53. ULONG ConfigListLCType;
  54. LOG_CONF CurrentLC;
  55. ULONG CurrentLCType;
  56. LOG_CONF MatchingLC;
  57. ULONG MatchingLCType;
  58. LOG_CONF SelectedLC;
  59. ULONG SelectedLCType;
  60. HDEVINFO hDevInfo;
  61. PSP_DEVINFO_DATA lpdi;
  62. HWND hDlg;
  63. DWORD dwFlags;
  64. DEVINST DevInst;
  65. TCHAR szDeviceID[MAX_DEVICE_ID_LEN];
  66. HANDLE hDialogEvent;
  67. } DMPROP_DATA, *LPDMPROP_DATA;
  68. typedef struct {
  69. RESOURCEID ResourceType;
  70. ULONG64 ulValue;
  71. ULONG64 ulLen;
  72. } LCDATA, *PLCDATA;
  73. typedef struct {
  74. RESOURCEID ResType;
  75. RES_DES MatchingResDes;
  76. ULONG RangeCount;
  77. ULONG64 ulValue;
  78. ULONG64 ulLen;
  79. ULONG64 ulEnd;
  80. ULONG ulFlags;
  81. BOOL bValid;
  82. BOOL bFixed;
  83. } ITEMDATA, *PITEMDATA;
  84. typedef struct _ResourceEditInfo_tag {
  85. HWND hDlg;
  86. ULONG dwPropFlags;
  87. WORD wResNum;
  88. RESOURCEID ridResType; // resource type
  89. LOG_CONF KnownLC;
  90. LOG_CONF MatchingBasicLC;
  91. LOG_CONF SelectedBasicLC;
  92. RES_DES ResDes; // res des that values are based on
  93. LPBYTE pData; // data for ResDes field
  94. //DEVINST dnDevInst;
  95. ULONG ulRangeCount; // range that resource settings are based on
  96. ULONG64 ulCurrentVal; // current resource start value
  97. ULONG64 ulCurrentLen; // current resource range length
  98. ULONG64 ulCurrentEnd; // current resource end value
  99. ULONG ulCurrentFlags; // current resource type specific flag
  100. PSP_DEVINFO_DATA lpdi; // only used for devinst
  101. DWORD dwFlags; // internal state information
  102. BOOL bShareable; // Resource is shareable
  103. HMACHINE hMachine;
  104. } RESOURCEEDITINFO, *PRESOURCEEDITINFO;
  105. // ClearEditResConflictList Flags defines
  106. #define CEF_UNKNOWN 0x00000001
  107. #define REI_FLAGS_CONFLICT 0x00000001
  108. #define REI_FLAG_NONUSEREDIT 0x00000002
  109. #define REI_FLAG_MODIFY 0x00000004
  110. typedef struct Generic_Des_s {
  111. DWORD GENERIC_Count;
  112. DWORD GENERIC_Type;
  113. } GENERIC_DES, *PGENERIC_DES;
  114. typedef struct Generic_Resource_S {
  115. GENERIC_DES GENERIC_Header;
  116. } GENERIC_RESOURCE, *PGENERIC_RESOURCE;
  117. #define szNoValue TEXT(" ?")
  118. #define szOneDWordHexNoConflict TEXT("%08lX")
  119. #define szTwoDWordHexNoConflict TEXT("%08lX - %08lX")
  120. #define szOne64bitHexNoConflict TEXT("%016I64X")
  121. #define szTwo64bitHexNoConflict TEXT("%016I64X - %016I64X")
  122. #define szOneWordHexNoConflict TEXT("%04lX")
  123. #define szTwoWordHexNoConflict TEXT("%04lX - %04lX")
  124. #define szOneDecNoConflict TEXT("%02u")
  125. #define NO_LC_MATCH (0x00000000)
  126. #define LC_MATCH_SUPERSET (0x00000001)
  127. #define LC_MATCH_SUBSET (0x00000002)
  128. #define LC_MATCH (0x00000003)
  129. #define ORDERED_LC_MATCH (0x00000004)
  130. typedef struct _RESDES_ENTRY {
  131. struct _RESDES_ENTRY *Next;
  132. struct _RESDES_ENTRY *CrossLink;
  133. LPBYTE ResDesData;
  134. RESOURCEID ResDesType;
  135. ULONG ResDesDataSize;
  136. RES_DES ResDesHandle;
  137. } RESDES_ENTRY, *PRESDES_ENTRY;
  138. typedef struct _RDE_LIST {
  139. struct _RDE_LIST *Prev;
  140. struct _RDE_LIST *Next;
  141. PRESDES_ENTRY Entry;
  142. } RDE_LIST, *PRDE_LIST;
  143. typedef struct _ITEMDATA_LISTNODE {
  144. struct _ITEMDATA_LISTNODE *Next;
  145. PITEMDATA ItemData;
  146. } ITEMDATA_LISTNODE, *PITEMDATA_LISTNODE;
  147. //
  148. // NTRAID#166214-2000/08/19-JamieHun Conflict Supression Hack
  149. // this stuff needs to be fixed proper
  150. //
  151. #define MAX_CE_TAGS (8) // only recognise first 8 tags specified
  152. #define CE_TAG_RESERVED TEXT("*") // special tag
  153. #define CE_RES_IO TEXT("IO")
  154. #define CE_RES_MEM TEXT("MEM")
  155. #define CE_RES_IRQ TEXT("IRQ")
  156. #define CE_RES_DMA TEXT("DMA")
  157. typedef struct _CE_TAGS {
  158. LONG nTags;
  159. LONG Tag[MAX_CE_TAGS];
  160. } CE_TAGS, *PCE_TAGS;
  161. typedef struct _CE_ENTRY {
  162. struct _CE_ENTRY * Next;
  163. RESOURCEID resType;
  164. ULONG64 resStart;
  165. ULONG64 resEnd;
  166. CE_TAGS tags;
  167. } CE_ENTRY, *PCE_ENTRY;
  168. typedef struct _CONFLICT_EXCEPTIONS {
  169. PVOID ceTagMap;
  170. PCE_ENTRY exceptions;
  171. } CONFLICT_EXCEPTIONS, *PCONFLICT_EXCEPTIONS;
  172. //
  173. // Prototypes
  174. //
  175. HPROPSHEETPAGE
  176. GetResourceSelectionPage(
  177. IN HDEVINFO DeviceInfoSet,
  178. IN PSP_DEVINFO_DATA DeviceInfoData
  179. );
  180. INT_PTR
  181. CALLBACK
  182. pResourcePickerDlgProc(
  183. HWND hDlg,
  184. UINT message,
  185. WPARAM wParam,
  186. LPARAM lParam
  187. );
  188. UINT CALLBACK pResourcePickerPropPageCallback(
  189. HWND hwnd,
  190. UINT uMsg,
  191. LPPROPSHEETPAGE ppsp
  192. );
  193. HMACHINE
  194. pGetMachine(
  195. LPDMPROP_DATA lpdmpd
  196. );
  197. BOOL
  198. pInitDevResourceDlg(
  199. LPDMPROP_DATA lpdmpd
  200. );
  201. PITEMDATA
  202. pGetResourceToChange(
  203. IN LPDMPROP_DATA lpdmpd,
  204. OUT int *pCur
  205. );
  206. VOID
  207. pCheckEnableResourceChange(
  208. LPDMPROP_DATA lpdmpd
  209. );
  210. BOOL
  211. pDevHasConfig(
  212. DEVINST DevInst,
  213. ULONG ulConfigType,
  214. HMACHINE hMachine
  215. );
  216. DWORD
  217. pGetMinLCPriority(
  218. IN DEVINST DevInst,
  219. IN ULONG ulConfigType,
  220. IN HMACHINE hMachine
  221. );
  222. BOOL
  223. pDevRequiresResources(
  224. DEVINST DevInst,
  225. HMACHINE hMachine
  226. );
  227. BOOL
  228. pGetCurrentConfig(
  229. IN OUT LPDMPROP_DATA lpdmpd
  230. );
  231. void
  232. pGetHdrValues(
  233. IN LPBYTE pData,
  234. IN RESOURCEID ResType,
  235. OUT PULONG64 pulValue,
  236. OUT PULONG64 pulLen,
  237. OUT PULONG64 pulEnd,
  238. OUT PULONG pulFlags
  239. );
  240. void
  241. pGetRangeValues(
  242. IN LPBYTE pData,
  243. IN RESOURCEID ResType,
  244. IN ULONG ulIndex,
  245. OUT PULONG64 pulValue, OPTIONAL
  246. OUT PULONG64 pulLen, OPTIONAL
  247. OUT PULONG64 pulEnd, OPTIONAL
  248. OUT PULONG64 pulAlign, OPTIONAL
  249. OUT PULONG pulFlags OPTIONAL
  250. );
  251. BOOL
  252. pAlignValues(
  253. IN OUT PULONG64 pulValue,
  254. IN ULONG64 ulStart,
  255. IN ULONG64 ulLen,
  256. IN ULONG64 ulEnd,
  257. IN ULONG64 ulAlignment,
  258. IN int Increment
  259. );
  260. void
  261. pFormatResString(
  262. LPDMPROP_DATA lpdmpd,
  263. LPTSTR lpszString,
  264. ULONG64 ulVal,
  265. ULONG64 ulLen,
  266. RESOURCEID ResType
  267. );
  268. BOOL
  269. pUnFormatResString(
  270. LPTSTR lpszString,
  271. PULONG64 pulVal,
  272. PULONG64 pulEnd,
  273. RESOURCEID ridResType
  274. );
  275. BOOL
  276. pConvertEditText(
  277. LPTSTR lpszConvert,
  278. PULONG64 pulVal,
  279. RESOURCEID ridResType
  280. );
  281. void
  282. pWarnResSettingNotEditable(
  283. HWND hDlg,
  284. WORD idWarning
  285. );
  286. LPVOID
  287. pGetListViewItemData(
  288. HWND hList,
  289. int iItem,
  290. int iSubItem
  291. );
  292. BOOL
  293. pSaveDevResSettings(
  294. LPDMPROP_DATA lpdmpd
  295. );
  296. BOOL
  297. pSaveCustomResSettings(
  298. LPDMPROP_DATA lpdmpd,
  299. IN HMACHINE hMachine
  300. );
  301. BOOL
  302. pWriteResDesRangeToForced(
  303. IN LOG_CONF ForcedLogConf,
  304. IN RESOURCEID ResType,
  305. IN ULONG RangeIndex,
  306. IN RES_DES RD, OPTIONAL
  307. IN LPBYTE ResDesData, OPTIONAL
  308. IN HMACHINE hMachine OPTIONAL
  309. );
  310. BOOL
  311. pWriteValuesToForced(
  312. IN LOG_CONF ForcedLogConf,
  313. IN RESOURCEID ResType,
  314. IN ULONG RangeIndex,
  315. IN RES_DES RD,
  316. IN ULONG64 ulValue,
  317. IN ULONG64 ulLen,
  318. IN ULONG64 ulEnd,
  319. IN HMACHINE hMachine
  320. );
  321. BOOL
  322. MakeResourceData(
  323. OUT LPBYTE *ppResourceData,
  324. OUT PULONG pulSize,
  325. IN RESOURCEID ResType,
  326. IN ULONG64 ulValue,
  327. IN ULONG64 ulLen,
  328. IN ULONG ulFlags
  329. );
  330. BOOL
  331. pShowWindow(
  332. IN HWND hWnd,
  333. IN int nShow
  334. );
  335. BOOL
  336. pEnableWindow(
  337. IN HWND hWnd,
  338. IN BOOL Enable
  339. );
  340. BOOL
  341. pGetResDesDataList(
  342. IN LOG_CONF LogConf,
  343. IN OUT PRESDES_ENTRY *pResList,
  344. IN BOOL bArbitratedOnly,
  345. IN HMACHINE hMachine
  346. );
  347. VOID
  348. pDeleteResDesDataList(
  349. IN PRESDES_ENTRY pResList
  350. );
  351. VOID
  352. pHideAllControls(
  353. IN LPDMPROP_DATA lpdmpd
  354. );
  355. VOID
  356. pShowViewNoResources(
  357. IN LPDMPROP_DATA lpdmpd
  358. );
  359. BOOL
  360. pShowViewMFReadOnly(
  361. IN LPDMPROP_DATA lpdmpd,
  362. IN BOOL HideIfProb
  363. );
  364. BOOL
  365. pShowViewReadOnly(
  366. IN LPDMPROP_DATA lpdmpd,
  367. IN BOOL HideIfProb
  368. );
  369. VOID
  370. pShowViewNoAlloc(
  371. IN LPDMPROP_DATA lpdmpd
  372. );
  373. VOID
  374. pShowViewNeedForced(
  375. IN LPDMPROP_DATA lpdmpd
  376. );
  377. VOID
  378. pShowViewAllEdit(
  379. IN LPDMPROP_DATA lpdmpd
  380. );
  381. BOOL
  382. pLoadCurrentConfig(
  383. IN LPDMPROP_DATA lpdmpd,
  384. BOOL ReadOnly
  385. );
  386. BOOL
  387. pLoadConfig(
  388. LPDMPROP_DATA lpdmpd,
  389. LOG_CONF forceLC,
  390. ULONG forceLCType
  391. );
  392. BOOL
  393. bIsMultiFunctionChild(
  394. PSP_DEVINFO_DATA lpdi,
  395. HMACHINE hMachine
  396. );
  397. VOID
  398. pSelectLogConf(
  399. LPDMPROP_DATA lpdmpd,
  400. LOG_CONF forceLC,
  401. ULONG forceLCType,
  402. BOOL Always
  403. );
  404. VOID
  405. pChangeCurrentResSetting(
  406. IN LPDMPROP_DATA lpdmpd
  407. );
  408. VOID
  409. pShowConflicts(
  410. IN LPDMPROP_DATA lpdmpd
  411. );
  412. VOID
  413. pShowUpdateEdit(
  414. IN LPDMPROP_DATA lpdmpd
  415. );
  416. int
  417. pWarnNoSave(
  418. HWND hDlg,
  419. WORD idWarning
  420. );
  421. BOOL
  422. pOkToSave(
  423. IN LPDMPROP_DATA lpdmpd
  424. );
  425. //
  426. //
  427. //
  428. BOOL
  429. pGetMatchingRange(
  430. IN ULONG64 ulKnownValue,
  431. IN ULONG64 ulKnownLen,
  432. IN LPBYTE pData,
  433. IN RESOURCEID ResType,
  434. OUT PULONG pRange,
  435. OUT PBOOL pExact,
  436. OUT PULONG pFlags
  437. );
  438. ULONG
  439. pMergeResDesDataLists(
  440. IN OUT PRESDES_ENTRY pKnown,
  441. IN OUT PRESDES_ENTRY pTest,
  442. OUT PULONG pMatchCount
  443. );
  444. ULONG
  445. pCompareLogConf(
  446. IN LOG_CONF KnownLogConf,
  447. IN LOG_CONF TestLogConf,
  448. IN HMACHINE hMachine,
  449. OUT PULONG pMatchCount
  450. );
  451. BOOL
  452. pFindMatchingAllocConfig(
  453. IN LPDMPROP_DATA lpdmpd
  454. );
  455. BOOL
  456. pGetMatchingResDes(
  457. IN ULONG64 ulKnownValue,
  458. IN ULONG64 ulKnownLen,
  459. IN ULONG64 ulKnownEnd,
  460. IN RESOURCEID ResType,
  461. IN LOG_CONF MatchingLogConf,
  462. OUT PRES_DES pMatchingResDes,
  463. IN HMACHINE hMachine
  464. );
  465. BOOL
  466. pConfigHasNoAlternates(
  467. LPDMPROP_DATA lpdmpd,
  468. LOG_CONF testLC
  469. );
  470. //
  471. // NTRAID#166214-2000/08/19-JamieHun Conflict Supression Hack
  472. // this stuff needs to be fixed proper
  473. //
  474. PCONFLICT_EXCEPTIONS pLoadConflictExceptions(
  475. IN LPDMPROP_DATA lpdmpd
  476. );
  477. VOID pFreeConflictExceptions(
  478. IN PCONFLICT_EXCEPTIONS pExceptions
  479. );
  480. BOOL pIsConflictException(
  481. IN LPDMPROP_DATA lpdmpd,
  482. IN PCONFLICT_EXCEPTIONS pExceptions,
  483. IN DEVINST devConflict,
  484. IN PCTSTR resDesc,
  485. IN RESOURCEID resType,
  486. IN ULONG64 resValue,
  487. IN ULONG64 resLength
  488. );
  489. INT_PTR
  490. WINAPI
  491. EditResourceDlgProc(
  492. HWND hDlg,
  493. UINT wMsg,
  494. WPARAM wParam,
  495. LPARAM lParam
  496. );
  497. BOOL
  498. LocateClosestValue(
  499. IN LPBYTE pData,
  500. IN RESOURCEID ResType,
  501. IN ULONG64 TestValue,
  502. IN ULONG64 TestLen,
  503. IN INT Mode,
  504. OUT PULONG64 OutValue, OPTIONAL
  505. OUT PULONG64 OutLen, OPTIONAL
  506. OUT PULONG OutIndex OPTIONAL
  507. );