How to overwrite/create "raw" UFunction?

Okay, this is, I guess a weird request, but something I heavily want to do.

Basically, UHT creates “execRealFunctionName” functions which are then pointed to by the function pointer in a UFunction instance.
These functions wrap the real function and do the input/output from the stack “frame”.
My question is now, can I write a function with that code by my self?

The end goal is to have a universal function implementation I can use to overwrite underlying function pointers of BP functions.
That means, after the “magic”… when the function “FuncA” of the BP Class “BPA” gets called, in reality the universal function implementation will get executed.
I can’t use delegates for that, cause the universal function implementation should be able to handle multiple different declarations.

I know for a fact that I can implement the “unversial function”… I just need to find out, how create my own “exec” function.

By sound of what you trying to make, i think it’s gonna be a lot easier to just make (and most impotently understand) your own UK2Node (K2 means Kismet 2 as blueprints are UE3 Kismet successor, this name i still used in source code).

Each node type in Blueprints has it’s own UK2Node class, defining appearance of node and what VM code in generates:

For example all function call nodes (nodes with “f” icon) are contained in single class as single UK2Node can create multiple nodes of same type, in this case, for each exposed function

Making UK2Node not only let you control what is executed and generly create your own VM code, but also appernce of node, what pins it can have and such. It gives you a hell lot more options then trying to hack UFunctions.

In fact Epic does something that you want too, they created UK2Node specifically for SpawnActor and only reason why they did that insted of using normal UFunction binding is to auto cast the output node to type of spawned actor. And i think this is great start point for oyu to learn as it’s most similar to what you trying to do which sound like specially called function:

https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Editor/BlueprintGraph/Private/K2Node_SpawnActor.cpp

One note, UK2Node are editor only classes, so you would need to create editor only module (set that in uproject or uplugin whatever yo working on). UK2Nodes don’t get in to run time, since once they generate VM code during packaging, they are no needed.