Storm/Entry_Point.cpp

316 lines
12 KiB
C++
Raw Normal View History

2024-04-04 03:17:09 +08:00
#include <Windows.h>
#include <TlHelp32.h>
#include <cstdio>
#include "Byte_Manager/Byte_Manager.hpp"
#include "Redirection_Manager/Redirection_Manager.hpp"
void* Engine_Module;
#include "Extended_Interface.hpp"
void* Client_Module;
#include "Post_Network_Data_Received.hpp"
#include "Set_Move_Type.hpp"
2024-04-04 03:17:09 +08:00
#include "Interpolate.hpp"
2024-10-07 03:45:39 +08:00
#include "Update_Animations.hpp"
2024-04-04 03:17:09 +08:00
#include <unordered_set>
2024-10-07 03:45:39 +08:00
#include <unordered_map>
2024-04-04 03:17:09 +08:00
#include "Estimate_Velocity.hpp"
#include "Spawn_Grenade.hpp"
2024-10-07 03:45:39 +08:00
#include "Update.hpp"
2024-04-04 03:17:09 +08:00
#include "Run_Command.hpp"
2024-10-07 03:45:39 +08:00
#include "Process_Movement.hpp"
2024-04-04 03:17:09 +08:00
#include "Play_Footstep_Sound.hpp"
#include <algorithm>
#include "Finish_Move.hpp"
#include "Item_Post_Frame.hpp"
#include "Perform_Trace.hpp"
#include "Perform_Shove_Trace.hpp"
#include "Read_Packets.hpp"
#include "Move.hpp"
2024-10-07 03:45:39 +08:00
#include "Send_Move.hpp"
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
#include <vector>
2024-04-04 03:17:09 +08:00
#include "Copy_Command.hpp"
#include "Calculate_View.hpp"
#include "Draw_Effect.hpp"
#include "Write_Texture.hpp"
#include "Paint.hpp"
#include "Get_Glow_Color.hpp"
#include "Draw_Crosshair.hpp"
__int32 __stdcall DllMain(HMODULE This_Module, unsigned __int32 Call_Reason, void* Reserved)
{
if (Call_Reason == DLL_PROCESS_DETACH)
{
__fastfail(EXIT_SUCCESS);
}
else
{
if (Call_Reason == DLL_PROCESS_ATTACH)
{
if (GetModuleHandleW(L"left4dead2.exe") == nullptr)
{
void* Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32W Snapshot_Entry;
Snapshot_Entry.dwSize = sizeof(Snapshot_Entry);
Traverse_Snapshot_Label:
{
if (Process32NextW(Snapshot, &Snapshot_Entry) == 0)
{
return 1;
}
if (wcscmp(Snapshot_Entry.szExeFile, L"left4dead2.exe") != 0)
{
goto Traverse_Snapshot_Label;
}
}
void* Process = OpenProcess(PROCESS_ALL_ACCESS, 0, Snapshot_Entry.th32ProcessID);
void* Remote_Path = VirtualAllocEx(Process, nullptr, 1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
wchar_t Local_Path[MAX_PATH];
GetModuleFileNameW(This_Module, Local_Path, sizeof(Local_Path));
WriteProcessMemory(Process, Remote_Path, Local_Path, sizeof(Local_Path), nullptr);
WaitForSingleObject(CreateRemoteThread(Process, nullptr, 0, (LPTHREAD_START_ROUTINE)LoadLibraryW, Remote_Path, 0, nullptr), INFINITE);
VirtualFreeEx(Process, Remote_Path, 0, MEM_RELEASE);
}
else
{
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)LoadLibraryW(L"vaudio_speex.dll") + 9440), 1, 195);
2024-04-04 03:17:09 +08:00
AllocConsole();
SetConsoleTitleW(L"Storm");
_wfreopen(L"CONOUT$", L"w", stdout);
SetConsoleOutputCP(65001);
HANDLE Standard_Output_Handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX Console_Font_Information;
Console_Font_Information.cbSize = sizeof(CONSOLE_FONT_INFOEX);
Console_Font_Information.nFont = 0;
Console_Font_Information.dwFontSize.X = 0;
Console_Font_Information.dwFontSize.Y = 12;
Console_Font_Information.FontFamily = FF_DONTCARE;
Console_Font_Information.FontWeight = FW_NORMAL;
wcscpy(Console_Font_Information.FaceName, L"Terminal");
SetCurrentConsoleFontEx(Standard_Output_Handle, 0, &Console_Font_Information);
CONSOLE_CURSOR_INFO Console_Cursor_Information;
Console_Cursor_Information.bVisible = 0;
Console_Cursor_Information.dwSize = sizeof(Console_Cursor_Information);
SetConsoleTextAttribute(Standard_Output_Handle, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE);
SetConsoleCursorInfo(Standard_Output_Handle, &Console_Cursor_Information);
CONSOLE_SCREEN_BUFFER_INFO Console_Screen_Buffer_Information;
GetConsoleScreenBufferInfo(Standard_Output_Handle, &Console_Screen_Buffer_Information);
2024-11-09 22:36:57 +08:00
COORD Top_Left = { };
2024-04-04 03:17:09 +08:00
2024-11-09 22:36:57 +08:00
DWORD Characters_Written;
2024-04-04 03:17:09 +08:00
2024-11-09 22:36:57 +08:00
FillConsoleOutputAttribute(Standard_Output_Handle, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE, Console_Screen_Buffer_Information.dwSize.X * Console_Screen_Buffer_Information.dwSize.Y, Top_Left, &Characters_Written);
2024-04-04 03:17:09 +08:00
Engine_Module = GetModuleHandleW(L"engine.dll");
_putws(L"[ + ] Extend Interface");
{
Implement_Extended_Interface();
}
Client_Module = GetModuleHandleW(L"client.dll");
_putws(L"[ + ] Events");
{
2024-11-09 20:31:28 +08:00
Original_Post_Network_Data_Received_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 1555264), (void*)Redirected_Post_Network_Data_Received);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 316816), 1, 195);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Engine_Module + 350575), 1, 94);
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Engine_Module + 521741), 1, 235);
*(void**)((unsigned __int32)Client_Module + 7492840) = (void*)Redirected_Set_Move_Type;
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Interpolation");
{
2024-11-09 20:31:28 +08:00
Original_Interpolate_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 214256), (void*)Redirected_Interpolate);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Animations");
{
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 205296), (void*)Redirected_Update_Animations);
2024-11-09 20:31:28 +08:00
Original_Estimate_Velocity_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 311856), (void*)Redirected_Estimate_Velocity);
2024-04-04 03:17:09 +08:00
unsigned __int8 Maintain_Sequence_Transitions_Bytes[3] = { 194, 24, 0 };
2024-11-09 20:31:28 +08:00
Byte_Manager::Copy_Bytes(0, (void*)((unsigned __int32)Client_Module + 245232), sizeof(Maintain_Sequence_Transitions_Bytes), Maintain_Sequence_Transitions_Bytes);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 3244278), 1, 15);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Prediction");
{
auto Add_Prediction_Fields = [](Prediction_Descriptor_Structure* Descriptor, Prediction_Field_Structure* Fields, __int32 Size) -> void
{
Prediction_Descriptor_Structure* Original_Descriptor = (Prediction_Descriptor_Structure*)malloc(sizeof(Prediction_Descriptor_Structure));
2024-11-09 20:31:28 +08:00
Byte_Manager::Copy_Bytes(1, Original_Descriptor, sizeof(Prediction_Descriptor_Structure), Descriptor);
Descriptor->Fields = Fields;
2024-04-04 03:17:09 +08:00
Descriptor->Size = Size;
2024-04-04 03:17:09 +08:00
Descriptor->Parent = Original_Descriptor;
};
2024-04-04 03:17:09 +08:00
static Prediction_Field_Structure Player_Fields = { 5, (char*)(*(unsigned __int32*)((unsigned __int32)GetModuleHandleW(L"vphysics.dll") + 1701868) + 2226), 16, 1, { }, sizeof(__int32) };
2024-04-04 03:17:09 +08:00
Add_Prediction_Fields((Prediction_Descriptor_Structure*)((unsigned __int32)Client_Module + 7236480), &Player_Fields, sizeof(Player_Fields) / sizeof(Prediction_Field_Structure));
2024-04-04 03:17:09 +08:00
static Prediction_Field_Structure Weapon_Fields = { 1, (char*)"m_fMaxSpread", 3340, 1, { }, sizeof(float) };
2024-04-04 03:17:09 +08:00
Add_Prediction_Fields((Prediction_Descriptor_Structure*)((unsigned __int32)Client_Module + 7290836), &Weapon_Fields, sizeof(Weapon_Fields) / sizeof(Prediction_Field_Structure));
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Spawn_Grenade_Caller = Redirection_Manager::Redirect_Function(2, (void*)((unsigned __int32)Client_Module + 2227424), (void*)Redirected_Spawn_Grenade);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Update_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 1554304), (void*)Redirected_Update);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 1554528), 1, 235);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 1557776), 1, 235);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Run_Command_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 1553504), (void*)Redirected_Run_Command);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Process_Movement_Caller = Redirection_Manager::Redirect_Function(2, (void*)((unsigned __int32)Client_Module + 2590832), (void*)Redirected_Process_Movement);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Play_Footstep_Sound_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 978464), (void*)Redirected_Play_Footstep_Sound);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Finish_Move_Caller = Redirection_Manager::Redirect_Function(2, (void*)((unsigned __int32)Client_Module + 1553264), (void*)Redirected_Finish_Move);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Item_Post_Frame_Caller = Redirection_Manager::Redirect_Function(3, (void*)((unsigned __int32)Client_Module + 2542896), (void*)Redirected_Item_Post_Frame);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
*(__int32*)((unsigned __int32)Original_Item_Post_Frame_Caller + 5) = (__int32)((unsigned __int32)Client_Module + 2438551) - (__int32)Original_Item_Post_Frame_Caller;
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Perform_Trace_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 3093744), (void*)Redirected_Perform_Trace);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
Original_Perform_Shove_Trace_Caller = (void*)((unsigned __int32)Client_Module + 3221111);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 3221102), (void*)Redirected_Perform_Shove_Trace);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Network");
{
2024-11-09 20:31:28 +08:00
Original_Read_Packets_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Engine_Module + 499264), (void*)Redirected_Read_Packets);
2024-10-07 03:45:39 +08:00
2024-11-09 20:31:28 +08:00
Original_Move_Caller = Redirection_Manager::Redirect_Function(3, (void*)((unsigned __int32)Engine_Module + 512288), (void*)Redirected_Move);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Engine_Module + 511680), (void*)Redirected_Send_Move);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Input");
{
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 1250629), 3, 144);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 417204), 1, 235);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Copy_Command_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 1094624), (void*)Redirected_Copy_Command);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Effects");
{
2024-11-09 20:31:28 +08:00
Original_Calculate_View_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 132944), (void*)Redirected_Calculate_View);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 133424), 1, 235);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 2881566), 1, 246);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Draw_Effect_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)Client_Module + 1425888), (void*)Redirected_Draw_Effect);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 1868237), 1, 52);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 2655546), 1, 216);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
*(void**)((unsigned __int32)Client_Module + 8115120) = (void*)((unsigned __int32)Client_Module + 955708);
2024-04-04 03:17:09 +08:00
}
_putws(L"[ + ] Paint");
{
2024-11-09 20:31:28 +08:00
Original_Write_Texture_Caller = Redirection_Manager::Redirect_Function(0, (void*)((unsigned __int32)GetModuleHandleW(L"vguimatsurface.dll") + 100592), (void*)Redirected_Write_Texture);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 2913504), (void*)Redirected_Paint);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Original_Get_Glow_Color_Caller = Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 2455600), (void*)Redirected_Get_Glow_Color);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 3244715), 1, 49);
2024-10-25 13:12:24 +08:00
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 2301184), (void*)Redirected_Draw_Crosshair);
2024-04-04 03:17:09 +08:00
2024-11-09 20:31:28 +08:00
Byte_Manager::Set_Bytes(0, (void*)((unsigned __int32)Client_Module + 2930985), 1, 235);
2024-04-04 03:17:09 +08:00
2024-10-07 03:45:39 +08:00
Redirection_Manager::Redirect_Function(1, (void*)((unsigned __int32)Client_Module + 3118720), (void*)Redirected_Draw_Crosshair);
2024-04-04 03:17:09 +08:00
}
}
}
}
return 1;
}