Feeder.
This commit is contained in:
parent
6584d06109
commit
2473ce8119
3
.gitignore
vendored
3
.gitignore
vendored
@ -56,8 +56,7 @@ Temporary Items
|
||||
*.suo
|
||||
|
||||
# Additional stuff
|
||||
Release
|
||||
iw4/Release
|
||||
Normal
|
||||
|
||||
# IDA
|
||||
# =========================
|
||||
|
6
iw4.sln
6
iw4.sln
@ -7,11 +7,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iw4", "iw4\iw4.vcxproj", "{
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
Normal|Win32 = Normal|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{38B4FC13-CEBC-4099-8698-3E62943C1EAA}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{38B4FC13-CEBC-4099-8698-3E62943C1EAA}.Release|Win32.Build.0 = Release|Win32
|
||||
{38B4FC13-CEBC-4099-8698-3E62943C1EAA}.Normal|Win32.ActiveCfg = Normal|Win32
|
||||
{38B4FC13-CEBC-4099-8698-3E62943C1EAA}.Normal|Win32.Build.0 = Normal|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
287
iw4/Components/Feeder.cpp
Normal file
287
iw4/Components/Feeder.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
#include "..\STDInclude.hpp"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Feeder::Container Feeder::Current;
|
||||
std::map<float, Feeder::Callbacks> Feeder::Feeders;
|
||||
|
||||
void Feeder::Add(float feeder, Feeder::GetItemCount_t itemCountCb, Feeder::GetItemText_t itemTextCb, Feeder::Select_t selectCb)
|
||||
{
|
||||
Feeder::Feeders[feeder] = { itemCountCb, itemTextCb, selectCb };
|
||||
}
|
||||
|
||||
const char* Feeder::GetItemText()
|
||||
{
|
||||
if (Feeder::Feeders.find(Feeder::Current.Num) != Feeder::Feeders.end())
|
||||
{
|
||||
return Feeder::Feeders[Feeder::Current.Num].GetItemText(Feeder::Current.Index, Feeder::Current.Column);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Feeder::GetItemCount()
|
||||
{
|
||||
if (Feeder::Feeders.find(Feeder::Current.Num) != Feeder::Feeders.end())
|
||||
{
|
||||
return Feeder::Feeders[Feeder::Current.Num].GetItemCount();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Feeder::SetItemSelection()
|
||||
{
|
||||
if (Feeder::Feeders.find(Feeder::Current.Num) != Feeder::Feeders.end())
|
||||
{
|
||||
Feeder::Feeders[Feeder::Current.Num].Select(Feeder::Current.Index);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Feeder::CheckFeeder()
|
||||
{
|
||||
if (Feeder::Current.Num == 15.0f) return false;
|
||||
return (Feeder::Feeders.find(Feeder::Current.Num) != Feeder::Feeders.end());
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::SetItemSelectionStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [esp + 08h]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
mov eax, [esp + 0Ch]
|
||||
mov Feeder::Current.Index, eax
|
||||
|
||||
call Feeder::SetItemSelection
|
||||
|
||||
test eax, eax
|
||||
jz continue
|
||||
|
||||
retn
|
||||
|
||||
continue:
|
||||
fld ds : 739FD0h
|
||||
|
||||
mov eax, 4C25D6h
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::GetItemTextStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [esp + 0Ch]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
mov eax, [esp + 10h]
|
||||
mov Feeder::Current.Index, eax
|
||||
|
||||
mov eax, [esp + 14h]
|
||||
mov Feeder::Current.Column, eax
|
||||
|
||||
call Feeder::GetItemText
|
||||
|
||||
test eax, eax
|
||||
jz continue
|
||||
|
||||
push ebx
|
||||
mov ebx, [esp + 4 + 28h]
|
||||
mov dword ptr[ebx], 0
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
continue:
|
||||
push ecx
|
||||
fld ds:739FD0h
|
||||
|
||||
mov eax, 4CE9E7h
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::GetItemCountStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [esp + 8h]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
call Feeder::GetItemCount
|
||||
|
||||
test eax, eax
|
||||
jz continue
|
||||
|
||||
retn
|
||||
|
||||
continue:
|
||||
push ecx
|
||||
fld ds:739FD0h
|
||||
|
||||
mov eax, 41A0D7h
|
||||
jmp eax;
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::HandleKeyStub()
|
||||
{
|
||||
static int NextClickTime = 0;
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ebx, ebp
|
||||
mov eax, [ebp + 12Ch]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
push ebx
|
||||
call Feeder::CheckFeeder
|
||||
pop ebx
|
||||
|
||||
test eax, eax
|
||||
jz continueOriginal
|
||||
|
||||
// Get current milliseconds
|
||||
call Game::Com_Milliseconds
|
||||
|
||||
// Check if allowed to click
|
||||
cmp eax, NextClickTime
|
||||
jl continueOriginal
|
||||
|
||||
// Set next allowed click time to current time + 300ms
|
||||
add eax, 300
|
||||
mov NextClickTime, eax
|
||||
|
||||
// Get item cursor position ptr
|
||||
mov ecx, ebx
|
||||
add ecx, Game::itemDef_t::cursorPos
|
||||
|
||||
// Get item listbox ptr
|
||||
mov edx, ebx
|
||||
add edx, Game::itemDef_t::typeData
|
||||
|
||||
// Get listbox cursor pos
|
||||
mov edx, [edx]
|
||||
add edx, Game::listBoxDef_s::startPos
|
||||
mov edx, [edx]
|
||||
|
||||
// Resolve item cursor pos pointer
|
||||
mov ebx, [ecx]
|
||||
|
||||
// Check if item cursor pos equals listbox cursor pos
|
||||
cmp ebx, edx
|
||||
je returnSafe
|
||||
|
||||
// Update indices if not
|
||||
mov [ecx], edx
|
||||
mov Feeder::Current.Index, edx
|
||||
|
||||
call Feeder::SetItemSelection
|
||||
|
||||
returnSafe:
|
||||
retn
|
||||
|
||||
continueOriginal:
|
||||
mov eax, 635570h
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::MouseEnterStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [edi + 12Ch]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
call Feeder::CheckFeeder
|
||||
|
||||
test eax, eax
|
||||
jnz continue
|
||||
|
||||
mov[edi + 130h], esi
|
||||
|
||||
continue:
|
||||
mov eax, 639D75h
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::MouseSelectStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [esp + 08h]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
call Feeder::CheckFeeder
|
||||
|
||||
test eax, eax
|
||||
jnz continue
|
||||
|
||||
mov eax, 4C25D0h
|
||||
jmp eax
|
||||
|
||||
continue:
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void __declspec(naked) Feeder::PlaySoundStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, [edi + 12Ch]
|
||||
mov Feeder::Current.Num, eax
|
||||
|
||||
call Feeder::CheckFeeder
|
||||
|
||||
test eax, eax
|
||||
jnz continue
|
||||
|
||||
mov eax, 685E10h
|
||||
jmp eax
|
||||
|
||||
continue:
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
Feeder::Feeder()
|
||||
{
|
||||
// Get feeder item count
|
||||
Utils::Hook(0x41A0D0, Feeder::GetItemCountStub, HOOK_JUMP).Install()->Quick();
|
||||
|
||||
// Get feeder item text
|
||||
Utils::Hook(0x4CE9E0, Feeder::GetItemTextStub, HOOK_JUMP).Install()->Quick();
|
||||
|
||||
// Select feeder item
|
||||
Utils::Hook(0x4C25D0, Feeder::SetItemSelectionStub, HOOK_JUMP).Install()->Quick();
|
||||
|
||||
// Mouse enter check
|
||||
Utils::Hook(0x639D6E, Feeder::MouseEnterStub, HOOK_JUMP).Install()->Quick();
|
||||
|
||||
// Handle key event
|
||||
Utils::Hook(0x63C5BC, Feeder::HandleKeyStub, HOOK_CALL).Install()->Quick();
|
||||
|
||||
// Mouse select check
|
||||
Utils::Hook(0x639D31, Feeder::MouseSelectStub, HOOK_CALL).Install()->Quick();
|
||||
|
||||
// Play mouse over sound check
|
||||
Utils::Hook(0x639D66, Feeder::PlaySoundStub, HOOK_CALL).Install()->Quick();
|
||||
|
||||
// some thing overwriting feeder 2's data
|
||||
Utils::Hook::Set<BYTE>(0x4A06A9, 0xEB);
|
||||
|
||||
Feeder::Add(2.0f, [] () { return 10; }, [] (int index, int column) { return Utils::VA("%d : %d", index, column); }, [] (int index){});
|
||||
}
|
||||
|
||||
Feeder::~Feeder()
|
||||
{
|
||||
Feeder::Feeders.clear();
|
||||
}
|
||||
}
|
51
iw4/Components/Feeder.hpp
Normal file
51
iw4/Components/Feeder.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
namespace Components
|
||||
{
|
||||
class Feeder : public Component
|
||||
{
|
||||
public:
|
||||
typedef int(__cdecl * GetItemCount_t)();
|
||||
typedef const char* (__cdecl * GetItemText_t)(int index, int column);
|
||||
typedef void(__cdecl * Select_t)(int index);
|
||||
|
||||
struct Callbacks
|
||||
{
|
||||
GetItemCount_t GetItemCount;
|
||||
GetItemText_t GetItemText;
|
||||
Select_t Select;
|
||||
};
|
||||
|
||||
Feeder();
|
||||
~Feeder();
|
||||
const char* GetName() { return "Feeder"; };
|
||||
|
||||
static void Add(float feeder, GetItemCount_t itemCountCb, GetItemText_t itemTextCb, Select_t selectCb);
|
||||
|
||||
private:
|
||||
struct Container
|
||||
{
|
||||
float Num;
|
||||
int Index;
|
||||
int Column;
|
||||
};
|
||||
|
||||
static Container Current;
|
||||
|
||||
static void GetItemCountStub();
|
||||
static int GetItemCount();
|
||||
|
||||
static void GetItemTextStub();
|
||||
static const char* GetItemText();
|
||||
|
||||
static void SetItemSelectionStub();
|
||||
static bool SetItemSelection();
|
||||
|
||||
static bool CheckFeeder();
|
||||
|
||||
static void MouseEnterStub();
|
||||
static void MouseSelectStub();
|
||||
static void HandleKeyStub();
|
||||
static void PlaySoundStub();
|
||||
|
||||
static std::map<float, Callbacks> Feeders;
|
||||
};
|
||||
}
|
@ -13,6 +13,7 @@ namespace Components
|
||||
Loader::Register(new Menus());
|
||||
Loader::Register(new Party());
|
||||
Loader::Register(new Colors());
|
||||
Loader::Register(new Feeder());
|
||||
Loader::Register(new Logger());
|
||||
Loader::Register(new Window());
|
||||
Loader::Register(new Command());
|
||||
|
@ -24,6 +24,7 @@ namespace Components
|
||||
#include "Maps.hpp"
|
||||
#include "Menus.hpp"
|
||||
#include "Colors.hpp"
|
||||
#include "Feeder.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "Window.hpp"
|
||||
#include "Command.hpp"
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<ProjectConfiguration Include="Normal|Win32">
|
||||
<Configuration>Normal</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
@ -12,7 +12,7 @@
|
||||
<RootNamespace>iw4</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
@ -22,15 +22,17 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>iw4m</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Configuration)\Bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)$(Configuration)\Obj\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
@ -59,6 +61,7 @@
|
||||
<ClInclude Include="Components\Dedicated.hpp" />
|
||||
<ClInclude Include="Components\Dvar.hpp" />
|
||||
<ClInclude Include="Components\FastFiles.hpp" />
|
||||
<ClInclude Include="Components\Feeder.hpp" />
|
||||
<ClInclude Include="Components\FileSystem.hpp" />
|
||||
<ClInclude Include="Components\Loader.hpp" />
|
||||
<ClInclude Include="Components\Localization.hpp" />
|
||||
@ -97,6 +100,7 @@
|
||||
<ClCompile Include="Components\Dedicated.cpp" />
|
||||
<ClCompile Include="Components\Dvar.cpp" />
|
||||
<ClCompile Include="Components\FastFiles.cpp" />
|
||||
<ClCompile Include="Components\Feeder.cpp" />
|
||||
<ClCompile Include="Components\FileSystem.cpp" />
|
||||
<ClCompile Include="Components\Loader.cpp" />
|
||||
<ClCompile Include="Components\Localization.cpp" />
|
||||
@ -123,8 +127,8 @@
|
||||
<ClCompile Include="Steam\Interfaces\SteamUser.cpp" />
|
||||
<ClCompile Include="Steam\Interfaces\SteamUtils.cpp" />
|
||||
<ClCompile Include="Main.cpp">
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils\Hooking.cpp" />
|
||||
|
@ -134,6 +134,9 @@
|
||||
<ClCompile Include="Components\Singleton.cpp">
|
||||
<Filter>Source\Components\Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Components\Feeder.cpp">
|
||||
<Filter>Source\Components\Modules</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Steam\Interfaces\SteamUser.hpp">
|
||||
@ -244,5 +247,8 @@
|
||||
<ClInclude Include="Components\Singleton.hpp">
|
||||
<Filter>Source\Components\Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Components\Feeder.hpp">
|
||||
<Filter>Source\Components\Modules</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Normal|Win32'">
|
||||
<LocalDebuggerCommand>iw4m.exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>D:\Games\SteamLibrary\steamapps\common\Call of Duty Modern Warfare 2\</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
|
Loading…
Reference in New Issue
Block a user