Skip to content

Commit

Permalink
Restore access to The Amazing Secret
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisaphone committed Apr 19, 2020
1 parent 3455a36 commit 1d59b33
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.1.2 – 2020-04-19

- Restore access to The Amazing Secret.

## v0.1.1 – 2020-04-18

- `/show_triggers` now also draws load regions
Expand Down
7 changes: 3 additions & 4 deletions crates/aether/src/commands/load_map_menu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::hooks::ON_POST_UPDATE_QUEUE;
use darksiders1_sys::target;
use crate::{darksiders1::gfc, hooks::ON_POST_UPDATE_QUEUE};

pub fn run(_command: &str) {
let mut guard = ON_POST_UPDATE_QUEUE.lock();
Expand All @@ -10,6 +9,6 @@ pub fn run(_command: &str) {
}

unsafe fn go() {
let window_helper = *target::gfc__Singleton_gfc__WindowHelper_gfc__CreateStatic_gfc__SingletonLongevity__DieFirst___InstanceHandle;
target::gfc__WindowHelper__pushWindow(window_helper, hstring!("ui_core/loadmapmenu").as_ptr());
let window_helper = <gfc::Singleton<gfc::WindowHelper>>::get_instance();
window_helper.push_window(&hstring!("ui_core/loadmapmenu"));
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod helper;
pub mod teleporthelper;
pub mod windowhelper;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::darksiders1::{gfc, Lift};
use darksiders1_sys::target;

struct_wrapper!(WindowHelper, target::gfc__WindowHelper);
struct_wrapper_super!(WindowHelper, gfc::Helper);

impl WindowHelper {
pub fn push_window(&self, wndclass: &gfc::HString) {
unsafe {
target::gfc__WindowHelper__pushWindow(self.as_ptr(), wndclass.as_ptr());
}
}

pub fn get_window(&self) -> gfc::AutoRef<gfc::_UIControl> {
self.inner.mWindow.lift_ref().clone()
}
}
5 changes: 5 additions & 0 deletions crates/aether/src/darksiders1/code/vigil/gfc/base/autoref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ macro_rules! lowered_autoref {
}
}

lowered_autoref!(
target::gfc__AutoRef_gfc___UIControl_,
target::gfc___UIControl,
lift = true,
);
lowered_autoref!(target::gfc__AutoRef_gfc__Camera3D_, target::gfc__Camera3D);
lowered_autoref!(
target::gfc__AutoRef_gfc__CShape_,
Expand Down
1 change: 1 addition & 0 deletions crates/aether/src/darksiders1/code/vigil/gfc/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod uicontrol;
pub mod uimanager;
11 changes: 11 additions & 0 deletions crates/aether/src/darksiders1/code/vigil/gfc/ui/uicontrol.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::darksiders1::{gfc, Lift};
use darksiders1_sys::target;

struct_wrapper!(_UIControl, target::gfc___UIControl);
struct_wrapper_super!(_UIControl, gfc::Object);

impl _UIControl {
pub fn name(&self) -> &gfc::HString {
self.inner.mName.lift_ref()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ impl_singleton!(
gfc::TeleportHelper,
target::gfc__Singleton_gfc__TeleportHelper_gfc__CreateStatic_gfc__DefaultLifetime___InstanceHandle,
);
impl_singleton!(
gfc::WindowHelper,
target::gfc__Singleton_gfc__WindowHelper_gfc__CreateStatic_gfc__SingletonLongevity__DieFirst___InstanceHandle,
);
4 changes: 2 additions & 2 deletions crates/aether/src/darksiders1/gfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub use crate::darksiders1::code::vigil::{
darksiders::{
client::{
darksiders::Darksiders,
helpers::{helper::Helper, teleporthelper::TeleportHelper},
helpers::{helper::Helper, teleporthelper::TeleportHelper, windowhelper::WindowHelper},
ui::dsuimanager::DSUIManager,
},
world::{
Expand Down Expand Up @@ -50,7 +50,7 @@ pub use crate::darksiders1::code::vigil::{
memory::memop::{mem_alloc, mem_free},
oc::ooobjectwriter::OOObjectWriter,
reflection::scriptclass::ScriptClass,
ui::uimanager::_UIManager,
ui::{uicontrol::_UIControl, uimanager::_UIManager},
util::{
hstring::HString,
singleton::Singleton,
Expand Down
12 changes: 11 additions & 1 deletion crates/aether/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mod hook {
spawn_humans,
},
console::{self, InputHandled},
darksiders1::{Lift, Lower},
darksiders1::{gfc, Lift, Lower},
hooks::{DETOURS, ON_POST_UPDATE_QUEUE},
library::objects::{
override_get_material,
Expand Down Expand Up @@ -128,13 +128,23 @@ mod hook {

// Return `false` to swallow the event, or `true` to continue processing
// normally.
#[allow(clippy::shadow_unrelated)]
pub unsafe extern "thiscall" fn gfc__Darksiders__processInputEvent(
this: *mut target::gfc__Darksiders,
inputEvent: *const target::keen__InputEvent,
) -> bool {
let guard = DETOURS.read();
let detours = guard.as_ref().unwrap();

// Restore access to The Amazing Secret.
let window_helper = <gfc::Singleton<gfc::WindowHelper>>::get_instance();
let current_window = window_helper.get_window();
let result =
target::gfc__Darksiders__doTheMagic(this, inputEvent, current_window.name().as_ptr());
if !result {
return false;
}

let result = (detours.gfc__Darksiders__processInputEvent)(this, inputEvent);

// Setting this flag prevents the game from pausing when you deactivate the
Expand Down
1 change: 1 addition & 0 deletions crates/darksiders1-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pdbindgen \
-i '^gfc::CShapeMesh$' \
-i '^gfc::CShapeMesh::_Class$' \
-i '^gfc::ClassRegistry::classForName$' \
-i '^gfc::Darksiders::doTheMagic$' \
-i '^gfc::Darksiders::processInputEvent$' \
-i '^gfc::DetectorObject::_Class$' \
-i '^gfc::DetectorRegion::bodyEntered$' \
Expand Down
1 change: 1 addition & 0 deletions crates/darksiders1-sys/src/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub unsafe fn bind(args: &BindArgs) {
bind!(text, gfc__ObjectWriter___ObjectWriter);
bind!(text, gfc__World__getRegion_2);
bind!(text, gfc__Darksiders__processInputEvent);
bind!(text, gfc__Darksiders__doTheMagic);
bind!(text, gfc__UIRenderer__translate);
bind!(text, gfc__UIRenderer__rotate);
bind!(text, gfc__UIRenderer__scale);
Expand Down
1 change: 1 addition & 0 deletions crates/darksiders1-sys/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ symbols! {
pub static gfc__ObjectWriter___ObjectWriter: unsafe extern "thiscall" fn(this: *mut gfc__ObjectWriter) = Text(0x2103c0);
pub static gfc__World__getRegion_2: unsafe extern "thiscall" fn(this: *mut gfc__World, result: *mut gfc__AutoRef_gfc__WorldRegion_, _: i32) -> *mut gfc__AutoRef_gfc__WorldRegion_ = Text(0x223730);
pub static gfc__Darksiders__processInputEvent: unsafe extern "thiscall" fn(this: *mut gfc__Darksiders, _: *const keen__InputEvent) -> bool = Text(0x27b4b0);
pub static gfc__Darksiders__doTheMagic: unsafe extern "thiscall" fn(this: *mut gfc__Darksiders, _: *const keen__InputEvent, _: *const gfc__HString) -> bool = Text(0x27bed0);
pub static gfc__UIRenderer__translate: unsafe extern "thiscall" fn(this: *mut gfc__UIRenderer, _: f32, _: f32) = Text(0x1eb170);
pub static gfc__UIRenderer__rotate: unsafe extern "thiscall" fn(this: *mut gfc__UIRenderer, _: f32) = Text(0x1eb1b0);
pub static gfc__UIRenderer__scale: unsafe extern "thiscall" fn(this: *mut gfc__UIRenderer, _: f32, _: f32) = Text(0x1eb1e0);
Expand Down
1 change: 1 addition & 0 deletions crates/darksiders1-sys/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ symbols! {
pub fn gfc__ObjectWriter___ObjectWriter;
pub fn gfc__World__getRegion_2;
pub fn gfc__Darksiders__processInputEvent;
pub fn gfc__Darksiders__doTheMagic;
pub fn gfc__UIRenderer__translate;
pub fn gfc__UIRenderer__rotate;
pub fn gfc__UIRenderer__scale;
Expand Down

0 comments on commit 1d59b33

Please sign in to comment.