Raised This Month: $12 Target: $400
 3% 

Module: Orpheu (v2.6.3)


Post New Thread Reply   
 
Thread Tools Display Modes
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-23-2016 , 19:36   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1461

Quote:
Originally Posted by HamletEagle View Post
Using such signature on windows hlds, it works ok:
Code:
{
	"name"      : "packPlayerItem",
	"library"   : "mod",
	"arguments" :
	[
		{
			"type" : "CBasePlayer *"
		},
		{
			"type" : "CBasePlayerItem *"
		},
		{
			"type" : "bool"
		}
	],
	"identifiers" :
	[
		{
			"os"    : "windows",
			"mod"   : "cstrike",
			"value" : [0x83,"*","*",0x53,0x57,0x8B,"*","*","*",0x33,0xDB,0x3B,"*",0x0F]
		},
		{
			"os"    : "linux",
			"mod"   : "cstrike",
			"value" : "_ZL14packPlayerItemP11CBasePlayerP15CBasePlayerItemb"
		},
		{
			"os"    : "linux",
			"mod"   : "cstrike",
			"value" : "packPlayerItem__FP11CBasePlayerP15CBasePlayerItemb"
		}
	]
}
Output:
Code:
OnPackPlayerItem called id 1 wid 437 ammo 1
Can't test on linux. Btw, why are you using sign for linux? Just provide the symbol.
This has been discussed before. From Arkshine words: "Some functions symbols name doesn't work for some reasons, it might be the case for this one too. Some symbols doesn't work and I don't think it's related to orpheu itself.". This is one case
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-24-2016 , 12:28   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1462

This function seems to be optimized by the compiler. When it's called, the passed arguments are not pushed on the stack but instead are saved into the registers (fastcall convention?). This means Orpheu/Okapi can't retrieve properly the arguments. I'm not sure how to support that. About the symbol not found, it's probably the reason why it's "hidden', but it's possible to retrieve it with an indirect way.
__________________

Last edited by Arkshine; 07-24-2016 at 12:33.
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-24-2016 , 14:15   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1463

Quote:
Originally Posted by Arkshine View Post
This function seems to be optimized by the compiler. When it's called, the passed arguments are not pushed on the stack but instead are saved into the registers (fastcall convention?). This means Orpheu/Okapi can't retrieve properly the arguments. I'm not sure how to support that. About the symbol not found, it's probably the reason why it's "hidden', but it's possible to retrieve it with an indirect way.
SetAnimation_part_2 behavior? Or it's not related at all?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-24-2016 , 15:06   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1464

The same with the difference this function is split in two, one optimized skipping the first checks and one normal function with the first checks which calls the optimized one.
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-25-2016 , 00:35   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1465

So, there's nothing much I can do. GG
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 09-29-2016 , 22:04   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1466

I can't seem to find signatures for CGrenade::Smoke and CGrenade::Smoke3_C anywhere. Is anyone with IDA and the know how willing to help find them?
PartialCloning is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-30-2016 , 11:13   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1467

Some functions are exported under windows too, you don't need bytes. This also mean they keep their names, simply open IDA and search for "Smoke3_C" and "Smoke".

CGrenade::Smoke3_C
Code:
win: ?Smoke3_C@CGrenade@@QAEXXZ
lin: _ZN8CGrenade8Smoke3_CEv
CGrenade::Smoke
Code:
win: ?Smoke@CGrenade@@QAEXXZ
lin: _ZN8CGrenade5SmokeEv
Note that since this are think functions, you can "hook" them without orpheu, by using think and checking m_pfnThink offset. For fun and because it's interesting to show multiple ways, here's how you would do it:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>

enum _:Functions
{
    
Smoke,
    
Smoke3_C
}

const 
m_iTeam            114
const m_flStartThrow     30
const m_flTimeWeaponIdle 48
const m_pfnThink         4
const XoCBaseEntity       0
const XoPlayer            5
const XoCGrenade          4

new FunctionsAddresses[Functions]
new 
HandlePfnSetModelHook

new GrenadeEntityIndex

public plugin_init()
{
    
/*
        | How it works? Basically, game sets some function addresses on entities in m_pfnThink offset(check sdk for SetThink/SetTouch). 
        | If you retrieve this address, later, you can check in Think the current value of m_pfnThink and know what think function it's being executed. 
        | This can be expanded for most think/touch functions.
    */
    
    
RegisterHam(Ham_Think"grenade""OnCGrenade_Think")
    
    
/*
        | Create a fakeplayer and spawn
        | We use the fakeplayer for obtaining the function address
    */
    
new FakePlayer engfunc(EngFunc_CreateFakeClient"player")
    
dllfunc(DLLFunc_ClientPutInServerFakePlayer)
    
set_pdata_int(FakePlayerm_iTeam1XoPlayer)
    
ExecuteHam(Ham_SpawnFakePlayer)
    
    new const 
GrenadeWeapons[Functions][] =
    {
        
"weapon_flashbang"//for Smoke()
        
"weapon_hegrenade"  //for Smoke3_C()
    
}
    
    new 
EntityIndex
    
for(new isizeof GrenadeWeaponsi++)
    {
        
EntityIndex give_item(FakePlayerGrenadeWeapons[i])
        
HandlePfnSetModelHook register_forward(FM_SetModel"pfnSetModel"true)
        
        
//Make the bot ready to fire the nade
        
set_pdata_float(EntityIndexm_flTimeWeaponIdle0.0XoCGrenade)
        
set_pdata_float(EntityIndexm_flStartThrow0.1XoCGrenade)
        
        
ExecuteHam(Ham_Weapon_WeaponIdleEntityIndex)            
        
unregister_forward(FM_SetModelHandlePfnSetModelHooktrue)
        
        
EntityIndex GrenadeEntityIndex
        
        
/*
            | There are more think functions that are executed before Smoke and Smoke3_C
            | We need to pass them, so we call Think two times
            | Also set dmgtime so grenade can explode and Think functions advance
            | For example, for a flashbang the call order is:
            | WeaponIdle -> ShootTimed -> TumbleThink -> Detonate -> Explode -> Smoke
        */
        
        
set_pev(EntityIndexpev_dmgtime0.1)
        
        
//Keeping above example, here m_pfnThink points to TumbleThink
        
ExecuteHam(Ham_ThinkEntityIndex)
        
//Here it points to Detonate
        
ExecuteHam(Ham_ThinkEntityIndex)
        
//Now it is set to Smoke 
        
FunctionsAddresses[i] = get_pdata_int(EntityIndexm_pfnThinkXoCBaseEntity//finally retrieve what we wanted
    
}
    
    
set_task(0.1"RemoveFakePlayer"FakePlayer)
}


public 
pfnSetModel(const Entity, const Model[])
{
    if(
pev_valid(Entity))
    {
        
//Get the grenade entity index(the grenade created by ShootSmokeGrenade/ShootTimed/ShootTimed2)
        //SetModel() is called from above functions
        
        
new ClassName[32]
        
pev(Entitypev_classnameClassNamecharsmax(ClassName))
        if(
equal(ClassName"grenade")) //really needed?
        
{
            
GrenadeEntityIndex Entity     
        
}
    }
}

public 
RemoveFakePlayer(id)
{
    
//Get rid of the bot, no longer needed
    
server_cmd("kick #%i"get_user_userid(id))
}

public 
OnCGrenade_Think(const GrenadeEntity)
{
    if(
pev_valid(GrenadeEntity))
    {
        
//Retrieve current value of m_pfnThink and compare with what we retrieved before
        
new Think get_pdata_int(GrenadeEntitym_pfnThinkXoCBaseEntity)
        
        if(
Think == FunctionsAddresses[Smoke])
        {
            
client_print(0print_chat"CGrenade::Smoke called %i"GrenadeEntity)
        }
        else 
        {
            if(
Think == FunctionsAddresses[Smoke3_C])
            {
                
client_print(0print_chat"CGrenade::Smoke3_C called %i"GrenadeEntity)
            }
        }
    }

__________________

Last edited by HamletEagle; 09-30-2016 at 11:17.
HamletEagle is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 09-30-2016 , 12:42   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1468

Thank you. In terms of efficiency, is there a big difference? I know using Orpheu is more direct and better but is using Ham_Think inefficient?
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-30-2016 , 13:04   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1469

Should be just as good, the difference is trivial.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-01-2016 , 07:58   Re: Module: Orpheu (v2.6.3)
Reply With Quote #1470

Since you like and can use orpheu, I would go with it since code is shorter so it should be cleaner. But speacking about performance, difference is trivial, as Klippy said.
__________________

Last edited by HamletEagle; 10-01-2016 at 08:00.
HamletEagle 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:21.


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