Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Commit

Permalink
Fixed for 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Splamy committed Jun 22, 2019
1 parent c3bccdf commit 13e50ad
Show file tree
Hide file tree
Showing 13 changed files with 463 additions and 330 deletions.
9 changes: 5 additions & 4 deletions TS3Hook/PatchTools.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "main.h"
#include <Windows.h>
#include <Psapi.h>
#include <cstdio>

MODULEINFO GetModuleInfo(const LPCWSTR szModule)
{
Expand All @@ -12,7 +13,7 @@ MODULEINFO GetModuleInfo(const LPCWSTR szModule)
return modinfo;
}

SIZE_T FindPattern(const LPCWSTR module, const char *pattern, const char *mask)
SIZE_T FindPattern(const LPCWSTR module, const char* pattern, const char* mask)
{
//Get all module related information
const MODULEINFO mInfo = GetModuleInfo(module);
Expand Down Expand Up @@ -78,12 +79,12 @@ void MakeJMP(const PBYTE pAddress, const PVOID dwJumpTo, const SIZE_T dwLen)
// overwrite the next 4 bytes (which is the size of a DWORD)
// with the dwRelAddr

*reinterpret_cast<SIZE_T *>(pAddress + 0x1) = dwRelAddr;
*reinterpret_cast<SIZE_T*>(pAddress + 0x1) = dwRelAddr;

// overwrite the remaining bytes with the NOP opcode (0x90)
// NOP opcode = No OPeration

for (SIZE_T x = 0x5; x < dwLen; x++) *(pAddress + x) = 0x90;
for (SIZE_T x = 0x5; x < dwLen; x++)* (pAddress + x) = 0x90;

// restore the paged memory permissions saved in dwOldProtect

Expand Down Expand Up @@ -111,7 +112,7 @@ void MakeJMP(PBYTE const pAddress, const PVOID dwJumpTo, const SIZE_T dwLen)
memcpy(pAddress, stub, sizeof(stub));

for (int i = MinLen; i < dwLen; i++)
*reinterpret_cast<BYTE*>(reinterpret_cast<DWORD_PTR>(pAddress) + i) = 0x90;
* reinterpret_cast<BYTE*>(reinterpret_cast<DWORD_PTR>(pAddress) + i) = 0x90;

VirtualProtect(pAddress, dwLen, dwOld, &dwOld);
}
Expand Down
8 changes: 4 additions & 4 deletions TS3Hook/TS3Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions TS3Hook/Ts3Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "main.h"
#include "PatchTools.h"

#define PLUGIN_API_VERSION 22
#define PLUGIN_API_VERSION 23

const char* ts3plugin_name() { return "TS3Hook"; }
const char* ts3plugin_version() { return "1.2.5"; }
const char* ts3plugin_version() { return "1.3.0"; }

int ts3plugin_apiVersion() {
int target = -1;
Expand Down
50 changes: 49 additions & 1 deletion TS3Hook/asmhook.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ packet_in_hook1 proc
; Restore origial
MOV rcx, [r14+80]
MOV rax, [rcx]
MOV byte ptr [rsp+32], 0
MOV BYTE PTR [rsp+32], 0
MOV r9, [r14+88]
MOV r8, r14
MOV rdx, rbx
Expand All @@ -71,6 +71,31 @@ packet_in_hook1 proc
JMP packet_in_hook_return
packet_in_hook1 endp

packet_in_hook2 proc
; Restore origial
MOV rcx, [r15+80]
MOV rax, [rcx]
MOV BYTE PTR [rsp+32], 0
MOV r9, [r15+88]
MOV r8, r15
MOV rdx, rbx

pushaq
SUB rsp, 32

; Log in-packet
MOV rcx, QWORD PTR [rdx+8]
ADD rcx, 11 ; str
MOV edx, DWORD PTR [rdx+16]
SUB edx, 11 ; len
CALL log_in_packet

ADD rsp, 32
popaq

JMP packet_in_hook_return
packet_in_hook2 endp

packet_out_hook1 proc
pushaq
SUB rsp, 32
Expand Down Expand Up @@ -151,4 +176,27 @@ packet_out_hook3 proc
JMP packet_out_hook_return
packet_out_hook3 endp

packet_out_hook4 proc
pushaq
SUB rsp, 32

; Log out-packet
MOV rcx, QWORD PTR [rdi+8]
ADD rcx, 13 ; str
MOV edx, DWORD PTR [rdi+16]
SUB edx, 13 ; len
CALL log_out_packet

ADD rsp, 32
popaq

; Restore origial
MOV [rbp+2528], eax
CMP eax, r14d
SETZ r12b
CMP BYTE PTR [rsp+64], 0

JMP packet_out_hook_return
packet_out_hook4 endp

END
Loading

0 comments on commit 13e50ad

Please sign in to comment.