mirror of
https://github.com/r4sas/ExtraMirror
synced 2025-02-09 13:14:19 +00:00
Еще немного реконструкции
This commit is contained in:
parent
484c827a3b
commit
fc8339d30f
@ -30,7 +30,6 @@ void HookEngineMessages(){
|
||||
pSVC_SendCvarValue2 = HookEngineMsg("svc_sendcvarvalue2", SVC_SendCvarValue2);
|
||||
pSVC_Director = HookEngineMsg("svc_director", SVC_Director);
|
||||
pSVC_VoiceInit = HookEngineMsg("svc_voiceinit", SVC_VoiceInit);
|
||||
// pSVC_Resourcelist = HookEngineMsg("svc_resourcelist", SVC_Resourcelist);
|
||||
}
|
||||
|
||||
|
||||
@ -281,8 +280,10 @@ void SetRenderModel(struct model_s *model)
|
||||
g_Engine.Con_Printf("\tmodel: %s\n", model->name);
|
||||
g_Studio.SetRenderModel(model);
|
||||
}
|
||||
|
||||
void HookFunction(){
|
||||
g_pClient->CL_CreateMove = CL_CreateMove;
|
||||
|
||||
g_pClient->HUD_Frame = HUD_Frame;
|
||||
g_pEngine->pfnDrawUnicodeCharacter = pfnDrawUnicodeCharacter;
|
||||
// g_pStudio->SetRenderModel = SetRenderModel;
|
||||
|
@ -40,6 +40,8 @@ pfnEngineMessage pSVC_SendCvarValue;
|
||||
pfnEngineMessage pSVC_SendCvarValue2;
|
||||
pfnEngineMessage pSVC_Director;
|
||||
|
||||
void(*Cbuf_Execute)();
|
||||
void(*Cbuf_AddText)(char *text);
|
||||
|
||||
typedef enum cmd_source_s
|
||||
{
|
||||
@ -47,21 +49,17 @@ typedef enum cmd_source_s
|
||||
src_command = 1, // from the command buffer.
|
||||
} cmd_source_t;
|
||||
|
||||
void __cdecl ExecuteString(char *text, cmd_source_t src);
|
||||
void __cdecl Cmd_ExecuteString(char *text, cmd_source_t src);
|
||||
|
||||
HOOKINIT(
|
||||
ExecuteString_F, // the type created
|
||||
ExecuteString, // the function prototyped
|
||||
Cmd_ExecuteString, // the function prototyped
|
||||
ExecuteString_Tramp, // the trampoline to the original function
|
||||
ExecuteString_Prologue // the prologue object of the function used for this hook
|
||||
)
|
||||
|
||||
DWORD ExecuteString_call;
|
||||
DWORD ExecuteString_jump;
|
||||
DWORD Cbuf_Addtext_call;
|
||||
DWORD Cbuf_Addtext_jump;
|
||||
DWORD Cbuf_Execute_call;
|
||||
DWORD Cbuf_Execute_jump;
|
||||
|
||||
EasyHook::Hook32 hooker; // an object meant to service you
|
||||
|
||||
@ -125,106 +123,42 @@ bool CheckExecute(char *text)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// experimental
|
||||
|
||||
__declspec(naked) void Cmd_ExecuteString_CallHook( )
|
||||
{
|
||||
static char *text;
|
||||
__asm MOV text, ECX
|
||||
bool Test;
|
||||
Test = CheckExecute(text);
|
||||
if (Test)
|
||||
__asm mov text, ecx
|
||||
bool CheckValid;
|
||||
CheckValid = CheckExecute(text);
|
||||
if (CheckValid)
|
||||
{
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
__asm MOV ECX, [EBP + 0x8]
|
||||
__asm MOV EAX, [EBP + 0xC]
|
||||
__asm JMP[ExecuteString_jump]
|
||||
__asm {
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov ecx, [ebp + 0x8]
|
||||
mov eax, [ebp + 0xC]
|
||||
jmp[ExecuteString_jump]
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm ret;
|
||||
}
|
||||
|
||||
}/*
|
||||
__declspec(naked) void Cmd_ExecuteString_CallHook()
|
||||
{
|
||||
char *text;
|
||||
cmd_source_t src;
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
PUSH EAX
|
||||
PUSH ECX
|
||||
MOV text, ECX
|
||||
MOV src, EAX
|
||||
POP ECX
|
||||
POP EAX
|
||||
POP EBP
|
||||
}
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
jmp[ExecuteString_jump]
|
||||
}
|
||||
ConsolePrintColor(0, 255, 255, "%s", text);
|
||||
hooker.unhook(ExecuteString_Tramp, ExecuteString_Prologue);
|
||||
}
|
||||
/*__declspec(naked) void Cmd_ExecuteString_CallHook()
|
||||
{
|
||||
char *text;
|
||||
cmd_source_t src;
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
PUSH EAX
|
||||
PUSH ECX
|
||||
MOV text, ECX
|
||||
MOV src, EAX
|
||||
call ExecuteString
|
||||
POP ECX
|
||||
POP EAX
|
||||
POP EBP
|
||||
}
|
||||
//bool Test;
|
||||
//Test = CheckExecute((char*)&text);
|
||||
|
||||
//if (Test)
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
jmp[ExecuteString_jump]
|
||||
}
|
||||
hooker.unhook(ExecuteString_Tramp, ExecuteString_Prologue);
|
||||
}*/
|
||||
/*
|
||||
void __cdecl ExecuteString(char *text, cmd_source_t src)
|
||||
{
|
||||
if (FirstFrame)
|
||||
ConsolePrintColor(0, 255, 0, "%s %d \n", text, src);
|
||||
|
||||
//MessageBox(NULL, text, NULL, MB_OK);
|
||||
}
|
||||
*/
|
||||
void ExecuteString_Test(const char *str, pfnEngineMessage Func) {
|
||||
void ExecuteString_Add(const char *str) {
|
||||
ExecuteString_Tramp = (ExecuteString_F)hooker.hook(
|
||||
(LPVOID)ExecuteString_call, // pointer to the function you'd like to hook
|
||||
ExecuteString_Prologue, // the prologue created by the INIT macro
|
||||
Cmd_ExecuteString_CallHook // the hook function to which you want to redirect the original
|
||||
);
|
||||
Cbuf_AddText_CallHook_Ext((char*)str);
|
||||
Cbuf_Execute_CallHook_Ext();
|
||||
Cbuf_AddText((char*)str);
|
||||
Cbuf_Execute();
|
||||
hooker.unhook(ExecuteString_Tramp, ExecuteString_Prologue);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
bool BlackList(char *str) {
|
||||
bool changed = false;
|
||||
char *text = str;
|
||||
@ -254,7 +188,7 @@ bool BlackList(char *str) {
|
||||
char *a = isGood ? "[Extra Mirror] execute: \"" : "[Extra Mirror] blocked: \"";
|
||||
if (logsfiles->value > 0) { ConsolePrintColor(255, 255, 255, ("%s", a)); ConsolePrintColor(255, 255, 255, ("%s", c)); ConsolePrintColor(255, 255, 255, "\"\n"); }
|
||||
// if (isFake) a = isGood ? "[Extra Mirror] set fake cvar: \"" : "[Extra Mirror] block fake cvar: \"";
|
||||
/*else*/if (isSet)a = "[Extra Mirror] update server-side cvar: \"";
|
||||
/*else*//*if (isSet)a = "[Extra Mirror] update server-side cvar: \"";
|
||||
if (isGood)g_Engine.pfnClientCmd(c);
|
||||
if (isSet) { if (logsfiles->value > 0) { ConsolePrintColor(255, 255, 255, ("%s", a)); ConsolePrintColor(255, 255, 255, ("%s", c)); ConsolePrintColor(255, 255, 255, "\"\n"); } }
|
||||
len -= i;
|
||||
@ -262,7 +196,7 @@ bool BlackList(char *str) {
|
||||
else { text += i + 1; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
void SVC_SendCvarValue() {
|
||||
MSG_SaveReadCount();
|
||||
@ -402,31 +336,24 @@ bool CheckAndSetCvar(string FullCmd) {
|
||||
return true;
|
||||
}
|
||||
void SVC_StuffText() {
|
||||
//MSG_SaveReadCount();
|
||||
char* command = MSG_ReadString();
|
||||
//MSG_RestoreReadCount();
|
||||
ExecuteString_Test(command, pSVC_StuffText);
|
||||
/*char str[1024];
|
||||
strncpy(str, command, sizeof(str));
|
||||
str[sizeof(str) - 1] = 0;
|
||||
if (BlackList(str))return;
|
||||
MSG_RestoreReadCount();*/
|
||||
//ConsolePrintColor(0, 255, 0, "%s", command);
|
||||
ExecuteString_Add(command);
|
||||
}
|
||||
void SVC_Director() {
|
||||
/*MSG_SaveReadCount();
|
||||
MSG_SaveReadCount();
|
||||
int msglen = MSG_ReadByte();
|
||||
int msgtype = MSG_ReadByte();
|
||||
char* DirectCommand = MSG_ReadString();
|
||||
if (msgtype == 10) {
|
||||
char str[1024];
|
||||
strncpy(str, DirectCommand, sizeof(str));
|
||||
str[sizeof(str) - 1] = 0;
|
||||
if (BlackList(str))return;
|
||||
char* command = MSG_ReadString();
|
||||
ExecuteString_Add(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG_RestoreReadCount();
|
||||
pSVC_Director();
|
||||
}
|
||||
MSG_RestoreReadCount();
|
||||
pSVC_Director();*/
|
||||
}
|
||||
|
||||
void SVC_VoiceInit() {
|
||||
MSG_SaveReadCount();
|
||||
char* codec = MSG_ReadString(); int bitz = MSG_ReadByte(); bool blocked;
|
||||
|
@ -67,13 +67,13 @@ extern HL_MSG_ReadBitVec3Coord MSG_ReadBitVec3Coord;
|
||||
extern HL_MSG_ReadBits MSG_ReadBits;
|
||||
extern HL_MSG_StartBitReading MSG_StartBitReading;
|
||||
extern HL_MSG_EndBitReading MSG_EndBitReading;
|
||||
|
||||
/*
|
||||
typedef void(*HL_MSG_CBuf_AddText)(char* text);
|
||||
|
||||
extern HL_MSG_CBuf_AddText CBuf_AddText_Orign;
|
||||
*/
|
||||
void MSG_SaveReadCount();
|
||||
void MSG_RestoreReadCount();
|
||||
void CBuf_AddText(char* text);
|
||||
//void CBuf_AddText(char* text);
|
||||
|
||||
void SVC_StuffText();
|
||||
void SVC_SendCvarValue();
|
||||
@ -82,14 +82,10 @@ void SVC_Director();
|
||||
void SVC_Resourcelist();
|
||||
void SVC_VoiceInit();
|
||||
|
||||
extern DWORD Cbuf_Addtext_call;
|
||||
extern DWORD Cbuf_Addtext_jump;
|
||||
extern DWORD Cbuf_Execute_call;
|
||||
extern DWORD Cbuf_Execute_jump;
|
||||
extern DWORD ExecuteString_call;
|
||||
extern DWORD ExecuteString_jump;
|
||||
extern void Cbuf_AddText_CallHook_Ext(char *text);
|
||||
extern void Cbuf_Execute_CallHook_Ext();
|
||||
extern void(*Cbuf_Execute)();
|
||||
extern void(*Cbuf_AddText)(char *text);
|
||||
|
||||
extern pfnEngineMessage pSVC_VoiceInit;
|
||||
extern pfnEngineMessage pSVC_StuffText;
|
||||
|
@ -463,125 +463,12 @@ memcpy(pData, &revEmuTicket, sizeof(revEmuTicket));
|
||||
return sizeof(revEmuTicket);
|
||||
}
|
||||
|
||||
|
||||
__declspec(naked) void Cbuf_Execute_CallHook()
|
||||
{
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
__asm SUB ESP, 400h
|
||||
__asm JMP[Cbuf_Execute_jump]
|
||||
}
|
||||
|
||||
void Cbuf_Execute_CallHook_Ext()
|
||||
{
|
||||
Cbuf_Execute_CallHook();
|
||||
}
|
||||
|
||||
|
||||
__declspec(naked) void Cbuf_AddText_CallHook(char *text)
|
||||
{
|
||||
//MessageBox(NULL, text, NULL, MB_OK);
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
__asm PUSH ESI
|
||||
__asm MOV ESI, [EBP + 0x8]
|
||||
__asm JMP[Cbuf_Addtext_jump]
|
||||
/*MessageBox(NULL, text, NULL, MB_OK);*/
|
||||
}
|
||||
|
||||
void Cbuf_AddText_CallHook_Ext(char *text)
|
||||
{
|
||||
Cbuf_AddText_CallHook(text);
|
||||
}
|
||||
|
||||
void CL_ReadDemoMessage_OLD_Cbuf_AddText_CallHook(const char *str){
|
||||
// Add your filters there
|
||||
|
||||
//MessagePrintf("Demo tried to execute: %s", str);
|
||||
}
|
||||
|
||||
//void (*Original_ExecuteString)(char *text, cmd_source_t src);
|
||||
/*
|
||||
void __cdecl Cmd_ExecuteString_CallHook(char *text, cmd_source_t src)
|
||||
{
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
__asm MOV ECX, [EBP + 8]
|
||||
__asm MOV EAX, [EBP + 0Ch]
|
||||
__asm PUSH ESI
|
||||
__asm JMP [Original_ExecuteString]
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void Cmd_ExecuteString_CallHook(char *text, cmd_source_t src)
|
||||
{
|
||||
char * lox;
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
//__asm MOV ECX, DWORD PTR SS : [EBP + 0x8]
|
||||
__asm MOV ECX, [EBP + 0x8]
|
||||
__asm MOV EAX, [EBP + 0xC]
|
||||
__asm { MOV ECX, lox }
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << "1 " << lox;
|
||||
MessageBox(0, stream.str().c_str(), 0, MB_OK);
|
||||
}
|
||||
__asm PUSH ESI
|
||||
__asm JMP[Original_ExecuteString]
|
||||
}
|
||||
*/
|
||||
//void Cmd_ExecuteString_CallHook(char *text, cmd_source_t src)
|
||||
//__declspec(naked) void WINAPI Cmd_ExecuteString_CallHook()
|
||||
/*__declspec(naked) void Cmd_ExecuteString_CallHook()
|
||||
{
|
||||
__asm PUSH EBP
|
||||
__asm call ExecuteString
|
||||
__asm MOV EBP, ESP
|
||||
__asm MOV ECX, [EBP + 0x8]
|
||||
__asm MOV EAX, [EBP + 0xC]
|
||||
__asm JMP[Original_ExecuteString]
|
||||
}*/
|
||||
/*
|
||||
__declspec(naked) void Cmd_ExecuteString_CallHook()
|
||||
{
|
||||
static char *text; cmd_source_t src;
|
||||
__asm MOV text, ECX
|
||||
__asm MOV src, EAX
|
||||
ExecuteString(text, src);
|
||||
__asm PUSH EBP
|
||||
__asm MOV EBP, ESP
|
||||
__asm MOV ECX, [EBP + 0x8]
|
||||
__asm MOV EAX, [EBP + 0xC]
|
||||
__asm JMP[Original_ExecuteString]
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// good func #2
|
||||
__declspec(naked) void Cmd_ExecuteString_CallHook()
|
||||
{
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
PUSH EAX
|
||||
PUSH ECX
|
||||
call ExecuteString
|
||||
POP ECX
|
||||
POP EAX
|
||||
POP EBP
|
||||
}
|
||||
__asm {
|
||||
PUSH EBP
|
||||
MOV EBP, ESP
|
||||
MOV ECX, [EBP + 0x8]
|
||||
MOV EAX, [EBP + 0xC]
|
||||
jmp[Original_ExecuteString]
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void CL_ConnectionlessPacket_Cbuf_AddText_CallHook(const char *str){
|
||||
// Add your filters there
|
||||
//ConsolePrintColor(0, 255, 0, "Server tried to execute via connectionless: %s", str);
|
||||
@ -609,7 +496,6 @@ void ModuleLoaded() {
|
||||
ptr = pModule->FindFirstUseOfString("Error, bad server command %s\n");
|
||||
ptr = pModule->SearchUpForBinaryPattern(ptr, BinaryPattern("E8 ?? ?? ?? ?? 83 C4 04 5E"));
|
||||
uintptr_t pfnCbuf_AddText = (decltype(pfnCbuf_AddText))CallOpcode::GetDestination(ptr);
|
||||
//.data:01E55198 00000006 C quit\n
|
||||
{
|
||||
ptr = pModule->FindFirstUseOfString("connect local");
|
||||
ptr += sizeof(uintptr_t);
|
||||
@ -620,22 +506,14 @@ void ModuleLoaded() {
|
||||
{
|
||||
ptr = pModule->FindFirstUseOfString("exec config.cfg\n");
|
||||
ptr += sizeof(uintptr_t);
|
||||
Cbuf_Addtext_call = (uintptr_t)CallOpcode::GetDestination(ptr);
|
||||
Cbuf_AddText = (decltype(Cbuf_AddText))(uintptr_t)CallOpcode::GetDestination(ptr);
|
||||
{
|
||||
std::stringstream stream;
|
||||
ptr += 0xf;
|
||||
Cbuf_Execute_call = (uintptr_t)CallOpcode::GetDestination(ptr);
|
||||
stream << " LEL " << std::hex << Cbuf_Execute_call << " \n";
|
||||
Cbuf_Execute_jump = Cbuf_Execute_call + 0x9;
|
||||
//MessageBox(NULL, stream.str().c_str(), NULL, MB_OK);
|
||||
JmpOpcode::Setup(Cbuf_Execute_call, (DWORD)&Cbuf_Execute_CallHook);
|
||||
Cbuf_Execute = (decltype(Cbuf_Execute))(uintptr_t)CallOpcode::GetDestination(ptr);
|
||||
}
|
||||
Cbuf_Addtext_jump = Cbuf_Addtext_call + 0x7;
|
||||
JmpOpcode::Setup(Cbuf_Addtext_call, (DWORD)&Cbuf_AddText_CallHook);
|
||||
|
||||
|
||||
}
|
||||
//CallOpcode::SetDestination(ptr, &Cmd_ExecuteString_CallHook);
|
||||
//PlaceJMP((BYTE*)ptr, (DWORD)&Cmd_ExecuteString_CallHook, 0x9);
|
||||
//JmpOpcode::Setup(ptr, (DWORD)&Cmd_ExecuteString_CallHook);
|
||||
ptr = pModule->FindFirstUseOfString("Tried to read a demo message with no demo file\n");
|
||||
ptr = pModule->SearchDownForFirstCallToFunction(ptr, pfnCbuf_AddText);
|
||||
CallOpcode::SetDestination(ptr, &CL_ReadDemoMessage_OLD_Cbuf_AddText_CallHook);
|
||||
@ -659,7 +537,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved){
|
||||
TCHAR sFileName[MAX_PATH];
|
||||
StringCchCopyN(sFileName, ARRAYSIZE(sFileName), lpFileName, lpExtension - lpFileName);
|
||||
|
||||
bool fPrefixDetected = true;
|
||||
// debug no rename extramirror
|
||||
//bool fPrefixDetected = true;
|
||||
bool fPrefixDetected = false;
|
||||
for (PTCHAR pch = sFileName; *pch != '\0'; pch++) {
|
||||
if (*pch == 'm') {
|
||||
fPrefixDetected = true;
|
||||
|
@ -1,11 +1,6 @@
|
||||
#ifndef EASYHOOK_HPP
|
||||
#define EASYHOOK_HPP
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
#include <winternl.h>
|
||||
|
||||
#include "main.h"
|
||||
/* This macro creates the type, an instance of the type, and a prologue object specific to that function */
|
||||
#define HOOKINIT(functor_type, function, trampoline_name, prologue_name) \
|
||||
using functor_type = decltype(&function); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user