Skip to content

Commit 5876353

Browse files
authored
Merge pull request #5 from apple1417/master
add dsound.dll proxy, fill in extra exports
2 parents 6370285 + a8f9b4c commit 5876353

File tree

6 files changed

+297
-31
lines changed

6 files changed

+297
-31
lines changed

.github/workflows/build.yml

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: CI
22

3-
on: [
4-
push,
5-
pull_request,
6-
workflow_dispatch
7-
]
3+
on:
4+
push: {}
5+
pull_request: {}
6+
workflow_dispatch:
7+
inputs:
8+
new-release-tag:
9+
description: >
10+
New Release Tag. If given, creates a (draft) full release using the given tag.
11+
type: string
12+
required: false
813

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

2429
steps:
2530
- name: Cache Clang
26-
uses: actions/cache@v3
31+
uses: actions/cache@v4
2732
id: cache-clang
2833
with:
2934
path: C:\Program Files\LLVM
@@ -55,23 +60,23 @@ jobs:
5560
steps:
5661
- name: Restore Clang Cache
5762
if: startswith(matrix.preset, 'clang')
58-
uses: actions/cache/restore@v3
63+
uses: actions/cache/restore@v4
5964
with:
6065
path: C:\Program Files\LLVM
6166
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
6267
fail-on-cache-miss: true
6368

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

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

7378
- name: Checkout repository and submodules
74-
uses: actions/checkout@v3
79+
uses: actions/checkout@v4
7580
with:
7681
submodules: recursive
7782

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

8691
- name: Upload artifact
87-
uses: actions/upload-artifact@v3
92+
uses: actions/upload-artifact@v4
8893
with:
8994
name: ${{ matrix.preset }}
9095
path: out/install/${{ matrix.preset }}/
@@ -150,7 +155,7 @@ jobs:
150155
# xwin does take long enough that caching's worth it
151156
- name: Restore xwin cache
152157
if: contains(matrix.preset, 'cross')
153-
uses: actions/cache@v3
158+
uses: actions/cache@v4
154159
id: cache-xwin
155160
with:
156161
path: ~/xwin
@@ -169,7 +174,7 @@ jobs:
169174
--output ~/xwin
170175
171176
- name: Checkout repository and submodules
172-
uses: actions/checkout@v3
177+
uses: actions/checkout@v4
173178
with:
174179
submodules: recursive
175180

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

189194
- name: Upload artifact
190-
uses: actions/upload-artifact@v3
195+
uses: actions/upload-artifact@v4
191196
with:
192197
name: ${{ matrix.preset }}
193198
path: out/install/${{ matrix.preset }}/
@@ -208,7 +213,7 @@ jobs:
208213

209214
steps:
210215
- name: Restore Clang Cache
211-
uses: actions/cache/restore@v3
216+
uses: actions/cache/restore@v4
212217
with:
213218
path: C:\Program Files\LLVM
214219
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
@@ -222,7 +227,7 @@ jobs:
222227
run: pip install pyyaml
223228

224229
- name: Checkout repository and submodules
225-
uses: actions/checkout@v3
230+
uses: actions/checkout@v4
226231
with:
227232
submodules: recursive
228233

@@ -257,14 +262,14 @@ jobs:
257262

258263
steps:
259264
- name: Restore Clang Cache
260-
uses: actions/cache/restore@v3
265+
uses: actions/cache/restore@v4
261266
with:
262267
path: C:\Program Files\LLVM
263268
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
264269
fail-on-cache-miss: true
265270

266271
- name: Checkout repository
267-
uses: actions/checkout@v3
272+
uses: actions/checkout@v4
268273

269274
- name: Run clang-format
270275
run: |
@@ -282,7 +287,59 @@ jobs:
282287

283288
steps:
284289
- name: Checkout repository
285-
uses: actions/checkout@v3
290+
uses: actions/checkout@v4
286291

287292
- name: Check spelling
288293
uses: crate-ci/typos@master
294+
295+
# ==============================================================================
296+
297+
release-draft-full:
298+
runs-on: ubuntu-latest
299+
if: >
300+
github.ref == 'refs/heads/master'
301+
&& github.repository == 'bl-sdk/pluginloader'
302+
&& inputs.new-release-tag != ''
303+
304+
needs:
305+
- build-ubuntu
306+
- build-windows
307+
- clang-tidy
308+
- clang-format
309+
- spelling
310+
311+
permissions:
312+
contents: write
313+
314+
steps:
315+
- name: Checkout repository
316+
uses: actions/checkout@v4
317+
318+
- name: Download artifacts
319+
uses: actions/download-artifact@v4
320+
with:
321+
path: ~/releases
322+
323+
- name: Zip artifacts
324+
shell: bash
325+
run: |
326+
cd ~/releases
327+
for folder in */ ; do
328+
cd "$folder"
329+
zip -r "${folder%/}.zip" .
330+
cd ..
331+
done
332+
333+
- name: Create new release tag
334+
uses: rickstaa/action-create-tag@v1
335+
with:
336+
tag: ${{ inputs.new-release-tag }}
337+
338+
- name: Upload releases
339+
uses: softprops/action-gh-release@v1
340+
with:
341+
tag_name: ${{ inputs.new-release-tag }}
342+
files: "/home/runner/releases/*/*.zip"
343+
fail_on_unmatched_files: true
344+
draft: true
345+
generate_release_notes: true

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.24)
22

3-
project(pluginloader VERSION 1.0.2)
3+
project(pluginloader VERSION 1.0.3)
44

55
add_library(_pluginloader_base INTERFACE)
66
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
@@ -58,12 +58,14 @@ endfunction()
5858

5959
pluginloader_add_impl(no_proxy "src/proxy/none.cpp")
6060
pluginloader_add_impl(d3d11 "src/proxy/d3d11.cpp")
61+
pluginloader_add_impl(dsound "src/proxy/dsound.cpp")
6162
pluginloader_add_impl(xinput1_3 "src/proxy/xinput1_3.cpp" "src/proxy/xinput1_3.def")
6263

6364
install(
6465
TARGETS
6566
pluginloader_no_proxy
6667
pluginloader_d3d11
68+
pluginloader_dsound
6769
pluginloader_xinput1_3
6870
RUNTIME DESTINATION .
6971
)

src/proxy/d3d11.cpp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ HMODULE dx11_dll_handle = nullptr;
1313
FARPROC d3d11_core_create_device_ptr = nullptr;
1414
FARPROC d3d11_create_device_ptr = nullptr;
1515
FARPROC d3d11_create_device_and_swap_chain_ptr = nullptr;
16+
FARPROC d3d11_on_12_create_device_ptr = nullptr;
1617

1718
} // namespace
1819

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

2627
DLL_EXPORT HRESULT D3D11CoreCreateDevice(void* fact,
2728
void* adapt,
28-
unsigned int flag,
29+
UINT flag,
2930
void* fl,
30-
unsigned int featureLevels,
31+
UINT featureLevels,
3132
void** ppDev) {
3233
return reinterpret_cast<decltype(&D3D11CoreCreateDevice)>(d3d11_core_create_device_ptr)(
3334
fact, adapt, flag, fl, featureLevels, ppDev);
3435
}
3536

3637
DLL_EXPORT HRESULT D3D11CreateDevice(void* adapt,
37-
unsigned int dt,
38+
UINT dt,
3839
void* soft,
39-
unsigned int flags,
40+
UINT flags,
4041
int* ft,
41-
unsigned int fl,
42-
unsigned int ver,
42+
UINT fl,
43+
UINT ver,
4344
void** ppDevice,
4445
void* featureLevel,
4546
void** context) {
@@ -48,12 +49,12 @@ DLL_EXPORT HRESULT D3D11CreateDevice(void* adapt,
4849
}
4950

5051
DLL_EXPORT HRESULT D3D11CreateDeviceAndSwapChain(void* adapt,
51-
unsigned int dt,
52+
UINT dt,
5253
void* soft,
53-
unsigned int flags,
54+
UINT flags,
5455
int* ft,
55-
unsigned int fl,
56-
unsigned int ver,
56+
UINT fl,
57+
UINT ver,
5758
void* swapChainDesc,
5859
void** swapChain,
5960
void** ppDevice,
@@ -64,6 +65,21 @@ DLL_EXPORT HRESULT D3D11CreateDeviceAndSwapChain(void* adapt,
6465
swapChain, ppDevice, featureLevel, context);
6566
}
6667

68+
DLL_EXPORT HRESULT D3D11On12CreateDevice(void* pDevice,
69+
UINT Flags,
70+
void* pFeatureLevels,
71+
UINT FeatureLevels,
72+
void** ppCommandQueues,
73+
UINT NumQueues,
74+
UINT NodeMask,
75+
void** ppDevice,
76+
void** ppImmediateContext,
77+
void* pChosenFeatureLevel) {
78+
return reinterpret_cast<decltype(&D3D11On12CreateDevice)>(d3d11_on_12_create_device_ptr)(
79+
pDevice, Flags, pFeatureLevels, FeatureLevels, ppCommandQueues, NumQueues, NodeMask,
80+
ppDevice, ppImmediateContext, pChosenFeatureLevel);
81+
}
82+
6783
#if defined(__MINGW32__)
6884
#pragma GCC diagnostic pop
6985
#endif
@@ -82,11 +98,16 @@ void init(HMODULE /*this_dll*/) {
8298

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

86106
d3d11_core_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11CoreCreateDevice");
87107
d3d11_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11CreateDevice");
88108
d3d11_create_device_and_swap_chain_ptr =
89109
GetProcAddress(dx11_dll_handle, "D3D11CreateDeviceAndSwapChain");
110+
d3d11_on_12_create_device_ptr = GetProcAddress(dx11_dll_handle, "D3D11On12CreateDevice");
90111
}
91112

92113
void free(void) {

0 commit comments

Comments
 (0)