UMXTools.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * UMXTools.h
  3. * ------------
  4. * Purpose: UMX/UAX (Unreal) helper functions
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs (inspired by code from http://wiki.beyondunreal.com/Legacy:Package_File_Format)
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. OPENMPT_NAMESPACE_BEGIN
  12. namespace UMX
  13. {
  14. // UMX File Header
  15. struct FileHeader
  16. {
  17. char magic[4]; // C1 83 2A 9E
  18. uint16le packageVersion;
  19. uint16le licenseMode;
  20. uint32le flags;
  21. uint32le nameCount;
  22. uint32le nameOffset;
  23. uint32le exportCount;
  24. uint32le exportOffset;
  25. uint32le importCount;
  26. uint32le importOffset;
  27. bool IsValid() const;
  28. uint32 GetMinimumAdditionalFileSize() const;
  29. };
  30. MPT_BINARY_STRUCT(FileHeader, 36)
  31. // Check validity of file header
  32. CSoundFile::ProbeResult ProbeFileHeader(MemoryFileReader file, const uint64* pfilesize, const char *requiredType);
  33. // Read compressed unreal integers - similar to MIDI integers, but signed values are possible.
  34. int32 ReadIndex(FileReader &chunk);
  35. // Returns true if the given nme exists in the name table.
  36. bool FindNameTableEntry(FileReader &file, const FileHeader &fileHeader, const char *name);
  37. // Returns true if the given nme exists in the name table.
  38. bool FindNameTableEntryMemory(MemoryFileReader &file, const FileHeader &fileHeader, const char *name);
  39. // Read an entry from the name table.
  40. std::string ReadNameTableEntry(FileReader &chunk, uint16 packageVersion);
  41. // Read complete name table.
  42. std::vector<std::string> ReadNameTable(FileReader &file, const FileHeader &fileHeader);
  43. // Read import table.
  44. std::vector<int32> ReadImportTable(FileReader &file, const FileHeader &fileHeader, const std::vector<std::string> &names);
  45. // Read an entry from the import table.
  46. int32 ReadImportTableEntry(FileReader &chunk, uint16 packageVersion);
  47. // Read an entry from the export table.
  48. std::pair<FileReader, int32> ReadExportTableEntry(FileReader &file, const FileHeader &fileHeader, const std::vector<int32> &classes, const std::vector<std::string> &names, const char *filterType);
  49. } // namespace UMX
  50. OPENMPT_NAMESPACE_END