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

amxxdump


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-21-2007 , 12:03   amxxdump
Reply With Quote #1

This is just a small tool I was working on for personal use, but I figured a couple people may find it useful so I made it a bit easier to use and got it to build on Windows.

This program is an amxmodx specific plugin disassembler. Specifically, plugins built with amxmodx 1.5+ (previous ones will not load).

This is meant to compliment Wraith's disassembler, not entirely replace it. My data section examination implementation is very poor (did it in about 5 minutes...), so it's better to use his for that regard. His also makes pseudo labels for jumps, this one just displays the address. Also his is in a nice GUI, this one is entirely console driven.

The biggest difference between the two disassemblers is this one was built with the sole purpose of looking up the plugin's symbol table. The symbol table (to my knowledge) was not in Small when Wraith made his disassembler.

For disassembly the symbol table is complete hax. You can view a variables exact offsets, the scope of the variable, the name, tags for it, dimensions, etc.

General usage:

As stated previous, this is ENTIRELY console driven. There is no GUI for this.

amxxdump file.amxx [ parameters ]

Here are the switches:

Quote:
-a Suppress address locations in most places.
-c Suppress all comments from disassembly.
-x List all public and stock functions and their parameters.
-n List all natives used by the plugin.
-D <name> Disassemble the provided function.
-d Disassemble the entire code section of the script.
-s Show all symbols.
-m Show required modules.
-r <name> Search for all references to the named function.
-R <name> Search for all references to the named native.
-v <val> Display the value of an address in the data section.
-A <size> In addition to -v, this dumps <size> many cells as an output.
-V <val> Display the value of an address in the data section as a string.
-F <val> Display the value of an address in the data section as a float.
-f Output the name of every file that included code (stocks).
-l Output line number and filename as comment on BREAK ops.
-j Output jump labels as comments for jumps, switches and case tables.
-e Attempt to estimate some data from push.c/const.pri ops. Do not read data literally.
-E Attempt to list parameters of standard native calls. Not all will work, requires include files.
-N Suppresses the variable dimensions, tags, and default values in the native guesser output. Implies -E
-g List all global variables. A pawn compiler bug will make not-used stock variables display as well.
-h Hide parameter numbers and addresses, useful for comparing with diffs.

-! Display this program's license.

-? This help screen.
For example, to output the assembly of the "cmdSlap" function in admincmd.amxx, I would do:

amxxdump admincmd.amxx -D cmdSlap

As stated before, the data viewing portion is very poorly implemented.

Just a warning, I haven't extensively tested the Windows build. The vast majority of my work has been with the Linux version.

v1.01, now with (hopefully!) less crashes on Windows, -f and -l (run with -? for details)
v1.02, now with -c (suppress all comments) and -j (generate pseudo labels for jumps)
v1.3, now with better Windows support, very basic SourceMod plugin support, and now with native parsing.
v1.3.1, fixed a few small quirks with the native parser
v1.3.2, fixed a few more quirks with the native parser
v1.4, more tweaks to the native parser, added comments to STACK and FILL ops, added comment when a variable scope begins. Added -g.
v1.5, fixed some crashes with the native parser on some awkward natives. Added -h, -N, and -A (consult -? for more details). Changed most address output (except for the disassembly itself) to be 0x%08X instead of 0x%X. Changed -m to give better output.
Attached Files
File Type: zip amxxdump.zip (424.7 KB, 12489 views)

Last edited by sawce the snail; 04-01-2007 at 10:33.
sawce is offline
BAILOPAN
Join Date: Jan 2004
Old 03-21-2007 , 13:59   Re: amxxdump
Reply With Quote #2

sawce how is it you're so awesome
__________________
egg
BAILOPAN is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-21-2007 , 14:29   Re: amxxdump
Reply With Quote #3

i no rite
sawce is offline
Juba_PornBorn1
BANNED
Join Date: Feb 2007
Location: Caracas
Old 03-21-2007 , 19:09   Re: amxxdump
Reply With Quote #4

I left a post searching for a plugin manager and here it is!!! Well not as I figured it would be but a benning of a program that may be very useful in a near future adding extra tools and make instead of console only a all full acess program with buttons, decomplilers etc...

http://forums.alliedmods.net/showthread.php?t=52770

This litle program is sweeetttt! I tryed some of the options and it's really easy to get the offsets of plugins I got, as well as natives! Hope someone develops this even further and take it to what I meant in the post link!

Last edited by Juba_PornBorn1; 03-21-2007 at 21:28.
Juba_PornBorn1 is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-22-2007 , 09:51   Re: amxxdump
Reply With Quote #5

Updated to v1.02:

Added:
-c Suppress all comments.
-j Generate pseudo labels for jumps.

v1.01 (old change log):

Hopefully fixed crashing on Windows.

Added:
-l Display file & line comments on BREAK opcodes.
-f Display all files that generated code (included stocks).

@Juba_PornBorn1 this is nothing like your request...

Last edited by sawce the snail; 03-22-2007 at 09:53.
sawce is offline
Jheshka
Senior Member
Join Date: Dec 2005
Old 03-23-2007 , 00:23   Re: amxxdump
Reply With Quote #6

Marry me?
__________________
James
Jheshka is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 03-23-2007 , 01:28   Re: amxxdump
Reply With Quote #7

Quote:
Originally Posted by Jheshka View Post
Marry me?
Deviance is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 03-23-2007 , 12:22   Re: amxxdump
Reply With Quote #8

Quote:
Originally Posted by Jheshka View Post
Marry me?
But seriously this is hella tight.

Last edited by SweatyBanana; 03-23-2007 at 12:34.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Jheshka
Senior Member
Join Date: Dec 2005
Old 03-23-2007 , 15:55   Re: amxxdump
Reply With Quote #9

I agree.

Sawce, I love you.
__________________
James
Jheshka is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 03-26-2007 , 09:46   Re: amxxdump
Reply With Quote #10

Updated to version 1.3:
  • Added better Windows support.
  • Added very basic SourceMod plugin support. Symbols and most of the utility, code-scanning abilities (eg: -D, -E) will not work yet, but you will get full opcode output (-d)
  • Added data guessing switch (-e). This will attempt to guess data from the push.c op code. It's not perfect.
  • Added native guessing switch (-E). This will attempt to guess data passed to a native. Only natives with a series of push's immediately before them (eg: no ternary operator, or natives with function return values) will be auto detected.

The "includes" directory (provided) needs to be in the same directory as the amxxdump binary for this feature to work.

so people know what I'm talking about, here's the example output from the new -E switch (admincmd.amxx, plugin_init):
Code:
[~/amxxdump/bin]> ./amxxdump ../admincmd.amxx -D plugin_init -E

0x990                      PROC              ; public plugin_init()
0x994                     BREAK
0x998                     BREAK
0x99C                    PUSH.C  0xADC
0x9A4                    PUSH.C  0x0
0x9AC                    PUSH.C  0xAA0
0x9B4                    PUSH.C  0xC
0x9BC                  SYSREQ.C  0xA         ; register_plugin("Admin Commands",AMXX_VERSION_STR[6]={"1.76c"},"AMXX Dev Team")
0x9C4                     STACK  0x10
0x9CC                     BREAK
0x9D0                    PUSH.C  0xB14
0x9D8                    PUSH.C  0x4
0x9E0                  SYSREQ.C  0xB         ; register_dictionary("admincmd.txt")
0x9E8                     STACK  0x8
0x9F0                     BREAK
0x9F4                    PUSH.C  0xB48
0x9FC                    PUSH.C  0x4
0xA04                  SYSREQ.C  0xB         ; register_dictionary("common.txt")
0xA0C                     STACK  0x8
0xA14                     BREAK
0xA18                    PUSH.C  0xBB8
0xA20                    PUSH.C  0x4
0xA28                    PUSH.C  0xB98
0xA30                    PUSH.C  0xB74
0xA38                    PUSH.C  0x10
0xA40                  SYSREQ.C  0xC         ; register_concmd("amx_kick","cmdKick",4,"<name or #userid> [reason]")
0xA48                     STACK  0x14
0xA50                     BREAK
0xA54                    PUSH.C  0xC60
0xA5C                    PUSH.C  0x8
0xA64                    PUSH.C  0xC44
0xA6C                    PUSH.C  0xC24
0xA74                    PUSH.C  0x10
0xA7C                  SYSREQ.C  0xC         ; register_concmd("amx_ban","cmdBan",8,"<name or #userid> <minutes> [reason]")
0xA84                     STACK  0x14
0xA8C                     BREAK
0xA90                    PUSH.C  0xD40
0xA98                    PUSH.C  0x8
0xAA0                    PUSH.C  0xD1C
0xAA8                    PUSH.C  0xCF4
0xAB0                    PUSH.C  0x10
0xAB8                  SYSREQ.C  0xC         ; register_concmd("amx_banip","cmdBanIP",8,"<name or #userid> <minutes> [reason]")
0xAC0                     STACK  0x14
0xAC8                     BREAK
0xACC                    PUSH.C  0xE28
0xAD4                    PUSH.C  0x8
0xADC                    PUSH.C  0xE00
0xAE4                    PUSH.C  0xDD4
0xAEC                    PUSH.C  0x10
0xAF4                  SYSREQ.C  0xC         ; register_concmd("amx_addban","cmdAddBan",8,"<authid or ip> <minutes> [reason]")
0xAFC                     STACK  0x14
0xB04                     BREAK
0xB08                    PUSH.C  0xEFC
0xB10                    PUSH.C  0x8
0xB18                    PUSH.C  0xED8
0xB20                    PUSH.C  0xEB0
0xB28                    PUSH.C  0x10
0xB30                  SYSREQ.C  0xC         ; register_concmd("amx_unban","cmdUnban",8,"<authid or ip>")
0xB38                     STACK  0x14
0xB40                     BREAK
0xB44                    PUSH.C  0xF7C
0xB4C                    PUSH.C  0x10
0xB54                    PUSH.C  0xF5C
0xB5C                    PUSH.C  0xF38
0xB64                    PUSH.C  0x10
0xB6C                  SYSREQ.C  0xC         ; register_concmd("amx_slay","cmdSlay",16,"<name or #userid>")
0xB74                     STACK  0x14
0xB7C                     BREAK
0xB80                    PUSH.C  0x1008
0xB88                    PUSH.C  0x10
0xB90                    PUSH.C  0xFE8
0xB98                    PUSH.C  0xFC4
0xBA0                    PUSH.C  0x10
0xBA8                  SYSREQ.C  0xC         ; register_concmd("amx_slap","cmdSlap",16,"<name or #userid> [power]")
0xBB0                     STACK  0x14
0xBB8                     BREAK
0xBBC                    PUSH.C  0x10BC
0xBC4                    PUSH.C  0x4
0xBCC                    PUSH.C  0x1098
0xBD4                    PUSH.C  0x1070
0xBDC                    PUSH.C  0x10
0xBE4                  SYSREQ.C  0xC         ; register_concmd("amx_leave","cmdLeave",4,"<tag> [tag] [tag] [tag]")
0xBEC                     STACK  0x14
0xBF4                     BREAK
0xBF8                    PUSH.C  0x1168
0xC00                    PUSH.C  0x40
0xC08                    PUSH.C  0x1144
0xC10                    PUSH.C  0x111C
0xC18                    PUSH.C  0x10
0xC20                  SYSREQ.C  0xC         ; register_concmd("amx_pause","cmdPause",64,"- pause or unpause the game")
0xC28                     STACK  0x14
0xC30                     BREAK
0xC34                    PUSH.C  0x1214
0xC3C                    PUSH.C  0x1000000
0xC44                    PUSH.C  0x11F8
0xC4C                    PUSH.C  0x11D8
0xC54                    PUSH.C  0x10
0xC5C                  SYSREQ.C  0xC         ; register_concmd("amx_who","cmdWho",16777216,"- displays who is on server")
0xC64                     STACK  0x14
0xC6C                     BREAK
0xC70                    PUSH.C  0x12C8
0xC78                    PUSH.C  0x40
0xC80                    PUSH.C  0x12A8
0xC88                    PUSH.C  0x1284
0xC90                    PUSH.C  0x10
0xC98                  SYSREQ.C  0xC         ; register_concmd("amx_cvar","cmdCvar",64,"<cvar> [value]")
0xCA0                     STACK  0x14
0xCA8                     BREAK
0xCAC                 CONST.pri  0x1360
0xCB4                      HEAP  0x4
0xCBC                      MOVS  0x4
0xCC4                  PUSH.alt
0xCC8                    PUSH.C  0x1000000
0xCD0                    PUSH.C  0x1334
0xCD8                    PUSH.C  0x1304
0xCE0                    PUSH.C  0x10
0xCE8                  SYSREQ.C  0xC         ; register_concmd("amx_plugins","cmdPlugins",16777216,"")
0xCF0                     STACK  0x14
0xCF8                      HEAP  0xFFFFFFFC
0xD00                     BREAK
0xD04                 CONST.pri  0x1360
0xD0C                      HEAP  0x4
0xD14                      MOVS  0x4
0xD1C                  PUSH.alt
0xD20                    PUSH.C  0x1000000
0xD28                    PUSH.C  0x1394
0xD30                    PUSH.C  0x1364
0xD38                    PUSH.C  0x10
0xD40                  SYSREQ.C  0xC         ; register_concmd("amx_modules","cmdModules",16777216,"")
0xD48                     STACK  0x14
0xD50                      HEAP  0xFFFFFFFC
0xD58                     BREAK
0xD5C                    PUSH.C  0x13FC
0xD64                    PUSH.C  0x20
0xD6C                    PUSH.C  0x13E0
0xD74                    PUSH.C  0x13C0
0xD7C                    PUSH.C  0x10
0xD84                  SYSREQ.C  0xC         ; register_concmd("amx_map","cmdMap",32,"<mapname>")
0xD8C                     STACK  0x14
0xD94                     BREAK
0xD98                    PUSH.C  0x1460
0xDA0                    PUSH.C  0x80
0xDA8                    PUSH.C  0x1444
0xDB0                    PUSH.C  0x1424
0xDB8                    PUSH.C  0x10
0xDC0                  SYSREQ.C  0xC         ; register_concmd("amx_cfg","cmdCfg",128,"<filename>")
0xDC8                     STACK  0x14
0xDD0                     BREAK
0xDD4                    PUSH.C  0x14D0
0xDDC                    PUSH.C  0x10
0xDE4                    PUSH.C  0x14B0
0xDEC                    PUSH.C  0x148C
0xDF4                    PUSH.C  0x10
0xDFC                  SYSREQ.C  0xC         ; register_concmd("amx_nick","cmdNick",16,"<name or #userid> <new nick>")
0xE04                     STACK  0x14
0xE0C                     BREAK
0xE10                    PUSH.C  0x1588
0xE18                    PUSH.C  0x800
0xE20                    PUSH.C  0x1568
0xE28                    PUSH.C  0x1544
0xE30                    PUSH.C  0x10
0xE38                  SYSREQ.C  0xD         ; register_clcmd("amx_rcon","cmdRcon",2048,"<command line>")
0xE40                     STACK  0x14
0xE48                     BREAK
0xE4C                    PUSH.C  0x1628
0xE54                    PUSH.C  0x800
0xE5C                    PUSH.C  0x15F8
0xE64                    PUSH.C  0x15C4
0xE6C                    PUSH.C  0x10
0xE74                  SYSREQ.C  0xD         ; register_clcmd("amx_showrcon","cmdShowRcon",2048,"<command line>")
0xE7C                     STACK  0x14
0xE84                     BREAK
0xE88                 CONST.pri  0x16AC
0xE90                      HEAP  0x4
0xE98                      MOVS  0x4
0xEA0                  PUSH.alt
0xEA4                    PUSH.C  0xFFFFFFFF
0xEAC                    PUSH.C  0x1688
0xEB4                    PUSH.C  0x1664
0xEBC                    PUSH.C  0x10
0xEC4                  SYSREQ.C  0xD         ; register_clcmd("pauseAck","cmdLBack",-1,"")
0xECC                     STACK  0x14
0xED4                      HEAP  0xFFFFFFFC
0xEDC                  ZERO.pri
0xEE0                      RETN
As you'll see, there's a few minor annoyances I have to fix yet, but for the most part it's operational.

Last edited by sawce the snail; 03-26-2007 at 13:02.
sawce 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:04.


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