[EXTENSION] Hacks
2 Attachment(s)
This extension lets you hook some usefull functions, scan & call functions
by its signature/symbol and call functions by its offset. It has also some
other usefull functions.
Current Version: 1.3.0.0 (07/01/07)
Install:
Code:
1. Extract 'hacks.ext.dll' and 'hacks.ext.so' to the 'addons/sourcemod/extensions' folder.
2. Extract 'hacks.inc' to the 'addons/sourcemod/scripting/include' folder.
3. Extract 'hacks.ext.cfg' to the 'addons/sourcemod/configs' folder.
Natives:
Code:
/**
* Hooks a virtual function.
*
* @param entity Index of the entity.
* @param type Type of the function, see Hacks_HookType.
* @param handler Your function that will be called on hooking.
* @param post True for post operation, false for pre operation.
* @return HookID, that's needed to unhook.
*/
native Hacks_Hook(entity, Hacks_HookType:type, Hacks_HookFunc:func, bool:post=false);
/**
* Unhooks a virtual function.
*
* @param hookid The returned hookid from Hacks_Hook.
* @noreturn
*/
native Hacks_Unhook(hookid);
/**
* Scans for a function in the memory.
*
* @param name Name of the function (e.g. "CBaseAnimating::Ignite").
* @param signature Signature to scan for (Windows). 2A = wildcard
* (e.g. "56 8B 74 24 0C 83 FE FF 57 8B 7C 24 0C 74 25 8B")
* @param symbol Symbol to scan for (Linux).
* @return CallID, that's needed to call the function.
*/
native Hacks_Find(const String:name[], const String:signature[], const String:symbol[]);
/**
* Calls a previously scanned function.
*
* @param entity Index of the entity.
* @param callid The returned callid from Hacks_Find.
* @param calltype Type to call, see Hacks_CallType.
* @param returntype Return type, see Hacks_ReturnType.
* @param[x] argtype Datatype of argument, see Hacks_Param.
* @param[y] arg Argument for function.
* @return If there was a failure in the function, it will return -1,
* otherwise see Hacks_ReturnType.
*/
native Hacks_Call(entity, callid, Hacks_CallType:calltype, Hacks_ReturnType:returntype, any:...);
/**
* Calls a virtual function by its offset.
*
* @param entity Index of the entity.
* @param windows Windows offset.
* @param linux Linux offset.
* @param calltype Type to call, see Hacks_CallType.
* @param returntype Return type, see Hacks_ReturnType.
* @param[x] argtype Datatype of argument, see Hacks_Param.
* @param[y] arg Argument for function.
* @return If there was a failure in the function, it will return -1,
* otherwise see Hacks_ReturnType.
*/
native Hacks_Call_Offset(entity, windows, linux, Hacks_CallType:calltype, Hacks_ReturnType:returntype, any:...);
/**
* Calls a previously scanned function, but without an entity.
*
* @param callid The returned callid from Hacks_Find.
* @param returntype Return type, see Hacks_ReturnType.
* @param[x] argtype Datatype of argument, see Hacks_Param.
* @param[y] arg Argument for function.
* @return If there was a failure in the function, it will return -1,
* otherwise see Hacks_ReturnType.
*/
native Hacks_Call_NoEntity(callid, Hacks_ReturnType:returntype, any:...);
/**
* Adds a file to be force downloaded (cleared every map change).
*
* @param ... Each argument = One file that will be added.
* @noreturn
*/
native Hacks_AddDownload(const String:...);
/**
* Creates a patch that you can use with Hacks_Patch/Hacks_Unpatch
*
* @param callid The returned callid from Hacks_Find.
* @param windows_bytes New Bytes (eg "C2 08 00")
* @param windows_offset Offset (addr to patch = func_addr + offset)
* @param linux_bytes
* @param linux_offset
* @return PatchID, that's needed to patch/unpatch.
*/
native Hacks_CreatePatch(callid, const String:windows_bytes[], windows_offset, const String:linux_bytes[], linux_offset);
/**
* Writes new bytes to a given address
*
* @param patchid The returned patchid from Hacks_CreatePatch.
* @noreturn
*/
native Hacks_Patch(patchid);
/**
* Writes the original bytes to a given address
*
* @param patchid The returned patchid from Hacks_CreatePatch.
* @noreturn
*/
native Hacks_Unpatch(patchid);
Functions to hook:
Code:
// Args: 0, 0, 0, 0, 0
Spawn()
// Args: inflictor, attacker, damage, hitbox, hitgroup
TraceAttack(CTakeDamageInfo const&, Vector const&, CGameTrace*)
// Args: inflictor, attacker, damage, damagetype, ammotype
OnTakeDamage(CTakeDamageInfo const&)
// Args: inflictor, attacker, damage, damagetype, ammotype
Event_Killed(CTakeDamageInfo const&)
// Args: other, 0, 0, 0, 0
StartTouch(CBaseEntity*)
// Args: other, 0, 0, 0, 0
Touch(CBaseEntity*)
// Args: other, 0, 0, 0, 0
EndTouch(CBaseEntity*)
// Args: 0, 0, 0, 0, 0
UpdateOnRemove()
// Args: weapon, 0, 0, 0, 0
Weapon_CanUse(CBaseCombatWeapon*)
// Args: weapon, 0, 0, 0, 0
Weapon_Drop(CBaseCombatWeapon*, Vector const*, Vector const*)
// Args: weapon, 0, 0, 0, 0
Weapon_CanSwitchTo(CBaseCombatWeapon*)
// Args: 0, 0, 0, 0, 0
CommitSuicide()
// Args: impulse, 0, 0, 0, 0
ImpulseCommands()
// Args: buttons, weapon, forwardmove, sidemove, upmove
PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
Example:
Code:
#include <sourcemod>
#include <hacks>
new g_iCreateEntityByName;
new g_iHooks[MAXPLAYERS + 1] = { -1, ... };
public Plugin:myinfo =
{
name = "Hacks Test",
author = "Knagg0",
description = "",
version = "1.0.0.0",
url = "http://www.mfzb.de"
};
public OnPluginStart()
{
// As a wildcard, you can use 2A in the signature
g_iCreateEntityByName = Hacks_Find("CreateEntityByName", "56 8B 74 24 0C 83 FE FF 57 8B 7C 24 0C 74 25 8B", "_Z18CreateEntityByNamePKci");
RegConsoleCmd("give_awp", GiveAWP, "", FCVAR_GAMEDLL);
}
public OnClientPutInServer(client)
{
g_iHooks[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, Weapon_CanUse, false);
}
public OnClientDisconnect(client)
{
Hacks_Unhook(g_iHooks[client]);
}
public Action:GiveAWP(client, args)
{
new iEntity = GiveNamedItem(client, "weapon_awp", 0);
PrintToChat(client, "Entity index: %d", iEntity);
return Plugin_Continue;
}
public Weapon_CanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
{
new String:sBuffer[50];
if(weapon != 0 && GetEdictClassname(weapon, sBuffer, sizeof(sBuffer)))
{
// Can't pickup deagle
if(StrEqual("weapon_deagle", sBuffer))
return 0;
}
return Hacks_Continue;
}
public SomeFunction(client, args)
{
new iEntity = CreateEntityByName("prop_physics", -1);
if(iEntity != -1)
{
// Set origin, angles, model, collision...
// Spawn...
}
}
public GiveNamedItem(client, String:name[], subtype)
{
return Hacks_Call_Offset(client, 329, 330, HACKS_RTYPE_ENTITY, HACKS_PARAM_STRING, name, HACKS_PARAM_INT, subtype);
}
public CreateEntityByName(String:name[], forceindex)
{
return Hacks_Call_NoEntity(g_iCreateEntityByName, HACKS_RTYPE_ENTITY, HACKS_PARAM_STRING, name, HACKS_PARAM_INT, forceindex);
}
Changelog:
Quote:
1.3.0.0 (07/01/07)- Removed Hacks_FindSendPropOffs (FindSendPropOffs already searches recursive)
- Added 3 new natives (Hacks_CreatePatch, Hacks_Patch & Hacks_Unpatch)
- Added the ability to call CEventQueue & CGameRules functions
1.2.0.0 (06/15/07)- Added 2 new functions that you can hook (ImpulseCommands & PlayerRunCommand)
- Added 2 new natives (Hacks_AddDownload & Hacks_FindSendPropOffs)
- Added 1 new paramter (Hacks_CallType) to Hacks_Call_Offset (so plugins needs to be edit to use this version)
- Added IPhysicsObject support to Hacks_CallType & Hacks_Param
- Changed the args of TraceAttack
1.1.0.0 (06/14/07)- Added new natives to hook virtual functions
- Changed some enums
1.0.0.0 (06/11/07)
|
Big thanks to PimpinJuice and his Signature Scan Extension.
It helps me a lot with handling the args :up:
|