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.

302 lines
10 KiB

  1. /****************************Module*Header******************************\
  2. * Module Name: ICMPRIV.H
  3. *
  4. * Module Descripton: Internal data structures and constants for ICM
  5. *
  6. * Warnings:
  7. *
  8. * Issues:
  9. *
  10. * Created: 8 January 1996
  11. * Author: Srinivasan Chandrasekar [srinivac]
  12. *
  13. * Copyright (c) Microsoft Corporation. All rights reserved.
  14. \***********************************************************************/
  15. #ifndef _ICMPRIV_H_
  16. #define _ICMPRIV_H_
  17. #include "icm.h" // include external stuff first
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. //
  22. // External (but OS internal) functional declarations
  23. //
  24. BOOL InternalGetPS2ColorSpaceArray (PBYTE, DWORD, DWORD, PBYTE, PDWORD, PBOOL);
  25. BOOL InternalGetPS2ColorRenderingIntent(PBYTE, DWORD, PBYTE, PDWORD);
  26. BOOL InternalGetPS2ColorRenderingDictionary(PBYTE, DWORD, PBYTE, PDWORD, PBOOL);
  27. BOOL InternalGetPS2PreviewCRD(PBYTE, PBYTE, DWORD, PBYTE, PDWORD, PBOOL);
  28. BOOL InternalGetPS2CSAFromLCS(LPLOGCOLORSPACE, PBYTE, PDWORD, PBOOL);
  29. BOOL InternalGetDeviceConfig(LPCTSTR,DWORD,DWORD,PVOID,PDWORD);
  30. BOOL InternalSetDeviceConfig(LPCTSTR,DWORD,DWORD,PVOID,DWORD);
  31. //
  32. // Function ID for InternalGet/SetDeviceConfig
  33. //
  34. #define MSCMS_PROFILE_ENUM_MODE 1
  35. #if !defined(_GDI32_) // not include from here if gdi32.
  36. //
  37. // Useful macros
  38. //
  39. #define ABS(x) ((x) > 0 ? (x) : -(x))
  40. #define DWORD_ALIGN(x) (((x) + 3) & ~3)
  41. #ifdef LITTLE_ENDIAN
  42. #define FIX_ENDIAN(x) (((x) & 0xff000000) >> 24 | \
  43. ((x) & 0xff0000) >> 8 | \
  44. ((x) & 0xff00) << 8 | \
  45. ((x) & 0xff) << 24 )
  46. #define FIX_ENDIAN16(x) (((x) & 0xff00) >> 8 | ((x) & 0xff) << 8)
  47. #else
  48. #define FIX_ENDIAN(x) (x)
  49. #define FIX_ENDIAN16(x) (x)
  50. #endif
  51. #if !defined(FROM_PS) // not include from here if postscript driver.
  52. //
  53. // MSCMS Internal definition
  54. //
  55. typedef struct tagTAGDATA {
  56. TAGTYPE tagType;
  57. DWORD dwOffset;
  58. DWORD cbSize;
  59. } TAGDATA;
  60. typedef TAGDATA *PTAGDATA;
  61. //
  62. // ICM supports the following objects:
  63. // 1. Profile object: This is created when an application requsts a handle
  64. // to a profile.
  65. // 2. Color transform object: This is created when an application creates
  66. // a color transform.
  67. // 3. CMM object: This is created when ICM loads a CMM into memory to
  68. // perform color matching.
  69. //
  70. typedef enum {
  71. OBJ_PROFILE = 'PRFL',
  72. OBJ_TRANSFORM = 'XFRM',
  73. OBJ_CMM = ' CMM',
  74. } OBJECTTYPE;
  75. typedef struct tagOBJHEAD {
  76. OBJECTTYPE objType;
  77. DWORD dwUseCount;
  78. } OBJHEAD;
  79. typedef OBJHEAD *POBJHEAD;
  80. //
  81. // Profile object:
  82. // Memory for profile objects is allocated from ICM's per process heap.
  83. // These objects use handles from ICM's per process handle table.
  84. //
  85. typedef struct tagPROFOBJ {
  86. OBJHEAD objHdr; // common object header info
  87. DWORD dwType; // type (from profile structure)
  88. PVOID pProfileData; // data (from profile structure)
  89. DWORD cbDataSize; // size of data (from profile structure)
  90. DWORD dwFlags; // miscellaneous flags
  91. HANDLE hFile; // handle to open profile
  92. HANDLE hMap; // handle to profile mapping
  93. DWORD dwMapSize; // size of the file mapping object
  94. PBYTE pView; // pointer to mapped view of profile
  95. } PROFOBJ;
  96. typedef PROFOBJ *PPROFOBJ;
  97. //
  98. // Flags for ((PPROFOBJ)0)->dwFlags
  99. //
  100. #define MEMORY_MAPPED 1 // memory mapped profile
  101. #define PROFILE_TEMP 2 // temporary profile has been created
  102. #define READWRITE_ACCESS 4 // if this bit is set, app has read & write
  103. // access to profile, else it has only read
  104. // read access.
  105. //
  106. // Transform returned by CMM
  107. //
  108. typedef HANDLE HCMTRANSFORM;
  109. //
  110. // For internal use, compiler doesn't accept PBYTE* below
  111. //
  112. typedef PBYTE* PPBYTE;
  113. //
  114. // CMM function calltable
  115. //
  116. typedef struct tagCMMFNS {
  117. //
  118. // Required functions
  119. //
  120. DWORD (WINAPI *pCMGetInfo)(DWORD);
  121. HCMTRANSFORM (WINAPI *pCMCreateTransform)(LPLOGCOLORSPACE, PVOID, PVOID);
  122. HCMTRANSFORM (WINAPI *pCMCreateTransformExt)(LPLOGCOLORSPACE, PVOID, PVOID, DWORD);
  123. BOOL (WINAPI *pCMDeleteTransform)(HCMTRANSFORM);
  124. BOOL (WINAPI *pCMTranslateRGBs)(HCMTRANSFORM, PVOID, BMFORMAT,
  125. DWORD, DWORD, DWORD, PVOID, BMFORMAT, DWORD);
  126. BOOL (WINAPI *pCMTranslateRGBsExt)(HCMTRANSFORM, PVOID, BMFORMAT,
  127. DWORD, DWORD, DWORD, PVOID, BMFORMAT, DWORD, PBMCALLBACKFN, LPARAM);
  128. BOOL (WINAPI *pCMCheckRGBs)(HCMTRANSFORM, PVOID, BMFORMAT,
  129. DWORD, DWORD, DWORD, PBYTE, PBMCALLBACKFN, LPARAM);
  130. HCMTRANSFORM (WINAPI *pCMCreateMultiProfileTransform)(PHPROFILE, DWORD, PDWORD, DWORD, DWORD);
  131. BOOL (WINAPI *pCMTranslateColors)(HCMTRANSFORM, PCOLOR, DWORD,
  132. COLORTYPE, PCOLOR, COLORTYPE);
  133. BOOL (WINAPI *pCMCheckColors)(HCMTRANSFORM, PCOLOR, DWORD,
  134. COLORTYPE, PBYTE);
  135. //
  136. // Optional functions
  137. //
  138. BOOL (WINAPI *pCMCreateProfile)(LPLOGCOLORSPACE, PPBYTE);
  139. BOOL (WINAPI *pCMGetNamedProfileInfo)(HPROFILE, PNAMED_PROFILE_INFO);
  140. BOOL (WINAPI *pCMConvertColorNameToIndex)(HPROFILE, LPCOLOR_NAME, LPDWORD, DWORD);
  141. BOOL (WINAPI *pCMConvertIndexToColorName)(HPROFILE, LPDWORD, LPCOLOR_NAME, DWORD);
  142. BOOL (WINAPI *pCMCreateDeviceLinkProfile)(PHPROFILE, DWORD, PDWORD, DWORD, DWORD, PPBYTE);
  143. BOOL (WINAPI *pCMIsProfileValid)(HPROFILE, PBOOL);
  144. BOOL (WINAPI *pCMGetPS2ColorSpaceArray)(HPROFILE, DWORD, DWORD, PBYTE, PDWORD, PBOOL);
  145. BOOL (WINAPI *pCMGetPS2ColorRenderingIntent)(HPROFILE, DWORD, PBYTE, PDWORD);
  146. BOOL (WINAPI *pCMGetPS2ColorRenderingDictionary)(HPROFILE, DWORD,
  147. PBYTE, PDWORD, PBOOL);
  148. } CMMFNS;
  149. typedef CMMFNS *PCMMFNS;
  150. //
  151. // CMM object:
  152. // Memory for CMM objects is allocated from ICM's per process heap.
  153. // They are maintained in a linked list.
  154. //
  155. typedef struct tagCMMOBJ {
  156. OBJHEAD objHdr;
  157. DWORD dwFlags; // miscellaneous flags
  158. DWORD dwCMMID; // ICC identifier
  159. DWORD dwTaskID; // process ID of current task
  160. HINSTANCE hCMM; // handle to instance of CMM dll
  161. CMMFNS fns; // function calltable
  162. struct tagCMMOBJ* pNext; // pointer to next object
  163. } CMMOBJ;
  164. typedef CMMOBJ *PCMMOBJ;
  165. //
  166. // dwFlags for CMMOBJ
  167. //
  168. #define CMM_DONT_USE_PS2_FNS 0x00001
  169. //
  170. // Color transform object
  171. //
  172. typedef struct tagTRANSFORMOBJ {
  173. OBJHEAD objHdr;
  174. PCMMOBJ pCMMObj; // pointer to CMM object
  175. HCMTRANSFORM hcmxform; // transform returned by CMM
  176. } TRANSFORMOBJ;
  177. typedef TRANSFORMOBJ *PTRANSFORMOBJ;
  178. //
  179. // Parameter to InternalHandleColorProfile
  180. //
  181. typedef enum {
  182. ADDPROFILES,
  183. REMOVEPROFILES,
  184. ENUMPROFILES,
  185. } PROFILEOP;
  186. //
  187. // CMM returned transform should be larger than this value
  188. //
  189. #define TRANSFORM_ERROR (HTRANSFORM)255
  190. #define PROFILE_SIGNATURE 'psca'
  191. #define HEADER(pProfObj) ((PPROFILEHEADER)pProfObj->pView)
  192. #define VIEW(pProfObj) (pProfObj->pView)
  193. #define PROFILE_SIZE(pProfObj) (FIX_ENDIAN(HEADER(pProfObj)->phSize))
  194. #define TAG_COUNT(pProfObj) (*((DWORD *)(VIEW(pProfObj) + \
  195. sizeof(PROFILEHEADER))))
  196. #define TAG_DATA(pProfObj) ((PTAGDATA)(VIEW(pProfObj) + \
  197. sizeof(PROFILEHEADER) + sizeof(DWORD)))
  198. #define MAGIC 'ICM '
  199. #define PTRTOHDL(x) ((HANDLE)((ULONG_PTR)(x) ^ MAGIC))
  200. #define HDLTOPTR(x) ((ULONG_PTR)(x) ^ MAGIC)
  201. PVOID MemAlloc(DWORD);
  202. PVOID MemReAlloc(PVOID, DWORD);
  203. VOID MemFree(PVOID);
  204. VOID MyCopyMemory(PBYTE, PBYTE, DWORD);
  205. PVOID AllocateHeapObject(OBJECTTYPE);
  206. VOID FreeHeapObject(HANDLE);
  207. BOOL ValidHandle(HANDLE, OBJECTTYPE);
  208. PCMMOBJ GetColorMatchingModule(DWORD);
  209. BOOL ValidColorMatchingModule(DWORD,PTSTR);
  210. PCMMOBJ GetPreferredCMM();
  211. VOID ReleaseColorMatchingModule(PCMMOBJ);
  212. BOOL ValidProfile(PPROFOBJ);
  213. BOOL ConvertToAnsi(PCWSTR, PSTR*, BOOL);
  214. BOOL ConvertToUnicode(PCSTR, PWSTR*, BOOL);
  215. PTSTR GetFilenameFromPath(PTSTR);
  216. //
  217. // For use with the new Device Settings tag
  218. //
  219. typedef struct _SETTINGS {
  220. DWORD dwSettingType; // 'rsln', 'mdia' etc.
  221. DWORD dwSizePerValue; // number of bytes per value
  222. DWORD nValues; // number of values
  223. DWORD Value[1]; // array of value entries
  224. } SETTINGS, *PSETTINGS;
  225. typedef struct _SETTINGCOMBOS {
  226. DWORD dwSize; // size of this structure, including sub structures
  227. DWORD nSettings; // number of setting structures
  228. SETTINGS Settings[1]; // array of setting entries
  229. } SETTINGCOMBOS, *PSETTINGCOMBOS;
  230. typedef struct _PERPLATFORMENTRY {
  231. DWORD PlatformID; // platform signature ('msft', 'appl' etc.)
  232. DWORD dwSize; // size of this structure, including sub structures
  233. DWORD nSettingCombos; // number of setting combo structures
  234. SETTINGCOMBOS SettingCombos[1]; // array of setting combos entries
  235. } PLATFORMENTRY, *PPLATFORMENTRY;
  236. typedef struct _DEVICESETTINGS {
  237. DWORD dwTagID; // 'devs'
  238. DWORD dwReserved; // must be 0
  239. DWORD nPlatforms; // number of platform structures
  240. PLATFORMENTRY PlatformEntry[1]; // array of platform entries
  241. } DEVICESETTINGS, *PDEVICESETTINGS;
  242. #endif // ifndef FROM_PS
  243. #endif // ifndef _GDI32_
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif // ifndef _ICMPRIV_H_