Skip to content

Commit

Permalink
Added 0.6.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed Nov 3, 2023
1 parent b0cd260 commit 76bc583
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Code/Hooks/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Utils/File.hpp"
#include "Utils/Json.hpp"

#include "offsets.hpp"

#include <MinHook.h>

void replace_content_key_data(std::string& path, const std::string& key_repl)
Expand Down Expand Up @@ -199,9 +201,9 @@ int __fastcall Hooks::h_LuaInitFunc(LuaVM* lua_vm, void** some_ptr, int some_num
void Hooks::RunHooks()
{
const std::uintptr_t v_module_handle = std::uintptr_t(GetModuleHandle(NULL));
const std::uintptr_t v_load_shapesets_addr = v_module_handle + 0x5C4250;
const std::uintptr_t v_init_shape_manager_addr = v_module_handle + 0x378170;
const std::uintptr_t v_lua_init_addr = v_module_handle + 0x5784D0;
const std::uintptr_t v_load_shapesets_addr = v_module_handle + OFF_LOAD_SHAPESETS_FUNCTION;
const std::uintptr_t v_init_shape_manager_addr = v_module_handle + OFF_INIT_SHAPESET_MANAGER_FUNCTION;
const std::uintptr_t v_lua_init_addr = v_module_handle + OFF_INIT_LUA_MANAGER_FUNCTION;

HMODULE v_lua_dll = GetModuleHandleA("lua51.dll");
if (v_lua_dll)
Expand Down
23 changes: 23 additions & 0 deletions Code/Hooks/offsets.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#define GAME_VERSION 066

#if !defined(GAME_VERSION)
#error GAME_VERSION must be defined!
#endif

#if GAME_VERSION == 066
#define OFF_LOAD_SHAPESETS_FUNCTION 0x5A6A60
#define OFF_INIT_SHAPESET_MANAGER_FUNCTION 0x359490
#define OFF_INIT_LUA_MANAGER_FUNCTION 0x55A640
#define OFF_AUDIO_MANAGER_PTR 0x128D720
#define OFF_DIRECTORY_MANAGER_PTR 0x128D8F0
#define OFF_GAME_SETTINGS_PTR 0x128D830
#elif GAME_VERSION == 065
#define OFF_LOAD_SHAPESETS_FUNCTION 0x5C4250
#define OFF_INIT_SHAPESET_MANAGER_FUNCTION 0x378170
#define OFF_INIT_LUA_MANAGER_FUNCTION 0x5784D0
#define OFF_AUDIO_MANAGER_PTR 0x12A7710
#define OFF_DIRECTORY_MANAGER_PTR 0x12A78F0
#define OFF_GAME_SETTINGS_PTR 0x12A7840
#endif
3 changes: 2 additions & 1 deletion Code/SM/AudioManager.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Hooks/offsets.hpp"
#include "win_include.hpp"

#include <DirectXMath.h>
Expand Down Expand Up @@ -34,7 +35,7 @@ namespace SM

inline static AudioManager* GetInstance()
{
return *reinterpret_cast<AudioManager**>(std::uintptr_t(GetModuleHandle(NULL)) + 0x12A7710);
return *reinterpret_cast<AudioManager**>(std::uintptr_t(GetModuleHandle(NULL)) + OFF_AUDIO_MANAGER_PTR);
}

}; // Size: 0x2D8
Expand Down
3 changes: 2 additions & 1 deletion Code/SM/DirectoryManager.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Hooks/offsets.hpp"
#include "win_include.hpp"

#include <unordered_map>
Expand All @@ -14,7 +15,7 @@ namespace SM

inline static DirectoryManager* GetInstance()
{
return *reinterpret_cast<DirectoryManager**>(std::uintptr_t(GetModuleHandle(NULL)) + 0x12A78F0);
return *reinterpret_cast<DirectoryManager**>(std::uintptr_t(GetModuleHandle(NULL)) + OFF_DIRECTORY_MANAGER_PTR);
}

inline bool get_replacement(const std::string& key, std::string& replacement)
Expand Down
2 changes: 1 addition & 1 deletion Code/SM/GameSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace SM

inline static GameSettings* GetInstance()
{
return *reinterpret_cast<GameSettings**>(std::uintptr_t(GetModuleHandle(NULL)) + 0x12A7840);
return *reinterpret_cast<GameSettings**>(std::uintptr_t(GetModuleHandle(NULL)) + OFF_GAME_SETTINGS_PTR);
}

inline float get_effect_volume()
Expand Down
1 change: 1 addition & 0 deletions CustomAudioExtension.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<ClCompile Include="Code\Utils\Json.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Code\Hooks\offsets.hpp" />
<ClInclude Include="Code\SM\AudioManager.hpp" />
<ClInclude Include="Code\SM\DirectoryManager.hpp" />
<ClInclude Include="Code\Hooks\fmod_hooks.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions CustomAudioExtension.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@
<ClInclude Include="Code\SM\GameSettings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Code\Hooks\offsets.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 76bc583

Please sign in to comment.