Skip to content

Commit

Permalink
Merge Add heap corruption checking (mr-587)
Browse files Browse the repository at this point in the history
8a8c141 - feat(game): add heap corruption checking
  • Loading branch information
prikolium-cfx committed Nov 19, 2024
2 parents 785035d + 8a8c141 commit 8a6a363
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 66 deletions.
1 change: 1 addition & 0 deletions code/client/shared/atPool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

// Actually fwBasePool
class atPoolBase
{
protected:
Expand Down
3 changes: 2 additions & 1 deletion code/components/gta-core-five/component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ return function()

links 'CitiCore'
files {
'components/gta-core-rdr3/src/ErrorHandler.cpp'
'components/gta-core-rdr3/src/ErrorHandler.cpp',
'components/gta-core-rdr3/src/SimpleAllocator.cpp'
}
add_dependencies { 'vendor:eastl' }
end
10 changes: 10 additions & 0 deletions code/components/gta-core-five/src/GameSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <ICoreGameInit.h>
#include <CrossBuildRuntime.h>

extern void ValidateHeaps();

static std::unordered_map<uint32_t, std::string> g_initFunctionNames;

namespace rage
Expand Down Expand Up @@ -95,6 +97,8 @@ namespace rage

void gameSkeleton::RunInitFunctions(InitFunctionType type)
{
ValidateHeaps();

trace(__FUNCTION__ ": Running %s init functions\n", InitFunctionTypeToString(type));

OnInitFunctionStart(type);
Expand All @@ -112,6 +116,8 @@ namespace rage

for (int index : entry->functions)
{
ValidateHeaps();

auto func = m_initFunctions[index];

if (OnInitFunctionInvoking(type, i, func))
Expand All @@ -130,6 +136,8 @@ namespace rage
OnInitFunctionInvoked(type, func);

++i;

ValidateHeaps();
}

OnInitFunctionEndOrder(type, entry->order);
Expand All @@ -139,6 +147,8 @@ namespace rage

OnInitFunctionEnd(type);

ValidateHeaps();

trace(__FUNCTION__ ": Done running %s init functions!\n", InitFunctionTypeToString(type));
}

Expand Down
10 changes: 10 additions & 0 deletions code/components/gta-core-rdr3/src/GameSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <ICoreGameInit.h>

extern void ValidateHeaps();

static std::unordered_map<uint32_t, std::string> g_initFunctionNames;

// rage::strStreamingEngine::ms_bIsPerformingAsyncInit
Expand Down Expand Up @@ -88,6 +90,8 @@ namespace rage

void gameSkeleton::RunInitFunctions(InitFunctionType type)
{
ValidateHeaps();

trace(__FUNCTION__ ": Running %s init functions\n", InitFunctionTypeToString(type));

OnInitFunctionStart(type);
Expand All @@ -109,6 +113,8 @@ namespace rage
{
for (int index : entry->functions)
{
ValidateHeaps();

auto func = m_initFunctions[index];

bool isAsync = (func.asyncInitMask & type) != 0;
Expand All @@ -134,6 +140,8 @@ namespace rage
OnInitFunctionInvoked(type, func);

++i;

ValidateHeaps();
}
}

Expand All @@ -146,6 +154,8 @@ namespace rage

OnInitFunctionEnd(type);

ValidateHeaps();

trace(__FUNCTION__ ": Done running %s init functions!\n", InitFunctionTypeToString(type));
}

Expand Down
Loading

0 comments on commit 8a6a363

Please sign in to comment.