Raised This Month: $248 Target: $400
 62% 

[EXTENSION] Hacks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Knagg0
SourceMod Donor
Join Date: Dec 2005
Location: Germany
Old 06-11-2007 , 13:49   [EXTENSION] Hacks
Reply With Quote #1

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
Attached Files
File Type: zip hacks_1.3.0.0.zip (159.7 KB, 68303 views)
File Type: zip hacks_1.3.0.0_src.zip (27.2 KB, 7143 views)
__________________

MFZB Gaming Community

[ www.mfzb.de ]


Last edited by Knagg0; 07-01-2007 at 09:53.
Knagg0 is offline
API
Veteran Member
Join Date: May 2006
Old 06-11-2007 , 16:05   Re: [EXTENSION] Hacks
Reply With Quote #2

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
__________________
API is offline
Send a message via AIM to API
Knagg0
SourceMod Donor
Join Date: Dec 2005
Location: Germany
Old 06-11-2007 , 16:43   Re: [EXTENSION] Hacks
Reply With Quote #3

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...
__________________

MFZB Gaming Community

[ www.mfzb.de ]

Knagg0 is offline
API
Veteran Member
Join Date: May 2006
Old 06-11-2007 , 18:42   Re: [EXTENSION] Hacks
Reply With Quote #4

It does return value, I just need to post my update with HandleToIndex. I'll tweak my code for those things listed above.
__________________
API is offline
Send a message via AIM to API
Olly
Senior Member
Join Date: Mar 2007
Location: UK
Old 06-12-2007 , 13:29   Re: [EXTENSION] Hacks
Reply With Quote #5

Dont use * as the wildcard >< sigscans have always used '?' also my little program for masking the sig uses ?

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
__________________
Tumblr Me: http://raspberryteen.tumblr.com


// Yarrrr!
Olly is offline
Send a message via MSN to Olly
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 06-12-2007 , 17:34   Re: [EXTENSION] Hacks
Reply With Quote #6

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.

L. Duke is offline
Knagg0
SourceMod Donor
Join Date: Dec 2005
Location: Germany
Old 06-14-2007 , 18:42   Re: [EXTENSION] Hacks
Reply With Quote #7

Update
__________________

MFZB Gaming Community

[ www.mfzb.de ]

Knagg0 is offline
API
Veteran Member
Join Date: May 2006
Old 06-14-2007 , 20:04   Re: [EXTENSION] Hacks
Reply With Quote #8

I definately like what you have done with it, we should merge the code into sigoffset for compatibility.
__________________
API is offline
Send a message via AIM to API
Knagg0
SourceMod Donor
Join Date: Dec 2005
Location: Germany
Old 06-15-2007 , 17:11   Re: [EXTENSION] Hacks
Reply With Quote #9

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
__________________

MFZB Gaming Community

[ www.mfzb.de ]

Knagg0 is offline
Falco
SourceMod Donor
Join Date: Dec 2004
Location: CANADA
Old 06-15-2007 , 18:28   Re: [EXTENSION] Hacks
Reply With Quote #10

Link to file?
__________________
[DmZ|EPSILON CSS 70.75.139.92:27016
[DmZ|EPSILON GG 70.75.167.30:27015
[DmZ|EPSILON CS:GO Classic Casual 70.75.139.92:27013
[DmZ|EPSILON CS:GO Demolition 70.75.139.92:27014
[DmZ|EPSILON BF3 69.46.43.221:25203 (8-slot) Practice Server
www.dmzepsilon.ca
----------------------
Falco is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:24.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode