mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2025-05-30 23:19:17 +08:00
Sprint 1 (#10)
* feat(FileMgr/BaseObj): Added implicit path conversion Closes #9 * feat(Game/GTA): implemented script globals Closes #2 * fix(ScriptGlobal): code style * feat(Game/GTA): implement script locals Closes #3 * refactor: update namespace name Closes #8
This commit is contained in:
parent
84f912cb34
commit
1df9405203
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@ -75,7 +75,20 @@
|
||||
"span": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"xhash": "cpp",
|
||||
"filesystem": "cpp"
|
||||
"filesystem": "cpp",
|
||||
"any": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"future": "cpp",
|
||||
"map": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"regex": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp",
|
||||
"xtree": "cpp"
|
||||
},
|
||||
"C_Cpp.default.configurationProvider": "maxmitti.cmake-tools-fork"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include "common.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
std::atomic<bool> g_Running{true};
|
||||
HINSTANCE g_DllInstance{nullptr};
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace al;
|
||||
#include "core/logger/LogHelper.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "BaseObj.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
BaseObj::BaseObj(const std::filesystem::path& path) :
|
||||
m_Path(path)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class BaseObj
|
||||
{
|
||||
@ -11,6 +11,11 @@ namespace NewBase
|
||||
[[nodiscard]] bool Exists() const;
|
||||
const std::filesystem::path& Path() const;
|
||||
|
||||
operator std::filesystem::path() const
|
||||
{
|
||||
return m_Path;
|
||||
}
|
||||
|
||||
protected:
|
||||
const std::filesystem::path m_Path;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "File.hpp"
|
||||
#include "FileMgr.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
File::File(const std::filesystem::path& path) :
|
||||
BaseObj(path)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "BaseObj.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class File final : public BaseObj
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "File.hpp"
|
||||
#include "Folder.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
void FileMgr::Init(const std::filesystem::path& rootFolder)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "File.hpp"
|
||||
#include "Folder.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class FileMgr final
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "Folder.hpp"
|
||||
#include "FileMgr.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
Folder::Folder(const std::filesystem::path& path) :
|
||||
BaseObj(path)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "BaseObj.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class Folder final : public BaseObj
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <MinHook.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
BaseHook::BaseHook(const std::string_view name) :
|
||||
m_Name(name),
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class BaseHook
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <MinHook.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
template<typename T = int*>
|
||||
class DetourHook : public BaseHook
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "game/hooks/Hooks.hpp"
|
||||
#include "game/pointers/Pointers.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
Hooking::Hooking()
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "MinHook.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class Hooking
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "memory/Module.hpp"
|
||||
#include "memory/PointerCalculator.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
template<typename T = int*>
|
||||
class IATHook : public BaseHook
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <MinHook.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class MinHook
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
template<std::size_t N>
|
||||
class VMTHook : public BaseHook
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
enum class LogColor
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "LogSink.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
void LogHelper::Destroy()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
#define ADD_COLOR_TO_STREAM(color) "\x1b[" << int(color) << "m"
|
||||
#define RESET_STREAM_COLOR "\x1b[0m"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "LogColor.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
LogColor LogSink::GetColor(const eLogLevel level)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
using namespace al;
|
||||
enum class LogColor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "BytePatch.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
BytePatch::~BytePatch()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
template<typename T>
|
||||
concept SpanCompatibleType = requires(T a)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Module.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
Module::Module(LDR_DATA_TABLE_ENTRY* dllEntry) :
|
||||
m_Path(dllEntry->FullDllName.Buffer),
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <winternl.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class Module
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "util/Joaat.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
Module* ModuleMgr::Get(const std::string_view name)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Module.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
using joaat_t = std::uint32_t;
|
||||
|
||||
@ -31,5 +31,5 @@ namespace NewBase
|
||||
std::unordered_map<std::uint32_t, std::unique_ptr<Module>> m_CachedModules;
|
||||
};
|
||||
|
||||
inline NewBase::ModuleMgr ModuleMgr;
|
||||
inline YimMenu::ModuleMgr ModuleMgr;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
template<std::size_t N>
|
||||
struct Signature
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
PatternScanner::PatternScanner(const Module* module) :
|
||||
m_Module(module),
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class Module;
|
||||
using PatternFunc = std::function<void(PointerCalculator)>;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class PointerCalculator final
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <backends/imgui_impl_win32.h>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
Renderer::Renderer()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <map>
|
||||
#include <windows.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
using DXCallback = std::function<void()>;
|
||||
using WindowProcedureCallback = std::function<void(HWND, UINT, WPARAM, LPARAM)>;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "menu/Menu.hpp"
|
||||
#include "core/renderer/Renderer.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
GUI::GUI() :
|
||||
m_IsOpen(false)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
class GUI final
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Menu.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
void Menu::Main()
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "game/frontend/GUI.hpp"
|
||||
|
||||
namespace NewBase::Menu
|
||||
namespace YimMenu::Menu
|
||||
{
|
||||
extern void Main();
|
||||
}
|
10
src/game/gta/ScriptGlobal.cpp
Normal file
10
src/game/gta/ScriptGlobal.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "game/pointers/Pointers.hpp"
|
||||
#include "ScriptGlobal.hpp"
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
void* ScriptGlobal::Get() const
|
||||
{
|
||||
return Pointers.ScriptGlobals[m_Index >> 0x12 & 0x3F] + (m_Index & 0x3FFFF);
|
||||
}
|
||||
}
|
44
src/game/gta/ScriptGlobal.hpp
Normal file
44
src/game/gta/ScriptGlobal.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
class ScriptGlobal
|
||||
{
|
||||
private:
|
||||
std::size_t m_Index;
|
||||
|
||||
public:
|
||||
constexpr ScriptGlobal(std::size_t idx) :
|
||||
m_Index(idx)
|
||||
{}
|
||||
|
||||
constexpr ScriptGlobal At(std::ptrdiff_t offset) const
|
||||
{
|
||||
return m_Index + offset;
|
||||
}
|
||||
|
||||
constexpr ScriptGlobal At(std::ptrdiff_t offset, std::size_t size) const
|
||||
{
|
||||
return m_Index + 1 + offset * size;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_pointer_v<T>, T> As() const
|
||||
{
|
||||
return static_cast<T>(Get());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_lvalue_reference_v<T>, T> As() const
|
||||
{
|
||||
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(Get());
|
||||
}
|
||||
|
||||
private:
|
||||
void* Get() const;
|
||||
|
||||
};
|
||||
|
||||
}
|
9
src/game/gta/ScriptLocal.cpp
Normal file
9
src/game/gta/ScriptLocal.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "ScriptLocal.hpp"
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
void* ScriptLocal::Get() const
|
||||
{
|
||||
return reinterpret_cast<uintptr_t*>((uintptr_t)m_StackPtr + (m_Index * sizeof(uintptr_t)));
|
||||
}
|
||||
}
|
72
src/game/gta/ScriptLocal.hpp
Normal file
72
src/game/gta/ScriptLocal.hpp
Normal file
@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
class ScriptLocal
|
||||
{
|
||||
private:
|
||||
std::size_t m_Index;
|
||||
void* m_StackPtr;
|
||||
|
||||
public:
|
||||
constexpr ScriptLocal(std::size_t index) :
|
||||
m_Index(index),
|
||||
m_StackPtr(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
constexpr ScriptLocal(void* stackPtr, std::size_t index) :
|
||||
m_Index(index),
|
||||
m_StackPtr(stackPtr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// TODO: Uncomment when GTAV-Classes have been added
|
||||
// constexpr ScriptLocal(rage::scrThread* thread, std::size_t index) :
|
||||
// ScriptLocal(thread->m_stack, index)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
constexpr ScriptLocal At(std::ptrdiff_t offset) const
|
||||
{
|
||||
return { m_StackPtr, m_Index + offset };
|
||||
}
|
||||
|
||||
constexpr ScriptLocal At(std::ptrdiff_t offset, std::size_t size) const
|
||||
{
|
||||
return { m_StackPtr, m_Index + 1 + offset * size };
|
||||
}
|
||||
|
||||
constexpr ScriptLocal Set(void* stackPtr)
|
||||
{
|
||||
return { stackPtr, m_Index };
|
||||
}
|
||||
|
||||
// TODO: Uncomment when GTAV-Classes have been added
|
||||
// constexpr ScriptLocal Set(rage::scrThread* thread)
|
||||
// {
|
||||
// return { thread, m_Index };
|
||||
// }
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_pointer_v<T>, T> As()
|
||||
{
|
||||
return static_cast<T>(Get());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_lvalue_reference_v<T>, T> As()
|
||||
{
|
||||
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(Get());
|
||||
}
|
||||
|
||||
private:
|
||||
void* Get() const;
|
||||
|
||||
};
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
#include "core/renderer/Renderer.hpp"
|
||||
#include "game/hooks/Hooks.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
HRESULT SwapChain::Present(IDXGISwapChain* that, UINT syncInterval, UINT flags)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "game/hooks/Hooks.hpp"
|
||||
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
LRESULT Window::WndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <d3d11.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
namespace SwapChain
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "core/memory/PatternScanner.hpp"
|
||||
#include "util/Joaat.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
bool Pointers::Init()
|
||||
{
|
||||
|
@ -2,13 +2,14 @@
|
||||
#include <d3d11.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
struct PointerData
|
||||
{
|
||||
IDXGISwapChain** SwapChain;
|
||||
HWND Hwnd;
|
||||
WNDPROC WndProc;
|
||||
std::int64_t** ScriptGlobals;
|
||||
};
|
||||
|
||||
struct Pointers : PointerData
|
||||
@ -16,5 +17,5 @@ namespace NewBase
|
||||
bool Init();
|
||||
};
|
||||
|
||||
inline NewBase::Pointers Pointers;
|
||||
inline YimMenu::Pointers Pointers;
|
||||
}
|
@ -7,14 +7,14 @@
|
||||
#include "game/pointers/Pointers.hpp"
|
||||
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
DWORD Main(void*)
|
||||
{
|
||||
const auto documents = std::filesystem::path(std::getenv("USERPROFILE")) / "Documents";
|
||||
FileMgr::Init(documents / "HellBase");
|
||||
|
||||
LogHelper::Init("henlo", FileMgr::GetProjectFile("./cout.log").Path());
|
||||
LogHelper::Init("henlo", FileMgr::GetProjectFile("./cout.log"));
|
||||
|
||||
if (!ModuleMgr.LoadModules())
|
||||
goto unload;
|
||||
@ -44,7 +44,7 @@ namespace NewBase
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, void*)
|
||||
{
|
||||
using namespace NewBase;
|
||||
using namespace YimMenu;
|
||||
|
||||
DisableThreadLibraryCalls(dllInstance);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Joaat.hpp"
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
constexpr joaat_t Joaat(const std::string_view str)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
using joaat_t = std::uint32_t;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace NewBase
|
||||
namespace YimMenu
|
||||
{
|
||||
inline constexpr std::uint8_t StrToHex(const char& ch) noexcept
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user