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

[TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-11-2012 , 06:46   [TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine
Reply With Quote #1

I've written a little Python module which ports a tiny fraction of the decompiler packaged in the sourcemod source. I wrote it to extract the `myinfo` struct from compiled plug-ins for a plug-in auto-updater. Maybe you can find it useful as well.

You can find it at https://github.com/theY4Kman/pysmx. To use it:
Code:
import smx
with open('myplugin.smx', 'rb') as fp:
    plugin = smx.SourcePawnPlugin(fp)
    print plugin.myinfo
UPDATE (7/19/2012): the abstract machine runs plug-ins that are a tad more complicated. 77/176 opcodes complete. Managed Python stack. Can match actual instructions executed to .asm files (spcomp -a). PySMX's PrintToServer matches SourceMod's (except 'L', 'N', 'T', 't').

UPDATE (7/15/2012): PySMX now includes a very basic abstract machine, and can execute the test plug-in provided with it. The new features can be found in the racecondition branch.
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.

Last edited by theY4Kman; 07-19-2012 at 22:06. Reason: Improved abstract machine
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
Mitchell
~lick~
Join Date: Mar 2010
Old 07-11-2012 , 14:51   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #2

wait, what does it do... exactly?
Mitchell is offline
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-11-2012 , 15:03   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #3

It opens compiled SourcePawn plug-ins, reads in all the public variables and extracts `myinfo`, which includes the name, author, description, version, and URL of the plug-in. That's the extent of its functionality now.

I hope to continue porting dvander's decompiler so one can disassemble and decompile plug-ins in Python. Then I'll include it in Viper's standard library. And one day I hope to use it to write a SourcePawn virtual machine in Python, allowing the execution of plug-ins without a server, which will finally make unit testing plug-ins feasible.
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-11-2012 , 15:11   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #4

Quote:
Originally Posted by theY4Kman View Post
I hope to continue porting dvander's decompiler so one can disassemble and decompile plug-ins in Python.
You probably want to reference Lysis instead.
__________________
asherkin is offline
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-11-2012 , 15:12   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #5

Yes, I do!
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-11-2012 , 16:28   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #6

Quote:
Originally Posted by theY4Kman View Post
Yes, I do!
Although, assuming you have Donor access, I highly recommend reading the Knight Redux thread.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-11-2012 , 19:41   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #7

For the sake of it, i'll link to a sourcepawn-only version.
https://forums.alliedmods.net/showth...01#post1635201
__________________
Peace-Maker is offline
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-11-2012 , 22:28   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #8

Quote:
Originally Posted by Peace-Maker View Post
For the sake of it, i'll link to a sourcepawn-only version.
https://forums.alliedmods.net/showth...01#post1635201
Ooh, I didn't even know about devicenull's script! Too bad I can't connect to code.devicenull.org to see it. And never in a million years did I ever think someone would use sm-gunzip. You've made my million years.
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-12-2012 , 05:03   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #9

Quote:
Originally Posted by theY4Kman View Post
Ooh, I didn't even know about devicenull's script! Too bad I can't connect to code.devicenull.org to see it. And never in a million years did I ever think someone would use sm-gunzip. You've made my million years.
It's still in the internet archive. Is your gunzip working by now? I love porting useful stuff to native sourcepawn
__________________
Peace-Maker is offline
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-12-2012 , 06:20   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #10

Quote:
Originally Posted by Peace-Maker View Post
It's still in the internet archive. Is your gunzip working by now? I love porting useful stuff to native sourcepawn
Heh, I got heckled a lot for the uselessness of gunzip I didn't think it would have a use, either, tbh. But unfortunately, no, I never got it to work. Something in _gz_bits just never wanted to cooperate, and I as never able to pinpoint the problem.

And ouch, his code hurt to read ;D Of course, I just want to showoff my lovely Python struct implementation: http://y4kstudios.com/post/making-ct...res-beautiful/
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
Reply



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 12:45.


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