How would I reimplement a function?
So, with the game I'm trying to recomp (Fallout 3), I got a few functions that, well, don't exist. How would I reimplement them? Would I just add a source file that has the function in it and treat it like a normal C function?
In your runtime, just define the function anywhere you want, and the linker will resolve it. For example:
PPC_FUNC(__imp__NtCreateFile)
{
// implementation here...
}
I recommend checking out what UnleashedRecomp does: https://github.com/hedge-dev/UnleashedRecomp/blob/main/UnleashedRecomp/kernel/imports.cpp
The hooks are created at the bottom of the file through a GUEST_FUNCTION_HOOK macro, which is a helper macro that auto generates the PPC function declaration while translating the PPC registers to real function arguments for easier usage. The macro is implemented here: https://github.com/hedge-dev/UnleashedRecomp/blob/main/UnleashedRecomp/kernel/function.h
With that NtCreateFile would look like:
uint32_t NtCreateFile
(
be<uint32_t>* FileHandle,
uint32_t DesiredAccess,
XOBJECT_ATTRIBUTES* Attributes,
XIO_STATUS_BLOCK* IoStatusBlock,
uint64_t* AllocationSize,
uint32_t FileAttributes,
uint32_t ShareAccess,
uint32_t CreateDisposition,
uint32_t CreateOptions
)
{
// implementation here...
}
GUEST_FUNCTION_HOOK(__imp__NtCreateFile, NtCreateFile);
How do you stub the unnecessary functions, I cant make sense of the files you suggested.