diff --git a/CMakeLists.txt b/CMakeLists.txt index dd4ab9d..648a2a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,4 +49,4 @@ find_package(lz4 REQUIRED) target_link_options(EGL2 PRIVATE "/DELAYLOAD:winfsp-x64.dll") target_include_directories(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\inc" ${RAPIDJSON_INCLUDE_DIRS} "libdeflate") -target_link_libraries(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\lib\\winfsp-x64.lib" OpenSSL::SSL OpenSSL::Crypto Crypt32 ZLIB::ZLIB lz4::lz4 delayimp "${CMAKE_CURRENT_SOURCE_DIR}\\libdeflate\\libdeflatestatic.lib") \ No newline at end of file +target_link_libraries(EGL2 PRIVATE "$ENV{ProgramFiles\(x86\)}\\WinFsp\\lib\\winfsp-x64.lib" OpenSSL::SSL OpenSSL::Crypto Crypt32 ZLIB::ZLIB lz4::lz4 Psapi delayimp "${CMAKE_CURRENT_SOURCE_DIR}\\libdeflate\\libdeflatestatic.lib") \ No newline at end of file diff --git a/README.md b/README.md index cf5fd1a..e3c5369 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## Installation / Getting Started The process can be a little awkward, so here's a simple step by step guide: 1. Install [WinFsp](http://www.secfs.net/winfsp/), which can be downloaded [here](https://github.com/billziss-gh/winfsp/releases/download/v1.7B1/winfsp-1.7.20038.msi). (Only the "Core" feature is necessary) - 2. Download the latest install of EGL2 [here](https://github.com/WorkingRobot/EGL2/releases/latest/download/EGL2.exe). + 2. Download the latest install of EGL2 [here](https://github.com/WorkingRobot/EGL2/releases/latest/download/EGL2.exe). If you get an error about a VCRUNTIME dll missing, install the [Visual C++ redistributable](https://aka.ms/vs/16/release/vc_redist.x64.exe). 3. When ran, you should be greeted with a window with a several buttons. If instead you see an error, follow the instructions it shows. 4. Click "Setup", where a new window will prompt you to setup where you want your data to be stored. 5. If you want to be able to play the game (and not just download it), you will need to select a game directory as well. If you do not want to play, deselect the checkbox in the bottom right corner. diff --git a/gui/cApp.cpp b/gui/cApp.cpp index eced918..0b97c6d 100644 --- a/gui/cApp.cpp +++ b/gui/cApp.cpp @@ -19,11 +19,8 @@ bool cApp::OnInit() { if (result != WinFspCheckResult::LOADED) { switch (result) { - case WinFspCheckResult::CANNOT_ENUMERATE: - MESSAGE_ERROR("Could not iterate over drivers to get WinFsp install. System-specific error: %d", GetLastError()); - break; - case WinFspCheckResult::NOT_FOUND: - MESSAGE_ERROR("Could not find WinFsp as an installed driver. Maybe you don't have it installed?"); + case WinFspCheckResult::NO_PATH: + MESSAGE_ERROR("Could not get your Program Files (x86) folder. I honestly have no idea how you'd get this error."); break; case WinFspCheckResult::NO_DLL: MESSAGE_ERROR("Could not find WinFsp's DLL in the driver's folder. Try reinstalling WinFsp."); diff --git a/winfspcheck.cpp b/winfspcheck.cpp index c3c3ad8..41b8b80 100644 --- a/winfspcheck.cpp +++ b/winfspcheck.cpp @@ -5,6 +5,7 @@ #include #include +#include namespace fs = std::filesystem; @@ -15,46 +16,23 @@ WinFspCheckResult LoadWinFsp() { return WinFspCheckResult::LOADED; } - DWORD driverByteCount; - if (EnumDeviceDrivers(NULL, 0, &driverByteCount)) { - - DWORD driverCount = driverByteCount / sizeof(LPVOID); - LPVOID* drivers = new LPVOID[driverCount]; - WinFspCheckResult result = WinFspCheckResult::NOT_FOUND; - - if (EnumDeviceDrivers(drivers, driverByteCount, &driverByteCount)) { - char driverFilename[MAX_PATH]; - - for (int i = 0; i < driverCount; ++i) { - if (GetDeviceDriverFileNameA(drivers[i], driverFilename, MAX_PATH) && strstr(driverFilename, "winfsp")) - { - - fs::path dll; - if (strncmp(driverFilename, "\\??\\", 4) == 0) { - dll = driverFilename + 4; - } - else { - dll = driverFilename; - } - dll = dll.replace_extension(".dll"); - - if (fs::status(dll).type() != fs::file_type::regular) { - result = WinFspCheckResult::NO_DLL; - continue; - } - if (LoadLibraryA(dll.string().c_str()) == NULL) { - result = WinFspCheckResult::CANNOT_LOAD; - continue; - } - alreadyLoaded = true; - result = WinFspCheckResult::LOADED; - break; - } - } + fs::path DataFolder; + { + PWSTR appDataFolder; + if (SHGetKnownFolderPath(FOLDERID_ProgramFilesX86, 0, NULL, &appDataFolder) != S_OK) { + return WinFspCheckResult::NO_PATH; } + DataFolder = appDataFolder; + CoTaskMemFree(appDataFolder); + } + DataFolder = DataFolder / "WinFsp" / "bin" / "winfsp-x64.dll"; - delete[] drivers; - return result; + if (fs::status(DataFolder).type() != fs::file_type::regular) { + return WinFspCheckResult::NO_DLL; + } + if (LoadLibraryA(DataFolder.string().c_str()) == NULL) { + return WinFspCheckResult::CANNOT_LOAD; } - return WinFspCheckResult::CANNOT_ENUMERATE; + alreadyLoaded = true; + return WinFspCheckResult::LOADED; } \ No newline at end of file diff --git a/winfspcheck.h b/winfspcheck.h index 9e82015..35490c0 100644 --- a/winfspcheck.h +++ b/winfspcheck.h @@ -2,9 +2,8 @@ enum class WinFspCheckResult { LOADED = 0, // successfully loaded - CANNOT_ENUMERATE = 1, // cannot enumerate over drivers - NOT_FOUND = 2, // cannot find driver - NO_DLL = 3, // no dll in driver folder + NO_PATH = 1, // cannot get program files x86 folder + NO_DLL = 3, // no dll in winfsp folder CANNOT_LOAD = 4, // cannot load dll };