sockstress
Member
Today, I figured I would release how to create your own natives. It requires RGH or CFW. Could
be done on PC no idea how though. What you will need to do is do some research or reversing to figure out what kind of native you want to do. I will be creating a native to show if a player has godmode and if he doesn't. You will need these offsets first:One of the Large Importing Native Functions
Xex: 0x8257D0B8
BLES: 0x6F0838
BLUS: 0x6F0668
Xex: 0x8257D0B8
BLES: 0x6F0838
BLUS: 0x6F0668
Function To Import Natives Into the Native Hash Table
Xex: 0x82845600
BLES: 0xA389B8
BLUS: 0xA387E8
Xex: 0x82845600
BLES: 0xA389B8
BLUS: 0xA387E8
Now, in the xex/sprx you will need to create a HookFunctionStart so we can import our natives like so.
C:
HookFunctionStart((PDWORD)0x8257D0B8, (PDWORD)SetNativeStub, (DWORD)SetNative);
After that you will need to create a SetNative function like so.
C:
HRESULT SetNative()
{
PushNative("IS_PLAYER_INVINCIBLE", (DWORD)IS_PLAYER_INVINCIBLE);
DbgPrint("Custom Native Entered!\n");
return SetNativeStub();
}
function go as PushNative(const char *NativeName, DWORD NativeAddress); The first parameter being what you want to call the native and that will be the native name the game hashes and imports into the native table. The next parameter being your function address we are going to import this will be the function you are going to create.
Code:
void IS_PLAYER_INVINCIBLE(DWORD native)
{
DWORD dwReturn = *(DWORD*)(native);
int Params = *(int*)(native + 0x04);
DWORD dwNative = *(DWORD*)(native + 0x08);
}
make even if it is returning a value. The reason for this is because GTA will send a pointer to your function as the first parameter. That pointer will go somewhere in memory and will store the return address for you function, how many parameters were sent to the native, and the address of those parameters.
Once you finish creating your native and the xex/sprx builds fine you will then need to import
your native into the sco compiler and import the native how you want in your script.
If all goes well you should be able to do something like this.
PM if you need help or need more explaining done.