Raised This Month: $32 Target: $400
 8% 

Orpheu: Patching strings in memory


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-06-2010 , 09:10   Orpheu: Patching strings in memory
Reply With Quote #1

This is a mini-tutorial to demonstrate how to use Orpheu to replace strings in memory. You can use this functionality to:
  1. Change text to something you want
  2. Replace models or sounds efficiently
  3. More stuff
First, download this software:

http://www.hex-rays.com/idapro/idadownfreeware.htm

Install it and open it.

[IMG]http://img231.**************/img231/6339/45340387.png[/IMG]

Press New

[IMG]http://img12.**************/img12/8282/79514323.png[/IMG]

PE Dynamic Library
OK

Now: to see the strings of the:

  • engine library, open the file swds.dll of your dedicated server folder.
  • mod, open the file mod/dlls/mp.dll in your dedicated server folder.
For this example I will use the engine library.

[IMG]http://img191.**************/img191/5043/29492852.png[/IMG]


View
Open subviews
Strings

And you will have a list of strings that the library uses.

For this example I will use:

Code:
#      name userid uniqueid frag time ping loss adr\n
First we need to make a file to identify the memory that we are dealing with. It should look like:

Code:
{
    "name"        : "engineString",
    "library"     : "engine",
    "type"        : "string",
    "memoryType"  : "data"
}
The name is up to you, the library is where it is, the type is "string" for this tutorial and memoryType you can check it from the strings table as you have in IDA. Like:

[IMG]http://img46.**************/img46/883/71307609.png[/IMG]

data is "data"
rdata is "rodata"
text is "code"

This field is meant to ensure integrity after messing with memory but is only useful in Linux. Anyway, you have to provide a valid type.

Now, save the file with the content described above in

configs/orpheu/memory and name it as you want.

To use it now you would do something like:

PHP Code:
    #include <amxmodx>
    #include <orpheu_memory>
    
    
public plugin_precache()
    {
        
OrpheuMemoryReplace("engineString",0,"#      name userid uniqueid frag time ping loss adr^n","# Arkshine loves Connor^n")
    } 
Beware that when you do this you should not use replacement strings longer than the original.

Now, when running this plugin, if your server users use the command status they will see:

[IMG]http://img205.**************/img205/184/60858560.png[/IMG]
__________________
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-06-2010 , 09:14   Re: Orpheu: Patching strings in memory
Reply With Quote #2

Nice.

I hate your tutorial.
__________________
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-06-2010 , 09:16   Re: Orpheu: Patching strings in memory
Reply With Quote #3

A more useful example (replaces the sound of when you press +USE without using nothing):

Code:
{
    "name"        : "modString",
    "library"     : "mod",
    "type"        : "string",
    "memoryType"  : "data"
}
PHP Code:
    #include <amxmodx>
    #include <orpheu_memory>
    
    
public plugin_precache()
    {
        
OrpheuMemoryReplace("modString",0,"common/wpn_denyselect.wav","common/bodysplat.wav")
    } 
__________________
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-06-2010 , 09:26   Re: Orpheu: Patching strings in memory
Reply With Quote #4

Changing weapon models is now a lot more efficient :

Code:
{
    "name"        : "weaponModels",
    "library"     : "mod",
    "type"        : "string",
    "memoryType"  : "data"
}

Code:
#include <amxmodx> #include <orpheu_memory>     public plugin_precache() {      OrpheuMemoryReplace( "weaponModels", 0, "models/v_hegrenade.mdl", "models/v_hegrenad.mdl" );      OrpheuMemoryReplace( "weaponModels", 0, "models/w_m4a1.mdl", "models/w_m4a2.mdl" ); }

The weapon sounds won't still work since it's handled by the client.
__________________

Last edited by Arkshine; 02-06-2010 at 09:35.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-06-2010 , 09:34   Re: Orpheu: Patching strings in memory
Reply With Quote #5

Wow, thats really nice
__________________
xPaw is offline
KadiR
Unnecessary Member
Join Date: Aug 2008
Location: Zürich / Switzerland
Old 02-06-2010 , 10:56   Re: Orpheu: Patching strings in memory
Reply With Quote #6

[/AGREE]

Quote:
Originally Posted by xPaw View Post
Wow, thats really nice
[/AGREED]

Nice comments Arkshine
KadiR is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-06-2010 , 14:28   Re: Orpheu: Patching strings in memory
Reply With Quote #7

Quote:
Arkshine loves Connor
LOL

Will there be more tutorials about using Orpheu?
This helped me learn some about it, but I'm kind of lost as to what this module can do and how to use it.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-06-2010 , 14:56   Re: Orpheu: Patching strings in memory
Reply With Quote #8

'Quim will probably post about the use of virtual functions.
I'm writing a tuto "How find functions and make signatures". Something like.

You have to use IDA or such software to understand that you can do a lot of things, like to find that such function is called from others functions ( to block, etc.. ). HLSDK is obviously not enough for CS functions. Or you need to block/replace a specific thing in one function, so you see the disassembled code, then you could for example find a constant value you could change and making a patch. Like the plugin 'infinite round' I nop a check so the whole if() is ignored.

You have to know how are done the funtions so you can do almost what you want. For example, using IDA by decompiling and changing some things, you can see for example what does exactly PM_Jump : http://paste.ak-team.com/f87e7065 ; then you see there are constants, you could change easily, or ignoring.

What I say is for the game dll, but you can do more things with other library like "engine", so much interesting functions there to alter.
Anyway above is very specific, you can also change param/param of struct of a function on-the-fly easily and such.
__________________

Last edited by Arkshine; 02-06-2010 at 15:35.
Arkshine is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 02-06-2010 , 15:58   Re: Orpheu: Patching strings in memory
Reply With Quote #9

So I could do something like

PHP Code:
    #include <amxmodx>
    #include <orpheu_memory>
    
    
public plugin_precache()
    {
        
OrpheuMemoryReplace("engineString",0,"Connection accepted by %s^n","Welcome %s to porn server !!!^n")
    } 
Code:
{
    "name"        : "engineString",
    "library"     : "engine",
    "type"        : "string",
    "memoryType"  : "data"
}
01101101 is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 02-06-2010 , 15:59   Re: Orpheu: Patching strings in memory
Reply With Quote #10

This is very interesting. Thanks.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
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 07:06.


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