test: object.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# object.c File Reference

`#include "mscms.h"`

Go to the source code of this file.

## Defines

#define | NUM_REQ_FNS 10
#define | NUM_OPT_FNS 6
#define | NUM_PS_FNS 3

## Functions

HANDLE | AllocateHeapObject (OBJECTTYPE objType)
VOID | FreeHeapObject (HANDLE hObject)
BOOL | ValidHandle (HANDLE hObject, OBJECTTYPE objType)
BOOL | ValidProfile (PPROFOBJ pProfObj)
PVOID | MemAlloc (DWORD dwSize)
PVOID | MemReAlloc (PVOID pMemory, DWORD dwNewSize)
VOID | MemFree (PVOID pMemory)
VOID | MyCopyMemory (PBYTE pDest, PBYTE pSrc, DWORD dwCount)
BOOL | ConvertToUnicode (PCSTR pszAnsiStr, PWSTR *ppwszUnicodeStr, BOOL bAllocate)
BOOL | ConvertToAnsi (PCWSTR pwszUnicodeStr, PSTR *ppszAnsiStr, BOOL bAllocate)
BOOL | ValidColorMatchingModule (DWORD cmmID, PTSTR pCMMDll)
PCMMOBJ | GetColorMatchingModule (DWORD cmmID)
PCMMOBJ | GetPreferredCMM ()
VOID | ReleaseColorMatchingModule (PCMMOBJ pCMMObj)

## Define Documentation

#define NUM_OPT_FNS 6

| Definition at line 25 of file object.c. Referenced by GetColorMatchingModule().

#define NUM_PS_FNS 3

| Definition at line 26 of file object.c. Referenced by GetColorMatchingModule().

#define NUM_REQ_FNS 10

| Definition at line 24 of file object.c. Referenced by GetColorMatchingModule(), and ValidColorMatchingModule().

## Function Documentation

HANDLE AllocateHeapObject | ( | OBJECTTYPE | objType | ) |

Definition at line 46 of file object.c.

References DWORD, MemAlloc(), NULL, and RIP.

Referenced by CreateMultiProfileTransform(), GetColorMatchingModule(), InternalCreateColorTransform(), and InternalOpenColorProfile().

    00049 {
    00050     DWORD    dwSize;
    00051     POBJHEAD pObject;
    00052
    00053     switch (objType)
    00054     {
    00055     case OBJ_PROFILE:
    00056         dwSize = sizeof(PROFOBJ);
    00057         break;
    00058
    00059     case OBJ_TRANSFORM:
    00060         dwSize = sizeof(TRANSFORMOBJ);
    00061         break;
    00062
    00063     case OBJ_CMM:
    00064         dwSize = sizeof(CMMOBJ);
    00065         break;
    00066
    00067     default:
    00068         RIP((__TEXT("Allocating invalid object\n")));
    00069         dwSize = 0;
    00070         break;
    00071     }
    00072
    00073     pObject = (POBJHEAD)MemAlloc(dwSize);
    00074
    00075     if (!pObject)
    00076     {
    00077         return NULL;
    00078     }
    00079
    00080     pObject->objType = objType;
    00081
    00082     return(PTRTOHDL(pObject));
    00083 }

BOOL ConvertToAnsi | ( | PCWSTR | pwszUnicodeStr,
|  | PSTR * | ppszAnsiStr,
|  | BOOL | bAllocate
| ) |

Definition at line 419 of file object.c.

References BOOL, DWORD, FALSE, MemAlloc(), MemFree(), NULL, TRUE, and WARNING.

Referenced by AssociateColorProfileWithDeviceW(), DisassociateColorProfileFromDeviceW(), EnumColorProfilesW(), GetColorDirectoryW(), GetStandardColorSpaceProfileW(), InstallColorProfileW(), RegisterCMMW(), SetStandardColorSpaceProfileW(), UninstallColorProfileW(), and UnregisterCMMW().

    00424 {
    00425     DWORD dwLen;                    // length of Ansi string
    00426     BOOL  bUsedDefaultChar;         // if default characters were used in
    00427                                     // converting Unicode to Ansi
    00428
    00429     dwLen = (lstrlenW(pwszUnicodeStr) + 1) * sizeof(char);
    00430
    00431     //
    00432     // Allocate memory for Ansi string
    00433     //
    00434
    00435     if (bAllocate)
    00436     {
    00437         *ppszAnsiStr = (PSTR)MemAlloc(dwLen);
    00438         if (! (*ppszAnsiStr))
    00439         {
    00440             WARNING((__TEXT("Error allocating memory for ANSI name\n")));
    00441             SetLastError(ERROR_NOT_ENOUGH_MEMORY);
    00442             return FALSE;
    00443         }
    00444     }
    00445
    00446     //
    00447     // Convert Unicode string to Ansi
    00448     //
    00449
    00450     if (! WideCharToMultiByte(CP_ACP, 0, pwszUnicodeStr, -1, *ppszAnsiStr,
    00451             dwLen, NULL, &bUsedDefaultChar) || bUsedDefaultChar)
    00452     {
    00453         WARNING((__TEXT("Error converting to Ansi name\n")));
    00454         MemFree(*ppszAnsiStr);
    00455         *ppszAnsiStr = NULL;
    00456         return FALSE;
    00457     }
    00458
    00459     return TRUE;
    00460 }

BOOL ConvertToUnicode | ( | PCSTR | pszAnsiStr,
|  | PWSTR * | ppwszUnicodeStr,
|  | BOOL | bAllocate
| ) |

Definition at line 357 of file object.c.

References DWORD, FALSE, MemAlloc(), MemFree(), NULL, TRUE, and WARNING.

Referenced by EnumColorProfilesW(), GetColorDirectoryW(), GetScannerData(), GetStandardColorSpaceProfileW(), OpenScanner(), and SetScannerData().

    00362 {
    00363     DWORD dwLen;                    // length of Unicode string
    00364
    00365     dwLen = (lstrlenA(pszAnsiStr) + 1) * sizeof(WCHAR);
    00366
    00367     //
    00368     // Allocate memory for Unicode string
    00369     //
    00370
    00371     if (bAllocate)
    00372     {
    00373         *ppwszUnicodeStr =  (PWSTR)MemAlloc(dwLen);
    00374         if (! (*ppwszUnicodeStr))
    00375         {
    00376             WARNING((__TEXT("Error allocating memory for Unicode name\n")));
    00377             SetLastError(ERROR_NOT_ENOUGH_MEMORY);
    00378             return FALSE;
    00379         }
    00380     }
    00381
    00382     //
    00383     // Convert Ansi string to Unicode
    00384     //
    00385
    00386     if (! MultiByteToWideChar(CP_ACP, 0, pszAnsiStr, -1,
    00387             *ppwszUnicodeStr, dwLen))
    00388     {
    00389         WARNING((__TEXT("Error converting to Unicode name\n")));
    00390         MemFree(*ppwszUnicodeStr);
    00391         *ppwszUnicodeStr = NULL;
    00392         return FALSE;
    00393     }
    00394
    00395     return TRUE;
    00396 }

VOID FreeHeapObject | ( | HANDLE | hObject | ) |

Definition at line 102 of file object.c.

References ASSERT, MemFree(), and NULL.

Referenced by CreateMultiProfileTransform(), DeleteColorTransform(), FreeProfileObject(), GetColorMatchingModule(), and InternalCreateColorTransform().

    00105 {
    00106     POBJHEAD pObject;
    00107
    00108     ASSERT(hObject != NULL);
    00109
    00110     pObject = (POBJHEAD)HDLTOPTR(hObject);
    00111
    00112     ASSERT(pObject->dwUseCount == 0);
    00113
    00114     pObject->objType = 0;       // in case the handle gets reused
    00115
    00116     MemFree((PVOID)pObject);
    00117 }

PCMMOBJ GetColorMatchingModule | ( | DWORD | cmmID | ) |

Definition at line 564 of file object.c.

References AllocateHeapObject(), ASSERT, BOOL, BYTE, CMM_IDENT, CMM_VERSION, critsec, DWORD, ERR, FALSE, FreeHeapObject(), GetCurrentProcessId, gpCMMChain, gszCMMOptFns, gszCMMReqFns, gszDefaultCMM, gszICMatcher, gszPSFns, MAX_PATH, NULL, NUM_OPT_FNS, NUM_PS_FNS, NUM_REQ_FNS, TRUE, and WARNING.

Referenced by ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateDeviceLinkProfile(), CreateMultiProfileTransform(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), InternalCreateColorTransform(), InternalCreateProfileFromLCS(), IsColorProfileValid(), and SelectCMM().

    00567 {
    00568     HANDLE    hCMMObj;
    00569     PCMMOBJ   pCMMObj = NULL;
    00570     FARPROC   *ppTemp;
    00571     HINSTANCE hInstance = NULL;
    00572     HKEY      hkCMM = NULL;
    00573     DWORD     dwTaskID;
    00574     TCHAR     szCMMID[5];
    00575     DWORD     dwType, bufSize, i;
    00576     TCHAR     szBuffer[MAX_PATH];
    00577     BOOL      rc = FALSE;       // Assume failure
    00578
    00579     //
    00580     // Check if we have already loaded this CMM
    00581     //
    00582
    00583     dwTaskID = GetCurrentProcessId();
    00584
    00585     EnterCriticalSection(&critsec);     // Critical section
    00586     pCMMObj = gpCMMChain;
    00587
    00588     while (pCMMObj)
    00589     {
    00590         if ((pCMMObj->dwCMMID == cmmID) && (pCMMObj->dwTaskID == dwTaskID))
    00591         {
    00592             pCMMObj->objHdr.dwUseCount++;
    00593             break;
    00594         }
    00595         pCMMObj = pCMMObj->pNext;
    00596     }
    00597     LeaveCriticalSection(&critsec);     // Critical section
    00598
    00599     if (pCMMObj)
    00600         return pCMMObj;
    00601
    00602     //
    00603     // CMM not already loaded - check to see if it is default CMM before
    00604     // looking in the registry
    00605     //
    00606
    00607     if (cmmID == CMM_WINDOWS_DEFAULT)
    00608     {
    00609         hInstance = LoadLibrary(gszDefaultCMM);
    00610         goto AttemptedLoadingCMM;
    00611     }
    00612
    00613     //
    00614     // Not default CMM, look in the registry
    00615     //
    00616
    00617     if (RegOpenKey(HKEY_LOCAL_MACHINE, gszICMatcher, &hkCMM) != ERROR_SUCCESS)
    00618     {
    00619         return NULL;
    00620     }
    00621
    00622     //
    00623     // Make a string with the CMM ID
    00624     //
    00625
    00626 #ifdef UNICODE
    00627     {
    00628         DWORD temp = FIX_ENDIAN(cmmID);
    00629
    00630         if (!MultiByteToWideChar(CP_ACP, 0, (PSTR)&temp, 4, szCMMID, 5))
    00631         {
    00632             WARNING((__TEXT("Could not convert cmmID %x to Unicode\n"), temp));
    00633             goto EndGetColorMatchingModule;
    00634         }
    00635     }
    00636 #else
    00637     for (i=0; i<4; i++)
    00638     {
    00639         szCMMID[i] = ((PSTR)&cmmID)[3-i];
    00640     }
    00641 #endif
    00642     szCMMID[4] = '\0';
    00643
    00644     //
    00645     // Get the file name of the CMM dll if registered
    00646     //
    00647
    00648     bufSize = MAX_PATH;
    00649     if (RegQueryValueEx(hkCMM, (PTSTR)szCMMID, 0, &dwType, (BYTE *)szBuffer, &bufSize) !=
    00650         ERROR_SUCCESS)
    00651     {
    00652         WARNING((__TEXT("CMM %s not registered\n"), szCMMID));
    00653         goto EndGetColorMatchingModule;
    00654     }
    00655
    00656     //
    00657     // Load the CMM
    00658     //
    00659
    00660     hInstance = LoadLibrary(szBuffer);
    00661
    00662 AttemptedLoadingCMM:
    00663
    00664     if (!hInstance)
    00665     {
    00666         WARNING((__TEXT("Could not load CMM %x\n"), cmmID));
    00667         goto EndGetColorMatchingModule;
    00668     }
    00669
    00670     //
    00671     // Allocate a CMM object
    00672     //
    00673
    00674     hCMMObj = AllocateHeapObject(OBJ_CMM);
    00675     if (!hCMMObj)
    00676     {
    00677         ERR((__TEXT("Could not allocate CMM object\n")));
    00678         goto EndGetColorMatchingModule;
    00679     }
    00680
    00681     pCMMObj = (PCMMOBJ)HDLTOPTR(hCMMObj);
    00682
    00683     ASSERT(pCMMObj != NULL);
    00684
    00685     //
    00686     // Fill in the CMM object
    00687     //
    00688
    00689     pCMMObj->objHdr.dwUseCount = 1;
    00690     pCMMObj->dwCMMID = cmmID;
    00691     pCMMObj->dwTaskID = dwTaskID;
    00692     pCMMObj->hCMM = hInstance;
    00693
    00694     ppTemp = (FARPROC *)&pCMMObj->fns.pCMGetInfo;
    00695     *ppTemp = GetProcAddress(hInstance, gszCMMReqFns[0]);
    00696     ppTemp++;
    00697
    00698     if (!pCMMObj->fns.pCMGetInfo)
    00699     {
    00700         ERR((__TEXT("CMM does not export CMGetInfo\n")));
    00701         goto EndGetColorMatchingModule;
    00702     }
    00703
    00704     //
    00705     // Check if the CMM is the right version and reports the same ID
    00706     //
    00707
    00708     if (pCMMObj->fns.pCMGetInfo(CMM_VERSION) < 0x00050000 ||
    00709         pCMMObj->fns.pCMGetInfo(CMM_IDENT) != cmmID)
    00710     {
    00711         ERR((__TEXT("CMM not correct version or reports incorrect ID\n")));
    00712         goto EndGetColorMatchingModule;
    00713     }
    00714
    00715     //
    00716     // Load the remaining required functions
    00717     //
    00718
    00719     for (i=1; i<NUM_REQ_FNS; i++)
    00720     {
    00721         *ppTemp = GetProcAddress(hInstance, gszCMMReqFns[i]);
    00722         if (!*ppTemp)
    00723         {
    00724             ERR((__TEXT("CMM %s does not export %s\n"), szCMMID, gszCMMReqFns[i]));
    00725             goto EndGetColorMatchingModule;
    00726         }
    00727         ppTemp++;
    00728     }
    00729
    00730     //
    00731     // Load the optional functions
    00732     //
    00733
    00734     for (i=0; i<NUM_OPT_FNS; i++)
    00735     {
    00736         *ppTemp = GetProcAddress(hInstance, gszCMMOptFns[i]);
    00737
    00738         //
    00739         // Even these functions are required for Windows default CMM
    00740         //
    00741
    00742         if (cmmID == CMM_WINDOWS_DEFAULT && !*ppTemp)
    00743         {
    00744             ERR((__TEXT("Windows default CMM does not export %s\n"), gszCMMOptFns[i]));
    00745             goto EndGetColorMatchingModule;
    00746         }
    00747         ppTemp++;
    00748     }
    00749
    00750     //
    00751     // Load the PS functions - these are optional even for the default CMM
    00752     //
    00753
    00754     for (i=0; i<NUM_PS_FNS; i++)
    00755     {
    00756         *ppTemp = GetProcAddress(hInstance, gszPSFns[i]);
    00757         ppTemp++;
    00758     }
    00759
    00760     //
    00761     // If any of the PS Level2 fns is not exported, do not use this CMM
    00762     // for any of the PS Level 2 functionality
    00763     //
    00764
    00765     if (!pCMMObj->fns.pCMGetPS2ColorSpaceArray ||
    00766         !pCMMObj->fns.pCMGetPS2ColorRenderingIntent ||
    00767         !pCMMObj->fns.pCMGetPS2ColorRenderingDictionary)
    00768     {
    00769         pCMMObj->fns.pCMGetPS2ColorSpaceArray = NULL;
    00770         pCMMObj->fns.pCMGetPS2ColorRenderingIntent = NULL;
    00771         pCMMObj->fns.pCMGetPS2ColorRenderingDictionary = NULL;
    00772         pCMMObj->dwFlags |= CMM_DONT_USE_PS2_FNS;
    00773     }
    00774
    00775     //
    00776     // Add the CMM object to the chain at the beginning
    00777     //
    00778
    00779     EnterCriticalSection(&critsec);     // Critical section
    00780     pCMMObj->pNext = gpCMMChain;
    00781     gpCMMChain = pCMMObj;
    00782     LeaveCriticalSection(&critsec);     // Critical section
    00783
    00784     rc = TRUE;                          // Success!
    00785
    00786 EndGetColorMatchingModule:
    00787
    00788     if (!rc)
    00789     {
    00790         if (pCMMObj)
    00791         {
    00792             pCMMObj->objHdr.dwUseCount--;   // decrement before freeing
    00793             FreeHeapObject(hCMMObj);
    00794             pCMMObj = NULL;
    00795         }
    00796         if (hInstance)
    00797         {
    00798             FreeLibrary(hInstance);
    00799         }
    00800     }
    00801
    00802     if (hkCMM)
    00803     {
    00804         RegCloseKey(hkCMM);
    00805     }
    00806
    00807     return pCMMObj;
    00808 }

PCMMOBJ GetPreferredCMM | ( |  | ) |

Definition at line 826 of file object.c.

References critsec, and gpPreferredCMM.

Referenced by ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateMultiProfileTransform(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), and InternalCreateColorTransform().

    00828 {
    00829     PCMMOBJ pCMMObj;
    00830
    00831     EnterCriticalSection(&critsec);     // Critical section
    00832     pCMMObj = gpPreferredCMM;
    00833
    00834     if (pCMMObj)
    00835     {
    00836         //
    00837         // Increment use count
    00838         //
    00839
    00840         pCMMObj->objHdr.dwUseCount++;
    00841     }
    00842     LeaveCriticalSection(&critsec);     // Critical section
    00843
    00844     return pCMMObj;
    00845 }

PVOID MemAlloc | ( | DWORD | dwSize | ) |

Definition at line 205 of file object.c.

References NULL.

Referenced by AllocateHeapObject(), Ascii85Encode(), ColorSpaceControl(), ConvertToAnsi(), ConvertToUnicode(), CreateColorantArray(), CreateColSpArray(), CreateColSpProc(), CreateCRDControl(), CreateFloatString(), CreateHostLutCRD(), CreateHostRevTRCInputTable(), CreateINTENTControl(), CreateLutCRD(), CreateMatrixCRD(), CreateMonoCRD(), CreateProfCRDControl(), EnumColorProfilesW(), GetColorDirectoryW(), GetCPMediaWhitePoint(), GetCRDInputOutputArraySize(), GetHostCSA(), GetPS2CSA_DEFG(), GetPS2CSA_MONO_A(), GetPS2CSA_MONO_ABC(), GetPS2PreviewColorRenderingDictionary(), GetStandardColorSpaceProfileW(), GetTRCData(), IGetDeviceData(), InternalAssociateColorProfileWithDevice(), InternalCreateColorTransform(), InternalGetPS2PreviewCRD(), InternalOpenColorProfile(), IsSRGB(), LoadCP(), OpenColorProfileW(), OpenScanner(), and RtlVirtualUnwind().

    00208 {
    00209     if (dwSize > 0)
    00210         return (PVOID)GlobalAllocPtr(GHND | GMEM_ZEROINIT, dwSize);
    00211     else
    00212         return NULL;
    00213 }

VOID MemFree | ( | PVOID | pMemory | ) |

Definition at line 260 of file object.c.

References DWORD.

Referenced by Ascii85Encode(), AssociateColorProfileWithDeviceW(), CloseScanner(), ColorSpaceControl(), ConvertToAnsi(), ConvertToUnicode(), CreateColorantArray(), CreateColSpArray(), CreateColSpProc(), CreateCRDControl(), CreateFloatString(), CreateHostLutCRD(), CreateHostRevTRCInputTable(), CreateINTENTControl(), CreateLutCRD(), CreateMatrixCRD(), CreateMonoCRD(), CreateProfCRDControl(), DisassociateColorProfileFromDeviceW(), EnumColorProfilesW(), FreeCP(), FreeHeapObject(), FreeProfileObject(), GetColorDirectoryW(), GetCPMediaWhitePoint(), GetCRDInputOutputArraySize(), GetHostCSA(), GetHostMatrixCSAorCRD(), GetPS2CSA_DEFG(), GetPS2CSA_MONO_A(), GetPS2CSA_MONO_ABC(), GetPS2PreviewColorRenderingDictionary(), GetScannerData(), GetStandardColorSpaceProfileW(), GetTRCData(), InstallColorProfileW(), InternalAssociateColorProfileWithDevice(), InternalCreateColorTransform(), InternalDisassociateColorProfileFromDevice(), InternalEnumColorProfiles(), InternalGetPS2PreviewCRD(), InternalOpenColorProfile(), IsSRGB(), OpenColorProfileW(), RegisterCMMW(), RtlVirtualUnwind(), SetScannerData(), SetStandardColorSpaceProfileW(), SpoolerCopyFileEvent(), UninstallColorProfileW(), and UnregisterCMMW().

    00263 {
    00264     DWORD dwErr;
    00265
    00266     //
    00267     // GlobalFree() resets last error, we get and set around it so we don't
    00268     // lose anything we have set.
    00269     //
    00270
    00271     dwErr = GetLastError();
    00272     GlobalFreePtr(pMemory);
    00273     if (dwErr)
    00274     {
    00275         SetLastError(dwErr);
    00276     }
    00277 }

PVOID MemReAlloc | ( | PVOID | pMemory,
|  | DWORD | dwNewSize
| ) |

Definition at line 234 of file object.c.

Referenced by GrowProfile(), and InternalAssociateColorProfileWithDevice().

    00238 {
    00239     return (PVOID)GlobalReAllocPtr(pMemory, dwNewSize, GMEM_ZEROINIT);
    00240 }

VOID MyCopyMemory | ( | PBYTE | pDest,
|  | PBYTE | pSrc,
|  | DWORD | dwCount
| ) |

Definition at line 300 of file object.c.

Referenced by AddTagTableEntry(), InsertInBuffer(), MoveProfileData(), and RemoveStringFromMultiSz().

    00305 {
    00306     //
    00307     // Make sure overlapping cases are handled
    00308     //
    00309
    00310     if ((pSrc < pDest) && ((pSrc + dwCount) >= pDest))
    00311     {
    00312         //
    00313         // Overlapping case, copy in reverse
    00314         //
    00315
    00316         pSrc += dwCount - 1;
    00317         pDest += dwCount - 1;
    00318
    00319         while (dwCount--)
    00320         {
    00321             *pDest-- = *pSrc--;
    00322         }
    00323
    00324     }
    00325     else
    00326     {
    00327         while (dwCount--)
    00328         {
    00329             *pDest++ = *pSrc++;
    00330         }
    00331     }
    00332
    00333     return;
    00334 }

VOID ReleaseColorMatchingModule | ( | PCMMOBJ | pCMMObj | ) |

Definition at line 865 of file object.c.

References ASSERT, and critsec.

Referenced by ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateDeviceLinkProfile(), CreateMultiProfileTransform(), DeleteColorTransform(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), InternalCreateColorTransform(), InternalCreateProfileFromLCS(), and IsColorProfileValid().

    00868 {
    00869     EnterCriticalSection(&critsec);     // Critical section
    00870
    00871     ASSERT(pCMMObj->objHdr.dwUseCount > 0);
    00872
    00873     pCMMObj->objHdr.dwUseCount--;
    00874
    00875     if (pCMMObj->objHdr.dwUseCount == 0)
    00876     {
    00877         //
    00878         // Unloading the CMM everytime a transform is freed might not be
    00879         // very efficient. So for now, I am not going to unload it. When
    00880         // the app terminates, kernel should unload all dll's loaded by
    00881         // this app
    00882         //
    00883     }
    00884     LeaveCriticalSection(&critsec);     // Critical section
    00885
    00886     return;
    00887 }

BOOL ValidColorMatchingModule | ( | DWORD | cmmID,
|  | PTSTR | pCMMDll
| ) |

Definition at line 477 of file object.c.

References BOOL, CMM_IDENT, CMM_VERSION, DWORD, ERR, FALSE, gszCMMReqFns, NULL, NUM_REQ_FNS, TRUE, and WARNING.

Referenced by InternalRegisterCMM().

    00481 {
    00482     HINSTANCE hInstance = NULL;
    00483     DWORD    (WINAPI *pfnCMGetInfo)(DWORD);
    00484     FARPROC   pfnCMRequired;
    00485     DWORD     i;
    00486     BOOL      rc = FALSE;       // Assume failure
    00487
    00488     //
    00489     // Load the CMM
    00490     //
    00491
    00492     hInstance = LoadLibrary(pCMMDll);
    00493
    00494     if (!hInstance)
    00495     {
    00496         WARNING((__TEXT("Could not load CMM %s\n"), pCMMDll));
    00497         goto EndValidColorMatchingModule;
    00498     }
    00499
    00500     (PVOID) pfnCMGetInfo = (PVOID) GetProcAddress(hInstance, gszCMMReqFns[0]);
    00501
    00502     if (!pfnCMGetInfo)
    00503     {
    00504         ERR((__TEXT("CMM does not export CMGetInfo\n")));
    00505         goto EndValidColorMatchingModule;
    00506     }
    00507
    00508     //
    00509     // Check if the CMM is the right version and reports the same ID
    00510     //
    00511
    00512     if ((pfnCMGetInfo(CMM_VERSION) < 0x00050000) ||
    00513         (pfnCMGetInfo(CMM_IDENT) != cmmID))
    00514     {
    00515         ERR((__TEXT("CMM %s not correct version or reports incorrect ID\n"), pCMMDll));
    00516         goto EndValidColorMatchingModule;
    00517     }
    00518
    00519     //
    00520     // Check the remaining required functions is presented
    00521     //
    00522
    00523     for (i=1; i<NUM_REQ_FNS; i++)
    00524     {
    00525         pfnCMRequired = GetProcAddress(hInstance, gszCMMReqFns[i]);
    00526         if (!pfnCMRequired)
    00527         {
    00528             ERR((__TEXT("CMM %s does not export %s\n"), pCMMDll, gszCMMReqFns[i]));
    00529             goto EndValidColorMatchingModule;
    00530         }
    00531     }
    00532
    00533     rc = TRUE;
    00534
    00535 EndValidColorMatchingModule:
    00536
    00537     if (hInstance)
    00538     {
    00539         FreeLibrary(hInstance);
    00540     }
    00541
    00542     return rc;
    00543 }

BOOL ValidHandle | ( | HANDLE | hObject,
|  | OBJECTTYPE | objType
| ) |

Definition at line 138 of file object.c.

References BOOL, DWORD, and FALSE.

Referenced by CheckBitmapBits(), CheckColors(), CloseColorProfile(), ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateDeviceLinkProfile(), CreateMultiProfileTransform(), DeleteColorTransform(), GetCMMInfo(), GetColorProfileElement(), GetColorProfileElementTag(), GetColorProfileFromHandle(), GetColorProfileHeader(), GetCountColorProfileElements(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), InternalCreateColorTransform(), IsColorProfileTagPresent(), IsColorProfileValid(), SetColorProfileElement(), SetColorProfileElementReference(), SetColorProfileElementSize(), SetColorProfileHeader(), TranslateBitmapBits(), and TranslateColors().

    00142 {
    00143     POBJHEAD pObject;
    00144     BOOL     rc;
    00145
    00146     if (!hObject)
    00147     {
    00148         return FALSE;
    00149     }
    00150
    00151     pObject = (POBJHEAD)HDLTOPTR(hObject);
    00152
    00153     rc = !IsBadReadPtr(pObject, sizeof(DWORD)) &&
    00154          (pObject->objType == objType);
    00155
    00156     return rc;
    00157 }

BOOL ValidProfile | ( | PPROFOBJ | pProfObj | ) |

Definition at line 176 of file object.c.

References BOOL, and DWORD.

Referenced by ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateDeviceLinkProfile(), CreateMultiProfileTransform(), GetColorProfileElement(), GetColorProfileElementTag(), GetColorProfileHeader(), GetCountColorProfileElements(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), InternalCreateColorTransform(), InternalOpenColorProfile(), IsColorProfileTagPresent(), IsColorProfileValid(), SetColorProfileElement(), SetColorProfileElementReference(), and SetColorProfileElementSize().

    00179 {
    00180     DWORD dwSize = FIX_ENDIAN(HEADER(pProfObj)->phSize);
    00181
    00182     return ((dwSize <= pProfObj->dwMapSize) &&
    00183             (HEADER(pProfObj)->phSignature == PROFILE_SIGNATURE) &&
    00184             (dwSize >= (sizeof(PROFILEHEADER) + sizeof(DWORD))));
    00185 }