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.

661 lines
17 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. icons.h
  5. Abstract:
  6. Implements a set of routines for handling icons in ICO, PE and NE files
  7. Author:
  8. Calin Negreanu (calinn) 16-Jum-2000
  9. Revision History:
  10. --*/
  11. #pragma once
  12. //
  13. // Includes
  14. //
  15. // None
  16. //
  17. // Debug constants
  18. //
  19. // None
  20. //
  21. // Strings
  22. //
  23. // None
  24. //
  25. // Constants
  26. //
  27. #define ICON_ICOFILE 0x00000001
  28. #define ICON_PEFILE 0x00000002
  29. #define ICON_NEFILE 0x00000003
  30. //
  31. // Macros
  32. //
  33. // None
  34. //
  35. // Types
  36. //
  37. #pragma pack(push)
  38. #pragma pack(2)
  39. typedef struct {
  40. BYTE Width; // Width, in pixels, of the image
  41. BYTE Height; // Height, in pixels, of the image
  42. BYTE ColorCount; // Number of colors in image (0 if >=8bpp)
  43. BYTE Reserved; // Reserved ( must be 0)
  44. WORD Planes; // Color Planes
  45. WORD BitCount; // Bits per pixel
  46. DWORD BytesInRes; // How many bytes in this resource?
  47. DWORD ImageOffset; // Where in the file is this image?
  48. } ICONDIRENTRY, *PICONDIRENTRY;
  49. typedef struct {
  50. WORD Reserved; // Reserved (must be 0)
  51. WORD Type; // Resource Type (1 for icons)
  52. WORD Count; // How many images?
  53. ICONDIRENTRY Entries[]; // An entry for each image (idCount of 'em)
  54. } ICONDIR, *PICONDIR;
  55. typedef struct {
  56. WORD Reserved; // Reserved (must be 0)
  57. WORD Type; // Resource Type (1 for icons)
  58. WORD Count; // How many images?
  59. } ICONDIRBASE, *PICONDIRBASE;
  60. typedef struct {
  61. BYTE Width; // Width, in pixels, of the image
  62. BYTE Height; // Height, in pixels, of the image
  63. BYTE ColorCount; // Number of colors in image (0 if >=8bpp)
  64. BYTE Reserved; // Reserved
  65. WORD Planes; // Color Planes
  66. WORD BitCount; // Bits per pixel
  67. DWORD BytesInRes; // how many bytes in this resource?
  68. WORD ID; // the ID
  69. } GRPICONDIRENTRY, *PGRPICONDIRENTRY;
  70. typedef struct {
  71. WORD Reserved; // Reserved (must be 0)
  72. WORD Type; // Resource type (1 for icons)
  73. WORD Count; // How many images?
  74. GRPICONDIRENTRY Entries[]; // The entries for each image
  75. } GRPICONDIR, *PGRPICONDIR;
  76. typedef struct {
  77. WORD Reserved; // Reserved (must be 0)
  78. WORD Type; // Resource type (1 for icons)
  79. WORD Count; // How many images?
  80. } GRPICONDIRBASE, *PGRPICONDIRBASE;
  81. #pragma pack( pop )
  82. typedef struct {
  83. BYTE Width;
  84. BYTE Height;
  85. BYTE ColorCount;
  86. WORD Planes;
  87. WORD BitCount;
  88. DWORD Size;
  89. WORD Id;
  90. PBYTE Image;
  91. } ICON_IMAGE, *PICON_IMAGE;
  92. typedef struct {
  93. PMHANDLE Pool;
  94. WORD IconsCount;
  95. PICON_IMAGE Icons[];
  96. } ICON_GROUP, *PICON_GROUP;
  97. typedef struct {
  98. DWORD DataSize;
  99. PBYTE Data;
  100. } ICON_SGROUP, *PICON_SGROUP;
  101. typedef struct {
  102. PICON_GROUP IconGroup;
  103. PCSTR ResourceId;
  104. WORD Index;
  105. // private members, do not touch
  106. DWORD FileType;
  107. BOOL FreeHandle;
  108. HANDLE ModuleHandle;
  109. GROWBUFFER Buffer;
  110. MULTISZ_ENUMA MultiSzEnum;
  111. } ICON_ENUMA, *PICON_ENUMA;
  112. typedef struct {
  113. PICON_GROUP IconGroup;
  114. PCWSTR ResourceId;
  115. WORD Index;
  116. // private members, do not touch
  117. DWORD FileType;
  118. BOOL FreeHandle;
  119. HANDLE ModuleHandle;
  120. GROWBUFFER Buffer;
  121. MULTISZ_ENUMW MultiSzEnum;
  122. } ICON_ENUMW, *PICON_ENUMW;
  123. //
  124. // Globals
  125. //
  126. // None
  127. //
  128. // Macro expansion list
  129. //
  130. // None
  131. //
  132. // Function prototypes
  133. //
  134. VOID
  135. IcoReleaseResourceIdA (
  136. PCSTR ResourceId
  137. );
  138. VOID
  139. IcoReleaseResourceIdW (
  140. PCWSTR ResourceId
  141. );
  142. VOID
  143. IcoReleaseIconGroup (
  144. IN PICON_GROUP IconGroup
  145. );
  146. VOID
  147. IcoReleaseIconSGroup (
  148. IN OUT PICON_SGROUP IconSGroup
  149. );
  150. BOOL
  151. IcoSerializeIconGroup (
  152. IN PICON_GROUP IconGroup,
  153. OUT PICON_SGROUP IconSGroup
  154. );
  155. PICON_GROUP
  156. IcoDeSerializeIconGroup (
  157. IN PICON_SGROUP IconSGroup
  158. );
  159. PICON_GROUP
  160. IcoExtractIconGroupFromIcoFileEx (
  161. IN HANDLE IcoFileHandle
  162. );
  163. PICON_GROUP
  164. IcoExtractIconGroupFromIcoFileA (
  165. IN PCSTR IcoFile
  166. );
  167. PICON_GROUP
  168. IcoExtractIconGroupFromIcoFileW (
  169. IN PCWSTR IcoFile
  170. );
  171. BOOL
  172. IcoWriteIconGroupToIcoFileEx (
  173. IN HANDLE IcoFileHandle,
  174. IN PICON_GROUP IconGroup
  175. );
  176. BOOL
  177. IcoWriteIconGroupToIcoFileA (
  178. IN PCSTR IcoFile,
  179. IN PICON_GROUP IconGroup,
  180. IN BOOL OverwriteExisting
  181. );
  182. BOOL
  183. IcoWriteIconGroupToIcoFileW (
  184. IN PCWSTR IcoFile,
  185. IN PICON_GROUP IconGroup,
  186. IN BOOL OverwriteExisting
  187. );
  188. INT
  189. IcoGetIndexFromPeResourceIdExA (
  190. IN HANDLE ModuleHandle,
  191. IN PCSTR GroupIconId
  192. );
  193. INT
  194. IcoGetIndexFromPeResourceIdExW (
  195. IN HANDLE ModuleHandle,
  196. IN PCWSTR GroupIconId
  197. );
  198. INT
  199. IcoGetIndexFromPeResourceIdA (
  200. IN PCSTR ModuleName,
  201. IN PCSTR GroupIconId
  202. );
  203. INT
  204. IcoGetIndexFromPeResourceIdW (
  205. IN PCWSTR ModuleName,
  206. IN PCWSTR GroupIconId
  207. );
  208. PICON_GROUP
  209. IcoExtractIconGroupFromPeFileExA (
  210. IN HANDLE ModuleHandle,
  211. IN PCSTR GroupIconId,
  212. OUT PINT Index OPTIONAL
  213. );
  214. PICON_GROUP
  215. IcoExtractIconGroupFromPeFileExW (
  216. IN HANDLE ModuleHandle,
  217. IN PCWSTR GroupIconId,
  218. OUT PINT Index OPTIONAL
  219. );
  220. PICON_GROUP
  221. IcoExtractIconGroupFromPeFileA (
  222. IN PCSTR ModuleName,
  223. IN PCSTR GroupIconId,
  224. OUT PINT Index OPTIONAL
  225. );
  226. PICON_GROUP
  227. IcoExtractIconGroupFromPeFileW (
  228. IN PCWSTR ModuleName,
  229. IN PCWSTR GroupIconId,
  230. OUT PINT Index OPTIONAL
  231. );
  232. VOID
  233. IcoAbortPeEnumIconGroupA (
  234. IN OUT PICON_ENUMA IconEnum
  235. );
  236. VOID
  237. IcoAbortPeEnumIconGroupW (
  238. IN OUT PICON_ENUMW IconEnum
  239. );
  240. BOOL
  241. IcoEnumFirstIconGroupInPeFileExA (
  242. IN HANDLE ModuleHandle,
  243. OUT PICON_ENUMA IconEnum
  244. );
  245. BOOL
  246. IcoEnumFirstIconGroupInPeFileExW (
  247. IN HANDLE ModuleHandle,
  248. OUT PICON_ENUMW IconEnum
  249. );
  250. BOOL
  251. IcoEnumFirstIconGroupInPeFileA (
  252. IN PCSTR ModuleName,
  253. OUT PICON_ENUMA IconEnum
  254. );
  255. BOOL
  256. IcoEnumFirstIconGroupInPeFileW (
  257. IN PCWSTR ModuleName,
  258. OUT PICON_ENUMW IconEnum
  259. );
  260. BOOL
  261. IcoEnumNextIconGroupInPeFileA (
  262. IN OUT PICON_ENUMA IconEnum
  263. );
  264. BOOL
  265. IcoEnumNextIconGroupInPeFileW (
  266. IN OUT PICON_ENUMW IconEnum
  267. );
  268. PICON_GROUP
  269. IcoExtractIconGroupByIndexFromPeFileExA (
  270. IN HANDLE ModuleHandle,
  271. IN INT Index,
  272. OUT PCSTR *GroupIconId OPTIONAL
  273. );
  274. PICON_GROUP
  275. IcoExtractIconGroupByIndexFromPeFileExW (
  276. IN HANDLE ModuleHandle,
  277. IN INT Index,
  278. OUT PCWSTR *GroupIconId OPTIONAL
  279. );
  280. PICON_GROUP
  281. IcoExtractIconGroupByIndexFromPeFileA (
  282. IN PCSTR ModuleName,
  283. IN INT Index,
  284. OUT PCSTR *GroupIconId OPTIONAL
  285. );
  286. PICON_GROUP
  287. IcoExtractIconGroupByIndexFromPeFileW (
  288. IN PCWSTR ModuleName,
  289. IN INT Index,
  290. OUT PCWSTR *GroupIconId OPTIONAL
  291. );
  292. BOOL
  293. IcoWriteIconGroupToPeFileExA (
  294. IN HANDLE ModuleHandle,
  295. IN HANDLE UpdateHandle,
  296. IN PICON_GROUP IconGroup,
  297. OUT PCSTR *ResourceId OPTIONAL
  298. );
  299. BOOL
  300. IcoWriteIconGroupToPeFileExW (
  301. IN HANDLE ModuleHandle,
  302. IN HANDLE UpdateHandle,
  303. IN PICON_GROUP IconGroup,
  304. OUT PCWSTR *ResourceId OPTIONAL
  305. );
  306. BOOL
  307. IcoWriteIconGroupToPeFileA (
  308. IN PCSTR ModuleName,
  309. IN PICON_GROUP IconGroup,
  310. OUT PCSTR *ResourceId, OPTIONAL
  311. OUT PINT Index OPTIONAL
  312. );
  313. BOOL
  314. IcoWriteIconGroupToPeFileW (
  315. IN PCWSTR ModuleName,
  316. IN PICON_GROUP IconGroup,
  317. OUT PCWSTR *ResourceId, OPTIONAL
  318. OUT PINT Index OPTIONAL
  319. );
  320. INT
  321. IcoGetIndexFromNeResourceIdExA (
  322. IN HANDLE ModuleHandle,
  323. IN PCSTR GroupIconId
  324. );
  325. INT
  326. IcoGetIndexFromNeResourceIdExW (
  327. IN HANDLE ModuleHandle,
  328. IN PCWSTR GroupIconId
  329. );
  330. INT
  331. IcoGetIndexFromNeResourceIdA (
  332. IN PCSTR ModuleName,
  333. IN PCSTR GroupIconId
  334. );
  335. INT
  336. IcoGetIndexFromNeResourceIdW (
  337. IN PCWSTR ModuleName,
  338. IN PCWSTR GroupIconId
  339. );
  340. PICON_GROUP
  341. IcoExtractIconGroupFromNeFileExA (
  342. IN HANDLE ModuleHandle,
  343. IN PCSTR GroupIconId,
  344. OUT PINT Index OPTIONAL
  345. );
  346. PICON_GROUP
  347. IcoExtractIconGroupFromNeFileExW (
  348. IN HANDLE ModuleHandle,
  349. IN PCWSTR GroupIconId,
  350. OUT PINT Index OPTIONAL
  351. );
  352. PICON_GROUP
  353. IcoExtractIconGroupFromNeFileA (
  354. IN PCSTR ModuleName,
  355. IN PCSTR GroupIconId,
  356. OUT PINT Index OPTIONAL
  357. );
  358. PICON_GROUP
  359. IcoExtractIconGroupFromNeFileW (
  360. IN PCWSTR ModuleName,
  361. IN PCWSTR GroupIconId,
  362. OUT PINT Index OPTIONAL
  363. );
  364. VOID
  365. IcoAbortNeEnumIconGroupA (
  366. IN OUT PICON_ENUMA IconEnum
  367. );
  368. VOID
  369. IcoAbortNeEnumIconGroupW (
  370. IN OUT PICON_ENUMW IconEnum
  371. );
  372. BOOL
  373. IcoEnumFirstIconGroupInNeFileExA (
  374. IN HANDLE ModuleHandle,
  375. OUT PICON_ENUMA IconEnum
  376. );
  377. BOOL
  378. IcoEnumFirstIconGroupInNeFileExW (
  379. IN HANDLE ModuleHandle,
  380. OUT PICON_ENUMW IconEnum
  381. );
  382. BOOL
  383. IcoEnumFirstIconGroupInNeFileA (
  384. IN PCSTR ModuleName,
  385. OUT PICON_ENUMA IconEnum
  386. );
  387. BOOL
  388. IcoEnumFirstIconGroupInNeFileW (
  389. IN PCWSTR ModuleName,
  390. OUT PICON_ENUMW IconEnum
  391. );
  392. BOOL
  393. IcoEnumNextIconGroupInNeFileA (
  394. IN OUT PICON_ENUMA IconEnum
  395. );
  396. BOOL
  397. IcoEnumNextIconGroupInNeFileW (
  398. IN OUT PICON_ENUMW IconEnum
  399. );
  400. PICON_GROUP
  401. IcoExtractIconGroupByIndexFromNeFileExA (
  402. IN HANDLE ModuleHandle,
  403. IN INT Index,
  404. OUT PCSTR *GroupIconId OPTIONAL
  405. );
  406. PICON_GROUP
  407. IcoExtractIconGroupByIndexFromNeFileExW (
  408. IN HANDLE ModuleHandle,
  409. IN INT Index,
  410. OUT PCWSTR *GroupIconId OPTIONAL
  411. );
  412. PICON_GROUP
  413. IcoExtractIconGroupByIndexFromNeFileA (
  414. IN PCSTR ModuleName,
  415. IN INT Index,
  416. OUT PCSTR *GroupIconId OPTIONAL
  417. );
  418. PICON_GROUP
  419. IcoExtractIconGroupByIndexFromNeFileW (
  420. IN PCWSTR ModuleName,
  421. IN INT Index,
  422. OUT PCWSTR *GroupIconId OPTIONAL
  423. );
  424. VOID
  425. IcoAbortEnumIconGroupA (
  426. IN OUT PICON_ENUMA IconEnum
  427. );
  428. VOID
  429. IcoAbortEnumIconGroupW (
  430. IN OUT PICON_ENUMW IconEnum
  431. );
  432. BOOL
  433. IcoEnumFirstIconGroupInFileA (
  434. IN PCSTR FileName,
  435. OUT PICON_ENUMA IconEnum
  436. );
  437. BOOL
  438. IcoEnumFirstIconGroupInFileW (
  439. IN PCWSTR FileName,
  440. OUT PICON_ENUMW IconEnum
  441. );
  442. BOOL
  443. IcoEnumNextIconGroupInFileA (
  444. IN OUT PICON_ENUMA IconEnum
  445. );
  446. BOOL
  447. IcoEnumNextIconGroupInFileW (
  448. IN OUT PICON_ENUMW IconEnum
  449. );
  450. PICON_GROUP
  451. IcoExtractIconGroupFromFileA (
  452. IN PCSTR ModuleName,
  453. IN PCSTR GroupIconId,
  454. OUT PINT Index OPTIONAL
  455. );
  456. PICON_GROUP
  457. IcoExtractIconGroupFromFileW (
  458. IN PCWSTR ModuleName,
  459. IN PCWSTR GroupIconId,
  460. OUT PINT Index OPTIONAL
  461. );
  462. PICON_GROUP
  463. IcoExtractIconGroupByIndexFromFileA (
  464. IN PCSTR ModuleName,
  465. IN INT Index,
  466. OUT PCSTR *GroupIconId
  467. );
  468. PICON_GROUP
  469. IcoExtractIconGroupByIndexFromFileW (
  470. IN PCWSTR ModuleName,
  471. IN INT Index,
  472. OUT PCWSTR *GroupIconId
  473. );
  474. //
  475. // Macro expansion definition
  476. //
  477. // None
  478. //
  479. // TCHAR mappings
  480. //
  481. #ifndef UNICODE
  482. #define ICON_ENUM ICON_ENUMA
  483. #define IcoReleaseResourceId IcoReleaseResourceIdA
  484. #define IcoExtractIconGroupFromIcoFile IcoExtractIconGroupFromIcoFileA
  485. #define IcoWriteIconGroupToIcoFile IcoWriteIconGroupToIcoFileA
  486. #define IcoGetIndexFromPeResourceIdEx IcoGetIndexFromPeResourceIdExA
  487. #define IcoGetIndexFromPeResourceId IcoGetIndexFromPeResourceIdA
  488. #define IcoExtractIconGroupFromPeFileEx IcoExtractIconGroupFromPeFileExA
  489. #define IcoExtractIconGroupFromPeFile IcoExtractIconGroupFromPeFileA
  490. #define IcoAbortPeEnumIconGroup IcoAbortPeEnumIconGroupA
  491. #define IcoEnumFirstIconGroupInPeFileEx IcoEnumFirstIconGroupInPeFileExA
  492. #define IcoEnumFirstIconGroupInPeFile IcoEnumFirstIconGroupInPeFileA
  493. #define IcoEnumNextIconGroupInPeFile IcoEnumNextIconGroupInPeFileA
  494. #define IcoExtractIconGroupByIndexFromPeFileEx IcoExtractIconGroupByIndexFromPeFileExA
  495. #define IcoExtractIconGroupByIndexFromPeFile IcoExtractIconGroupByIndexFromPeFileA
  496. #define IcoWriteIconGroupToPeFileEx IcoWriteIconGroupToPeFileExA
  497. #define IcoWriteIconGroupToPeFile IcoWriteIconGroupToPeFileA
  498. #define IcoGetIndexFromNeResourceIdEx IcoGetIndexFromNeResourceIdExA
  499. #define IcoGetIndexFromNeResourceId IcoGetIndexFromNeResourceIdA
  500. #define IcoExtractIconGroupFromNeFileEx IcoExtractIconGroupFromNeFileExA
  501. #define IcoExtractIconGroupFromNeFile IcoExtractIconGroupFromNeFileA
  502. #define IcoAbortNeEnumIconGroup IcoAbortNeEnumIconGroupA
  503. #define IcoEnumFirstIconGroupInNeFileEx IcoEnumFirstIconGroupInNeFileExA
  504. #define IcoEnumFirstIconGroupInNeFile IcoEnumFirstIconGroupInNeFileA
  505. #define IcoEnumNextIconGroupInNeFile IcoEnumNextIconGroupInNeFileA
  506. #define IcoExtractIconGroupByIndexFromNeFileEx IcoExtractIconGroupByIndexFromNeFileExA
  507. #define IcoExtractIconGroupByIndexFromNeFile IcoExtractIconGroupByIndexFromNeFileA
  508. #define IcoAbortEnumIconGroup IcoAbortEnumIconGroupA
  509. #define IcoEnumFirstIconGroupInFile IcoEnumFirstIconGroupInFileA
  510. #define IcoEnumNextIconGroupInFile IcoEnumNextIconGroupInFileA
  511. #define IcoExtractIconGroupFromFile IcoExtractIconGroupFromFileA
  512. #define IcoExtractIconGroupByIndexFromFile IcoExtractIconGroupByIndexFromFileA
  513. #else
  514. #define ICON_ENUM ICON_ENUMW
  515. #define IcoReleaseResourceId IcoReleaseResourceIdW
  516. #define IcoExtractIconGroupFromIcoFile IcoExtractIconGroupFromIcoFileW
  517. #define IcoWriteIconGroupToIcoFile IcoWriteIconGroupToIcoFileW
  518. #define IcoGetIndexFromPeResourceIdEx IcoGetIndexFromPeResourceIdExW
  519. #define IcoGetIndexFromPeResourceId IcoGetIndexFromPeResourceIdW
  520. #define IcoExtractIconGroupFromPeFileEx IcoExtractIconGroupFromPeFileExW
  521. #define IcoExtractIconGroupFromPeFile IcoExtractIconGroupFromPeFileW
  522. #define IcoAbortPeEnumIconGroup IcoAbortPeEnumIconGroupW
  523. #define IcoEnumFirstIconGroupInPeFileEx IcoEnumFirstIconGroupInPeFileExW
  524. #define IcoEnumFirstIconGroupInPeFile IcoEnumFirstIconGroupInPeFileW
  525. #define IcoEnumNextIconGroupInPeFile IcoEnumNextIconGroupInPeFileW
  526. #define IcoExtractIconGroupByIndexFromPeFileEx IcoExtractIconGroupByIndexFromPeFileExW
  527. #define IcoExtractIconGroupByIndexFromPeFile IcoExtractIconGroupByIndexFromPeFileW
  528. #define IcoWriteIconGroupToPeFileEx IcoWriteIconGroupToPeFileExW
  529. #define IcoWriteIconGroupToPeFile IcoWriteIconGroupToPeFileW
  530. #define IcoGetIndexFromNeResourceIdEx IcoGetIndexFromNeResourceIdExW
  531. #define IcoGetIndexFromNeResourceId IcoGetIndexFromNeResourceIdW
  532. #define IcoExtractIconGroupFromNeFileEx IcoExtractIconGroupFromNeFileExW
  533. #define IcoExtractIconGroupFromNeFile IcoExtractIconGroupFromNeFileW
  534. #define IcoAbortNeEnumIconGroup IcoAbortNeEnumIconGroupW
  535. #define IcoEnumFirstIconGroupInNeFileEx IcoEnumFirstIconGroupInNeFileExW
  536. #define IcoEnumFirstIconGroupInNeFile IcoEnumFirstIconGroupInNeFileW
  537. #define IcoEnumNextIconGroupInNeFile IcoEnumNextIconGroupInNeFileW
  538. #define IcoExtractIconGroupByIndexFromNeFileEx IcoExtractIconGroupByIndexFromNeFileExW
  539. #define IcoExtractIconGroupByIndexFromNeFile IcoExtractIconGroupByIndexFromNeFileW
  540. #define IcoAbortEnumIconGroup IcoAbortEnumIconGroupW
  541. #define IcoEnumFirstIconGroupInFile IcoEnumFirstIconGroupInFileW
  542. #define IcoEnumNextIconGroupInFile IcoEnumNextIconGroupInFileW
  543. #define IcoExtractIconGroupFromFile IcoExtractIconGroupFromFileW
  544. #define IcoExtractIconGroupByIndexFromFile IcoExtractIconGroupByIndexFromFileW
  545. #endif