Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2.01 #92

Merged
merged 5 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/RED4ext/Addresses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ constexpr uintptr_t CClass_Unserialize = 0x14014CCE4 - ImageBase; // 48 89 5C 24
constexpr uintptr_t CClass_ToString = 0x140920280 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ?, expected: 341, index: 104
constexpr uintptr_t CClass_sub_80 = 0x141FAE574 - ImageBase; // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC ?, expected: 987, index: 514
constexpr uintptr_t CClass_sub_88 = 0x141FAE4C8 - ImageBase; // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B 02, expected: 65, index: 34
constexpr uintptr_t CClass_sub_90 = 0x1409581C0 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?, expected: 3, index: 1
constexpr uintptr_t CClass_sub_90 = 0x140760AD0 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?, expected: 3, index: 0
constexpr uintptr_t CClass_sub_98 = 0x141FAF750 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?, expected: 3, index: 2
constexpr uintptr_t CClass_sub_A0 = 0x141FAED84 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 56 41 57 48 8B EC, expected: 538, index: 354
constexpr uintptr_t CClass_sub_B0 = 0x14087C070 - ImageBase; // 48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 48 89 78 ? 41 56 48 83 EC ? 48 8B 05 ? ? ? ?, expected: 1, index: 0
constexpr uintptr_t CClass_sub_C0 = 0x140547E70 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 83 64 24 ? ?, expected: 58, index: 11
constexpr uintptr_t CClass_sub_C0 = 0x140558740 - ImageBase; // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 83 64 24 ? ?, expected: 58, index: 12
constexpr uintptr_t CClass_GetMaxAlignment = 0x1405586C4 - ImageBase; // 48 89 5C 24 ? 57 48 83 EC ? 8B 59 ?, expected: 126, index: 18
constexpr uintptr_t CClass_sub_D0 = 0x14208CE88 - ImageBase; // 4C 8B DC 49 89 5B ? 49 89 6B ? 49 89 73 ? 57 41 54 41 55 41 56, expected: 33, index: 26
constexpr uintptr_t CClass_sub_D0 = 0x141FAF420 - ImageBase; // 4C 8B DC 49 89 5B ? 49 89 6B ? 49 89 73 ? 57 41 54 41 55 41 56, expected: 33, index: 25
constexpr uintptr_t CClass_CreateInstance = 0x14014C660 - ImageBase; // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 65 48 8B 04 25 ? ? ? ?, expected: 421, index: 7
constexpr uintptr_t CClass_GetProperty = 0x14014D5E8 - ImageBase; // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 33 FF 48 8B DA, expected: 4, index: 0
constexpr uintptr_t CClass_GetProperties = 0x140558850 - ImageBase; // 48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 48 89 78 ? 41 56 48 83 EC ? 48 8B D9, expected: 31, index: 5
Expand Down Expand Up @@ -104,7 +104,7 @@ constexpr uintptr_t CStack_vtbl = 0x142A08238 - ImageBase; // 48 8D 05 ? ? ? ? 4

#pragma region CString
constexpr uintptr_t CString_ctor_str = 0x140251288 - ImageBase; // 48 85 D2 74 15 48 83 C8 FF 48 FF C0, expected: 1, index: 0
constexpr uintptr_t CString_ctor_span = 0x140678644 - ImageBase; // 40 53 48 83 EC ? 33 C0 48 8B D9 48 89 41 ?, expected: 6, index: 3
constexpr uintptr_t CString_ctor_span = 0x1409394E4 - ImageBase; // 40 53 48 83 EC ? 33 C0 48 8B D9 48 89 41 ? 88 01 89 41 ? E8, expected: 3, index: 2
constexpr uintptr_t CString_copy = 0x14011DA8C - ImageBase; // B8 ? ? ? ? 39 41 ? 73 19 39 42 ?, expected: 1, index: 0
constexpr uintptr_t CString_dtor = 0x14014A704 - ImageBase; // 40 53 48 83 EC ? 8B 41 ? 48 8B D9 C1 E8 ?, expected: 2, index: 0
#pragma endregion
Expand Down Expand Up @@ -170,7 +170,7 @@ constexpr uintptr_t ResourceDepot = 0x1446DF9C8 - ImageBase; // 48 89 05 ? ? ? ?
#pragma endregion

#pragma region ResourceLoader
constexpr uintptr_t ResourceLoader = 0x143811B08 - ImageBase; // 48 89 05 ? ? ? ? 48 83 C4 ? 5F C3, expected: 6, index: 0, offset: 3
constexpr uintptr_t ResourceLoader = 0x1432EDC78 - ImageBase; // 48 89 05 ? ? ? ? 48 83 C4 ? 5F C3, expected: 6, index: 1, offset: 3
constexpr uintptr_t ResourceLoader_FindTokenFast = 0x140151C5C - ImageBase; // 48 8B C4 4C 89 40 ? 53 48 83 EC ? 48 8B DA 4C 8D 40 ?, expected: 2, index: 0
constexpr uintptr_t ResourceLoader_LoadAsync = 0x140608484 - ImageBase; // 48 89 5C 24 ? 55 48 8B EC 48 83 EC ? 83 4D E8 ? 33 C0, expected: 1, index: 0
#pragma endregion
Expand Down
1 change: 1 addition & 0 deletions include/RED4ext/Api/Runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define RED4EXT_RUNTIME_1_63 RED4EXT_V0_RUNTIME_1_63
#define RED4EXT_RUNTIME_1_63_HOTFIX_1 RED4EXT_V0_RUNTIME_1_63_HOTFIX_1
#define RED4EXT_RUNTIME_2_00 RED4EXT_V0_RUNTIME_2_00
#define RED4EXT_RUNTIME_2_01 RED4EXT_V0_RUNTIME_2_01

/**
* @brief Supports all game versions.
Expand Down
3 changes: 2 additions & 1 deletion include/RED4ext/Api/v0/Runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define RED4EXT_V0_RUNTIME_1_63 RED4EXT_V0_FILEVER(3, 0, 72, 45053)
#define RED4EXT_V0_RUNTIME_1_63_HOTFIX_1 RED4EXT_V0_FILEVER(3, 0, 72, 54038)
#define RED4EXT_V0_RUNTIME_2_00 RED4EXT_V0_FILEVER(3, 0, 74, 53121)
#define RED4EXT_V0_RUNTIME_2_01 RED4EXT_V0_FILEVER(3, 0, 74, 63017)

/**
* @brief Supports all game versions.
Expand All @@ -35,4 +36,4 @@
/*
* @brief The latest game version.
*/
#define RED4EXT_V0_RUNTIME_LATEST RED4EXT_V0_RUNTIME_2_00
#define RED4EXT_V0_RUNTIME_LATEST RED4EXT_V0_RUNTIME_2_01
18 changes: 14 additions & 4 deletions include/RED4ext/Dump/Reflection-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,6 @@ RED4EXT_INLINE void BitfieldFileDescriptor::EmitFile(std::filesystem::path aOutP
o << "struct " << nameQualified;
}

// TODO: Struct alignment: __declspec(align(X))

o << std::endl;
o << "{" << std::endl;

Expand Down Expand Up @@ -783,6 +781,7 @@ RED4EXT_INLINE void ClassDependencyBuilder::ToFileDescriptor(ClassFileDescriptor

aFd.trueName = name.ToString();
aFd.size = pType->GetSize();
aFd.alignment = pType->GetAlignment();
aFd.directory = aTypeToPath(pType);
aFd.override = aTypeToOverride(pType);
aFd.usedAsHandle = aHandleCompatChecker(pType);
Expand Down Expand Up @@ -1082,11 +1081,22 @@ RED4EXT_INLINE void ClassFileDescriptor::EmitFile(std::filesystem::path aOutPath

o << "namespace " << ns << std::endl;
o << "{" << std::endl;
o << "struct " << name;
}

o << "struct ";

if (alignment == 0x10)
{
o << "__declspec(align(0x" << std::hex << std::uppercase << alignment << ")) ";
wopss marked this conversation as resolved.
Show resolved Hide resolved
}

if (nsIndex != std::string::npos)
{
o << name;
}
else
{
o << "struct " << nameQualified;
o << nameQualified;
}

if (!parent.empty())
Expand Down
1 change: 1 addition & 0 deletions include/RED4ext/Dump/Reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ClassFileDescriptor
std::string override;
bool usedAsHandle;
size_t size = 0;
size_t alignment = 0;
size_t parentSize = 0;

struct PropertyDescriptor
Expand Down
2 changes: 1 addition & 1 deletion include/RED4ext/ResourceLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct ResourceLoader
using FindToken_t = uintptr_t (*)(ResourceLoader*, SharedPtr<ResourceToken<T>>*, ResourcePath);
RelocFunc<FindToken_t> func(Addresses::ResourceLoader_FindTokenFast);

std::shared_lock<SharedMutex> _;
std::shared_lock<SharedMutex> _(tokenLock);

SharedPtr<ResourceToken<T>> token;
func(this, &token, aPath);
Expand Down
2 changes: 1 addition & 1 deletion include/RED4ext/Scripting/Natives/Generated/Quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace RED4ext
{
struct __declspec(align(16)) Quaternion
struct __declspec(align(0x10)) Quaternion
{
static constexpr const char* NAME = "Quaternion";
static constexpr const char* ALIAS = NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct DynamicSpawnSystem : game::IDynamicSpawnSystem
static constexpr const char* NAME = "gameDynamicSpawnSystem";
static constexpr const char* ALIAS = "DynamicSpawnSystem";

uint8_t unk48[0x120 - 0x48]; // 48
uint8_t unk48[0x130 - 0x48]; // 48
};
RED4EXT_ASSERT_SIZE(DynamicSpawnSystem, 0x120);
RED4EXT_ASSERT_SIZE(DynamicSpawnSystem, 0x130);
} // namespace game
using gameDynamicSpawnSystem = game::DynamicSpawnSystem;
using DynamicSpawnSystem = game::DynamicSpawnSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ struct GameSessionDesc
static constexpr const char* NAME = "gameGameSessionDesc";
static constexpr const char* ALIAS = NAME;

uint8_t unk00[0x1C0 - 0x0]; // 0
uint8_t unk00[0x1D0 - 0x0]; // 0
};
RED4EXT_ASSERT_SIZE(GameSessionDesc, 0x1C0);
RED4EXT_ASSERT_SIZE(GameSessionDesc, 0x1D0);
} // namespace game
using gameGameSessionDesc = game::GameSessionDesc;
} // namespace RED4ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ struct MovingPlatform : ent::IPlacedComponent
CName soundPositionName; // 1A8
uint8_t unk1B0[0x1DC - 0x1B0]; // 1B0
game::MovingPlatformLoopType loopType; // 1DC
uint8_t unk1E0[0x1E3 - 0x1E0]; // 1E0
bool supportLegacyUnalignedMarkers; // 1E3
bool enableWaterInteractions; // 1E4
uint8_t unk1E5[0x1F0 - 0x1E5]; // 1E5
uint8_t unk1E0[0x1E8 - 0x1E0]; // 1E0
bool supportLegacyUnalignedMarkers; // 1E8
bool enableWaterInteractions; // 1E9
uint8_t unk1EA[0x200 - 0x1EA]; // 1EA
};
RED4EXT_ASSERT_SIZE(MovingPlatform, 0x1F0);
RED4EXT_ASSERT_SIZE(MovingPlatform, 0x200);
} // namespace game
using gameMovingPlatform = game::MovingPlatform;
using MovingPlatform = game::MovingPlatform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ struct MovingPlatformMoveTo : red::Event
CName destinationName; // 50
int32_t data; // 58
uint8_t unk5C[0x60 - 0x5C]; // 5C
bool isElevator; // 60
uint8_t unk61[0x68 - 0x61]; // 61
};
RED4EXT_ASSERT_SIZE(MovingPlatformMoveTo, 0x60);
RED4EXT_ASSERT_SIZE(MovingPlatformMoveTo, 0x68);
} // namespace game
using gameMovingPlatformMoveTo = game::MovingPlatformMoveTo;
using MoveTo = game::MovingPlatformMoveTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct MovingPlatformRestoreMoveTo : game::MovingPlatformMoveTo
static constexpr const char* NAME = "gameMovingPlatformRestoreMoveTo";
static constexpr const char* ALIAS = NAME;

uint8_t unk60[0x90 - 0x60]; // 60
uint8_t unk68[0x90 - 0x68]; // 68
};
RED4EXT_ASSERT_SIZE(MovingPlatformRestoreMoveTo, 0x90);
} // namespace game
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct State_PreGameSession : gsm::State_Session
static constexpr const char* NAME = "gsmState_PreGameSession";
static constexpr const char* ALIAS = NAME;

uint8_t unk320[0x330 - 0x320]; // 320
uint8_t unk330[0x340 - 0x330]; // 330
};
RED4EXT_ASSERT_SIZE(State_PreGameSession, 0x330);
RED4EXT_ASSERT_SIZE(State_PreGameSession, 0x340);
} // namespace gsm
using gsmState_PreGameSession = gsm::State_PreGameSession;
} // namespace RED4ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct State_Session : gsm::State
static constexpr const char* NAME = "gsmState_Session";
static constexpr const char* ALIAS = NAME;

uint8_t unkB8[0x320 - 0xB8]; // B8
uint8_t unkB8[0x330 - 0xB8]; // B8
};
RED4EXT_ASSERT_SIZE(State_Session, 0x320);
RED4EXT_ASSERT_SIZE(State_Session, 0x330);
} // namespace gsm
using gsmState_Session = gsm::State_Session;
} // namespace RED4ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct State_SessionRestoreFromSave : gsm::State
static constexpr const char* NAME = "gsmState_SessionRestoreFromSave";
static constexpr const char* ALIAS = NAME;

uint8_t unkB8[0x2A0 - 0xB8]; // B8
uint8_t unkB8[0x2B0 - 0xB8]; // B8
};
RED4EXT_ASSERT_SIZE(State_SessionRestoreFromSave, 0x2A0);
RED4EXT_ASSERT_SIZE(State_SessionRestoreFromSave, 0x2B0);
} // namespace gsm
using gsmState_SessionRestoreFromSave = gsm::State_SessionRestoreFromSave;
} // namespace RED4ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ICharacterConditionType : quest::IConditionType
static constexpr const char* NAME = "questICharacterConditionType";
static constexpr const char* ALIAS = NAME;

game::EntityReference puppetRef; // 38
game::EntityReference objectRef; // 38
bool isPlayer; // 70
uint8_t unk71[0x78 - 0x71]; // 71
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

// clang-format off

// This file is generated from the Game's Reflection data

#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/game/ui/Context.hpp>
#include <RED4ext/Scripting/Natives/Generated/quest/IUIConditionType.hpp>

namespace RED4ext
{
namespace quest
{
struct UIContextState_ConditionType : quest::IUIConditionType
{
static constexpr const char* NAME = "questUIContextState_ConditionType";
static constexpr const char* ALIAS = NAME;

game::ui::Context state; // 38
bool active; // 3C
uint8_t unk3D[0x40 - 0x3D]; // 3D
};
RED4EXT_ASSERT_SIZE(UIContextState_ConditionType, 0x40);
} // namespace quest
using questUIContextState_ConditionType = quest::UIContextState_ConditionType;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct UseWorkspotParamsV1 : quest::AICommandParams
bool repeatCommandOnInterrupt; // CC
bool continueInCombat; // CD
bool meshDissolvingEnabled; // CE
uint8_t unkCF[0xD0 - 0xCF]; // CF
bool dangleResetSimulation; // CF
};
RED4EXT_ASSERT_SIZE(UseWorkspotParamsV1, 0xD0);
} // namespace quest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct RuntimeSystemUI : world::IRuntimeSystem
static constexpr const char* NAME = "worlduiRuntimeSystemUI";
static constexpr const char* ALIAS = NAME;

uint8_t unk48[0x260 - 0x48]; // 48
uint8_t unk48[0x298 - 0x48]; // 48
};
RED4EXT_ASSERT_SIZE(RuntimeSystemUI, 0x260);
RED4EXT_ASSERT_SIZE(RuntimeSystemUI, 0x298);
} // namespace world::ui
using worlduiRuntimeSystemUI = world::ui::RuntimeSystemUI;
} // namespace RED4ext
Expand Down
10 changes: 5 additions & 5 deletions scripts/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def get_groups() -> List[Group]:
Item(name='ToString', pattern='48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ?', expected=341, index=104),
Item(name='sub_80', pattern='48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC ?', expected=987, index=514),
Item(name='sub_88', pattern='48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B 02', expected=65, index=34),
Item(name='sub_90', pattern='48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?', expected=3, index=1),
Item(name='sub_90', pattern='48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?', expected=3, index=0),
Item(name='sub_98', pattern='48 89 5C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 81 EC ? ? ? ?', expected=3, index=2),
Item(name='sub_A0', pattern='48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 56 41 57 48 8B EC', expected=538, index=354),
Item(name='sub_B0', pattern='48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 48 89 78 ? 41 56 48 83 EC ? 48 8B 05 ? ? ? ?', expected=1, index=0),
Item(name='sub_C0', pattern='48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 83 64 24 ? ?', expected=58, index=11),
Item(name='sub_C0', pattern='48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 83 64 24 ? ?', expected=58, index=12),
Item(name='GetMaxAlignment', pattern='48 89 5C 24 ? 57 48 83 EC ? 8B 59 ?', expected=126, index=18),
Item(name='sub_D0', pattern='4C 8B DC 49 89 5B ? 49 89 6B ? 49 89 73 ? 57 41 54 41 55 41 56', expected=33, index=26),
Item(name='sub_D0', pattern='4C 8B DC 49 89 5B ? 49 89 6B ? 49 89 73 ? 57 41 54 41 55 41 56', expected=33, index=25),

Item(name='CreateInstance', pattern='48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 65 48 8B 04 25 ? ? ? ?', expected=421, index=7),
Item(name='GetProperty', pattern='48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 33 FF 48 8B DA', expected=4, index=0),
Expand Down Expand Up @@ -126,7 +126,7 @@ def get_groups() -> List[Group]:

Group(name='CString', functions=[
Item(name='ctor_str', pattern='48 85 D2 74 15 48 83 C8 FF 48 FF C0', expected=1, index=0),
Item(name='ctor_span', pattern='40 53 48 83 EC ? 33 C0 48 8B D9 48 89 41 ?', expected=6, index=3),
Item(name='ctor_span', pattern='40 53 48 83 EC ? 33 C0 48 8B D9 48 89 41 ? 88 01 89 41 ? E8', expected=3, index=2),
Item(name='copy', pattern='B8 ? ? ? ? 39 41 ? 73 19 39 42 ?', expected=1, index=0),
Item(name='dtor', pattern='40 53 48 83 EC ? 8B 41 ? 48 8B D9 C1 E8 ?', expected=2, index=0)
]),
Expand Down Expand Up @@ -197,7 +197,7 @@ def get_groups() -> List[Group]:
]),

Group(name='ResourceLoader', pointers=[
Item(pattern='48 89 05 ? ? ? ? 48 83 C4 ? 5F C3', offset=3, expected=6, index=0)
Item(pattern='48 89 05 ? ? ? ? 48 83 C4 ? 5F C3', offset=3, expected=6, index=1)
],
functions=[
Item(name='FindTokenFast', pattern='48 8B C4 4C 89 40 ? 53 48 83 EC ? 48 8B DA 4C 8D 40 ?', expected=2, index=0),
Expand Down
Loading