Browse Source

Added static necessary libs to bin and error handling while runtime libs working

Ivan Arkhipov 4 years ago
parent
commit
ececfafac2
5 changed files with 59 additions and 1 deletions
  1. 6 1
      .gitignore
  2. BIN
      bin/datexport.dll
  3. BIN
      bin/msvcr71.dll
  4. BIN
      bin/zlib1T.dll
  5. 53 0
      src/datexportapi.cpp

+ 6 - 1
.gitignore

@@ -21,4 +21,9 @@ debug_build/*
 release_build/*
 release_build/*
 bin/*
 bin/*
 install/*
 install/*
-lib/*
+lib/*
+
+!bin/README.md
+!bin/datexport.dll
+!bin/msvcr71.dll
+!bin/zlib1T.dll

BIN
bin/datexport.dll


BIN
bin/msvcr71.dll


BIN
bin/zlib1T.dll


+ 53 - 0
src/datexportapi.cpp

@@ -1,34 +1,87 @@
 #include "datexportapi.h"
 #include "datexportapi.h"
 
 
+#include <EasyLogging++/easylogging++.h>
+
+void ReportWinAPIError(std::string error_msg) {
+  int error_code = GetLastError();
+  LOG(ERROR) << error_msg << "Error code: " << error_code;
+  
+  error_msg = error_msg + 
+              " Error code: "  + 
+              std::to_string(error_code) +
+              "\n\n"
+              "Please, contact #support at LotRO Legacy Discord Channel (https://discord.gg/j25MdKR)\n"
+              "or write an e-mail to developer (me@endevir.ru) with this error description!";
+
+  MessageBox(
+      NULL,
+      error_msg.c_str(),
+      "Endevir's LotroDat library error!",
+      MB_ICONERROR | MB_OK
+  );
+
+  exit(1);
+}
+
 DatExportApi::DatExportApi() {
 DatExportApi::DatExportApi() {
   datexport_dll_ = LoadLibraryA("datexport");
   datexport_dll_ = LoadLibraryA("datexport");
+  if (datexport_dll_ == NULL) {
+    ReportWinAPIError("Error while opening runtime library!");
+  }
 
 
   /* get pointer to the function in the dll*/ 
   /* get pointer to the function in the dll*/ 
   open_dat_file_addr_ = GetProcAddress(datexport_dll_, "OpenDatFileEx2"); 
   open_dat_file_addr_ = GetProcAddress(datexport_dll_, "OpenDatFileEx2"); 
+  if (open_dat_file_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x1!");
+  }
   open_dat_file_func_ = DatExportApiPrivate::OpenDatFileFunc(open_dat_file_addr_); 
   open_dat_file_func_ = DatExportApiPrivate::OpenDatFileFunc(open_dat_file_addr_); 
   
   
   get_num_subfiles_addr_ = GetProcAddress(datexport_dll_, "GetNumSubfiles"); 
   get_num_subfiles_addr_ = GetProcAddress(datexport_dll_, "GetNumSubfiles"); 
+  if (get_num_subfiles_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x2!");
+  }
   get_num_subfiles_func_ = DatExportApiPrivate::GetNumSubfilesFunc(get_num_subfiles_addr_); 
   get_num_subfiles_func_ = DatExportApiPrivate::GetNumSubfilesFunc(get_num_subfiles_addr_); 
   
   
   get_subfile_sizes_addr_ = GetProcAddress(datexport_dll_, "GetSubfileSizes"); 
   get_subfile_sizes_addr_ = GetProcAddress(datexport_dll_, "GetSubfileSizes"); 
+  if (get_subfile_sizes_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x3!");
+  }
   get_subfile_sizes_func_ = DatExportApiPrivate::GetSubFileSizesFunc(get_subfile_sizes_addr_); 
   get_subfile_sizes_func_ = DatExportApiPrivate::GetSubFileSizesFunc(get_subfile_sizes_addr_); 
   
   
   get_subfile_version_addr_ = GetProcAddress(datexport_dll_, "GetSubfileVersion"); 
   get_subfile_version_addr_ = GetProcAddress(datexport_dll_, "GetSubfileVersion"); 
+    if (get_subfile_version_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x4!");
+  }
   get_subfile_version_func_ = DatExportApiPrivate::GetSubFileVersionFunc(get_subfile_version_addr_); 
   get_subfile_version_func_ = DatExportApiPrivate::GetSubFileVersionFunc(get_subfile_version_addr_); 
   
   
   get_subfile_data_addr_ = GetProcAddress(datexport_dll_, "GetSubfileData"); 
   get_subfile_data_addr_ = GetProcAddress(datexport_dll_, "GetSubfileData"); 
+  if (get_subfile_data_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x5!");
+  }
   get_subfile_data_func_ = DatExportApiPrivate::GetSubfileDataFunc(get_subfile_data_addr_); 
   get_subfile_data_func_ = DatExportApiPrivate::GetSubfileDataFunc(get_subfile_data_addr_); 
   
   
   close_dat_file_addr_ = GetProcAddress(datexport_dll_, "CloseDatFile"); 
   close_dat_file_addr_ = GetProcAddress(datexport_dll_, "CloseDatFile"); 
+  if (close_dat_file_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x6!");
+  }
   close_dat_file_func_ = DatExportApiPrivate::CloseDatFileFunc(close_dat_file_addr_); 
   close_dat_file_func_ = DatExportApiPrivate::CloseDatFileFunc(close_dat_file_addr_); 
   
   
   purge_subfile_data_addr_ = GetProcAddress(datexport_dll_, "PurgeSubfileData"); 
   purge_subfile_data_addr_ = GetProcAddress(datexport_dll_, "PurgeSubfileData"); 
+  if (purge_subfile_data_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x7!");
+  }
   purge_subfile_data_func_ = DatExportApiPrivate::PurgeSubFileDataFunc(purge_subfile_data_addr_);
   purge_subfile_data_func_ = DatExportApiPrivate::PurgeSubFileDataFunc(purge_subfile_data_addr_);
 
 
   put_subfile_data_addr_ = GetProcAddress(datexport_dll_, "PutSubfileData"); 
   put_subfile_data_addr_ = GetProcAddress(datexport_dll_, "PutSubfileData"); 
+  if (open_dat_file_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x8!");
+  }
   put_subfile_data_func_ = DatExportApiPrivate::PutSubFileDataFunc(put_subfile_data_addr_); 
   put_subfile_data_func_ = DatExportApiPrivate::PutSubFileDataFunc(put_subfile_data_addr_); 
   
   
   flush_addr_ = GetProcAddress(datexport_dll_, "Flush"); 
   flush_addr_ = GetProcAddress(datexport_dll_, "Flush"); 
+  if (open_dat_file_addr_ == NULL) {
+    ReportWinAPIError("Error while parsing runtime library funciton 0x9!");
+  }
   flush_func_ = DatExportApiPrivate::FlushFunc(flush_func_);
   flush_func_ = DatExportApiPrivate::FlushFunc(flush_func_);
 }
 }