Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 90 additions & 50 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite

jobs:
build:
name: Build USVFS
Expand All @@ -19,44 +16,66 @@ jobs:
arch: [x86, x64]
config: [Debug, Release]
runs-on: windows-2022

steps:
# set VCPKG Root
- name: "Set environmental variables"
# Set vcpkg root directory
- name: "Set environment variables"
shell: bash
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV

# checkout USVFS and vcpkg
# Checkout code
- uses: actions/checkout@v4

# configure
- run: cmake --preset vs2022-windows-${{ matrix.arch }} -B build_${{ matrix.arch }} "-DCMAKE_INSTALL_PREFIX=install/${{ matrix.config }}"

# build
- run: cmake --build build_${{ matrix.arch }} --config ${{ matrix.config }} --target INSTALL

# package install
- uses: actions/upload-artifact@master

# Setup vcpkg binary caching (GitHub Actions cache)
- name: Configure vcpkg cache
uses: actions/cache@v4
id: cache-vcpkg
with:
path: |
${{ env.VCPKG_ROOT }}/downloads
${{ env.VCPKG_ROOT }}/installed
${{ env.VCPKG_ROOT }}/buildtrees
key: ${{ runner.os }}-vcpkg-${{ matrix.arch }}-${{ matrix.config }}-${{ hashFiles('**/vcpkg.json', '**/CMakeLists.txt', '**/vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ matrix.arch }}-${{ matrix.config }}-
${{ runner.os }}-vcpkg-

# Configure
- name: Configure CMake
run: cmake --preset vs2022-windows-${{ matrix.arch }} -B build_${{ matrix.arch }} "-DCMAKE_INSTALL_PREFIX=install/${{ matrix.config }}"

# Build
- name: Build project
run: cmake --build build_${{ matrix.arch }} --config ${{ matrix.config }} --target INSTALL

# Package install files
- name: Upload install files
uses: actions/upload-artifact@v4
with:
name: usvfs_${{ matrix.config }}_${{ matrix.arch }}
path: ./install/${{ matrix.config }}

# package test/dlls/etc. for tests

- uses: actions/upload-artifact@master
# Package test files, etc.
- name: Upload library files
uses: actions/upload-artifact@v4
with:
name: usvfs-libs_${{ matrix.config }}_${{ matrix.arch }}
path: ./lib
- uses: actions/upload-artifact@master

- name: Upload binary files
uses: actions/upload-artifact@v4
with:
name: usvfs-bins_${{ matrix.config }}_${{ matrix.arch }}
path: ./bin
- uses: actions/upload-artifact@master

- name: Upload test files
uses: actions/upload-artifact@v4
with:
name: usvfs-tests_${{ matrix.config }}_${{ matrix.arch }}
path: ./test/bin

# merge x86 / x64 artifacts for tests (root bin/lib and test folder)
# Merge x86/x64 test artifacts
merge-artifacts-for-tests:
runs-on: ubuntu-latest
name: Merge Test Artifacts
Expand All @@ -65,23 +84,25 @@ jobs:
matrix:
config: [Debug, Release]
steps:
- name: Merge USVFS libs
- name: Merge USVFS library files
uses: actions/upload-artifact/merge@v4
with:
name: usvfs-libs_${{ matrix.config }}
pattern: usvfs-libs_${{ matrix.config }}_*
- name: Merge USVFS bins

- name: Merge USVFS binary files
uses: actions/upload-artifact/merge@v4
with:
name: usvfs-bins_${{ matrix.config }}
pattern: usvfs-bins_${{ matrix.config }}_*
- name: Merge USVFS tests

- name: Merge USVFS test files
uses: actions/upload-artifact/merge@v4
with:
name: usvfs-tests_${{ matrix.config }}
pattern: usvfs-tests_${{ matrix.config }}_*

# merge x86 / x64 artifacts (install folder)
# Merge x86/x64 install artifacts
merge-artifacts-for-release:
runs-on: ubuntu-latest
name: Merge Install Artifacts
Expand All @@ -90,7 +111,7 @@ jobs:
matrix:
config: [Debug, Release]
steps:
- name: Merge USVFS install
- name: Merge USVFS install files
uses: actions/upload-artifact/merge@v4
with:
name: usvfs_${{ matrix.config }}
Expand All @@ -106,33 +127,52 @@ jobs:
arch: [x86, x64]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@master

- uses: actions/download-artifact@v4
with:
name: usvfs-libs_${{ matrix.config }}
path: ./lib
- uses: actions/download-artifact@master

- uses: actions/download-artifact@v4
with:
name: usvfs-bins_${{ matrix.config }}
path: ./bin
- uses: actions/download-artifact@master

- uses: actions/download-artifact@v4
with:
name: usvfs-tests_${{ matrix.config }}
path: ./test/bin
- run: ./test/bin/shared_test_${{ matrix.arch }}.exe

- name: Run shared tests
run: ./test/bin/shared_test_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/testinject_bin_${{ matrix.arch }}.exe

- name: Run injection tests
run: ./test/bin/testinject_bin_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/thooklib_test_${{ matrix.arch }}.exe

- name: Run hook library tests
run: ./test/bin/thooklib_test_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/tinjectlib_test_${{ matrix.arch }}.exe

- name: Run inject library tests
run: ./test/bin/tinjectlib_test_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/tvfs_test_${{ matrix.arch }}.exe

- name: Run VFS tests
run: ./test/bin/tvfs_test_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/usvfs_test_runner_${{ matrix.arch }}.exe

- name: Run USVFS test runner
run: ./test/bin/usvfs_test_runner_${{ matrix.arch }}.exe
if: always()
- run: ./test/bin/usvfs_global_test_runner_${{ matrix.arch }}.exe

- name: Run USVFS global test runner
run: ./test/bin/usvfs_global_test_runner_${{ matrix.arch }}.exe
if: always()
- uses: actions/upload-artifact@v4

- name: Upload test outputs
uses: actions/upload-artifact@v4
if: always()
with:
name: tests-outputs_${{ matrix.config }}_${{ matrix.arch }}
Expand All @@ -148,26 +188,26 @@ jobs:
permissions:
contents: write
steps:
# USVFS does not use different names for debug and release so we are going to
# USVFS does not use different names for Debug and Release so we are going to
# retrieve both install artifacts and put them under install/ and install/debug/

- name: Download Release Artifact
uses: actions/download-artifact@master
- name: Download Release artifact
uses: actions/download-artifact@v4
with:
name: usvfs_Release
path: ./install

- name: Download Debug Artifact
uses: actions/download-artifact@master
- name: Download Debug artifact
uses: actions/download-artifact@v4
with:
name: usvfs_Debug
path: ./install/debug

- name: Create USVFS Base archive
- name: Create USVFS base archive
run: 7z a usvfs_${{ github.ref_name }}.7z ./install/*

- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release create --draft=false --notes="Release ${{ github.ref_name }}" "${{ github.ref_name }}" ./usvfs_${{ github.ref_name }}.7z
run: gh release create --draft=false --notes="Release ${{ github.ref_name }}" "${{ github.ref_name }}" ./usvfs_${{ github.ref_name }}.7z
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check format
uses: ModOrganizer2/check-formatting-action@master
with:
Expand Down
6 changes: 6 additions & 0 deletions src/shared/ntdll_declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ NtQueryFullAttributesFile_type NtQueryFullAttributesFile;
NtQueryAttributesFile_type NtQueryAttributesFile;
NtQueryObject_type NtQueryObject;
NtQueryInformationFile_type NtQueryInformationFile;
NtSetInformationFile_type NtSetInformationFile;
NtQueryInformationByName_type NtQueryInformationByName;
NtOpenFile_type NtOpenFile;
NtCreateFile_type NtCreateFile;
Expand All @@ -41,6 +42,8 @@ RtlDosPathNameToRelativeNtPathName_U_WithStatus_type
RtlReleaseRelativeName_type RtlReleaseRelativeName;
RtlGetVersion_type RtlGetVersion;
NtTerminateProcess_type NtTerminateProcess;
NtReadFile_type NtReadFile;
NtWriteFile_type NtWriteFile;

static bool ntdll_initialized;

Expand All @@ -55,6 +58,7 @@ void ntdll_declarations_init()
LOAD_EXT(ntDLLMod, NtQueryAttributesFile);
LOAD_EXT(ntDLLMod, NtQueryObject);
LOAD_EXT(ntDLLMod, NtQueryInformationFile);
LOAD_EXT(ntDLLMod, NtSetInformationFile);
LOAD_EXT(ntDLLMod, NtQueryInformationByName);
LOAD_EXT(ntDLLMod, NtCreateFile);
LOAD_EXT(ntDLLMod, NtOpenFile);
Expand All @@ -64,6 +68,8 @@ void ntdll_declarations_init()
LOAD_EXT(ntDLLMod, RtlReleaseRelativeName);
LOAD_EXT(ntDLLMod, RtlGetVersion);
LOAD_EXT(ntDLLMod, NtTerminateProcess);
LOAD_EXT(ntDLLMod, NtReadFile);
LOAD_EXT(ntDLLMod, NtWriteFile);

ntdll_initialized = true;
}
Expand Down
22 changes: 22 additions & 0 deletions src/shared/ntdll_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ typedef struct _FILE_REPARSE_POINT_INFORMATION
#define STATUS_NO_MORE_FILES ((NTSTATUS)0x80000006L)
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
#define STATUS_NO_SUCH_FILE ((NTSTATUS)0xC000000FL)
#define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
#define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121L)

#define SL_RESTART_SCAN 0x01
#define SL_RETURN_SINGLE_ENTRY 0x02
Expand All @@ -375,6 +377,7 @@ typedef enum _FILE_INFORMATION_CLASS
FileNameInformation = 9,
FileRenameInformation = 10,
FileNamesInformation = 12,
FilePositionInformation = 14,
FileAllInformation = 18,
FileObjectIdInformation = 29,
FileReparsePointInformation = 33,
Expand Down Expand Up @@ -563,6 +566,9 @@ using NtQueryObject_type = NTSTATUS(WINAPI*)(
using NtQueryInformationFile_type = NTSTATUS(WINAPI*)(
HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation,
ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);
using NtSetInformationFile_type = NTSTATUS(WINAPI*)(
HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation,
ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);

using NtQueryInformationByName_type = NTSTATUS(WINAPI*)(
HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation,
Expand All @@ -579,6 +585,18 @@ using NtClose_type = NTSTATUS(WINAPI*)(HANDLE);
using NtTerminateProcess_type = NTSTATUS(WINAPI*)(HANDLE ProcessHandle,
NTSTATUS ExitStatus);

using NtReadFile_type = NTSTATUS(WINAPI*)(HANDLE FileHandle, HANDLE Event,
PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
ULONG Length, PLARGE_INTEGER ByteOffset,
PULONG Key);

using NtWriteFile_type = NTSTATUS(WINAPI*)(HANDLE FileHandle, HANDLE Event,
PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
ULONG Length, PLARGE_INTEGER ByteOffset,
PULONG Key);

// Rtl

using RtlDoesFileExists_U_type = NTSYSAPI BOOLEAN(NTAPI*)(PCWSTR);
Expand All @@ -594,11 +612,15 @@ extern NtQueryFullAttributesFile_type NtQueryFullAttributesFile;
extern NtQueryAttributesFile_type NtQueryAttributesFile;
extern NtQueryObject_type NtQueryObject;
extern NtQueryInformationFile_type NtQueryInformationFile;
extern NtSetInformationFile_type NtSetInformationFile;
extern NtQueryInformationByName_type NtQueryInformationByName;
extern NtOpenFile_type NtOpenFile;
extern NtCreateFile_type NtCreateFile;
extern NtClose_type NtClose;
extern NtTerminateProcess_type NtTerminateProcess;
extern NtReadFile_type NtReadFile;
extern NtWriteFile_type NtWriteFile;

extern RtlDoesFileExists_U_type RtlDoesFileExists_U;
extern RtlDosPathNameToRelativeNtPathName_U_WithStatus_type
RtlDosPathNameToRelativeNtPathName_U_WithStatus;
Expand Down
3 changes: 3 additions & 0 deletions src/usvfs_dll/hookmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,15 @@ void HookManager::initHooks()
installHook(ntdllMod, nullptr, "NtQueryDirectoryFileEx", hook_NtQueryDirectoryFileEx);
installHook(ntdllMod, nullptr, "NtQueryObject", hook_NtQueryObject);
installHook(ntdllMod, nullptr, "NtQueryInformationFile", hook_NtQueryInformationFile);
installHook(ntdllMod, nullptr, "NtSetInformationFile", hook_NtSetInformationFile);
installHook(ntdllMod, nullptr, "NtQueryInformationByName",
hook_NtQueryInformationByName);
installHook(ntdllMod, nullptr, "NtOpenFile", hook_NtOpenFile);
installHook(ntdllMod, nullptr, "NtCreateFile", hook_NtCreateFile);
installHook(ntdllMod, nullptr, "NtClose", hook_NtClose);
installHook(ntdllMod, nullptr, "NtTerminateProcess", hook_NtTerminateProcess);
installHook(ntdllMod, nullptr, "NtReadFile", hook_NtReadFile);
installHook(ntdllMod, nullptr, "NtWriteFile", hook_NtWriteFile);

installHook(kbaseMod, k32Mod, "LoadLibraryExA", hook_LoadLibraryExA);
installHook(kbaseMod, k32Mod, "LoadLibraryExW", hook_LoadLibraryExW);
Expand Down
4 changes: 2 additions & 2 deletions src/usvfs_dll/hooks/file_information_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace usvfs::details

#define DECLARE_HAS_FIELD(Field) \
template <typename T> \
constexpr auto HasFieldImpl##Field(int)->decltype(std::declval<T>().Field, void(), \
std::true_type()) \
constexpr auto HasFieldImpl##Field(int) \
-> decltype(std::declval<T>().Field, void(), std::true_type()) \
{ \
return {}; \
} \
Expand Down
Loading