Files
UnrealEngineUWP/Engine/Source/Developer/Windows/LiveCodingServer/Private/External/LC_ModuleCache.h

107 lines
3.1 KiB
C
Raw Normal View History

// Copyright 2011-2020 Molecular Matters GmbH, all rights reserved.
#pragma once
// BEGIN EPIC MOD
#include "CoreTypes.h"
// END EPIC MOD
#include "LC_Symbols.h"
#include "LC_Hook.h"
#include "LC_CriticalSection.h"
#include "LC_ProcessTypes.h"
class LiveProcess;
class DuplexPipe;
// thread-safe
class ModuleCache
{
public:
static const size_t SEARCH_ALL_MODULES = static_cast<size_t>(-1);
struct ProcessData
{
// all data except moduleBase is redundant and stored per cache entry, but this doesn't
// increase memory requirements by much. we'd rather have all information accessible fast.
Process::Id processId;
Process::Handle processHandle;
const DuplexPipe* pipe;
void* moduleBase;
};
struct Data
{
uint16_t index; // index of the patch corresponding to the data (0 = original executable)
const symbols::SymbolDB* symbolDb;
const symbols::ContributionDB* contributionDb;
const symbols::CompilandDB* compilandDb;
const symbols::ThunkDB* thunkDb;
const symbols::ImageSectionDB* imageSectionDb;
// BEGIN EPIC MOD
uint64_t lastModificationTime;
// END EPIC MOD
types::vector<ProcessData> processes; // all processes that this patch is loaded into
};
struct FindSymbolData
{
const Data* data;
const symbols::Symbol* symbol;
};
struct FindHookData
{
const Data* data;
uint32_t firstRva;
uint32_t lastRva;
};
ModuleCache(void);
// adds an entry to the cache. does not take ownership of the databases.
// returns a token for registering a process associated with this entry.
// BEGIN EPIC MOD
size_t Insert(const symbols::SymbolDB* symbolDb, const symbols::ContributionDB* contributionDb, const symbols::CompilandDB* compilandDb, const symbols::ThunkDB* thunkDb, const symbols::ImageSectionDB* imageSectionDb, uint64_t lastModicationTime);
// END EPIC MOD
// associates a process with an entry identified by a previously returned token.
void RegisterProcess(size_t token, LiveProcess* liveProcess, void* moduleBase);
// removes a process from all entries
void UnregisterProcess(LiveProcess* liveProcess);
// tries finding a symbol by name, starting from the first module, walking to the latest, excluding the module with the given token
FindSymbolData FindSymbolByName(size_t ignoreToken, const ImmutableString& symbolName) const;
LiveCoding Re-instancing LIMITATIONS: 1) Re-instancing will only update UClass instance data. 2) Adding and removing properties should only be done towards the end of a class or structure and can not be followed by complex data types. 3) Adding and removing properties from a base class should not be done if a derived class contains complex data types. KNOWN ISSUES: 1) Changes to enumerations and structures will not be reflected in existing blueprints. However, adding new nodes to the blueprint will show the updated enumeration or structure. 2) If a class contains an enumeration or structure as a member, the class will not be re-instanced if enumeration or structure is changed. CHANGES: 1) LiveCodingServer 1a) Modified to always execute certain static instances during load. 1b) Modified to exclude the _Statics static structures to avoid patching to old copies. 2) Added support for LiveCoding reinstancing 2a) Refactored deferred registration system for UClass, UEnum, and UScriptStruct to use a common system that works for normal game, hot reload and live coding. 2b) Type specific version check data is possible (i.e. enum doesn't have a size) 2c) Single registration static for UClass 2d) Single registration class for all types that is just a blind forward to API. 2e) Static and dynamic registrations use different API entry points to avoid having overloaded argument lists that just apply to one or the other. 2f) Shims for older API 3) New common "Reload" system to avoid using HotReload code. 3a) Support common delegates regardless of who is reloading/reinstancing. 3b) Re-instancing code moved from HotReload to Kismet2 (where the bulk of the re-instance code already existed). 3c) Modified PyWrapper to use new helper class instead of depending on HotRelaod 3d) Added WITH_RELOAD which is defined if HotReload or LiveCoding is enabled. 3e) Modifed existing code to use new #define and delegates. Robert did the review on the changes covered by Part 2. Remaining changes are all straightforward. #rb robert.manuszewski #jira UE-74493 [CL 15736777 by Tim Smith in ue5-main branch]
2021-03-18 08:13:59 -04:00
// BEGIN EPIC MOD
// tries finding a symbol by name, starting from the last module, walking to the first, excluding the module with the given token
FindSymbolData FindSymbolByNameBackwards(size_t ignoreToken, const ImmutableString& symbolName) const;
// END EPIC MOD
// tries finding the first and last hook in a given section, starting from the newest module, walking to the first, excluding the module with the given token
FindHookData FindHooksInSectionBackwards(size_t ignoreToken, const ImmutableString& sectionName) const;
types::vector<void*> GatherModuleBases(Process::Id processId) const;
inline size_t GetSize(void) const
{
return m_cache.size();
}
inline const Data& GetEntry(size_t i) const
{
return m_cache[i];
}
private:
mutable CriticalSection m_cs;
types::vector<Data> m_cache;
};