UnrealModFramework
Mod framework API
Loading...
Searching...
No Matches
ModAPINative.h
Go to the documentation of this file.
1// Copyright (c) 2026 Nelaric Contributors
3#pragma once
4
5#include "ModAPIRegistry.h"
6
7namespace Mod::API
8{
11{
13 uint64 Context = 0;
15 uint64 Scope = 0;
16};
17
19struct MODAPI_API FNativeAccess
20{
27 static TModResult<FNativeContext> Open(FRegistry& Registry, const FCaller& Caller, bool bExposeScope = true);
32 static TModResult<void> Close(uint64 Context);
40 static TModResult<FObjectBinding> Resolve(uint64 Context, uint64 Target, FName TypeId, const TCHAR* Signature);
48 static TModResult<FObjectBinding> ResolveObject(uint64 Context, uint64 Target, FName TypeId,
49 const TCHAR* Signature);
55 static TModResult<uint64> Publish(uint64 Context, FObjectBinding Binding);
61 static TModResult<void> Release(uint64 Context, uint64 Object);
62
63public:
65 template <class T> static void RegisterHostQuery(const char* Module, const char* Symbol, T Query)
66 {
67 StoreHostQuery(UTF8_TO_TCHAR(Module), UTF8_TO_TCHAR(Symbol), reinterpret_cast<void*>(Query));
68 }
69
70 static void* FindHostQuery(const TCHAR* Module, const TCHAR* Symbol);
72 static void ForgetHostQueries(const TCHAR* Module);
74 static TModResult<FObjectBinding> ResolveAnyObject(uint64 Context, uint64 Object);
76 static bool OwnsContext(uint64 Context, const FCaller& Caller);
78 static bool ReadSDKObjectPath(uint64 Context, uint64 Object, bool bWritable, FString& OutPath);
80 static bool MatchesObject(uint64 Context, uint64 Object, const UObject& Source);
83
84private:
85 static void StoreHostQuery(const TCHAR* Module, const TCHAR* Symbol, void* Query);
86};
87} // namespace Mod::API
A host-issued caller identity and permission grant.
Definition ModAPIRegistry.h:107
An opaque, non-owning object binding with a cached typed calling table.
Definition ModAPIObject.h:18
Owns a session's generated definitions, providers, scopes, and callers.
Definition ModAPIRegistry.h:117
A synchronous API result containing either a value or a stable error.
Definition ModAPIResult.h:47
Host-only token access for generated fixed-signature C ABI bridges.
Definition ModAPINative.h:20
static void * FindHostQuery(const TCHAR *Module, const TCHAR *Symbol)
Looks up an exact registered query on the game thread.
static void ForgetHostQueries(const TCHAR *Module)
Withdraws query addresses when the owning host registration goes away.
static bool OwnsContext(uint64 Context, const FCaller &Caller)
Checks whether the given context was issued to this host caller.
static void RegisterHostQuery(const char *Module, const char *Symbol, T Query)
Makes a generated host API query address available to native Mods.
Definition ModAPINative.h:65
static TModResult< FNativeContext > Open(FRegistry &Registry, const FCaller &Caller, bool bExposeScope=true)
Issues opaque tokens for a host-approved caller.
static bool MatchesObject(uint64 Context, uint64 Object, const UObject &Source)
Checks whether a live binding identifies this exact source object.
static TModResult< void > Close(uint64 Context)
Releases a native context and every object token it owns.
static TModResult< FObjectBinding > Resolve(uint64 Context, uint64 Target, FName TypeId, const TCHAR *Signature)
Resolves a scope/provider or object token for a generated call.
static TModResult< void > Release(uint64 Context, uint64 Object)
Releases an object token without affecting the actual UObject.
static TModResult< uint64 > Publish(uint64 Context, FObjectBinding Binding)
Publishes an authorized object as a context-owned token.
static TModResult< FObjectBinding > ResolveAnyObject(uint64 Context, uint64 Object)
Looks up a context-owned object for a native callback adapter.
static bool ReadSDKObjectPath(uint64 Context, uint64 Object, bool bWritable, FString &OutPath)
Recovers the path of a live SDK reference owned by the calling context.
static TModResult< FObjectBinding > ResolveObject(uint64 Context, uint64 Target, FName TypeId, const TCHAR *Signature)
Resolves an object token on the game thread.
static TModResult< const UObject * > ReadPayloadObject(const FObjectBinding &Binding)
Reads an object while its callback lease is valid.
Process-local tokens issued by the host for an authorized caller.
Definition ModAPINative.h:11
uint64 Context
Calling identity; zero is never a valid context.
Definition ModAPINative.h:13
uint64 Scope
The caller's scope; this token cannot be used by another context.
Definition ModAPINative.h:15