示例#1
0
static int AMXAPI amx_CallbackHookProc(AMX *amx, cell index, cell *result, cell *params) {
	amx_CallbackHook.Remove();

	// Forbid SYSREQ.D
	amx->sysreq_d = 0;

	// Natives can call amx_Exec()
	amx_ExecHook.Reinstall();
	int error = amx_Callback(amx, index, result, params);
	amx_ExecHook.Remove();

	amx_CallbackHook.Reinstall();
	return error;
}
示例#2
0
static int AMXAPI amx_ExecHookProc(AMX *amx, cell *retval, int index) {
	amx_ExecHook.Remove();

	bool canDoExec = true;
	if (index == AMX_EXEC_MAIN) {
		gamemode = amx;
		sampgdk::Wrapper::GetInstance().CallPublicHook(amx, retval, "OnGameModeInit");
	} else {
		if (amx == gamemode && index != AMX_EXEC_CONT) {
			canDoExec = sampgdk::Wrapper::GetInstance().CallPublicHook(amx, retval, currentPublic.c_str());
		}
		if (index == AMX_EXEC_GDK) {
			amx->stk += amx->paramcount * sizeof(cell);
			amx->paramcount = 0;
		}
	}

	int error = AMX_ERR_NONE;
	if (canDoExec) {
		error = amx_Exec(amx, retval, index);
		if (index == AMX_EXEC_GDK) {
			error = AMX_ERR_NONE;
		}
	}

	amx_ExecHook.Reinstall();
	return error;
}
示例#3
0
static int AMXAPI amx_FindPublicHookProc(AMX *amx, const char *name, int *index) {
	amx_FindPublicHook.Remove();

	int error = amx_FindPublic(amx, name, index);

	if (amx == gamemode) {
		if (error != AMX_ERR_NONE) {
			*index = AMX_EXEC_GDK;
			error = AMX_ERR_NONE;
		}
		currentPublic = name;
	}

	amx_FindPublicHook.Reinstall();
	return error;
}
示例#4
0
static int AMXAPI amx_RegisterHookProc(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number) {
	amx_RegisterHook.Remove();

	int error = amx_Register(amx, nativelist, number);

	for (int i = 0; nativelist[i].name != 0 && (i < number || number == -1); ++i) {
		sampgdk::Wrapper::GetInstance().SetNative(nativelist[i].name, nativelist[i].func);
		// Fix for funcidx() issue
		if (strcmp(nativelist[i].name, "funcidx") == 0) {
			SetJump((void*)nativelist[i].func, (void*)fixed_funcidx);
		}
	}

	amx_RegisterHook.Reinstall();
	return error;
}