Skip to content

Commit 18a726e

Browse files
authored
Merge pull request #602 from LavaGang/alpha-development
MelonLoader v0.6.2
2 parents b2de0ed + ca74c51 commit 18a726e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3085
-1218
lines changed

.github/workflows/build.yml

Lines changed: 77 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -8,148 +8,134 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
build_core_debug:
11+
build_melonloader:
1212
runs-on: windows-latest
1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: setup-msbuild
15+
- name: Setup MsBuild
1616
uses: microsoft/setup-msbuild@v1
17-
- name: Build Melonloader Core
18-
shell: cmd
19-
run: msbuild /restore /p:Platform="Windows - x64" # Platform is actually irrelevant for core, it's compiled as AnyCPU either way
20-
- name: Upload core artifact
21-
uses: actions/upload-artifact@v3
22-
with:
23-
name: MLCoreDebug
24-
path: Output/Debug/MelonLoader/
25-
build_core_release:
26-
runs-on: windows-latest
27-
steps:
28-
- uses: actions/checkout@v3
29-
- name: setup-msbuild
30-
uses: microsoft/setup-msbuild@v1
31-
- name: Build Melonloader Core
17+
- name: Build Melonloader (Release)
3218
shell: cmd
3319
run: msbuild /restore /p:Configuration=Release /p:Platform="Windows - x64"
34-
- name: Upload core artifact
20+
- name: Build MelonLoader (Debug)
21+
shell: cmd
22+
run: msbuild /restore /p:Platform="Windows - x64"
23+
- name: Upload Release Artifact
3524
uses: actions/upload-artifact@v3
3625
with:
3726
name: MLCoreRelease
3827
path: Output/Release/MelonLoader/
39-
build_rust_windows:
40-
runs-on: windows-latest
28+
- name: Upload Debug Artifact
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: MLCoreDebug
32+
path: Output/Debug/MelonLoader/
33+
build_rust:
34+
runs-on: ubuntu-latest
4135
steps:
4236
- uses: actions/checkout@v3
43-
- name: rust-toolchain
44-
uses: dtolnay/rust-toolchain@stable
45-
with:
46-
toolchain: nightly
47-
# Target triple to install for this toolchain
48-
targets: i686-pc-windows-msvc, x86_64-pc-windows-msvc
49-
# Build Rust Release
50-
- name: Build Rust Release | Windows - x86
51-
shell: cmd
52-
run: cargo +nightly build --target i686-pc-windows-msvc --release
37+
- name: Install Rust (nightly)
38+
run:
39+
curl https://sh.rustup.rs -sSf | sh -s -- -y
40+
- name: Make Rust Nightly
41+
shell: bash
42+
run: rustup default nightly
43+
- name: Install Linux target x64
44+
shell: bash
45+
run: rustup target add x86_64-unknown-linux-gnu
46+
- name: Install Windows target x64
47+
shell: bash
48+
run: rustup target add x86_64-pc-windows-msvc
49+
- name: Install Windows target x86
50+
shell: bash
51+
run: rustup target add i686-pc-windows-msvc
52+
- name: Install x-win
53+
shell: bash
54+
run: cargo install cargo-xwin
55+
- name: install dev dependencies
56+
shell: bash
57+
run: sudo apt-get install libgtk-3-dev wine llvm
58+
- name: Build Rust Release | Linux - x64
59+
shell: bash
60+
run: cargo build --target x86_64-unknown-linux-gnu --release
61+
- name: Build Rust Debug | Linux - x64
62+
shell: bash
63+
run: cargo build --target x86_64-unknown-linux-gnu
5364
- name: Build Rust Release | Windows - x64
54-
shell: cmd
55-
run: cargo +nightly build --target x86_64-pc-windows-msvc --release
56-
# Build Rust Debug
57-
- name: Build Rust Debug | Windows - x86
58-
shell: cmd
59-
run: cargo +nightly build --target i686-pc-windows-msvc
65+
shell: bash
66+
run: cargo xwin build --target x86_64-pc-windows-msvc --release
6067
- name: Build Rust Debug | Windows - x64
61-
shell: cmd
62-
run: cargo +nightly build --target x86_64-pc-windows-msvc
63-
# Upload Proxy Release - x86
68+
shell: bash
69+
run: cargo xwin build --target x86_64-pc-windows-msvc
70+
- name: Build Rust Release | Windows - x86
71+
shell: bash
72+
run: XWIN_ARCH=x86 cargo xwin build --target i686-pc-windows-msvc --release
73+
- name: Build Rust Debug | Windows - x86
74+
shell: bash
75+
run: XWIN_ARCH=x86 cargo xwin build --target i686-pc-windows-msvc
76+
- name: Upload Proxy Release | Linux x64
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: MLProxyX64-Linux-Release
80+
path: target/x86_64-unknown-linux-gnu/release/libversion.so
81+
- name: Upload Bootstrap Release | Linux x64
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: MLBootstrapX64-Linux-Release
85+
path: target/x86_64-unknown-linux-gnu/release/libBootstrap.so
86+
- name: Upload Proxy Debug | Linux x64
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: MLProxyX64-Linux-Debug
90+
path: target/x86_64-unknown-linux-gnu/debug/libversion.so
91+
- name: Upload Bootstrap Debug | Linux x64
92+
uses: actions/upload-artifact@v3
93+
with:
94+
name: MLBootstrapX64-Linux-Debug
95+
path: target/x86_64-unknown-linux-gnu/debug/libBootstrap.so
6496
- name: Upload Proxy Release | Windows x86
6597
uses: actions/upload-artifact@v3
6698
with:
6799
name: MLProxyX86-Windows-Release
68100
path: target/i686-pc-windows-msvc/release/version.dll
69-
# Upload Bootstrap Release - x86
70101
- name: Upload Bootstrap Release | Windows x86
71102
uses: actions/upload-artifact@v3
72103
with:
73104
name: MLBootstrapX86-Windows-Release
74105
path: target/i686-pc-windows-msvc/release/Bootstrap.dll
75-
# Upload Proxy Release - x64
76106
- name: Upload Proxy Release | Windows x64
77107
uses: actions/upload-artifact@v3
78108
with:
79109
name: MLProxyX64-Windows-Release
80110
path: target/x86_64-pc-windows-msvc/release/version.dll
81-
# Upload Bootstrap Release - x64
82111
- name: Upload Bootstrap Release | Windows x64
83112
uses: actions/upload-artifact@v3
84113
with:
85114
name: MLBootstrapX64-Windows-Release
86115
path: target/x86_64-pc-windows-msvc/release/Bootstrap.dll
87-
# Upload Proxy Debug - x86
88116
- name: Upload Proxy Debug | Windows x86
89117
uses: actions/upload-artifact@v3
90118
with:
91119
name: MLProxyX86-Windows-Debug
92120
path: target/i686-pc-windows-msvc/debug/version.dll
93-
# Upload Bootstrap Debug - x86
94121
- name: Upload Bootstrap Debug | Windows x86
95122
uses: actions/upload-artifact@v3
96123
with:
97124
name: MLBootstrapX86-Windows-Debug
98125
path: target/i686-pc-windows-msvc/debug/Bootstrap.dll
99-
# Upload Proxy Debug - x64
100126
- name: Upload Proxy Debug | Windows x64
101127
uses: actions/upload-artifact@v3
102128
with:
103129
name: MLProxyX64-Windows-Debug
104130
path: target/x86_64-pc-windows-msvc/debug/version.dll
105-
# Upload Bootstrap Debug - x64
106131
- name: Upload Bootstrap Debug | Windows x64
107132
uses: actions/upload-artifact@v3
108133
with:
109134
name: MLBootstrapX64-Windows-Debug
110135
path: target/x86_64-pc-windows-msvc/debug/Bootstrap.dll
111-
build_rust_linux:
112-
runs-on: ubuntu-latest
113-
steps:
114-
- uses: actions/checkout@v3
115-
- name: rust-toolchain
116-
uses: dtolnay/rust-toolchain@stable
117-
with:
118-
toolchain: nightly
119-
# Target triple to install for this toolchain
120-
targets: x86_64-unknown-linux-gnu
121-
- name: install dev dependencies
122-
shell: bash
123-
run: sudo apt-get install libgtk-3-dev
124-
- name: Build Rust Release | Linux - x64
125-
shell: bash
126-
run: cargo +nightly build --target x86_64-unknown-linux-gnu --release
127-
- name: Build Rust Debug | Linux - x64
128-
shell: bash
129-
run: cargo +nightly build --target x86_64-unknown-linux-gnu
130-
- name: Upload Proxy Release | Linux x64
131-
uses: actions/upload-artifact@v3
132-
with:
133-
name: MLProxyX64-Linux-Release
134-
path: target/x86_64-unknown-linux-gnu/release/libversion.so
135-
- name: Upload Bootstrap Release | Linux x64
136-
uses: actions/upload-artifact@v3
137-
with:
138-
name: MLBootstrapX64-Linux-Release
139-
path: target/x86_64-unknown-linux-gnu/release/libBootstrap.so
140-
- name: Upload Proxy Debug | Linux x64
141-
uses: actions/upload-artifact@v3
142-
with:
143-
name: MLProxyX64-Linux-Debug
144-
path: target/x86_64-unknown-linux-gnu/debug/libversion.so
145-
- name: Upload Bootstrap Debug | Linux x64
146-
uses: actions/upload-artifact@v3
147-
with:
148-
name: MLBootstrapX64-Linux-Debug
149-
path: target/x86_64-unknown-linux-gnu/debug/libBootstrap.so
150136
finalize_x64_debug_zip_windows:
151137
runs-on: windows-latest
152-
needs: [build_core_debug, build_rust_windows]
138+
needs: [build_rust, build_melonloader]
153139
steps:
154140
- uses: actions/checkout@v3
155141
- name: Download core artifact
@@ -191,7 +177,7 @@ jobs:
191177
path: ./Output/Debug/x64/*
192178
finalize_x86_debug_zip_windows:
193179
runs-on: windows-latest
194-
needs: [build_core_debug, build_rust_windows]
180+
needs: [build_rust, build_melonloader]
195181
steps:
196182
- uses: actions/checkout@v3
197183
- name: Download core artifact
@@ -233,7 +219,7 @@ jobs:
233219
path: ./Output/Debug/x86/*
234220
finalize_x64_release_zip_windows:
235221
runs-on: windows-latest
236-
needs: [build_core_release, build_rust_windows]
222+
needs: [build_rust, build_melonloader]
237223
steps:
238224
- uses: actions/checkout@v3
239225
- name: Download core artifact
@@ -275,7 +261,7 @@ jobs:
275261
path: ./Output/Release/x64/*
276262
finalize_x86_release_zip_windows:
277263
runs-on: windows-latest
278-
needs: [build_core_release, build_rust_windows]
264+
needs: [build_rust, build_melonloader]
279265
steps:
280266
- uses: actions/checkout@v3
281267
- name: Download core artifact
@@ -317,7 +303,7 @@ jobs:
317303
path: ./Output/Release/x86/*
318304
finalize_x64_debug_zip_linux:
319305
runs-on: windows-latest
320-
needs: [build_core_debug, build_rust_linux]
306+
needs: [build_rust, build_melonloader]
321307
steps:
322308
- uses: actions/checkout@v3
323309
- name: Download core artifact
@@ -356,7 +342,7 @@ jobs:
356342
path: ./Output/Debug/x64/*
357343
finalize_x64_release_zip_linux:
358344
runs-on: windows-latest
359-
needs: [build_core_release, build_rust_linux]
345+
needs: [build_rust, build_melonloader]
360346
steps:
361347
- uses: actions/checkout@v3
362348
- name: Download core artifact
Binary file not shown.

Bootstrap/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
[dependencies]
99
#unity-rs = { path = "C:/Users/sarah/Documents/rust/Ferrex/unity/" }
1010
unity-rs = { git = "https://github.com/RinLovesYou/Ferrex/", rev = "77d114c" }
11-
ctor = "0.1.26"
11+
ctor = "0.2.6"
1212
chrono = "0.4.23"
1313
colored = "2.0.0"
1414
thiserror = "1.0.39"
@@ -18,10 +18,11 @@ clap = { git = "https://github.com/RinLovesYou/clap", features = ["derive"] }
1818
libc = "0.2.140"
1919
dobby-rs = { git = "https://github.com/RinLovesYou/dobby-rs" }
2020
libc-stdhandle = "0.1.0"
21-
netcorehost = "0.13.1"
21+
netcorehost = "0.15.1"
22+
exe = "0.5.6"
2223

2324
[target.'cfg(windows)'.dependencies]
24-
windows = { version = "0.46.0", features = [
25+
windows = { version = "0.52.0", features = [
2526
"Win32_Foundation",
2627
"Win32_System_Console",
2728
"Win32_UI_WindowsAndMessaging"

Bootstrap/src/base_assembly/mono.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
use std::{ptr::null_mut, sync::Mutex};
1+
use std::{ptr::null_mut, sync::{RwLock, Mutex}};
22

33
use lazy_static::lazy_static;
44
use unity_rs::{
55
common::{assembly::UnityAssembly, method::UnityMethod},
66
runtime::FerrexRuntime,
77
};
88

9-
use crate::{debug, errors::DynErr, melonenv, runtime};
9+
use crate::{debug, errors::DynErr, melonenv::{self, paths}, runtime};
1010

1111
lazy_static! {
1212
pub static ref MONO_PRESTART: Mutex<UnityMethod> =
1313
Mutex::new(UnityMethod { inner: null_mut() });
1414
pub static ref MONO_START: Mutex<UnityMethod> = Mutex::new(UnityMethod { inner: null_mut() });
15-
pub static ref ASSEMBLYMANAGER_RESOLVE: Mutex<UnityMethod> =
16-
Mutex::new(UnityMethod { inner: null_mut() });
17-
pub static ref ASSEMBLYMANAGER_LOADINFO: Mutex<UnityMethod> =
18-
Mutex::new(UnityMethod { inner: null_mut() });
15+
pub static ref ASSEMBLYMANAGER_RESOLVE: RwLock<UnityMethod> =
16+
RwLock::new(UnityMethod { inner: null_mut() });
17+
pub static ref ASSEMBLYMANAGER_LOADINFO: RwLock<UnityMethod> =
18+
RwLock::new(UnityMethod { inner: null_mut() });
1919
}
2020

2121
pub fn init(runtime: &FerrexRuntime) -> Result<(), DynErr> {
2222
preload(runtime)?;
2323

2424
debug!("Initializing BaseAssembly")?;
2525

26+
let _runtime_dir = paths::runtime_dir()?;
27+
2628
//get MelonLoader.dll's path and confirm it exists
2729
let mut melonloader_dll = melonenv::paths::MELONLOADER_FOLDER.clone();
2830
melonloader_dll.extend(&["net35", "MelonLoader.dll"]);
@@ -52,8 +54,8 @@ pub fn init(runtime: &FerrexRuntime) -> Result<(), DynErr> {
5254
//store the methods for later, in a thread safe global static.
5355
*MONO_PRESTART.try_lock()? = prestart_method;
5456
*MONO_START.try_lock()? = start_method;
55-
*ASSEMBLYMANAGER_RESOLVE.try_lock()? = resolve_method;
56-
*ASSEMBLYMANAGER_LOADINFO.try_lock()? = loadinfo_method;
57+
*ASSEMBLYMANAGER_RESOLVE.try_write()? = resolve_method;
58+
*ASSEMBLYMANAGER_LOADINFO.try_write()? = loadinfo_method;
5759

5860
//invoke the MelonLoader initialize method.
5961
let _ = initialize_method.invoke(None, None, runtime)?;

Bootstrap/src/console/os/windows/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ lazy_static! {
2525

2626
pub unsafe fn init() -> Result<(), DynErr> {
2727
// creates a console window, if one already exists it'll just return true.
28-
if !AllocConsole().as_bool() {
29-
return Err(ConsoleError::FailedToAllocateConsole.into());
30-
}
28+
AllocConsole()?;
3129

3230
// store the console window handle
3331
let mut window = WINDOW.try_lock()?;
@@ -39,7 +37,7 @@ pub unsafe fn init() -> Result<(), DynErr> {
3937
}
4038

4139
// this lets us hook into console close events, and run some cleanup logic.
42-
if SetConsoleCtrlHandler(Some(ctrl_handler_hook), Foundation::TRUE) == Foundation::FALSE {
40+
if SetConsoleCtrlHandler(Some(ctrl_handler_hook), Foundation::TRUE).is_err() {
4341
return Err(ConsoleError::FailedToSetConsoleCtrlHandler.into());
4442
}
4543

@@ -80,12 +78,12 @@ pub unsafe fn init() -> Result<(), DynErr> {
8078

8179
mode |= ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
8280

83-
if SetConsoleMode(*output_handle, mode) != Foundation::TRUE {
81+
if SetConsoleMode(*output_handle, mode).is_err() {
8482
mode &= !(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
8583
} else {
8684
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
8785

88-
if SetConsoleMode(*output_handle, mode) != Foundation::TRUE {
86+
if SetConsoleMode(*output_handle, mode).is_err() {
8987
mode &= !ENABLE_VIRTUAL_TERMINAL_PROCESSING;
9088
}
9189
}

Bootstrap/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub type InvokeFnIl2Cpp = extern "C" fn(
1818
pub type InitFnMono = extern "C" fn(*const c_char, *const c_char) -> *mut MonoDomain;
1919
pub type InitFnIl2Cpp = extern "C" fn(*const c_char) -> *mut Il2CppDomain;
2020

21-
pub const MELON_VERSION: &str = "0.6.1";
21+
pub const MELON_VERSION: &str = "0.6.2";
2222

2323
pub const IS_ALPHA: bool = false;
2424

Bootstrap/src/icalls/resolve_internals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn assembly_resolve(
3333
) -> Result<*mut MonoAssembly, DynErr> {
3434
let runtime = runtime!()?;
3535

36-
let resolve_method = base_assembly::mono::ASSEMBLYMANAGER_RESOLVE.try_lock()?;
36+
let resolve_method = base_assembly::mono::ASSEMBLYMANAGER_RESOLVE.try_read()?;
3737

3838
if resolve_method.inner.is_null() {
3939
return Err("AssemblyManager.Resolve is null".into());
@@ -90,7 +90,7 @@ fn load_hook_inner(assembly: *mut MonoAssembly) -> Result<(), DynErr> {
9090
return Ok(());
9191
}
9292

93-
let load_method = base_assembly::mono::ASSEMBLYMANAGER_LOADINFO.try_lock()?;
93+
let load_method = base_assembly::mono::ASSEMBLYMANAGER_LOADINFO.try_read()?;
9494
if load_method.inner.is_null() {
9595
return Ok(());
9696
}

0 commit comments

Comments
 (0)