-
Notifications
You must be signed in to change notification settings - Fork 3
Hook example #1
Gratt-5r2 edited this page Apr 9, 2022
·
3 revisions
The engine has a few functions when called in the game startup. But the first and easy function is a oCarsten_StartUp
. This functions prepares some console and game settings. So, we know the name of the function, which means we can use the CreateHookByName
macro.
⠀
You can find it in the project explorer.
⠀
And find the oCarsten_StartUp
name. In this line we can see the function signature.
⠀
We can ignore __cdecl
and void
arguments, because it expected by default.
void oCarsten_StartUp_Hooked();
⠀
Use a CreateHookByName
to create a hook by the famous engine name.
auto Hook_oCarsten_StartUp = CreateHookByName( &oCarsten_StartUp, &oCarsten_StartUp_Hooked, Hook_Auto );
⠀
void oCarsten_StartUp_Hooked() {
Message::Box( "Hello, world!" );
// TODO
}
⠀
Use the Hook_oCarsten_StartUp
object like as function.
Hook_oCarsten_StartUp()
⠀
void oCarsten_StartUp_Hooked();
auto Hook_oCarsten_StartUp = CreateHookByName( &oCarsten_StartUp, &oCarsten_StartUp_Hooked, Hook_Auto );
void oCarsten_StartUp_Hooked() {
Message::Box( "Hello, world!" );
Hook_oCarsten_StartUp();
}
⠀
⠀
Compile and place .dll
to the Gothic\System\Autorun\
directory. Run the game and wait the start screen.
- Introduction
- Project hierarchy
- Default functions
- Build options
-
Gothic API
- Base objects
- Models and visuals
- Static and interactive objects
- Animations
- Interface
- Scripts
- Worlds
- Renderer
- Other
- User API
-
Union API
- Hook
- Hook Functions
- Array
- ArraySorted
- Map
- MapArray
- String
- Unicode string
- UTF-8 converter
- RowString
- Console
- Logger
- Message
- Thread
- Event
- Semaphore
- ThreadLocker
- Crc checker
- Options
- Timer
- Union
- VDFS functions
- VirtualFile
- Hooks
- dynamic_cast patch