Skip to content

Commit

Permalink
[CrashFix] If the razer passthrough sdk was not available the reset c…
Browse files Browse the repository at this point in the history
…all failed.

Added better error messages to the sdk dll loader.
  • Loading branch information
MartB committed Jun 10, 2017
1 parent 6a904f7 commit 5200523
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions server-exe/LightingSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ class LightingSDK {
const std::string& getSDKName() const { return SDK_NAME; }

void disconnect() {
reset();
// Dont call reset because we cant guarantee that the sdk checks for a valid dll.
if (m_dllInstance != nullptr) {
reset();
}
unloadDLL();
}

void unloadDLL() const {
if (!m_sdkLoader) {
if (!m_sdkLoader || m_dllInstance == nullptr) {
return;
}

Expand Down
6 changes: 5 additions & 1 deletion server-exe/SDKLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ void SDKLoader::destroy() {
bool SDKLoader::load(HINSTANCE& inst, const std::string& dllName, functionList& fList) {
// Force user to call reload.
if (isLoaded(dllName)) {
LOG_D("DLL already loaded you should call reload!");
return false;
}

inst = LoadLibraryA(dllName.c_str());

if (!inst) {
LOG_E("LoadLibraryA({0}) failed with code {1}", dllName, GetLastError());
return false;
}

for (auto& func : fList) {
void* fptr = GetProcAddress(inst, func.first.c_str());
const char * funcPtrName = func.first.c_str();
void* fptr = GetProcAddress(inst, funcPtrName);
if (!fptr) {
LOG_E("FunctionPtr {0} {1}", dllName, funcPtrName);
FreeLibrary(inst);
return false;
}
Expand Down

0 comments on commit 5200523

Please sign in to comment.