datexportapi.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include <windows.h>
  2. namespace DatExportApiPrivate {
  3. typedef int (__stdcall * OpenDatFileFunc)(
  4. int, // handle
  5. const char*, // filename
  6. unsigned int, // flags
  7. int*, // did_master_map
  8. int*, // block_size
  9. int*, // vnum_dat_file
  10. int*, // vnum_game_data
  11. unsigned long*, // dat_file_id
  12. void*, // dat_id_stamp
  13. void* // first_iter_guid
  14. );
  15. typedef int (__stdcall * GetNumSubfilesFunc)(
  16. int // handle
  17. );
  18. typedef int (__stdcall * GetSubFileSizesFunc)(
  19. int, // handle
  20. int*, // file_id list pointer
  21. int*, // size list pointer
  22. int*, // iteration list pointer
  23. int, // offset (index from 0 to num_subfiles - 1)
  24. int // count of files to get size of
  25. );
  26. typedef int (__stdcall * GetSubFileVersionFunc)(
  27. int, // handle
  28. int // file_id
  29. );
  30. typedef int (__stdcall * GetSubfileDataFunc)(
  31. int, // handle
  32. int, // file_id
  33. void*, // buffer for storing data
  34. int, // 0
  35. int* // version
  36. );
  37. typedef int (__stdcall * CloseDatFileFunc)(
  38. int // handle
  39. );
  40. typedef int (__stdcall * PurgeSubFileDataFunc)(
  41. int, // handle
  42. int // file_id
  43. );
  44. typedef int (__stdcall * PutSubFileDataFunc)(
  45. int, // handle
  46. int, // file_id
  47. void*, // buffer with subfile data
  48. int, // 0
  49. int, // size of data in bytes
  50. int, // version
  51. int, // iteration
  52. bool // 0
  53. );
  54. typedef int (__stdcall * FlushFunc)(
  55. int // handle
  56. );
  57. };
  58. class DatExportApi {
  59. public:
  60. DatExportApi();
  61. int OpenDatFile(int handle, const char* filename, unsigned int flags);
  62. int GetNumSubfiles(int handle);
  63. void GetSubfileSizes(int handle, int* file_ids, int* size, int* iteration, int offset, int count);
  64. int GetSubfileVersion(int handle, int file_id);
  65. int GetSubfileData(int handle, int file_id, void* target_buf, int& version);
  66. void CloseDatFile(int handle);
  67. int PurgeSubfileData(int handle, int file_id);
  68. int PutSubfileData(int handle, int file_id, void* data, int offset, int size, int version, int iteration, bool compress = false);
  69. void Flush(int handle);
  70. ~DatExportApi();
  71. private:
  72. HMODULE datexport_dll_;
  73. FARPROC open_dat_file_addr_;
  74. volatile DatExportApiPrivate::OpenDatFileFunc open_dat_file_func_;
  75. FARPROC get_num_subfiles_addr_;
  76. volatile DatExportApiPrivate::GetNumSubfilesFunc get_num_subfiles_func_;
  77. FARPROC get_subfile_sizes_addr_;
  78. volatile DatExportApiPrivate::GetSubFileSizesFunc get_subfile_sizes_func_;
  79. FARPROC get_subfile_version_addr_;
  80. volatile DatExportApiPrivate::GetSubFileVersionFunc get_subfile_version_func_;
  81. FARPROC get_subfile_data_addr_;
  82. volatile DatExportApiPrivate::GetSubfileDataFunc get_subfile_data_func_;
  83. FARPROC close_dat_file_addr_;
  84. volatile DatExportApiPrivate::CloseDatFileFunc close_dat_file_func_;
  85. FARPROC purge_subfile_data_addr_;
  86. volatile DatExportApiPrivate::PurgeSubFileDataFunc purge_subfile_data_func_;
  87. FARPROC put_subfile_data_addr_;
  88. volatile DatExportApiPrivate::PutSubFileDataFunc put_subfile_data_func_;
  89. FARPROC flush_addr_;
  90. volatile DatExportApiPrivate::FlushFunc flush_func_;
  91. };