Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/danielkrupinski/Osiris in…
Browse files Browse the repository at this point in the history
…to dev
  • Loading branch information
nkxingxh committed Jul 22, 2023
2 parents 32121a3 + 43eb73a commit 5988b90
Show file tree
Hide file tree
Showing 66 changed files with 1,194 additions and 653 deletions.
75 changes: 39 additions & 36 deletions Source/Endpoints.h

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions Source/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <Config/ResetConfigurator.h>
#include "Hacks/Features.h"

#include "Hooks.h"

constexpr auto windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;

Expand Down Expand Up @@ -94,25 +96,30 @@ GUI::GUI() noexcept
addFontFromVFONT("csgo/panorama/fonts/notosanssc-regular.vfont", 17.0f, io.Fonts->GetGlyphRangesChineseFull(), true);
}

void GUI::render(const EngineInterfaces& engineInterfaces, const ClientInterfaces& clientInterfaces, const OtherInterfaces& interfaces, const Memory& memory, Config& config) noexcept
void GUI::render(Hooks& hooks, const EngineInterfaces& engineInterfaces, const ClientInterfaces& clientInterfaces, const OtherInterfaces& interfaces, const Memory& memory, Config& config) noexcept
{
auto& features = config.getFeatures();
if (!config.style.menuStyle) {
renderMenuBar(config.getFeatures());
renderMenuBar(features);
renderAimbotWindow(config);
renderTriggerbotWindow(config);
config.getFeatures().backtrack.drawGUI(false);
config.getFeatures().glow.drawGUI(false);
features.backtrack.drawGUI(false);
features.glow.drawGUI(false);
renderChamsWindow(config);
StreamProofESP::drawGUI(config, false);
config.getFeatures().visuals.drawGUI(false);
config.getFeatures().inventoryChanger.drawGUI(memory, false);
config.getFeatures().sound.drawGUI(false);
features.visuals.drawGUI(false);
features.inventoryChanger.drawGUI(memory, false);
features.sound.drawGUI(false);
renderStyleWindow(config);
config.getFeatures().misc.drawGUI(config.getFeatures().visuals, config.getFeatures().inventoryChanger, config.getFeatures().glow, false);
features.misc.drawGUI(features.visuals, features.inventoryChanger, features.glow, false);
renderConfigWindow(interfaces, memory, config);
} else {
renderGuiStyle2(engineInterfaces, clientInterfaces, interfaces, memory, config);
}
if (features.misc.unhook) {
hooks.uninstall(features.misc, features.glow, features.visuals, features.inventoryChanger);
features.misc.unhook = false;
}
}

void GUI::updateColors(Config& config) const noexcept
Expand Down
3 changes: 2 additions & 1 deletion Source/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
class Visuals;
struct ImFont;
class ClientInterfaces;
class Hooks;
class Misc;

class GUI {
public:
GUI() noexcept;
void render(const EngineInterfaces& engineInterfaces, const ClientInterfaces& clientInterfaces, const OtherInterfaces& interfaces, const Memory& memory, Config& config) noexcept;
void render(Hooks& hooks, const EngineInterfaces& engineInterfaces, const ClientInterfaces& clientInterfaces, const OtherInterfaces& interfaces, const Memory& memory, Config& config) noexcept;
void handleToggle(Misc& misc, const OtherInterfaces& interfaces) noexcept;
[[nodiscard]] bool isOpen() const noexcept { return open; }
private:
Expand Down
77 changes: 51 additions & 26 deletions Source/GlobalContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#else
#include <imgui/imgui_impl_sdl.h>
#include <imgui/imgui_impl_opengl3.h>

#include "SdlFunctions.h"
#endif

#include "EventListener.h"
Expand Down Expand Up @@ -49,22 +51,30 @@

#include "Platform/DynamicLibrary.h"

template <typename PlatformApi>
GlobalContext<PlatformApi>::GlobalContext(PlatformApi platformApi)
: platformApi{ platformApi }
#if IS_LINUX()

int pollEvent(SDL_Event* event) noexcept;

#endif

#if IS_WIN32() || IS_WIN64()
GlobalContext::GlobalContext(HMODULE moduleHandle)
: moduleHandle{ moduleHandle }
#elif IS_LINUX()
GlobalContext::GlobalContext()
#endif
{
const DynamicLibrary<PlatformApi> clientDLL{ csgo::CLIENT_DLL };
const DynamicLibrary<PlatformApi> engineDLL{ csgo::ENGINE_DLL };
const DynamicLibrary clientDLL{ csgo::CLIENT_DLL };
const DynamicLibrary engineDLL{ csgo::ENGINE_DLL };

PatternNotFoundHandler patternNotFoundHandler;
retSpoofGadgets.emplace(PatternFinder{ clientDLL.getCodeSection(), patternNotFoundHandler }, PatternFinder{ clientDLL.getCodeSection(), patternNotFoundHandler });
retSpoofGadgets.emplace(PatternFinder{ clientDLL.getCodeSection().raw(), patternNotFoundHandler }, PatternFinder{ engineDLL.getCodeSection().raw(), patternNotFoundHandler });
}

#if IS_LINUX()
template <typename PlatformApi>
int GlobalContext<PlatformApi>::pollEventHook(SDL_Event* event)
int GlobalContext::pollEventHook(SDL_Event* event)
{
const auto result = hooks->pollEvent(event);
const auto result = pollEvent(event);

if (state == GlobalContextState::Initialized) {
if (result && ImGui_ImplSDL2_ProcessEvent(event) && gui->isOpen())
Expand All @@ -79,8 +89,7 @@ int GlobalContext<PlatformApi>::pollEventHook(SDL_Event* event)
return result;
}

template <typename PlatformApi>
void GlobalContext<PlatformApi>::swapWindowHook(SDL_Window* window)
void GlobalContext::swapWindowHook(SDL_Window* window)
{
[[maybe_unused]] static const auto _ = ImGui_ImplSDL2_InitForOpenGL(window, nullptr);

Expand All @@ -99,8 +108,7 @@ void GlobalContext<PlatformApi>::swapWindowHook(SDL_Window* window)

#endif

template <typename PlatformApi>
void GlobalContext<PlatformApi>::renderFrame()
void GlobalContext::renderFrame()
{
ImGui::NewFrame();

Expand All @@ -127,35 +135,52 @@ void GlobalContext<PlatformApi>::renderFrame()
gui->handleToggle(features->misc, getOtherInterfaces());

if (gui->isOpen())
gui->render(getEngineInterfaces(), ClientInterfaces{ retSpoofGadgets->client, *clientInterfaces }, getOtherInterfaces(), *memory, *config);
gui->render(*hooks, getEngineInterfaces(), ClientInterfaces{ retSpoofGadgets->client, *clientInterfaces }, getOtherInterfaces(), *memory, *config);
}

ImGui::EndFrame();
ImGui::Render();
}

template <typename PlatformApi>
void GlobalContext<PlatformApi>::initialize()
void GlobalContext::enable()
{
#if IS_WIN32() || IS_WIN64()
windowProcedureHook.emplace(FindWindowW(L"Valve001", nullptr));
#elif IS_LINUX()
SdlFunctions sdlFunctions{ DynamicLibrary{ "libSDL2-2.0.so.0" } };
pollEvent = *reinterpret_cast<decltype(pollEvent)*>(sdlFunctions.pollEvent);
*reinterpret_cast<decltype(::pollEvent)**>(sdlFunctions.pollEvent) = ::pollEvent;
#endif
}

void GlobalContext::initialize()
{
const DynamicLibrary<PlatformApi> clientSo{ csgo::CLIENT_DLL };
clientInterfaces = createClientInterfacesPODs(InterfaceFinderWithLog{ InterfaceFinder{ clientSo, retSpoofGadgets->client } });
const DynamicLibrary<PlatformApi> engineSo{ csgo::ENGINE_DLL };
engineInterfacesPODs = createEngineInterfacesPODs(InterfaceFinderWithLog{ InterfaceFinder{ engineSo, retSpoofGadgets->client } });
const DynamicLibrary clientDll{ csgo::CLIENT_DLL };
clientInterfaces = createClientInterfacesPODs(InterfaceFinderWithLog{ InterfaceFinder{ clientDll, retSpoofGadgets->client } });
const DynamicLibrary engineDll{ csgo::ENGINE_DLL };
engineInterfacesPODs = createEngineInterfacesPODs(InterfaceFinderWithLog{ InterfaceFinder{ engineDll, retSpoofGadgets->client } });

interfaces.emplace(PlatformApi{});
interfaces.emplace();
PatternNotFoundHandler patternNotFoundHandler;
const PatternFinder clientPatternFinder{ clientSo.getCodeSection(), patternNotFoundHandler };
const PatternFinder enginePatternFinder{ engineSo.getCodeSection(), patternNotFoundHandler };
const PatternFinder clientPatternFinder{ clientDll.getCodeSection().raw(), patternNotFoundHandler };
const PatternFinder enginePatternFinder{ engineDll.getCodeSection().raw(), patternNotFoundHandler };

memory.emplace(ClientPatternFinder{ clientPatternFinder }, EnginePatternFinder{ enginePatternFinder }, std::get<csgo::ClientPOD*>(*clientInterfaces), *retSpoofGadgets);

memory.emplace(PlatformApi{}, ClientPatternFinder{ clientPatternFinder }, EnginePatternFinder{ enginePatternFinder }, std::get<csgo::ClientPOD*>(*clientInterfaces), *retSpoofGadgets);
hooks.emplace(
#if IS_LINUX()
pollEvent,
#endif
*memory, std::get<csgo::ClientPOD*>(*clientInterfaces), getEngineInterfaces(), getOtherInterfaces(), clientDll, engineDll, DynamicLibrary{ csgo::VSTDLIB_DLL }, DynamicLibrary{ csgo::VGUIMATSURFACE_DLL });

Netvars::init(ClientInterfaces{ retSpoofGadgets->client, *clientInterfaces }.getClient());
gameEventListener.emplace(getEngineInterfaces().getGameEventManager(memory->getEventDescriptor));

randomGenerator.emplace();
features.emplace(createFeatures(*memory, ClientInterfaces{ retSpoofGadgets->client, *clientInterfaces }, getEngineInterfaces(), getOtherInterfaces(), ClientPatternFinder{ clientPatternFinder }, EnginePatternFinder{ enginePatternFinder }, *randomGenerator));
config.emplace(*features, getOtherInterfaces(), *memory);

features->chams.setModelRenderHooks(&hooks->modelRenderHooks);

gui.emplace();
hooks->install(std::get<csgo::ClientPOD*>(*clientInterfaces), getEngineInterfaces(), getOtherInterfaces(), *memory);
hooks->install();
}
17 changes: 12 additions & 5 deletions Source/GlobalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Utils/ReturnAddress.h"
#include "InventoryChanger/InventoryChanger.h"
#include "Hacks/Features.h"
#include "Hooks.h"

namespace csgo
{
Expand All @@ -45,18 +46,23 @@ enum class GlobalContextState {
Initialized
};

template <typename PlatformApi>
class GlobalContext {
public:
GlobalContext(PlatformApi platformApi);
#if IS_WIN32() || IS_WIN64()
GlobalContext(HMODULE moduleHandle);

HMODULE moduleHandle;
std::optional<WindowProcedureHook> windowProcedureHook;
#elif IS_LINUX()
GlobalContext();

std::add_pointer_t<int(SDL_Event*)> pollEvent;

#if IS_LINUX()
int pollEventHook(SDL_Event* event);
void swapWindowHook(SDL_Window* window);
#endif

PlatformApi platformApi;

std::optional<Hooks> hooks;
std::optional<EventListener> gameEventListener;
std::optional<EngineInterfacesPODs> engineInterfacesPODs;
std::optional<Features> features;
Expand All @@ -71,6 +77,7 @@ class GlobalContext {
return OtherInterfaces{ retSpoofGadgets->client, *interfaces };
}

void enable();
void renderFrame();

GlobalContextState state = GlobalContextState::NotInitialized;
Expand Down
8 changes: 4 additions & 4 deletions Source/Hacks/Chams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void Chams::renderPlayer(Backtrack& backtrack, const csgo::Entity& player) noexc
const auto records = backtrack.getRecords(player.getNetworkable().index());
if (records && !records->empty() && backtrack.valid(engineInterfaces.getEngine(), memory, records->front().simulationTime)) {
if (!appliedChams)
hooks->modelRenderHooks.getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customBoneToWorld);
modelRenderHooks->getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customBoneToWorld);
applyChams(chamsMaterials[static_cast<std::size_t>(ChamsCategory::Backtrack)].materials, health, records->back().matrix);
interfaces.getStudioRender().forcedMaterialOverride(nullptr);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ void Chams::applyChams(const std::array<ChamsLayer, 7>& chams, int health, csgo:
material.setMaterialVarFlag(MaterialVarFlag::IGNOREZ, true);
material.setMaterialVarFlag(MaterialVarFlag::WIREFRAME, cham.wireframe);
interfaces.getStudioRender().forcedMaterialOverride(material.getPOD());
hooks->modelRenderHooks.getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);
modelRenderHooks->getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);
interfaces.getStudioRender().forcedMaterialOverride(nullptr);
}

Expand Down Expand Up @@ -215,12 +215,12 @@ void Chams::applyChams(const std::array<ChamsLayer, 7>& chams, int health, csgo:
material.alphaModulate(pulse);

if (cham.cover && !appliedChams)
hooks->modelRenderHooks.getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);
modelRenderHooks->getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);

material.setMaterialVarFlag(MaterialVarFlag::IGNOREZ, false);
material.setMaterialVarFlag(MaterialVarFlag::WIREFRAME, cham.wireframe);
interfaces.getStudioRender().forcedMaterialOverride(material.getPOD());
hooks->modelRenderHooks.getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);
modelRenderHooks->getOriginalDrawModelExecute()(std::get<csgo::ModelRenderPOD*>(engineInterfaces.getPODs()), ctx, state, info, customMatrix ? customMatrix : customBoneToWorld);
appliedChams = true;
}
}
7 changes: 7 additions & 0 deletions Source/Hacks/Chams.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct MaterialPOD;
}

class Backtrack;
class ModelRenderHooks;

class Chams {
public:
Expand All @@ -39,6 +40,11 @@ class Chams {
bool render(Backtrack& backtrack, void*, void*, const csgo::ModelRenderInfo&, csgo::matrix3x4*) noexcept;
void updateInput() noexcept;

void setModelRenderHooks(const ModelRenderHooks* modelRenderHooks) noexcept
{
this->modelRenderHooks = modelRenderHooks;
}

static constexpr auto numberOfCategories = 9;

struct ChamsCategoryMaterials {
Expand Down Expand Up @@ -84,4 +90,5 @@ class Chams {
OtherInterfaces interfaces;
const Memory& memory;
ChamsMaterials materials;
const ModelRenderHooks* modelRenderHooks = nullptr;
};
2 changes: 1 addition & 1 deletion Source/Hacks/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ void Misc::drawGUI(Visuals& visuals, inventory_changer::InventoryChanger& invent
ImGui::PopID();

if (ImGui::Button("关闭 Osiris"))
hooks->uninstall(*this, glow, memory, visuals, inventoryChanger);
unhook = true;

ImGui::Text("Osiris-CHS 由 NKXingXh 汉化");
ImGui::Text("https://github.com/nkxingxh/Osiris-CHS");
Expand Down
2 changes: 2 additions & 0 deletions Source/Hacks/Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Misc {
void fromJson(const json& j) noexcept;
void resetConfig() noexcept;

bool unhook = false;

private:
void onVoteStart(const void* data, int size) noexcept;
void onVotePass() noexcept;
Expand Down
14 changes: 0 additions & 14 deletions Source/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,6 @@ std::vector<char> Helpers::loadBinaryFile(const std::string& path) noexcept
return result;
}

std::size_t Helpers::calculateVmtLength(const std::uintptr_t* vmt) noexcept
{
std::size_t length = 0;
#if IS_WIN32()
MEMORY_BASIC_INFORMATION memoryInfo;
while (VirtualQuery(LPCVOID(vmt[length]), &memoryInfo, sizeof(memoryInfo)) && memoryInfo.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY))
++length;
#else
while (vmt[length])
++length;
#endif
return length;
}

static bool transformWorldPositionToScreenPosition(const csgo::Matrix4x4& matrix, const csgo::Vector& worldPosition, ImVec2& screenPosition) noexcept
{
const auto w = matrix._41 * worldPosition.x + matrix._42 * worldPosition.y + matrix._43 * worldPosition.z + matrix._44;
Expand Down
2 changes: 0 additions & 2 deletions Source/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ namespace Helpers
template <typename T> constexpr auto deg2rad(T degrees) noexcept { return degrees * (std::numbers::pi_v<T> / static_cast<T>(180)); }
template <typename T> constexpr auto rad2deg(T radians) noexcept { return radians * (static_cast<T>(180) / std::numbers::pi_v<T>); }

[[nodiscard]] std::size_t calculateVmtLength(const std::uintptr_t* vmt) noexcept;

constexpr auto isKnife(WeaponId id) noexcept
{
return (id >= WeaponId::Bayonet && id <= WeaponId::SkeletonKnife) || id == WeaponId::KnifeT || id == WeaponId::Knife;
Expand Down
6 changes: 2 additions & 4 deletions Source/HookType.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma once

#include "Hooks/MinHook.h"
#include "Hooks/VmtHook.h"
#include "Hooks/VmtSwap.h"
#include "Platform/Macros/IsPlatform.h"
#include "Vmt/VmtSwapper.h"

#if IS_WIN32()
// Easily switch hooking method for all hooks, choose between MinHook/VmtHook/VmtSwap
using HookType = MinHook;
#else
using HookType = VmtSwap;
using HookType = VmtSwapper;
#endif
Loading

0 comments on commit 5988b90

Please sign in to comment.