AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] Hacks (https://forums.alliedmods.net/showthread.php?t=56323)

Knagg0 06-11-2007 13:49

[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)
  • First release

Big thanks to PimpinJuice and his Signature Scan Extension.
It helps me a lot with handling the args :up:

API 06-11-2007 16:05

Re: [EXTENSION] Hacks
 
Hey there,
Didn't I mention that I was making a vfunc caller? I wouldn't trust that source code of yours considering its an old version. Maybe I should just impliment vfuncs into sigoffset because people use it pretty often. Thanks, Anthony

Knagg0 06-11-2007 16:43

Re: [EXTENSION] Hacks
 
Hey... I just created this extension because i needed that
VFunc-Calls und Return-Values for the plugins i'am working on.
It would be cool if you add this to your sigoffset extension,
then i can use yours and delete this one :)

And please change the Find native. You don't need a mask
or length just use 2A (*) as a wildcard and get the length from
the signature. It's just a suggestion... :idea:

API 06-11-2007 18:42

Re: [EXTENSION] Hacks
 
It does return value, I just need to post my update with HandleToIndex. I'll tweak my code for those things listed above.

Olly 06-12-2007 13:29

Re: [EXTENSION] Hacks
 
Dont use * as the wildcard >< sigscans have always used '?' also my little program for masking the sig uses ? :P

but i do agree.. PimpinJuice: you need to remove 1 from the height of a not found sig. and also derive the sig length from the mask :P

L. Duke 06-12-2007 17:34

Re: [EXTENSION] Hacks
 
I use BAILOPAN's sigscanning class from CSDM (as do others, like c0ldfyr3) so I'm used to seeing "\x2A" (which is *) as the wild card. Also it doesn't use the mask stuff, so "xxxxx??xxx" looks weird.

:)

Knagg0 06-14-2007 18:42

Re: [EXTENSION] Hacks
 
Update

API 06-14-2007 20:04

Re: [EXTENSION] Hacks
 
I definately like what you have done with it, we should merge the code into sigoffset for compatibility.

Knagg0 06-15-2007 17:11

Re: [EXTENSION] Hacks
 
I don't know... At first i wanted to make a new extension for the hook stuff,
but then i thought that it's better to put all that stuff into one extension.
It's easier for me to make sm plugins with my functions, because i use
nearly the some in my standalone plugins for my servers.

Btw: Update :)

Falco 06-15-2007 18:28

Re: [EXTENSION] Hacks
 
Link to file?


All times are GMT -4. The time now is 01:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.