Source Engine - CreateInterface
🎯 Hate searching for memory offsets that break when the game updates?
Source Engine has a function called CreateInterface. Just pass it a string name, and it hands you the core interface pointer instantly.
👉 https://youtu.be/HHHlNdmzYqA
Factory Patterns and Dynamic Interface Retrieval
In C++ software development, the CreateInterface pattern is an implementation of the Abstract Factory design pattern commonly used in modular C++ engines (such as Valve's Source Engine) to expose internal subsystem APIs without tightly coupling modules.
Instead of exporting hundreds of individual class functions or requiring client applications to hardcode volatile memory offsets to global objects, a dynamic link library (DLL) exports a single factory function, typically named CreateInterface.
Mechanics of Interface Exporters
Interface Versioning: The factory function accepts an interface version string (e.g., "VEngineClient013") and an optional return code pointer.
Internal Registry: Inside the DLL, a linked list or registry of interface constructors (InterfaceReg) maps string identifiers to instantiated singleton objects or factory methods.
Pointer Return: When invoked, CreateInterface traverses its internal registry, matches the requested version string, and returns an opaque base class pointer (void* or an abstract class interface pointer) to the caller.
This design allows software developers to update internal implementation details, class layouts, and private member variables inside the DLL without breaking external plugins or tools, provided the abstract virtual method table (vtable) structure of the public interface remains consistent.
