dllLoader.cpp 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "dllLoader.h"
  2. #include "pikaConfig.h"
  3. #ifdef PIKA_DEVELOPMENT
  4. #ifdef PIKA_WINDOWS
  5. #define NOMINMAX
  6. #define WIN32_LEAN_AND_MEAN
  7. #include <Windows.h>
  8. static HMODULE dllHand;
  9. //todo error reporting with strings
  10. bool pika::loadDll(std::filesystem::path path,
  11. testStart_t **testStart, testUpdate_t **testUpdate)
  12. {
  13. path /= "pikaGameplay.dll";
  14. dllHand = LoadLibraryA(path.string().c_str());
  15. if (!dllHand) { return false; }
  16. *testStart = (testStart_t *)GetProcAddress(dllHand, "testStart");
  17. *testUpdate = (testUpdate_t *)GetProcAddress(dllHand, "testUpdate");
  18. if (!testStart) { return false; }
  19. if (!testUpdate) { return false; }
  20. return true;
  21. }
  22. #else
  23. #error "pika load dll works only on windows."
  24. #endif
  25. #elif defined(PIKA_PRODUCTION)
  26. #include <dllMain.h>
  27. bool pika::loadDll(std::filesystem::path path,
  28. testStart_t **testStart_, testUpdate_t **testUpdate_)
  29. {
  30. *testStart_ = testStart;
  31. *testUpdate_ = testUpdate;
  32. return true;
  33. }
  34. #endif