Bug fixes & new stuff

1. Fixed issue with radio scroll #45
2. Fixed crash with renderhook
3. Refactored code
4. Added option to control neon pulsing
5. Fixed a issue with huge crosshair when huge dmg is enabled
This commit is contained in:
Grinch_ 2021-01-08 03:07:45 +06:00
parent ff8a21eaf3
commit 2a6fdb1c72
17 changed files with 227 additions and 45 deletions

View File

@ -67,7 +67,13 @@
"*.def": "cpp", "*.def": "cpp",
"atomic": "cpp", "atomic": "cpp",
"compare": "cpp", "compare": "cpp",
"concepts": "cpp" "concepts": "cpp",
"charconv": "cpp",
"condition_variable": "cpp",
"mutex": "cpp",
"optional": "cpp",
"shared_mutex": "cpp",
"thread": "cpp"
}, },
"C_Cpp.errorSquiggles": "Enabled", "C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.intelliSenseEngineFallback": "Enabled" "C_Cpp.intelliSenseEngineFallback": "Enabled"

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR) cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PROJECT_NAME CheatMenu) set(PROJECT_NAME CheatMenu)
project(${PROJECT_NAME} CXX) project(${PROJECT_NAME} CXX)
@ -16,6 +16,7 @@ set(DIRECTX9_SDK_DIR $ENV{DIRECTX9_SDK_DIR})
# Required projects # Required projects
################################################################################ ################################################################################
add_subdirectory(src/vendor) add_subdirectory(src/vendor)
add_subdirectory(src/tests)
################################################################################ ################################################################################
# Source groups # Source groups

View File

@ -58,7 +58,7 @@ void Animation::Main()
if (ImGui::BeginChild("Anims Child")) if (ImGui::BeginChild("Anims Child"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawJSON(json, search_categories, selected_item, filter, &PlayAnimation, &RemoveEntry); Ui::DrawJSON(json, search_categories, selected_item, filter, &PlayAnimation, &RemoveAnimation);
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
@ -132,7 +132,7 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
Command<Commands::REMOVE_ANIMATION>(ifp.c_str()); Command<Commands::REMOVE_ANIMATION>(ifp.c_str());
} }
void Animation::RemoveEntry(std::string& ifp, std::string& anim, std::string& ifp_repeat) void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string& ifp_repeat)
{ {
flog << ifp << std::endl; flog << ifp << std::endl;
if (ifp == "Custom") if (ifp == "Custom")

View File

@ -10,16 +10,16 @@ private:
static std::vector<std::string> search_categories; static std::vector<std::string> search_categories;
static std::string selected_item; static std::string selected_item;
static char ifp_buffer[INPUT_BUFFER_SIZE];
static char anim_buffer[INPUT_BUFFER_SIZE]; static char anim_buffer[INPUT_BUFFER_SIZE];
static char ifp_buffer[INPUT_BUFFER_SIZE];
protected: protected:
Animation(); Animation();
~Animation() {}; ~Animation() {};
public: public:
static void Main(); static void Main();
static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp); static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
static void RemoveAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
static void RemoveEntry(std::string& rootkey, std::string& anim, std::string& ifp);
}; };

View File

@ -1,7 +1,9 @@
/* /*
Required: Required:
Visual Studio 2015.3 (v140) DirectX 9 SDK
Plugin SDK Plugin SDK
Visual Studio 2019 (v142)
Windows SDK
*/ */
#pragma once #pragma once
@ -50,7 +52,7 @@ public:
} }
/* /*
WndProc is extremely buggy without SilentPatch Mouse is extremely buggy without SilentPatch
Should have a better fix for this but everyone should have Should have a better fix for this but everyone should have
SilentPatch installed so mehh... SilentPatch installed so mehh...
*/ */

View File

@ -17,6 +17,14 @@ LRESULT Hook::InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{ {
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
if (Hook::show_mouse)
{
patch::Nop(0x4EB9F4, 5); // disable radio scroll
Call<0x541BD0>(); // CPad::ClearMouseHistory
}
else
patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable radio scroll
if (ImGui::GetIO().WantTextInput) if (ImGui::GetIO().WantTextInput)
{ {
Call<0x53F1E0>(); // CPad::ClearKeyboardHistory Call<0x53F1E0>(); // CPad::ClearKeyboardHistory
@ -24,7 +32,6 @@ LRESULT Hook::InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
} }
else else
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam); return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
} }
HRESULT Hook::ResetDx9(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters) HRESULT Hook::ResetDx9(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters)
@ -97,9 +104,11 @@ HRESULT Hook::PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Fl
if (Globals::init_done) if (Globals::init_done)
{ {
HRESULT hr = pSwapChain->Present(1, 0); if (mouse_visibility != show_mouse)
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
ImGui_ImplDX11_InvalidateDeviceObjects(); Hook::ShowMouse(show_mouse);
mouse_visibility = show_mouse;
}
// Change font size if the game resolution changes // Change font size if the game resolution changes
if (Globals::font_screen_size.x != screen::GetScreenWidth() if (Globals::font_screen_size.x != screen::GetScreenWidth()
@ -135,13 +144,13 @@ HRESULT Hook::PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Fl
DXGI_SWAP_CHAIN_DESC desc; DXGI_SWAP_CHAIN_DESC desc;
pSwapChain->GetDesc(&desc); pSwapChain->GetDesc(&desc);
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&Globals::device11); pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&Globals::device);
ID3D11DeviceContext* context; ID3D11DeviceContext* context;
Globals::device11->GetImmediateContext(&context); reinterpret_cast<ID3D11Device*>(Globals::device)->GetImmediateContext(&context);
ImGui::CreateContext(); ImGui::CreateContext();
ImGui_ImplWin32_Init(desc.OutputWindow); ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX11_Init(Globals::device11, context); ImGui_ImplDX11_Init(reinterpret_cast<ID3D11Device*>(Globals::device), context);
ImGui_ImplWin32_EnableDpiAwareness(); ImGui_ImplWin32_EnableDpiAwareness();
io.IniFilename = NULL; io.IniFilename = NULL;
@ -163,6 +172,7 @@ void Hook::ShowMouse(bool state)
patch::SetUChar(0x6194A0, 0xC3); patch::SetUChar(0x6194A0, 0xC3);
patch::Nop(0x53F417, 5); // don't call CPad__getMouseState patch::Nop(0x53F417, 5); // don't call CPad__getMouseState
patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement
//patch::Nop(0x4EB9F4, 5); // disable radio scroll
} }
else else
{ {
@ -171,6 +181,7 @@ void Hook::ShowMouse(bool state)
patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement
// jz loc_53F526 -> jl loc_53F526 // jz loc_53F526 -> jl loc_53F526
patch::SetUChar(0x6194A0, 0xE9); // jmp setup patch::SetUChar(0x6194A0, 0xE9); // jmp setup
//patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable radio scroll
} }
ImGui::GetIO().MouseDrawCursor = state; ImGui::GetIO().MouseDrawCursor = state;
@ -206,8 +217,6 @@ Hook::Hook()
Globals::renderer = Render_DirectX11; Globals::renderer = Render_DirectX11;
flog << "Successfully hooked dx11 device." << std::endl; flog << "Successfully hooked dx11 device." << std::endl;
} }
flog << "Successfully hooked dx11 device." << std::endl;
} }
else else
{ {

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION "2.5-beta" #define MENU_VERSION "2.5-beta"
#define BUILD_NUMBER "20210103" #define BUILD_NUMBER "20210108"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -30,17 +30,19 @@ NeonAPI::NeonAPI()
{ {
data->timer = CTimer::m_snTimeInMilliseconds; data->timer = CTimer::m_snTimeInMilliseconds;
if (data->val < 0.0f) if (data->pulsing)
{
if (data->val < 0.0f)
data->increment = true; data->increment = true;
if (data->val > 0.3f) if (data->val > 0.3f)
data->increment = false; data->increment = false;
if (data->increment)
data->val += 0.1f;
else
data->val -= 0.1f;
if (data->increment)
data->val += 0.1f;
else
data->val -= 0.1f;
}
} }
} }
}; };
@ -56,6 +58,16 @@ bool NeonAPI::IsNeonInstalled(CVehicle *pVeh)
return VehNeon.Get(pVeh).neon_installed; return VehNeon.Get(pVeh).neon_installed;
} }
bool NeonAPI::IsPulsingEnabled(CVehicle *pVeh)
{
return VehNeon.Get(pVeh).pulsing;
}
void NeonAPI::SetPulsing(CVehicle *pVeh, bool state)
{
VehNeon.Get(pVeh).pulsing = state;
}
void NeonAPI::InstallNeon(CVehicle *pVeh, int red, int green, int blue) void NeonAPI::InstallNeon(CVehicle *pVeh, int red, int green, int blue)
{ {
CRGBA &color = VehNeon.Get(pVeh).color; CRGBA &color = VehNeon.Get(pVeh).color;

View File

@ -12,6 +12,7 @@ private:
float val; float val;
uint timer; uint timer;
bool increment; bool increment;
bool pulsing;
NeonData(CVehicle *pVeh) NeonData(CVehicle *pVeh)
{ {
@ -29,6 +30,8 @@ public:
~NeonAPI(); ~NeonAPI();
static void InstallNeon(CVehicle *veh, int red, int green, int blue); static void InstallNeon(CVehicle *veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle *veh); static bool IsNeonInstalled(CVehicle *veh);
static bool IsPulsingEnabled(CVehicle *veh);
static void SetPulsing(CVehicle *veh, bool state);
static void RemoveNeon(CVehicle *veh); static void RemoveNeon(CVehicle *veh);
}; };

View File

@ -493,14 +493,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
&& (verify_func == nullptr || verify_func(text)) && (verify_func == nullptr || verify_func(text))
) )
{ {
void *texture = nullptr; if (ImGui::ImageButton(img_vec[i]->texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
if (Globals::renderer == Render_DirectX9)
texture = img_vec[i]->texture9;
else // consider 11
texture = img_vec[i]->texture11;
if (ImGui::ImageButton(texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
on_left_click(text); on_left_click(text);
if (ImGui::IsItemClicked(1) && on_right_click != nullptr) if (ImGui::IsItemClicked(1) && on_right_click != nullptr)

View File

@ -33,11 +33,11 @@ void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std
store_vec.push_back(std::make_unique<TextureStructure>()); store_vec.push_back(std::make_unique<TextureStructure>());
HRESULT hr = -1; HRESULT hr = -1;
if (Globals::renderer == Render_DirectX9) if (Globals::renderer == Render_DirectX9)
hr = D3DXCreateTextureFromFileA(GetD3DDevice(), p.path().string().c_str(), &store_vec.back().get()->texture9); hr = D3DXCreateTextureFromFileA(GetD3DDevice(), p.path().string().c_str(), reinterpret_cast<PDIRECT3DTEXTURE9*>(&store_vec.back().get()->texture));
if (Globals::renderer == Render_DirectX11) if (Globals::renderer == Render_DirectX11)
{ {
if (LoadTextureFromFileDx11(p.path().string().c_str(), &store_vec.back().get()->texture11)) if (LoadTextureFromFileDx11(p.path().string().c_str(), reinterpret_cast<ID3D11ShaderResourceView**>(&store_vec.back().get()->texture)))
hr = S_OK; hr = S_OK;
} }
@ -89,7 +89,7 @@ bool Util::LoadTextureFromFileDx11(const char* filename, ID3D11ShaderResourceVie
subResource.SysMemPitch = desc.Width * 4; subResource.SysMemPitch = desc.Width * 4;
subResource.SysMemSlicePitch = 0; subResource.SysMemSlicePitch = 0;
Globals::device11->CreateTexture2D(&desc, &subResource, &pTexture); reinterpret_cast<ID3D11Device*>(Globals::device)->CreateTexture2D(&desc, &subResource, &pTexture);
// Create texture view // Create texture view
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
@ -98,7 +98,7 @@ bool Util::LoadTextureFromFileDx11(const char* filename, ID3D11ShaderResourceVie
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = desc.MipLevels; srvDesc.Texture2D.MipLevels = desc.MipLevels;
srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MostDetailedMip = 0;
Globals::device11->CreateShaderResourceView(pTexture, &srvDesc, out_srv); reinterpret_cast<ID3D11Device*>(Globals::device)->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
pTexture->Release(); pTexture->Release();
stbi_image_free(image_data); stbi_image_free(image_data);

View File

@ -1043,6 +1043,11 @@ void Vehicle::Main()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(2, NULL, false); ImGui::Columns(2, NULL, false);
bool pulsing = NeonAPI::IsPulsingEnabled(veh);
if (Ui::CheckboxWithHint("Pulsing neons", &pulsing))
NeonAPI::SetPulsing(veh,pulsing);
Ui::CheckboxWithHint("Rainbow neons", &neon::rainbow, "Rainbow effect to neon lights"); Ui::CheckboxWithHint("Rainbow neons", &neon::rainbow, "Rainbow effect to neon lights");
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxWithHint("Traffic neons", &neon::traffic, "Adds neon lights to traffic vehicles.\n\ Ui::CheckboxWithHint("Traffic neons", &neon::traffic, "Adds neon lights to traffic vehicles.\n\

View File

@ -66,7 +66,7 @@ Weapon::Weapon()
CWeaponInfo *pweapon_info = CWeaponInfo::GetWeaponInfo(weapon_type, player->GetWeaponSkill(weapon_type)); CWeaponInfo *pweapon_info = CWeaponInfo::GetWeaponInfo(weapon_type, player->GetWeaponSkill(weapon_type));
if (huge_damage) if (huge_damage)
pweapon_info->m_nDamage = 5000; pweapon_info->m_nDamage = 1000;
if (long_range) if (long_range)
{ {

View File

@ -7,8 +7,8 @@ ImVec2 Globals::font_screen_size = ImVec2(-1, -1);
bool Globals::show_menu = false; bool Globals::show_menu = false;
bool Globals::init_done = false; bool Globals::init_done = false;
Renderer Globals::renderer = Render_Unknown; Renderer Globals::renderer = Render_Unknown;
ID3D11Device *Globals::device11 = nullptr;
bool Globals::gsync_time = false; bool Globals::gsync_time = false;
void *Globals::device = nullptr;
std::ofstream flog = std::ofstream("CheatMenu.log"); std::ofstream flog = std::ofstream("CheatMenu.log");
CJson config = CJson("config"); CJson config = CJson("config");

View File

@ -49,7 +49,7 @@
#include "extensions/ScriptCommands.h" #include "extensions/ScriptCommands.h"
#include "extensions/Screen.h" #include "extensions/Screen.h"
#include "eVehicleClass.h" #include "eVehicleClass.h"
#include "extensions\Paths.h" #include "extensions/Paths.h"
#include "vendor/imgui/imgui.h" #include "vendor/imgui/imgui.h"
#include "vendor/imgui/imgui_internal.h" #include "vendor/imgui/imgui_internal.h"
@ -86,16 +86,15 @@ struct Globals
static bool show_menu; static bool show_menu;
static bool init_done; static bool init_done;
static Renderer renderer; static Renderer renderer;
static ID3D11Device* device11;
static bool gsync_time; static bool gsync_time;
static void* device;
}; };
struct TextureStructure struct TextureStructure
{ {
std::string file_name; std::string file_name;
std::string category_name; std::string category_name;
PDIRECT3DTEXTURE9 texture9; void *texture = nullptr;
ID3D11ShaderResourceView* texture11;
}; };
extern CJson config; extern CJson config;

129
src/tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,129 @@
################################################################################
# Build Test.asi
# A testing plugin for the menu, recompiling the whole menu is tedious
################################################################################
cmake_minimum_required(VERSION 3.0)
project(Test)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} SHARED "Test.cpp")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${GTA_SA_DIR}/$<0:>/"
SUFFIX ".asi"
MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}
)
################################################################################
# Include directories
################################################################################
include_directories(
"${PLUGIN_SDK_DIR}/plugin_sa"
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa"
"${PLUGIN_SDK_DIR}/shared"
"${PLUGIN_SDK_DIR}/shared/game"
"${DIRECTX9_SDK_DIR}/include"
)
################################################################################
# Compile definitions
################################################################################
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Release>:"
"_NDEBUG"
">"
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"_CRT_SECURE_NO_WARNINGS;"
"_CRT_NON_CONFORMING_SWPRINTFS;"
"GTASA;"
"GTAGAME_NAME=\"San Andreas\";"
"GTAGAME_ABBR=\"SA\";"
"GTAGAME_ABBRLOW=\"sa\";"
"GTAGAME_PROTAGONISTNAME=\"CJ\";"
"GTAGAME_CITYNAME=\"San Andreas\";"
"_LA_SUPPORT;"
"_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;"
"_MBCS"
)
################################################################################
# Compile and link options
################################################################################
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy
>
$<$<CONFIG:Debug>:
/Od
/DEBUG:FULL
>
/std:c++latest;
/sdl-;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
/w44005
)
string(CONCAT FILE_CL_OPTIONS
"/Y-"
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/LTCG;
/OPT:ICF;
>
$<$<CONFIG:Debug>:
/DEBUG:FULL;
/SAFESEH:NO;
>
/SUBSYSTEM:WINDOWS
)
################################################################################
# Pre build events
################################################################################
add_custom_command(
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND taskkill /f /fi "imagename eq gta_sa.exe"
)
################################################################################
# Dependencies
################################################################################
target_link_libraries(${PROJECT_NAME} PUBLIC
optimized plugin
debug plugin_d
)
target_link_directories(${PROJECT_NAME} PUBLIC
"$ENV{PLUGIN_SDK_DIR}/output/lib/"
"$<$<CONFIG:Release>:"
"vendor/Release/"
">"
"$<$<CONFIG:Debug>:"
"vendor/Debug/"
">")
target_link_libraries(${PROJECT_NAME} PUBLIC
optimized plugin
debug plugin_d
)

23
src/tests/Test.cpp Normal file
View File

@ -0,0 +1,23 @@
#include "plugin.h"
using namespace plugin;
class Test
{
public:
Test()
{
Events::processScriptsEvent += []
{
if(KeyPressed(VK_UP))
{
patch::Nop(0x4EB9F4, 5); // disable
}
if(KeyPressed(VK_DOWN))
{
patch::SetRaw(0x4EB9F4, (void*)"\xE8\x67\xFC\xFF\xFF", 5); // enable
}
};
}
} test;