Skip to content

Commit

Permalink
Update sigs and send hook for Dawntrail (7.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
ff14wed committed Jun 26, 2024
1 parent 561df33 commit 332cffa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
26 changes: 8 additions & 18 deletions src/hook/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ use super::{Channel, HookError};

use log::error;

type HookedFunction =
unsafe extern "system" fn(*const u8, *const u8, usize, usize, usize, usize) -> usize;
type HookedFunction = unsafe extern "system" fn(*const u8, usize) -> usize;
type StaticHook = StaticDetour<HookedFunction>;

static_detour! {
static CompressPacketChat: unsafe extern "system" fn(*const u8, *const u8, usize, usize, usize, usize) -> usize;
static CompressPacketZone: unsafe extern "system" fn(*const u8, *const u8, usize, usize, usize, usize) -> usize;
static CompressPacketChat: unsafe extern "system" fn(*const u8, usize) -> usize;
static CompressPacketZone: unsafe extern "system" fn(*const u8, usize) -> usize;
}

#[derive(Clone)]
Expand Down Expand Up @@ -61,26 +60,17 @@ impl Hook {
unsafe fn setup_hook(&self, hook: &StaticHook, channel: Channel, rva: *const u8) -> Result<()> {
let self_clone = self.clone();
let ptr_fn: HookedFunction = mem::transmute(rva as *const ());
hook.initialize(ptr_fn, move |a, b, c, d, e, f| {
self_clone.compress_packet(channel, a, b, c, d, e, f)
hook.initialize(ptr_fn, move |a, b| {
self_clone.compress_packet(channel, a, b)
})?;
Ok(())
}

#[allow(clippy::too_many_arguments)]
unsafe fn compress_packet(
&self,
channel: Channel,
a1: *const u8,
a2: *const u8,
a3: usize,
a4: usize,
a5: usize,
a6: usize,
) -> usize {
unsafe fn compress_packet(&self, channel: Channel, a1: *const u8, a2: usize) -> usize {
let _guard = self.wg.add();

let ptr_frame: *const u8 = *(a1.add(16) as *const usize) as *const u8;
let ptr_frame: *const u8 = *(a1.add(32) as *const usize) as *const u8;

match packet::extract_packets_from_frame(ptr_frame) {
Ok(packets) => {
Expand Down Expand Up @@ -110,7 +100,7 @@ impl Hook {
Channel::Lobby => panic!("Not implemented."),
Channel::Zone => &CompressPacketZone,
};
hook.call(a1, a2, a3, a4, a5, a6)
hook.call(a1, a2)
}

pub fn shutdown() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use simplelog::{CombinedLogger, SimpleLogger};

const VERSION: &str = env!("CARGO_PKG_VERSION");

const RECV_SIG: &str = "E8 $ { ' } 4C 8B 43 10 41 8B 40 18";
const SEND_SIG: &str = "E8 $ { ' } 8B 53 2C 48 8D 8B";
const RECV_SIG: &str = "E8 $ { ' } 4C 8B 4F 10 8B 47 1C 45";
const SEND_SIG: &str = "40 57 41 56 48 83 EC 38 48 8B F9 4C 8B F2";
const SEND_LOBBY_SIG: &str = "40 53 48 83 EC 20 44 8B 41 28";

fn handle_payload(payload: rpc::Payload, hs: Arc<hook::State>) -> Result<()> {
Expand Down

0 comments on commit 332cffa

Please sign in to comment.