Skip to content

Commit

Permalink
Experimental x86 support
Browse files Browse the repository at this point in the history
- Added experimental x86 support
   - Known issue: Stage 2 hooks fail
   - Known issue: RValue Array offset isn't found
- Fixed a number of warnings in x86
- Fixed disassembler not taking into account the current architecture
- Fixed edgecases where the YYRunnerInterface stack base would be computed improperly
- Disabled internal structure access's struct size checks in x86
  • Loading branch information
Archie-osu committed Apr 8, 2024
1 parent e2a0337 commit 4508c6a
Show file tree
Hide file tree
Showing 10 changed files with 826 additions and 42 deletions.
64 changes: 60 additions & 4 deletions ExamplePlugin/include/YYToolkit/Shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@

#define YYTK_MAJOR 3
#define YYTK_MINOR 2
#define YYTK_PATCH 0
#define YYTK_PATCH 4

#ifndef YYTK_CPP_VERSION
#ifndef _MSVC_LANG
#define YYTK_CPP_VERSION __cplusplus
#else
#define YYTK_CPP_VERSION _MSVC_LANG
#endif // _MSVC_LANG
#endif // YYTK_CPP_VERSION

#include <Aurie/shared.hpp>
#include <FunctionWrapper/FunctionWrapper.hpp>
Expand Down Expand Up @@ -200,26 +208,29 @@ namespace YYTK
IN const char* Value
);

#if YYTK_CPP_VERSION > 202002L
RValue(
IN const char8_t* Value
);

#endif // YYTK_CPP_VERSION
RValue(
IN std::string_view Value
);

#if YYTK_CPP_VERSION > 202002L
RValue(
IN std::u8string_view Value
);

#endif // YYTK_CPP_VERSION
RValue(
IN const std::string& Value
);

#if YYTK_CPP_VERSION > 202002L
RValue(
IN const std::u8string& Value
);

#endif // YYTK_CPP_VERSION
RValue(
IN std::string_view Value,
IN YYTKInterface* Interface
Expand Down Expand Up @@ -1851,6 +1862,11 @@ namespace YYTK
IN int32_t InstanceID,
OUT CInstance*& Instance
) = 0;

virtual Aurie::AurieStatus InvokeWithObject(
IN const RValue& Object,
IN std::function<void(CInstance* Self, CInstance* Other)> Method
) = 0;
};

#if YYTK_DEFINE_INTERNAL
Expand Down Expand Up @@ -1952,7 +1968,9 @@ namespace YYTK
T* m_Last;
int32_t m_Count;
};
#ifdef _WIN64
static_assert(sizeof(LinkedList<CInstance>) == 0x18);
#endif // _WIN64

enum eBuffer_Type : int32_t
{
Expand Down Expand Up @@ -2002,7 +2020,9 @@ namespace YYTK
virtual uint8_t* Compress(int _offset, int _size, uint32_t& resultSize) = 0;
virtual uint8_t* Decompress(uint32_t& resultSize) = 0;
};
#ifdef _WIN64
static_assert(sizeof(IBuffer) == 0x8);
#endif // _WIN64

struct CLayerElementBase
{
Expand All @@ -2024,14 +2044,18 @@ namespace YYTK
CLayerElementBase* m_Blink;
};
};
#ifdef _WIN64
static_assert(sizeof(CLayerElementBase) == 0x30);
#endif // _WIN64

struct CLayerInstanceElement : CLayerElementBase
{
int32_t m_InstanceID;
CInstance* m_Instance;
};
#ifdef _WIN64
static_assert(sizeof(CLayerInstanceElement) == 0x40);
#endif // _WIN64

struct CLayerSpriteElement : CLayerElementBase
{
Expand All @@ -2049,7 +2073,9 @@ namespace YYTK
float m_X;
float m_Y;
};
#ifdef _WIN64
static_assert(sizeof(CLayerSpriteElement) == 0x68);
#endif // _WIN64

__declspec(align(8)) struct CLayer
{
Expand All @@ -2075,7 +2101,9 @@ namespace YYTK
CLayer* m_Blink;
PVOID m_GCProxy;
};
#ifdef _WIN64
static_assert(sizeof(CLayer) == 0xA0);
#endif // _WIN64

// A representation of a room, as from the data.win file
struct YYRoom
Expand Down Expand Up @@ -2112,7 +2140,9 @@ namespace YYTK
float m_PhysicsGravityY;
float m_PhysicsPixelToMeters;
};
#ifdef _WIN64
static_assert(sizeof(YYRoom) == 0x58);
#endif // _WIN64

// Note: this is not how RValues store arrays
template <typename T>
Expand All @@ -2121,7 +2151,9 @@ namespace YYTK
int32_t Length;
T* Array;
};
#ifdef _WIN64
static_assert(sizeof(CArrayStructure<int>) == 0x10);
#endif // _WIN64

// Seems to be mostly stable, some elements at the end are however omitted
struct CRoom
Expand Down Expand Up @@ -2173,15 +2205,19 @@ namespace YYTK
int32_t m_EffectLayerIdCount;
int32_t m_EffectLayerIdMax;
};
#ifdef _WIN64
static_assert(sizeof(CRoom) == 0x218);
#endif // _WIN64

struct CInstanceBase
{
virtual ~CInstanceBase() = 0;

RValue* m_YYVars;
};
#ifdef _WIN64
static_assert(sizeof(CInstanceBase) == 0x10);
#endif // _WIN64

enum EJSRetValBool : int32_t
{
Expand Down Expand Up @@ -2302,7 +2338,9 @@ namespace YYTK
int32_t m_RValueInitType;
int32_t m_CurrentSlot;
};
#ifdef _WIN64
static_assert(sizeof(YYObjectBase) == 0x88);
#endif // _WIN64

struct CScriptRef : YYObjectBase
{
Expand All @@ -2316,7 +2354,9 @@ namespace YYTK
PVOID m_Construct;
const char* m_Tag;
};
#ifdef _WIN64
static_assert(sizeof(CScriptRef) == 0xE0);
#endif // _WIN64

struct CPhysicsDataGM
{
Expand All @@ -2334,14 +2374,18 @@ namespace YYTK
float m_PhysicsFriction;
int m_PhysicsVertexCount;
};
#ifdef _WIN64
static_assert(sizeof(CPhysicsDataGM) == 0x30);
#endif // _WIN64

struct CEvent
{
CCode* m_Code;
int32_t m_OwnerObjectID;
};
#ifdef _WIN64
static_assert(sizeof(CEvent) == 0x10);
#endif // _WIN64

struct CObjectGM
{
Expand All @@ -2359,13 +2403,17 @@ namespace YYTK
int32_t m_Mask;
int32_t m_ID;
};
#ifdef _WIN64
static_assert(sizeof(CObjectGM) == 0x98);
#endif // _WIN64

struct GCObjectContainer : YYObjectBase
{
CHashMap<YYObjectBase*, YYObjectBase*, 3>* m_YYObjectMap;
};
#ifdef _WIN64
static_assert(sizeof(GCObjectContainer) == 0x90);
#endif // _WIN64

struct YYRECT
{
Expand Down Expand Up @@ -2418,7 +2466,9 @@ namespace YYTK
CInstance* m_Flink;
CInstance* m_Blink;
};
#ifdef _WIN64
static_assert(sizeof(CInstanceInternal) == 0xF8);
#endif // _WIN64

struct CInstance : YYObjectBase
{
Expand All @@ -2442,7 +2492,9 @@ namespace YYTK
public:
CInstanceInternal Members;
} Unmasked;
#ifdef _WIN64
static_assert(sizeof(Unmasked) == 0x100);
#endif // _WIN64

// 2022.1 => 2023.1 (may be used later, haven't checked)
struct
Expand All @@ -2453,7 +2505,9 @@ namespace YYTK
public:
CInstanceInternal Members;
} Masked;
#ifdef _WIN64
static_assert(sizeof(Masked) == 0x108);
#endif // _WIN64
};
public:

Expand All @@ -2471,7 +2525,9 @@ namespace YYTK
};
// sizeof(0x1A8) is for PreMasked instances
// sizeof(0x1B0) is for Masked instances
#ifdef _WIN64
static_assert(sizeof(CInstance) == 0x1A8 || sizeof(CInstance) == 0x1B0);
#endif // _WIN64

#endif // YYTK_DEFINE_INTERNAL
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ YYTK is split on two branches, that being [Legacy](https://github.com/AurieFrame
| GM 2023.x |||
| GM 2024.x beta |||
| VM runner support || 🟡 |
| x86 runner support || |
| x86 runner support || 🟡 |
| x64 runner support | 🟡 ||
| Active Development |||
| Accessing global variables |||
Expand Down
8 changes: 4 additions & 4 deletions YYToolkit/YYToolkit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
<ClCompile Include="source\YYTK\Module Internals\Console\Console.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
<ClCompile Include="source\YYTK\Module Internals\GameMaker\YYC-only.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
<ClCompile Include="source\YYTK\Module Interface\Interface.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
Expand All @@ -36,10 +33,13 @@
<ClCompile Include="source\YYTK\Shared.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
<ClCompile Include="source\YYTK\Module Internals\GameMaker\Generic.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
<ClCompile Include="source\YYTK\Module Internals\GameMaker\VM-only.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
<ClCompile Include="source\YYTK\Module Internals\GameMaker\Generic.cpp">
<ClCompile Include="source\YYTK\Module Internals\GameMaker\YYC-only.cpp">
<Filter>Zdrojové soubory</Filter>
</ClCompile>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion YYToolkit/source/YYTK/Module Interface/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ namespace YYTK
return AURIE_MODULE_INTERNAL_ERROR;

// Prevent ourselves from reading out-of-bounds
if (Index >= *m_BuiltinCount)
if (static_cast<int>(Index) >= *m_BuiltinCount)
return AURIE_INVALID_PARAMETER;

VariableInformation = &m_BuiltinArray[Index];
Expand Down
Loading

0 comments on commit 4508c6a

Please sign in to comment.