Skip to content

Commit

Permalink
Merge pull request #5 from apple1417/master
Browse files Browse the repository at this point in the history
add dsound.dll proxy, fill in extra exports
  • Loading branch information
apple1417 authored May 4, 2024
2 parents 6370285 + a8f9b4c commit 5876353
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 31 deletions.
93 changes: 75 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: CI

on: [
push,
pull_request,
workflow_dispatch
]
on:
push: {}
pull_request: {}
workflow_dispatch:
inputs:
new-release-tag:
description: >
New Release Tag. If given, creates a (draft) full release using the given tag.
type: string
required: false

env:
# Important to pin the clang version, cause we also use it for linting
Expand All @@ -23,7 +28,7 @@ jobs:

steps:
- name: Cache Clang
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-clang
with:
path: C:\Program Files\LLVM
Expand Down Expand Up @@ -55,23 +60,23 @@ jobs:
steps:
- name: Restore Clang Cache
if: startswith(matrix.preset, 'clang')
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true

- name: Add MSVC to PATH
if: startswith(matrix.preset, 'msvc')
uses: TheMrMilchmann/setup-msvc-dev@v2
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}

- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest

- name: Checkout repository and submodules
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -84,7 +89,7 @@ jobs:
run: cmake --build out/build/${{ matrix.preset }} --target install

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.preset }}
path: out/install/${{ matrix.preset }}/
Expand Down Expand Up @@ -150,7 +155,7 @@ jobs:
# xwin does take long enough that caching's worth it
- name: Restore xwin cache
if: contains(matrix.preset, 'cross')
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-xwin
with:
path: ~/xwin
Expand All @@ -169,7 +174,7 @@ jobs:
--output ~/xwin
- name: Checkout repository and submodules
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -187,7 +192,7 @@ jobs:
run: cmake --build out/build/${{ matrix.preset }} --target install

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.preset }}
path: out/install/${{ matrix.preset }}/
Expand All @@ -208,7 +213,7 @@ jobs:

steps:
- name: Restore Clang Cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
Expand All @@ -222,7 +227,7 @@ jobs:
run: pip install pyyaml

- name: Checkout repository and submodules
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -257,14 +262,14 @@ jobs:

steps:
- name: Restore Clang Cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run clang-format
run: |
Expand All @@ -282,7 +287,59 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check spelling
uses: crate-ci/typos@master

# ==============================================================================

release-draft-full:
runs-on: ubuntu-latest
if: >
github.ref == 'refs/heads/master'
&& github.repository == 'bl-sdk/pluginloader'
&& inputs.new-release-tag != ''
needs:
- build-ubuntu
- build-windows
- clang-tidy
- clang-format
- spelling

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ~/releases

- name: Zip artifacts
shell: bash
run: |
cd ~/releases
for folder in */ ; do
cd "$folder"
zip -r "${folder%/}.zip" .
cd ..
done
- name: Create new release tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ inputs.new-release-tag }}

- name: Upload releases
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.new-release-tag }}
files: "/home/runner/releases/*/*.zip"
fail_on_unmatched_files: true
draft: true
generate_release_notes: true
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.24)

project(pluginloader VERSION 1.0.2)
project(pluginloader VERSION 1.0.3)

add_library(_pluginloader_base INTERFACE)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
Expand Down Expand Up @@ -58,12 +58,14 @@ endfunction()

pluginloader_add_impl(no_proxy "src/proxy/none.cpp")
pluginloader_add_impl(d3d11 "src/proxy/d3d11.cpp")
pluginloader_add_impl(dsound "src/proxy/dsound.cpp")
pluginloader_add_impl(xinput1_3 "src/proxy/xinput1_3.cpp" "src/proxy/xinput1_3.def")

install(
TARGETS
pluginloader_no_proxy
pluginloader_d3d11
pluginloader_dsound
pluginloader_xinput1_3
RUNTIME DESTINATION .
)
41 changes: 31 additions & 10 deletions src/proxy/d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ HMODULE dx11_dll_handle = nullptr;
FARPROC d3d11_core_create_device_ptr = nullptr;
FARPROC d3d11_create_device_ptr = nullptr;
FARPROC d3d11_create_device_and_swap_chain_ptr = nullptr;
FARPROC d3d11_on_12_create_device_ptr = nullptr;

} // namespace

Expand All @@ -25,21 +26,21 @@ FARPROC d3d11_create_device_and_swap_chain_ptr = nullptr;

DLL_EXPORT HRESULT D3D11CoreCreateDevice(void* fact,
void* adapt,
unsigned int flag,
UINT flag,
void* fl,
unsigned int featureLevels,
UINT featureLevels,
void** ppDev) {
return reinterpret_cast<decltype(&D3D11CoreCreateDevice)>(d3d11_core_create_device_ptr)(
fact, adapt, flag, fl, featureLevels, ppDev);
}

DLL_EXPORT HRESULT D3D11CreateDevice(void* adapt,
unsigned int dt,
UINT dt,
void* soft,
unsigned int flags,
UINT flags,
int* ft,
unsigned int fl,
unsigned int ver,
UINT fl,
UINT ver,
void** ppDevice,
void* featureLevel,
void** context) {
Expand All @@ -48,12 +49,12 @@ DLL_EXPORT HRESULT D3D11CreateDevice(void* adapt,
}

DLL_EXPORT HRESULT D3D11CreateDeviceAndSwapChain(void* adapt,
unsigned int dt,
UINT dt,
void* soft,
unsigned int flags,
UINT flags,
int* ft,
unsigned int fl,
unsigned int ver,
UINT fl,
UINT ver,
void* swapChainDesc,
void** swapChain,
void** ppDevice,
Expand All @@ -64,6 +65,21 @@ DLL_EXPORT HRESULT D3D11CreateDeviceAndSwapChain(void* adapt,
swapChain, ppDevice, featureLevel, context);
}

DLL_EXPORT HRESULT D3D11On12CreateDevice(void* pDevice,
UINT Flags,
void* pFeatureLevels,
UINT FeatureLevels,
void** ppCommandQueues,
UINT NumQueues,
UINT NodeMask,
void** ppDevice,
void** ppImmediateContext,
void* pChosenFeatureLevel) {
return reinterpret_cast<decltype(&D3D11On12CreateDevice)>(d3d11_on_12_create_device_ptr)(
pDevice, Flags, pFeatureLevels, FeatureLevels, ppCommandQueues, NumQueues, NodeMask,
ppDevice, ppImmediateContext, pChosenFeatureLevel);
}

#if defined(__MINGW32__)
#pragma GCC diagnostic pop
#endif
Expand All @@ -82,11 +98,16 @@ void init(HMODULE /*this_dll*/) {

auto system_dx11 = std::filesystem::path{static_cast<wchar_t*>(buf)} / "d3d11.dll";
dx11_dll_handle = LoadLibraryA(system_dx11.generic_string().c_str());
if (dx11_dll_handle == nullptr) {
std::cerr << "Unable to find system d3d11.dll! We're probably about to crash.\n";
return;
}

d3d11_core_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11CoreCreateDevice");
d3d11_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11CreateDevice");
d3d11_create_device_and_swap_chain_ptr =
GetProcAddress(dx11_dll_handle, "D3D11CreateDeviceAndSwapChain");
d3d11_on_12_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11On12CreateDevice");
}

void free(void) {
Expand Down
Loading

0 comments on commit 5876353

Please sign in to comment.