Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround Win32 loader lock #22

Closed
wants to merge 3 commits into from
Closed
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
459 changes: 336 additions & 123 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
resolver = "2"
members = ["loader"]

[patch.crates-io]
proxygen-macros = { path = "proxygen-macros" }
2 changes: 2 additions & 0 deletions loader/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "x86_64-pc-windows-msvc"
25 changes: 20 additions & 5 deletions loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@
name = "loader"
version = "0.1.0"
edition = "2021"
# build = "build.rs"

[lib]
crate-type = ["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.89"
proxygen-macros = "0.5.1"
libc = "0.2.149"
winapi = { version = "0.3.9", features = [
"minwindef",
"libloaderapi",
"processthreadsapi",
"consoleapi",
"processenv",
"winbase",
"winuser",
"errhandlingapi",
] }
thiserror = "1.0.64"
isahc = "1.7.2"
netcorehost = "0.17.0"
proxy-dll = "0.2.5"
thiserror = "1.0.64"
anyhow = "1.0.89"
win-msgbox = "0.2.1"

[lib]
name = "winmm"
crate-type = ["cdylib"]
2 changes: 2 additions & 0 deletions loader/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
185 changes: 185 additions & 0 deletions loader/src/export_indices.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// After making changes in this file, you should run `proxygen update .`` in the root of this project to update exports

#![allow(non_upper_case_globals)]

pub const TOTAL_EXPORTS: usize = 180;
pub const Index_CloseDriver: usize = 0;
pub const Index_DefDriverProc: usize = 1;
pub const Index_DriverCallback: usize = 2;
pub const Index_DrvGetModuleHandle: usize = 3;
pub const Index_GetDriverModuleHandle: usize = 4;
pub const Index_OpenDriver: usize = 5;
pub const Index_PlaySound: usize = 6;
pub const Index_PlaySoundA: usize = 7;
pub const Index_PlaySoundW: usize = 8;
pub const Index_SendDriverMessage: usize = 9;
pub const Index_WOWAppExit: usize = 10;
pub const Index_auxGetDevCapsA: usize = 11;
pub const Index_auxGetDevCapsW: usize = 12;
pub const Index_auxGetNumDevs: usize = 13;
pub const Index_auxGetVolume: usize = 14;
pub const Index_auxOutMessage: usize = 15;
pub const Index_auxSetVolume: usize = 16;
pub const Index_joyConfigChanged: usize = 17;
pub const Index_joyGetDevCapsA: usize = 18;
pub const Index_joyGetDevCapsW: usize = 19;
pub const Index_joyGetNumDevs: usize = 20;
pub const Index_joyGetPos: usize = 21;
pub const Index_joyGetPosEx: usize = 22;
pub const Index_joyGetThreshold: usize = 23;
pub const Index_joyReleaseCapture: usize = 24;
pub const Index_joySetCapture: usize = 25;
pub const Index_joySetThreshold: usize = 26;
pub const Index_mciDriverNotify: usize = 27;
pub const Index_mciDriverYield: usize = 28;
pub const Index_mciExecute: usize = 29;
pub const Index_mciFreeCommandResource: usize = 30;
pub const Index_mciGetCreatorTask: usize = 31;
pub const Index_mciGetDeviceIDA: usize = 32;
pub const Index_mciGetDeviceIDFromElementIDA: usize = 33;
pub const Index_mciGetDeviceIDFromElementIDW: usize = 34;
pub const Index_mciGetDeviceIDW: usize = 35;
pub const Index_mciGetDriverData: usize = 36;
pub const Index_mciGetErrorStringA: usize = 37;
pub const Index_mciGetErrorStringW: usize = 38;
pub const Index_mciGetYieldProc: usize = 39;
pub const Index_mciLoadCommandResource: usize = 40;
pub const Index_mciSendCommandA: usize = 41;
pub const Index_mciSendCommandW: usize = 42;
pub const Index_mciSendStringA: usize = 43;
pub const Index_mciSendStringW: usize = 44;
pub const Index_mciSetDriverData: usize = 45;
pub const Index_mciSetYieldProc: usize = 46;
pub const Index_midiConnect: usize = 47;
pub const Index_midiDisconnect: usize = 48;
pub const Index_midiInAddBuffer: usize = 49;
pub const Index_midiInClose: usize = 50;
pub const Index_midiInGetDevCapsA: usize = 51;
pub const Index_midiInGetDevCapsW: usize = 52;
pub const Index_midiInGetErrorTextA: usize = 53;
pub const Index_midiInGetErrorTextW: usize = 54;
pub const Index_midiInGetID: usize = 55;
pub const Index_midiInGetNumDevs: usize = 56;
pub const Index_midiInMessage: usize = 57;
pub const Index_midiInOpen: usize = 58;
pub const Index_midiInPrepareHeader: usize = 59;
pub const Index_midiInReset: usize = 60;
pub const Index_midiInStart: usize = 61;
pub const Index_midiInStop: usize = 62;
pub const Index_midiInUnprepareHeader: usize = 63;
pub const Index_midiOutCacheDrumPatches: usize = 64;
pub const Index_midiOutCachePatches: usize = 65;
pub const Index_midiOutClose: usize = 66;
pub const Index_midiOutGetDevCapsA: usize = 67;
pub const Index_midiOutGetDevCapsW: usize = 68;
pub const Index_midiOutGetErrorTextA: usize = 69;
pub const Index_midiOutGetErrorTextW: usize = 70;
pub const Index_midiOutGetID: usize = 71;
pub const Index_midiOutGetNumDevs: usize = 72;
pub const Index_midiOutGetVolume: usize = 73;
pub const Index_midiOutLongMsg: usize = 74;
pub const Index_midiOutMessage: usize = 75;
pub const Index_midiOutOpen: usize = 76;
pub const Index_midiOutPrepareHeader: usize = 77;
pub const Index_midiOutReset: usize = 78;
pub const Index_midiOutSetVolume: usize = 79;
pub const Index_midiOutShortMsg: usize = 80;
pub const Index_midiOutUnprepareHeader: usize = 81;
pub const Index_midiStreamClose: usize = 82;
pub const Index_midiStreamOpen: usize = 83;
pub const Index_midiStreamOut: usize = 84;
pub const Index_midiStreamPause: usize = 85;
pub const Index_midiStreamPosition: usize = 86;
pub const Index_midiStreamProperty: usize = 87;
pub const Index_midiStreamRestart: usize = 88;
pub const Index_midiStreamStop: usize = 89;
pub const Index_mixerClose: usize = 90;
pub const Index_mixerGetControlDetailsA: usize = 91;
pub const Index_mixerGetControlDetailsW: usize = 92;
pub const Index_mixerGetDevCapsA: usize = 93;
pub const Index_mixerGetDevCapsW: usize = 94;
pub const Index_mixerGetID: usize = 95;
pub const Index_mixerGetLineControlsA: usize = 96;
pub const Index_mixerGetLineControlsW: usize = 97;
pub const Index_mixerGetLineInfoA: usize = 98;
pub const Index_mixerGetLineInfoW: usize = 99;
pub const Index_mixerGetNumDevs: usize = 100;
pub const Index_mixerMessage: usize = 101;
pub const Index_mixerOpen: usize = 102;
pub const Index_mixerSetControlDetails: usize = 103;
pub const Index_mmDrvInstall: usize = 104;
pub const Index_mmGetCurrentTask: usize = 105;
pub const Index_mmTaskBlock: usize = 106;
pub const Index_mmTaskCreate: usize = 107;
pub const Index_mmTaskSignal: usize = 108;
pub const Index_mmTaskYield: usize = 109;
pub const Index_mmioAdvance: usize = 110;
pub const Index_mmioAscend: usize = 111;
pub const Index_mmioClose: usize = 112;
pub const Index_mmioCreateChunk: usize = 113;
pub const Index_mmioDescend: usize = 114;
pub const Index_mmioFlush: usize = 115;
pub const Index_mmioGetInfo: usize = 116;
pub const Index_mmioInstallIOProcA: usize = 117;
pub const Index_mmioInstallIOProcW: usize = 118;
pub const Index_mmioOpenA: usize = 119;
pub const Index_mmioOpenW: usize = 120;
pub const Index_mmioRead: usize = 121;
pub const Index_mmioRenameA: usize = 122;
pub const Index_mmioRenameW: usize = 123;
pub const Index_mmioSeek: usize = 124;
pub const Index_mmioSendMessage: usize = 125;
pub const Index_mmioSetBuffer: usize = 126;
pub const Index_mmioSetInfo: usize = 127;
pub const Index_mmioStringToFOURCCA: usize = 128;
pub const Index_mmioStringToFOURCCW: usize = 129;
pub const Index_mmioWrite: usize = 130;
pub const Index_mmsystemGetVersion: usize = 131;
pub const Index_sndPlaySoundA: usize = 132;
pub const Index_sndPlaySoundW: usize = 133;
pub const Index_timeBeginPeriod: usize = 134;
pub const Index_timeEndPeriod: usize = 135;
pub const Index_timeGetDevCaps: usize = 136;
pub const Index_timeGetSystemTime: usize = 137;
pub const Index_timeGetTime: usize = 138;
pub const Index_timeKillEvent: usize = 139;
pub const Index_timeSetEvent: usize = 140;
pub const Index_waveInAddBuffer: usize = 141;
pub const Index_waveInClose: usize = 142;
pub const Index_waveInGetDevCapsA: usize = 143;
pub const Index_waveInGetDevCapsW: usize = 144;
pub const Index_waveInGetErrorTextA: usize = 145;
pub const Index_waveInGetErrorTextW: usize = 146;
pub const Index_waveInGetID: usize = 147;
pub const Index_waveInGetNumDevs: usize = 148;
pub const Index_waveInGetPosition: usize = 149;
pub const Index_waveInMessage: usize = 150;
pub const Index_waveInOpen: usize = 151;
pub const Index_waveInPrepareHeader: usize = 152;
pub const Index_waveInReset: usize = 153;
pub const Index_waveInStart: usize = 154;
pub const Index_waveInStop: usize = 155;
pub const Index_waveInUnprepareHeader: usize = 156;
pub const Index_waveOutBreakLoop: usize = 157;
pub const Index_waveOutClose: usize = 158;
pub const Index_waveOutGetDevCapsA: usize = 159;
pub const Index_waveOutGetDevCapsW: usize = 160;
pub const Index_waveOutGetErrorTextA: usize = 161;
pub const Index_waveOutGetErrorTextW: usize = 162;
pub const Index_waveOutGetID: usize = 163;
pub const Index_waveOutGetNumDevs: usize = 164;
pub const Index_waveOutGetPitch: usize = 165;
pub const Index_waveOutGetPlaybackRate: usize = 166;
pub const Index_waveOutGetPosition: usize = 167;
pub const Index_waveOutGetVolume: usize = 168;
pub const Index_waveOutMessage: usize = 169;
pub const Index_waveOutOpen: usize = 170;
pub const Index_waveOutPause: usize = 171;
pub const Index_waveOutPrepareHeader: usize = 172;
pub const Index_waveOutReset: usize = 173;
pub const Index_waveOutRestart: usize = 174;
pub const Index_waveOutSetPitch: usize = 175;
pub const Index_waveOutSetPlaybackRate: usize = 176;
pub const Index_waveOutSetVolume: usize = 177;
pub const Index_waveOutUnprepareHeader: usize = 178;
pub const Index_waveOutWrite: usize = 179;
16 changes: 16 additions & 0 deletions loader/src/intercepted_exports.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[allow(unused_imports)]
use proxygen_macros::{forward, post_hook, pre_hook, proxy};

use crate::start;

static mut STARTED: bool = false;

#[pre_hook(sig = "unknown")]
#[export_name = "timeBeginPeriod"]
pub extern "C" fn timeBeginPeriod() {
if STARTED {
return;
}
STARTED = true;
start();
}
Loading
Loading