AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   Lysis: An experimental .smx decompiler (https://forums.alliedmods.net/showthread.php?t=170898)

GoD-Tony 06-23-2012 06:09

Re: Lysis: An experimental .smx decompiler
 
Quote:

Originally Posted by schmidt (Post 1734373)
Error: bad file

Who can get source code?

Full error: (line #'s might be different on mine)
Code:

Unhandled Exception: System.Exception: bad file
  at SourcePawn.SourcePawnFile..ctor(Byte[] binary) in Lysis\SourcePawnFile.cs:line 441
  at Lysis.PawnFile.FromFile(String path) in Lysis\PawnFile.cs:line 47
  at Lysis.Program.Main(String[] args) in Lysis\Program.cs:line 94

It's becoming increasingly more common for closed-source communities to modify the *.smx in a way that blocks Lysis, but still loads on SourceMod.

Is Lysis just getting stuck on some unnecessary header changes?

Edit: Looks like the same issue over here. Time to ping psychonic.

Peace-Maker 06-23-2012 11:11

Re: Lysis: An experimental .smx decompiler
 
2 Attachment(s)
Quote:

Originally Posted by schmidt (Post 1734373)
Error: bad file

Who can get source code?
https://bugs.alliedmods.net/show_bug.cgi?id=5358

Where did you get that plugin? Seems like some strange way of seperating admins:D
xbox_throttlespoof 123 ?


Quote:

Originally Posted by GoD-Tony (Post 1734376)
Full error: (line #'s might be different on mine)
Code:

Unhandled Exception: System.Exception: bad file
  at SourcePawn.SourcePawnFile..ctor(Byte[] binary) in Lysis\SourcePawnFile.cs:line 441
  at Lysis.PawnFile.FromFile(String path) in Lysis\PawnFile.cs:line 47
  at Lysis.Program.Main(String[] args) in Lysis\Program.cs:line 94

It's becoming increasingly more common for closed-source communities to modify the *.smx in a way that blocks Lysis, but still loads on SourceMod.

Is Lysis just getting stuck on some unnecessary header changes?

Edit: Looks like the same issue over here. Time to ping psychonic.

Yes, it's some minor header changes that mock lysis. In the above one x.smx, the imagesize was changed from like 00001818 to 01001818, leaving the decompression check in the air, as it was expecting 16783081 uncompressed bytes instead of 5865.

Another change, which is also present in the kac thing you linked to is the removal of the null-terminator after the last section name. .dbg.strings\x00 would be .dbg.strings\x01 letting lysis skip too far and reading .dbg.strings€..

Changing both back to 00 fixed it.

You might be able to work around that, by touching the ReadString function and let it stop at any ascii control character instead of only 0.
Code:

if (bytes[count] == 0)
Code:

if (bytes[count] < 32)
For the imagesize change.. Well, one could simply remove the size check and only check, if the decompression was successful at all instead of expecting some kind of size.

schmidt 06-23-2012 16:43

Re: Lysis: An experimental .smx decompiler
 
Quote:

Originally Posted by Peace-Maker (Post 1734481)
Where did you get that plugin? Seems like some strange way of seperating admins:D
xbox_throttlespoof 123 ?

here =)
Peace-Maker, thank you very much.

NiceAndSimple 07-06-2012 23:46

Re: Lysis: An experimental .smx decompiler
 
1 Attachment(s)
can somebody please decompile this for me, it is a knockback plugin ive used for my zriot server but when i went to go look for the thread again it was gone and all the configuration has to be changed in the .sp file then compiled.

TnTSCS 07-07-2012 00:01

Re: Lysis: An experimental .smx decompiler
 
You asked once about this btw: http://forums.alliedmods.net/showthread.php?p=1742986

it doesn't decompile too well:
PHP Code:


new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "******************ο***************************",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"1000.0"
    
}
    {
        
"usp",
        
"1000.0"
    
}, 

Are any of these what you're looking for:
http://forums.alliedmods.net/showthread.php?t=60180
https://forums.alliedmods.net/showthread.php?t=156646

Peace-Maker 07-07-2012 13:24

Re: Lysis: An experimental .smx decompiler
 
You'll need to create that weaponKB array yourself again, but the plugin itself is straight forward.

PHP Code:

new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "ýý¿ýýý",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"1000.0"
    
},
    {
        
"usp",
        
"1000.0"
    
}
}
public 
__ext_core_SetNTVOptional()
{
    
MarkNativeAsOptional("GetFeatureStatus");
    
MarkNativeAsOptional("RequireFeature");
    
MarkNativeAsOptional("AddCommandListener");
    
MarkNativeAsOptional("RemoveCommandListener");
    
VerifyCoreVersion();
    return 
0;
}

ScaleVector(Float:vec[3], Float:scale)
{
    new 
var1 vec;
    
var1[0] = FloatMul(var1[0], scale);
    new 
var2 vec[4];
    
var2 FloatMul(var2scale);
    new 
var3 vec[8];
    
var3 FloatMul(var3scale);
    return 
0;
}

MakeVectorFromPoints(Float:pt1[3], Float:pt2[3], Float:output[3])
{
    
output[0] = FloatSub(pt2[0], pt1[0]);
    
output[4] = FloatSub(pt2[4], pt1[4]);
    
output[8] = FloatSub(pt2[8], pt1[8]);
    return 
0;
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
    return 
strcmp(str1str2caseSensitive) == 0;
}

public 
OnPluginStart()
{
    
CreateConVar("knockback_version""1.0""knockback plugin info cvar"8448false0.0false0.0);
    
HookEvent("player_hurt"EventHook:5EventHookMode:1);
    return 
0;
}

public 
Action:Player_Hurt(Handle:eventString:name[], bool:dontBroadcast)
{
    new 
Client GetClientOfUserId(GetEventInt(event"userid"));
    new 
Attacker GetClientOfUserId(GetEventInt(event"Attacker"));
    new 
var1;
    if (
AliveCheck(Client) == 1) {
        
decl String:k_weapon[32];
        
GetEventString(event"weapon"k_weapon32);
        new 
0;
        while (
28) {
            new 
var2 weaponKB[i][0][0];
            if (
StrEqual(var2[0][var2], k_weapontrue)) {
                
decl Float:Clientposition[3];
                
decl Float:targetposition[3];
                
decl Float:vector[3];
                
GetClientEyePosition(AttackerClientposition);
                
GetClientEyePosition(Clienttargetposition);
                
MakeVectorFromPoints(Clientpositiontargetpositionvector);
                
NormalizeVector(vectorvector);
                
ScaleVector(vectorStringToFloat(weaponKB[i][0][0][4]));
                
TeleportEntity(ClientNULL_VECTORNULL_VECTORvector);
            }
            
i++;
        }
    }
    return 
Action:0;
}

public 
bool:AliveCheck(Client)
{
    new 
var1;
    if (
Client 0) {
        if (
IsClientConnected(Client) == 1) {
            if (
IsClientInGame(Client) == 1) {
                if (
IsPlayerAlive(Client) == 1) {
                    return 
true;
                }
                return 
false;
            }
            return 
false;
        }
        return 
false;
    }
    return 
false;



TnTSCS 07-07-2012 18:50

Re: Lysis: An experimental .smx decompiler
 
how did you get it to decompile so well?

NiceAndSimple 07-07-2012 23:07

Re: Lysis: An experimental .smx decompiler
 
PHP Code:

new PlVers:__version 5;
new 
Float:NULL_VECTOR[3];
new 
String:NULL_STRING[1];
new 
Extension:__ext_core 68;
new 
MaxClients;
new 
Extension:__ext_sdktools 184;
public 
Plugin:myinfo =
{
    
name "KnockBack",
    
description "Weapon Knock Back",
    
author "ýý¿ýýý",
    
version "1.0",
    
url ""
};
new 
String:weaponKB[28][2][64] =
{
    {
        
"knife",
        
"0.0"
    
},
    {
        
"glock",
        
"40.0"
    
},
    {
        
"usp",
        
"40.0"
    
},
    {
        
"p228",
        
"40.0"
    
},
    {
        
"deagle",
        
"50.0"
    
},
    {
        
"fiveseven",
        
"40.0"
    
},
    {
        
"elite",
        
"40.0"
    
},
    {
        
"m3",
        
"100.0"
    
},
    {
        
"xm1014",
        
"80.0"
    
},
    {
        
"tmp",
        
"50.0"
    
},
    {
        
"mac10",
        
"50.0"
    
},
    {
        
"ump45",
        
"60.0"
    
},
    {
        
"mp5navy",
        
"60.0"
    
},
    {
        
"p90",
        
"60.0"
    
},
    {
        
"galil",
        
"70.0"
    
},
    {
        
"ak47",
        
"70.0"
    
},
    {
        
"m4a1",
        
"70.0"
    
},
    {
        
"famas",
        
"70.0"
    
},
    {
        
"aug",
        
"70.0"
    
},
    {
        
"sg552",
        
"70.0"
    
},
    {
        
"m249",
        
"70.0"
    
},
    {
        
"scout",
        
"150.0"
    
},    
    {
        
"awp",
        
"250.0"
    
},
    {
        
"sg550",
        
"80.0"
    
},
    {
        
"g3sg1",
        
"80.0"
    
}
}
public 
__ext_core_SetNTVOptional()
{
    
MarkNativeAsOptional("GetFeatureStatus");
    
MarkNativeAsOptional("RequireFeature");
    
MarkNativeAsOptional("AddCommandListener");
    
MarkNativeAsOptional("RemoveCommandListener");
    
VerifyCoreVersion();
    return 
0;
}

ScaleVector(Float:vec[3], Float:scale)
{
    new 
var1 vec;
    
var1[0] = FloatMul(var1[0], scale);
    new 
var2 vec[4];
    
var2 FloatMul(var2scale);
    new 
var3 vec[8];
    
var3 FloatMul(var3scale);
    return 
0;
}

MakeVectorFromPoints(Float:pt1[3], Float:pt2[3], Float:output[3])
{
    
output[0] = FloatSub(pt2[0], pt1[0]);
    
output[4] = FloatSub(pt2[4], pt1[4]);
    
output[8] = FloatSub(pt2[8], pt1[8]);
    return 
0;
}

bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
{
    return 
strcmp(str1str2caseSensitive) == 0;
}

public 
OnPluginStart()
{
    
CreateConVar("knockback_version""1.0""knockback plugin info cvar"8448false0.0false0.0);
    
HookEvent("player_hurt"EventHook:5EventHookMode:1);
    return 
0;
}

public 
Action:Player_Hurt(Handle:eventString:name[], bool:dontBroadcast)
{
    new 
Client GetClientOfUserId(GetEventInt(event"userid"));
    new 
Attacker GetClientOfUserId(GetEventInt(event"Attacker"));
    new 
var1;
    if (
AliveCheck(Client) == 1) {
        
decl String:k_weapon[32];
        
GetEventString(event"weapon"k_weapon32);
        new 
0;
        while (
28) {
            new 
var2 weaponKB[i][0][0];
            if (
StrEqual(var2[0][var2], k_weapontrue)) {
                
decl Float:Clientposition[3];
                
decl Float:targetposition[3];
                
decl Float:vector[3];
                
GetClientEyePosition(AttackerClientposition);
                
GetClientEyePosition(Clienttargetposition);
                
MakeVectorFromPoints(Clientpositiontargetpositionvector);
                
NormalizeVector(vectorvector);
                
ScaleVector(vectorStringToFloat(weaponKB[i][0][0][4]));
                
TeleportEntity(ClientNULL_VECTORNULL_VECTORvector);
            }
            
i++;
        }
    }
    return 
Action:0;
}

public 
bool:AliveCheck(Client)
{
    new 
var1;
    if (
Client 0) {
        if (
IsClientConnected(Client) == 1) {
            if (
IsClientInGame(Client) == 1) {
                if (
IsPlayerAlive(Client) == 1) {
                    return 
true;
                }
                return 
false;
            }
            return 
false;
        }
        return 
false;
    }
    return 
false;


I compiled this and got these 11 errors: And where the cool face is its meant to be an 8

/groups/sourcemod/compiler-1.4/include/core.inc(171) : warning 209: function "__ext_core_SetNTVOptional" should return a value
/groups/sourcemod/compiler-1.4/include/vector.inc(160) : warning 209: function "ScaleVector" should return a value
/groups/sourcemod/compiler-1.4/include/vector.inc(188) : warning 209: function "MakeVectorFromPoints" should return a value
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(1) : warning 213: tag mismatch
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(2) : error 021: symbol already defined: "NULL_VECTOR"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(3) : error 021: symbol already defined: "NULL_STRING"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(4) : warning 213: tag mismatch
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(5) : error 021: symbol already defined: "MaxClients"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(117) : error 052: multi-dimensional arrays must be fully initialized
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(119) : error 021: symbol already defined: "__ext_core_SetNTVOptional"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(129) : error 021: symbol already defined: "ScaleVector"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(130) : error 033: array must be indexed (variable "-unknown-")
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 028: invalid subscript (not an array or too many subscripts): "var1"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : warning 215: expression has no effect
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 001: expected token: ";", but found "]"
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDlQwwV.sp(131) : fatal error 127: too many error messages on one line

Peace-Maker 07-08-2012 10:43

Re: Lysis: An experimental .smx decompiler
 
You can't just compile the decompiled plugins. You'll have to clean it up or better just rewrite it, as it's that simple. The only interesting code is in the player_hurt event handler.

Quote:

Originally Posted by TnTSCS (Post 1745653)
how did you get it to decompile so well?

I changed the dumpStringArray method to not try to access invalid indexes, it's not a good solution as lots of the array is missing as you can see ;)

NiceAndSimple 07-09-2012 03:27

Re: Lysis: An experimental .smx decompiler
 
Quote:

Originally Posted by Peace-Maker (Post 1746078)
You can't just compile the decompiled plugins. You'll have to clean it up or better just rewrite it, as it's that simple. The only interesting code is in the player_hurt event handler.



I changed the dumpStringArray method to not try to access invalid indexes, it's not a good solution as lots of the array is missing as you can see ;)

Are you able to quickly do this for me? Please....


All times are GMT -4. The time now is 11:20.

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