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.

100 lines
2.4 KiB

  1. /************************************************************************
  2. Copyright (c) 2000 - 2000 Microsoft Corporation
  3. Module Name :
  4. metadata.h
  5. Abstract :
  6. Main header for code for reading and writting to the metadata.
  7. Author :
  8. Revision History :
  9. ***********************************************************************/
  10. // These functions may throw a ComError.
  11. //
  12. void SafeWriteFile( HANDLE hFile, void *pBuffer, DWORD dwSize );
  13. void SafeReadFile( HANDLE hFile, void *pBuffer, DWORD dwSize );
  14. void SafeWriteStringHandle( HANDLE hFile, StringHandle & str );
  15. StringHandle SafeReadStringHandle( HANDLE hFile );
  16. void SafeWriteFile( HANDLE hFile, WCHAR * str );
  17. void SafeReadFile( HANDLE hFile, WCHAR ** pStr );
  18. void SafeWriteSid( HANDLE hFile, SidHandle & Sid );
  19. void SafeReadSid( HANDLE hFile, SidHandle & sid );
  20. template <class T>
  21. void SafeWriteFile( HANDLE hFile, T Data )
  22. {
  23. SafeWriteFile( hFile, &Data, sizeof( Data ) );
  24. }
  25. template <class T>
  26. void SafeReadFile( HANDLE hFile, T *pBuffer)
  27. {
  28. SafeReadFile( hFile, pBuffer, sizeof(*pBuffer) );
  29. }
  30. void SafeWriteBlockBegin( HANDLE hFile, GUID BlockGuid );
  31. void SafeWriteBlockEnd( HANDLE hFile, GUID BlockGuid );
  32. void SafeReadBlockBegin( HANDLE hFile, GUID BlockGuid );
  33. void SafeReadBlockEnd( HANDLE hFile, GUID BlockGuid );
  34. //
  35. // allows any one of several GUIDs.
  36. //
  37. int SafeReadGuidChoice( HANDLE hFile, const GUID * guids[] );
  38. class CQmgrStateFiles
  39. {
  40. auto_FILE_HANDLE m_Files[2];
  41. auto_ptr<WCHAR> m_FileNames[2];
  42. UINT64 m_ExpandSize[2];
  43. INT64 m_OriginalFileSizes[2];
  44. DWORD m_CurrentIndex;
  45. static auto_ptr<WCHAR> GetNameFromIndex( DWORD dwIndex );
  46. static auto_FILE_HANDLE OpenMetadataFile( auto_ptr<WCHAR> FileName );
  47. public:
  48. CQmgrStateFiles();
  49. HANDLE GetNextStateFile();
  50. void UpdateStateFile();
  51. HANDLE GetCurrentStateFile();
  52. void ExtendMetadata( INT64 ExtendAmount = ( METADATA_PREALLOC_SIZE + METADATA_PADDING ) );
  53. void ShrinkMetadata();
  54. };
  55. class CQmgrReadStateFile
  56. {
  57. private:
  58. CQmgrStateFiles & m_StateFiles;
  59. HANDLE m_FileHandle;
  60. public:
  61. CQmgrReadStateFile( CQmgrStateFiles & StateFiles );
  62. HANDLE GetHandle() { return m_FileHandle;}
  63. void ValidateEndOfFile();
  64. };
  65. class CQmgrWriteStateFile
  66. {
  67. private:
  68. CQmgrStateFiles & m_StateFiles;
  69. HANDLE m_FileHandle;
  70. public:
  71. CQmgrWriteStateFile( CQmgrStateFiles & StateFiles );
  72. HANDLE GetHandle() { return m_FileHandle;}
  73. void CommitFile();
  74. };