Complete redirect native function, not only in AMX
#4

Код:
static void _sampgdk_amxhooks_hook_native(AMX *amx,
                                          const char *name,
                                          AMX_NATIVE address) {
  int index;
  AMX_HEADER *hdr = (AMX_HEADER *)amx->base;
  AMX_FUNCSTUBNT *natives = (AMX_FUNCSTUBNT *)(amx->base + hdr->natives);

  if (amx_FindNative(amx, name, &index) == AMX_ERR_NONE) {
    natives[index].address = (ucell)address;
  }
}
took from SA-MP GDK source code (amxhooks.c).

Also if you need to store the original address you can use my modification to zeex's function:
Код:
void _streamer_native_hook(AMX *amx, const char *name, AMX_NATIVE address, AMX_NATIVE *store) {
	int index;
	AMX_HEADER *hdr = (AMX_HEADER *)amx->base;
	AMX_FUNCSTUBNT *natives = (AMX_FUNCSTUBNT *)(amx->base + hdr->natives);

	if (amx_FindNative(amx, name, &index) == AMX_ERR_NONE) {
		if (store) {
			*store = (AMX_NATIVE)natives[index].address;
		}
		natives[index].address = (ucell)address;
	}
}
Took from my streamer plugin (native.c).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)