AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine (https://forums.alliedmods.net/showthread.php?t=189809)

theY4Kman 07-11-2012 06:46

[TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine
 
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. :fox:

Mitchell 07-11-2012 14:51

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
wait, what does it do... exactly?

theY4Kman 07-11-2012 15:03

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
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.

asherkin 07-11-2012 15:11

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Quote:

Originally Posted by theY4Kman (Post 1748230)
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.

theY4Kman 07-11-2012 15:12

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Yes, I do!

Powerlord 07-11-2012 16:28

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Quote:

Originally Posted by theY4Kman (Post 1748236)
Yes, I do!

Although, assuming you have Donor access, I highly recommend reading the Knight Redux thread.

Peace-Maker 07-11-2012 19:41

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
For the sake of it, i'll link to a sourcepawn-only version.
https://forums.alliedmods.net/showth...01#post1635201

theY4Kman 07-11-2012 22:28

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Quote:

Originally Posted by Peace-Maker (Post 1748380)
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.

Peace-Maker 07-12-2012 05:03

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Quote:

Originally Posted by theY4Kman (Post 1748444)
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 :)

theY4Kman 07-12-2012 06:20

Re: [TOOLS] Python SourcePawn Plug-in Reader
 
Quote:

Originally Posted by Peace-Maker (Post 1748605)
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 :P 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/


All times are GMT -4. The time now is 16:28.

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