Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Fixed winfsp error
Browse files Browse the repository at this point in the history
apparently the driver only exists if you install the kernel dev mode too
  • Loading branch information
WorkingRobot committed Apr 12, 2020
1 parent 6aeea49 commit 46baa7c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions gui/cApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
56 changes: 17 additions & 39 deletions winfspcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Psapi.h>

#include <filesystem>
#include <ShlObj_core.h>
namespace fs = std::filesystem;


Expand All @@ -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;
}
5 changes: 2 additions & 3 deletions winfspcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit 46baa7c

Please sign in to comment.