Skip to content

Commit

Permalink
feat(core/rdr3): rage parser support
Browse files Browse the repository at this point in the history
  • Loading branch information
Disquse committed Jul 10, 2023
1 parent c1af6de commit d2ef009
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
30 changes: 23 additions & 7 deletions code/components/gta-core-five/include/RageParser.h
@@ -1,11 +1,12 @@
#pragma once

#include "ComponentExport.h"
#include <atArray.h>

#ifdef COMPILING_GTA_CORE_FIVE
#define GTA_CORE_EXPORT DLL_EXPORT
#else
#define GTA_CORE_EXPORT DLL_IMPORT
#ifdef GTA_FIVE
#define GTA_CORE_TARGET GTA_CORE_FIVE
#elif IS_RDR3
#define GTA_CORE_TARGET GTA_CORE_RDR3
#endif

namespace rage
Expand Down Expand Up @@ -45,7 +46,12 @@ namespace rage
Half = 30,
Int64 = 31,
UInt64 = 32,
Double = 33
Double = 33,
#ifdef IS_RDR3
Guid = 34,
Vec2f = 35,
QuatV = 36,
#endif
};

struct parEnumField
Expand Down Expand Up @@ -143,13 +149,21 @@ namespace rage
public:
virtual ~parStructure() = default;

#if IS_RDR3
uint8_t m_critSection[0x28];
#endif

uint32_t m_nameHash; // +8

char m_pad[4]; // +12

parStructure* m_baseClass; // +16

#if IS_RDR3
char m_pad2[32]; // +24
#else
char m_pad2[24]; // +24
#endif

atArray<rage::parMember*> m_members; // +48

Expand All @@ -168,7 +182,9 @@ namespace rage
void(*m_delete)(void*);
};

GTA_CORE_EXPORT rage::parStructure* GetStructureDefinition(const char* structType);
COMPONENT_EXPORT(GTA_CORE_TARGET) rage::parStructure* GetStructureDefinition(const char* structType);

GTA_CORE_EXPORT rage::parStructure* GetStructureDefinition(uint32_t structHash);
COMPONENT_EXPORT(GTA_CORE_TARGET) rage::parStructure* GetStructureDefinition(uint32_t structHash);
}

#undef GTA_CORE_TARGET
1 change: 1 addition & 0 deletions code/components/gta-core-rdr3/component.lua
Expand Up @@ -8,5 +8,6 @@ return function()
files {
'components/gta-core-five/src/GameAudioState.cpp',
'components/gta-core-rdr3/include/GameAudioState.h',
'components/gta-core-five/include/RageParser.h',
}
end
28 changes: 28 additions & 0 deletions code/components/gta-core-rdr3/src/RageParser.cpp
@@ -0,0 +1,28 @@
#include <StdInc.h>
#include <Hooking.h>
#include <RageParser.h>

static void** g_parser;

static hook::cdecl_stub<rage::parStructure* (void* parser, uint32_t)> _parser_getStructure([]()
{
return hook::get_call(hook::get_pattern("8B 10 E8 ? ? ? ? 8A 48 50", 2));
});

namespace rage
{
DLL_EXPORT rage::parStructure* GetStructureDefinition(const char* structType)
{
return _parser_getStructure(*g_parser, HashRageString(structType));
}

DLL_EXPORT rage::parStructure* GetStructureDefinition(uint32_t structHash)
{
return _parser_getStructure(*g_parser, structHash);
}
}

static HookFunction hookFunction([]()
{
g_parser = hook::get_address<void**>(hook::get_pattern("8B 10 E8 ? ? ? ? 8A 48 50", -4));
});

0 comments on commit d2ef009

Please sign in to comment.