Eliot's Forum
Decompiling Switch statments - Printable Version

+- Eliot's Forum (http://eliotvu.com/forum)
+-- Forum: UE Explorer (http://eliotvu.com/forum/forumdisplay.php?fid=1)
+--- Forum: Unreal Deserialization (http://eliotvu.com/forum/forumdisplay.php?fid=14)
+--- Thread: Decompiling Switch statments (/showthread.php?tid=107)



Decompiling Switch statments - ELiZ - 03-22-2015

Hi.

I'm trying to decompiling some switchstatments, and are hitting a brick wall, most of them are decompiled correctly, but some don't.

I'm using UTPT and UE Explorer to check my results.
I also has an almost complete original source of the game as well.



The original Code:

Code:
static event string GetDescriptionText(string PropName)
{
    switch (PropName)
    {
        case "ServerName":    
            return default.GRIPropDescText[0];
        case "AdminName":    
            return default.GRIPropDescText[1];
        case "AdminEmail":    
            return default.GRIPropDescText[2];
        case "MessageOfTheDay":    
            return default.GRIPropDescText[3];
    }

    return Super.GetDescriptionText(PropName);
}

UE Explorer

Code:
static event string GetDescriptionText(string PropName)
{
   switch(PropName)
   {
       case "ServerName":
           return default.GRIPropDescText[0];
       case "AdminName":
           return default.GRIPropDescText[1];
       case "AdminEmail":
           return default.GRIPropDescText[2];
       case "MessageOfTheDay":
           return default.GRIPropDescText[3];
       default:
           return super(Info).GetDescriptionText(PropName);
   }
   //return;    
}

UTPT
Code:
function string GetDescriptionText(string PropName)
{

    switch (PropName)
    {
        case "ServerName":
        return Default.GRIPropDescText[0];
        case "AdminName":
        return Default.GRIPropDescText[1];
        case "AdminEmail":
        return Default.GRIPropDescText[2];
        case "MessageOfTheDay":
        return Default.GRIPropDescText[3];
        default:
    }
    return Super.GetDescriptionText(PropName);
    return;
}


The problem is "return Super.GetDescriptionText(PropName);" witch in the original code is after the switch code, UTPT places it correctly, but UE explorer places it in default:
My code is even worse, and that is why I was looking into why.

Here is the raw hex:
[Image: j60vhs.png]

I suspect that the problem occurs because the default: is empty in the switch

This is from Unreal Tournament Package File Format(v1.6).pdf by Antonio Cordero.

Quote:Size is the size of the Condition

expression. The end of the switch
is unknown except maybe for
some hints inside it.


It might also be just this game that has the issue(America's Army 2.5), but I hope that you have an idea how to detect the end of the switch in this cases.


RE: Decompiling Switch statments - eliot - 03-24-2015

Hey, I am aware of this issue but could never resolve it, because from the perspective of the decompiler they are both identical and there is no clear indication in the bytecode as to where the default block ends. Nonethless if you were to compile the decompiled code the logic would still be identical to the Unreal Engine, thus it's not exactly a problem in this case Wink