Initial commit
Rust workspace for VIctory: PE analysis, loader, HLE skeleton, DXBC/DXIL parsing with a GFX10 decoder, conversion cache, CLI and asset-policy enforcement. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
commit
f4504f6413
69 files changed
+7952
No files matched your search
@@ -0,0 +1,65 @@
|
||||
//! Overrides of shared Windows APIs whose console meaning differs.
|
||||
//!
|
||||
//! Only the differences live here; everything else passes through to the
|
||||
//! host (see `HostPolicy`).
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::ffi::c_void;
|
||||
|
||||
use crate::{HleModule, hle_export, runtime};
|
||||
|
||||
/// `GetModuleHandleW(NULL)` must return the title's image, not our exe.
|
||||
pub extern "system" fn GetModuleHandleW(name: *const u16) -> *mut c_void {
|
||||
if name.is_null() {
|
||||
return runtime::main_image().unwrap_or(0) as *mut c_void;
|
||||
}
|
||||
host::get_module_handle_w(name)
|
||||
}
|
||||
|
||||
/// `GetModuleHandleA(NULL)` must return the title's image, not our exe.
|
||||
pub extern "system" fn GetModuleHandleA(name: *const u8) -> *mut c_void {
|
||||
if name.is_null() {
|
||||
return runtime::main_image().unwrap_or(0) as *mut c_void;
|
||||
}
|
||||
host::get_module_handle_a(name)
|
||||
}
|
||||
|
||||
pub(crate) fn module() -> HleModule {
|
||||
HleModule {
|
||||
name: "kernel",
|
||||
dlls: &[
|
||||
"kernel32.dll",
|
||||
"kernelbase.dll",
|
||||
"api-ms-win-core-libraryloader-*",
|
||||
],
|
||||
exports: vec![hle_export!(GetModuleHandleW), hle_export!(GetModuleHandleA)],
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
mod host {
|
||||
use std::ffi::c_void;
|
||||
|
||||
pub(super) fn get_module_handle_w(name: *const u16) -> *mut c_void {
|
||||
// SAFETY: forwarding the title's own argument to the host API.
|
||||
unsafe { windows_sys::Win32::System::LibraryLoader::GetModuleHandleW(name) }
|
||||
}
|
||||
|
||||
pub(super) fn get_module_handle_a(name: *const u8) -> *mut c_void {
|
||||
// SAFETY: forwarding the title's own argument to the host API.
|
||||
unsafe { windows_sys::Win32::System::LibraryLoader::GetModuleHandleA(name) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
mod host {
|
||||
use std::ffi::c_void;
|
||||
|
||||
pub(super) fn get_module_handle_w(_: *const u16) -> *mut c_void {
|
||||
std::ptr::null_mut()
|
||||
}
|
||||
|
||||
pub(super) fn get_module_handle_a(_: *const u8) -> *mut c_void {
|
||||
std::ptr::null_mut()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//! Implementations, one module per area of the console API.
|
||||
//!
|
||||
//! Adding an API: write an `extern "system"` function named exactly like
|
||||
//! the import, then list it with `hle_export!` in the module's `module()`.
|
||||
//! Run `victory census` over your titles to see what is still missing.
|
||||
//!
|
||||
//! Planned areas (driven by census results, not by completeness):
|
||||
//! `xmem` (console memory types, GPU-visible allocations), `file` (package
|
||||
//! paths), `thread` (TLS callbacks for title threads), `d3d12x` (bridge to
|
||||
//! `victory-gpu`), `xaudio2`, `gameinput`, `xuser`/`xstore` stubs.
|
||||
|
||||
pub mod kernel;
|
||||
pub mod xgameruntime;
|
||||
|
||||
use crate::HleModule;
|
||||
|
||||
pub(crate) fn all() -> Vec<HleModule> {
|
||||
vec![kernel::module(), xgameruntime::module()]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//! `xgameruntime.dll`: the console game runtime (XGame*, XUser*, XTaskQueue*...).
|
||||
//!
|
||||
//! The DLL names titles actually import these from are confirmed by running
|
||||
//! `victory census` on real titles; extend `dlls` accordingly.
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::{HleModule, hle_export};
|
||||
|
||||
pub type HRESULT = i32;
|
||||
pub const S_OK: HRESULT = 0;
|
||||
|
||||
pub extern "system" fn XGameRuntimeInitialize() -> HRESULT {
|
||||
tracing::info!("XGameRuntimeInitialize");
|
||||
S_OK
|
||||
}
|
||||
|
||||
pub extern "system" fn XGameRuntimeUninitialize() {
|
||||
tracing::info!("XGameRuntimeUninitialize");
|
||||
}
|
||||
|
||||
pub(crate) fn module() -> HleModule {
|
||||
HleModule {
|
||||
name: "xgameruntime",
|
||||
dlls: &["xgameruntime.dll"],
|
||||
exports: vec![
|
||||
hle_export!(XGameRuntimeInitialize),
|
||||
hle_export!(XGameRuntimeUninitialize),
|
||||
],
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user