Skip to content

Commit

Permalink
Bump dependencies and add feature crates (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
veeenu authored Jun 27, 2023
1 parent 3145f42 commit 8c52d05
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ path = "examples/renderers/dx12.rs"
crate-type = ["bin"]

[dependencies]
imgui = "0.11.0"
imgui-opengl = "0.1.0"
parking_lot = "0.11.2"
imgui = "0.11"
imgui-opengl = "0.1"
parking_lot = "0.12"
windows = { version = "0.39.0", features = [
"Win32_Devices_HumanInterfaceDevice",
"Win32_Foundation",
Expand Down Expand Up @@ -97,6 +97,8 @@ windows = { version = "0.39.0", features = [
"Win32_UI_WindowsAndMessaging",
] }
tracing = { version = "0.1", features = ["log"] }
memoffset = "0.9.0"
once_cell = "1.18.0"

[dev-dependencies]
tracing-subscriber = "0.3"
Expand Down
12 changes: 6 additions & 6 deletions src/hooks/dx12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::ffi::c_void;
use std::mem::{self, ManuallyDrop};
use std::ptr::{null, null_mut};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::OnceLock;
use std::thread;
use std::time::{Duration, Instant};

use imgui::Context;
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
use tracing::{debug, error, info, trace};
use windows::core::{Interface, HRESULT, HSTRING, PCWSTR};
Expand Down Expand Up @@ -73,11 +73,11 @@ trait Renderer {
// Global singletons
////////////////////////////////////////////////////////////////////////////////////////////////////

static TRAMPOLINE: OnceLock<(
static TRAMPOLINE: OnceCell<(
DXGISwapChainPresentType,
ExecuteCommandListsType,
ResizeBuffersType,
)> = OnceLock::new();
)> = OnceCell::new();

const COMMAND_ALLOCATOR_NAMES: [&HSTRING; 8] = [
w!("hudhook Command allocator #0"),
Expand Down Expand Up @@ -119,9 +119,9 @@ unsafe fn print_dxgi_debug_messages() {
// Hook entry points
////////////////////////////////////////////////////////////////////////////////////////////////////

static mut IMGUI_RENDER_LOOP: OnceLock<Box<dyn ImguiRenderLoop + Send + Sync>> = OnceLock::new();
static mut IMGUI_RENDERER: OnceLock<Mutex<Box<ImguiRenderer>>> = OnceLock::new();
static mut COMMAND_QUEUE_GUARD: OnceLock<()> = OnceLock::new();
static mut IMGUI_RENDER_LOOP: OnceCell<Box<dyn ImguiRenderLoop + Send + Sync>> = OnceCell::new();
static mut IMGUI_RENDERER: OnceCell<Mutex<Box<ImguiRenderer>>> = OnceCell::new();
static mut COMMAND_QUEUE_GUARD: OnceCell<()> = OnceCell::new();
static DXGI_DEBUG_ENABLED: AtomicBool = AtomicBool::new(false);

static CQECL_RUNNING: Fence = Fence::new();
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#![feature(lazy_cell)]
#![feature(offset_of)]
#![feature(once_cell_try)]

//! # hudhook
//!
//! This library implements a mechanism for hooking into the
Expand Down
8 changes: 4 additions & 4 deletions src/mh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::ffi::c_void;
use std::ptr::null_mut;
use std::sync::LazyLock;
use std::sync::OnceLock;

use tracing::debug;

Expand Down Expand Up @@ -79,15 +79,15 @@ pub struct MhHook {
impl MhHook {
/// # Safety
pub unsafe fn new(addr: *mut c_void, hook_impl: *mut c_void) -> Result<Self, MH_STATUS> {
static INIT_CELL: LazyLock<()> = LazyLock::new(|| {
static INIT_CELL: OnceLock<()> = OnceLock::new();

INIT_CELL.get_or_init(|| {
let status = unsafe { crate::mh::MH_Initialize() };
debug!("MH_Initialize: {:?}", status);

status.ok().expect("Couldn't initialize hooks");
});

LazyLock::force(&INIT_CELL);

let mut trampoline = null_mut();
let status = MH_CreateHook(addr, hook_impl, &mut trampoline);
debug!("MH_CreateHook: {:?}", status);
Expand Down
3 changes: 2 additions & 1 deletion src/renderers/imgui_dx12.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::ffi::c_void;
use std::mem::{offset_of, size_of, ManuallyDrop};
use std::mem::{size_of, ManuallyDrop};
use std::ptr::{null, null_mut};

pub use imgui;
use imgui::internal::RawWrapper;
use imgui::{BackendFlags, DrawCmd, DrawData, DrawIdx, DrawVert, TextureId};
use memoffset::offset_of;
use tracing::{error, trace};
use windows::core::{Result, PCSTR, PCWSTR};
use windows::w;
Expand Down

0 comments on commit 8c52d05

Please sign in to comment.