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.

125 lines
4.5 KiB

  1. /**************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: fakecam.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * DATE: 18 July, 2000
  10. *
  11. * DESCRIPTION:
  12. * Fake Camera device
  13. *
  14. ***************************************************************************/
  15. #pragma once
  16. //
  17. // Structure to hold information about the device
  18. //
  19. typedef struct _FAKECAM_DEVICE_INFO
  20. {
  21. TCHAR tszRootPath[MAX_PATH];
  22. MCAM_ITEM_INFO *pFirstItem;
  23. MCAM_ITEM_INFO *pLastItem;
  24. INT iNumImages;
  25. INT iNumItems;
  26. HANDLE hFile;
  27. } UNALIGNED FAKECAM_DEVICE_INFO, * UNALIGNED PFAKECAM_DEVICE_INFO;
  28. //
  29. // Functions
  30. //
  31. inline BOOL IsImageType(const GUID *pFormat)
  32. {
  33. return (pFormat &&
  34. (IsEqualGUID(*pFormat, WiaImgFmt_JPEG) ||
  35. IsEqualGUID(*pFormat, WiaImgFmt_BMP) ||
  36. IsEqualGUID(*pFormat, WiaImgFmt_TIFF) ||
  37. IsEqualGUID(*pFormat, WiaImgFmt_MEMORYBMP) ||
  38. IsEqualGUID(*pFormat, WiaImgFmt_EXIF) ||
  39. IsEqualGUID(*pFormat, WiaImgFmt_FLASHPIX) ||
  40. IsEqualGUID(*pFormat, WiaImgFmt_JPEG2K) ||
  41. IsEqualGUID(*pFormat, WiaImgFmt_JPEG2KX) ||
  42. IsEqualGUID(*pFormat, WiaImgFmt_EMF) ||
  43. IsEqualGUID(*pFormat, WiaImgFmt_WMF) ||
  44. IsEqualGUID(*pFormat, WiaImgFmt_PNG) ||
  45. IsEqualGUID(*pFormat, WiaImgFmt_GIF) ||
  46. IsEqualGUID(*pFormat, WiaImgFmt_PHOTOCD) ||
  47. IsEqualGUID(*pFormat, WiaImgFmt_ICO) ||
  48. IsEqualGUID(*pFormat, WiaImgFmt_CIFF) ||
  49. IsEqualGUID(*pFormat, WiaImgFmt_PICT)));
  50. }
  51. HRESULT FakeCamOpen(PTSTR ptszPortName, MCAM_DEVICE_INFO *pDeviceInfo);
  52. HRESULT SearchDir(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pParent, PTSTR ptszPath);
  53. HRESULT SearchForAttachments(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pParent, PTSTR ptszMainItem);
  54. HRESULT CreateFolder(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pParent, WIN32_FIND_DATA *pFindData, MCAM_ITEM_INFO **ppFolder, PTSTR ptszFullName);
  55. HRESULT CreateImage(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pParent, WIN32_FIND_DATA *pFindData, MCAM_ITEM_INFO **ppImage, PTSTR ptszFullName);
  56. HRESULT CreateNonImage(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pParent, WIN32_FIND_DATA *pFindData, MCAM_ITEM_INFO **ppNonImage, PTSTR ptszFullName);
  57. HRESULT SetCommonFields(MCAM_ITEM_INFO *pItem, PTSTR ptszShortName, PTSTR ptszFullName, WIN32_FIND_DATA *pFindData);
  58. HRESULT AddItem(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pItem);
  59. HRESULT RemoveItem(FAKECAM_DEVICE_INFO *pPrivateDeviceInfo, MCAM_ITEM_INFO *pItem);
  60. //
  61. // Helper function - generate full file name as "<Path>\<FileName>"
  62. // cchFullNameSize - size of the buffer provided in ptszFullName. Function will return E_FAIL if
  63. // the buffer is not big enough to accomodate full path and teminating zero character
  64. //
  65. inline HRESULT MakeFullName(PTSTR ptszFullName, UINT cchFullNameSize, PTSTR ptszPath, PTSTR ptszFileName)
  66. {
  67. HRESULT hr = S_OK;
  68. if (_sntprintf(ptszFullName, cchFullNameSize, _T("%s\\%s"), ptszPath, ptszFileName) < 0)
  69. {
  70. hr = E_FAIL;
  71. }
  72. ptszFullName[cchFullNameSize - 1] = 0;
  73. return hr;
  74. }
  75. //
  76. // Constants for reading Exif files
  77. //
  78. const WORD TIFF_XRESOLUTION = 0x11a;
  79. const WORD TIFF_YRESOLUTION = 0x11b;
  80. const WORD TIFF_JPEG_DATA = 0x201;
  81. const WORD TIFF_JPEG_LEN = 0x202;
  82. const int APP1_OFFSET = 6; // Offset between the start of the APP1 segment and the start of the TIFF tags
  83. //
  84. // Structures for reading Exif files
  85. //
  86. typedef struct _DIR_ENTRY
  87. {
  88. WORD Tag;
  89. WORD Type;
  90. DWORD Count;
  91. DWORD Offset;
  92. } DIR_ENTRY, *PDIR_ENTRY;
  93. typedef struct _IFD
  94. {
  95. DWORD Offset;
  96. WORD Count;
  97. DIR_ENTRY *pEntries;
  98. DWORD NextIfdOffset;
  99. } IFD, *PIFD;
  100. //
  101. // Functions for reading Exif files
  102. //
  103. HRESULT ReadDimFromJpeg(PTSTR ptszFullName, WORD *pWidth, WORD *pHeight);
  104. HRESULT ReadJpegHdr(PTSTR ptszFileName, BYTE **ppBuf);
  105. HRESULT ReadExifJpeg(BYTE *pBuf, IFD *pImageIfd, IFD *pThumbIfd, BOOL *pbSwap);
  106. HRESULT ReadTiff(BYTE *pBuf, IFD *pImageIfd, IFD *pThumbIfd, BOOL *pbSwap);
  107. HRESULT ReadIfd(BYTE *pBuf, IFD *pIfd, BOOL bSwap);
  108. VOID FreeIfd(IFD *pIfd);
  109. WORD ByteSwapWord(WORD w);
  110. DWORD ByteSwapDword(DWORD dw);
  111. WORD GetWord(BYTE *pBuf, BOOL bSwap);
  112. DWORD GetDword(BYTE *pBuf, BOOL bSwap);