Skip to content

Commit

Permalink
Fixed possible merging of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
arcturus-prime committed Jul 19, 2024
1 parent 7962d05 commit 539aa57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
15 changes: 9 additions & 6 deletions client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod packet;

use tokio::net::windows::named_pipe::ClientOptions;
use tokio::{io::AsyncReadExt, net::windows::named_pipe::ClientOptions};

#[tokio::main(flavor = "current_thread")]
async fn main() {
println!("Connecting to server...");

let client = loop {
let mut client = loop {
let options = ClientOptions::new().open(r"//./pipe/StudioDumper");

match options {
Expand All @@ -22,11 +22,14 @@ async fn main() {
loop {
client.readable().await.unwrap();

let size = match client.try_read(&mut buffer) {
Ok(n) => if n == 0 { continue } else { n },
Err(_) => continue,
let Ok(size) = client.read_u32_le().await else {
continue;
};

println!("Incoming Packet: {:02X?}", &buffer[..size])
if let Err(_) = client.read_exact(&mut buffer[..size as usize]).await {
continue;
}

println!("Incoming Packet: {:02X?}", &buffer[..size as usize]);
}
}
9 changes: 4 additions & 5 deletions dumper/src/VFTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Region.h"

#include <cstdint>
#include <iostream>
#include <optional>
#include <string>
#include <windows.h>
Expand All @@ -15,8 +16,6 @@ class VFTable
uintptr_t* vftable;

public:
VFTable() = default;

static inline std::optional<VFTable> find(const Region& region, const std::string& mangled_name)
{
auto results = region.find(mangled_name);
Expand All @@ -28,13 +27,13 @@ class VFTable

auto xref_ibos = region.find(std::string((char*) &ibo_type_descriptor, 4));

for (auto xref_ibo : xref_ibos)
for (const auto& xref_ibo : xref_ibos)
{
uintptr_t completeObjLoc = xref_ibo - 0xC;
auto vftable_results = region.find(std::string((char*) &completeObjLoc, 8));

if (vftable_results.empty())
return std::nullopt;
continue;

auto vftable = (uintptr_t*) vftable_results[0] + 1;

Expand All @@ -48,7 +47,7 @@ class VFTable
ctx.vftable = vftable;

return ctx;
};
}
}

return std::nullopt;
Expand Down
5 changes: 3 additions & 2 deletions dumper/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ void hook_24(RakNet::RakPeer* rakPeer, char _1)
auto packet = rakPeer->queue_2.array[i];

DWORD num;
auto result = WriteFile(g_pipe, packet->data, packet->size, &num, NULL);
auto result_1 = WriteFile(g_pipe, (uint8_t*) &packet->size, 4, &num, NULL);
auto result_2 = WriteFile(g_pipe, packet->data, packet->size, &num, NULL);

if (result)
if (result_1 && result_2)
continue;

if (GetLastError() == ERROR_NO_DATA)
Expand Down

0 comments on commit 539aa57

Please sign in to comment.