Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release GDec v1.2 (GSC Decompiler for BO2)
[Image: elf7Jti.png]

Started working on this ages ago, only start polishing and refining the code/features recently. Thought it was about time I actually released it. Picture explains it all, pretty simple to get GSCs decompiled. If no output directory is specified (eg. because you drag-and-dropped), it defaults to a "Decompiled" folder.

- Decompiles all GSCs from @kokole GSC rip.
- Optimizes expressions to make them more readable. Example: if ( !( !isDefined( level.usingscorestreaks ) ) ) --> if ( isDefined( level.usingscorestreaks ) )
- Can print out the raw instructions of every GSC, similar to IL in .NET
- Automatic detection of undiscovered DVARs in hash form as well as detection of infinite loops.

Example of "instructions" (--out-instr):

    /* I_0000: OP_CreateLocalVariable () { rankxp, rankxpcapped } */
    /* I_0006: OP_PreScriptCall */
    /* I_0007: OP_GetString "StatValue" */
    /* I_000A: OP_GetString "RANKXP" */
    /* I_000E: OP_GetString "playerstatslist" */
    /* I_0012: OP_GetSelf */
    /* I_0013: OP_ScriptMethodCall getdstat */
    /* I_001C: OP_EvalLocalVariableRefCached 1 */
    /* I_001E: OP_SetVariableField */
    rankxp = self getdstat( "playerstatslist", "RANKXP", "StatValue" );
    /* I_001F: OP_PreScriptCall */
    /* I_0020: OP_EvalLocalVariableCached 1 */
    /* I_0022: OP_ScriptFunctionCall getrankxpcapped */
    /* I_0028: OP_EvalLocalVariableRefCached 0 */
    /* I_002A: OP_SetVariableField */
    rankxpcapped = getrankxpcapped( rankxp );
    /* I_002B: OP_EvalLocalVariableCached 1 */
    /* I_002D: OP_EvalLocalVariableCached 0 */
    /* I_002F: OP_greater */
    /* I_0030: OP_JumpOnFalse I_004D */
    if ( rankxp > rankxpcapped )
        /* I_0034: OP_PreScriptCall */
        /* I_0035: OP_EvalLocalVariableCached 0 */
        /* I_0037: OP_GetString "StatValue" */
        /* I_003A: OP_GetString "RANKXP" */
        /* I_003E: OP_GetString "playerstatslist" */
        /* I_0042: OP_GetSelf */
        /* I_0043: OP_ScriptMethodCall setdstat */
        /* I_004C: OP_DecTop */
        self setdstat( "playerstatslist", "RANKXP", "StatValue", rankxpcapped );
    /* I_004D: OP_EvalLocalVariableCached 0 */
    /* I_004F: OP_Return */
    return rankxpcapped;

Known bugs:
- Some if statements might be slightly inaccurate if they combine different logical operators (&& and ||) in the same statement.

Changes in v1.1: (1st March 2014)
- Improved detection of infinite loops.
- Added proper continue and return support for while loops.
- Added else block detection.
- Fixed the calls to getDvarColorXXXX.
- Fixed developer code blocks.

Changes in v1.2: (1st March 2014)
- Fixed bug with "Object reference not set to instance of an object" message on DLC.
- Added support for compound assingments (+=, -=, *=, /=)

Thanks to @kokole and @Nukem for their reversing efforts.

I've attached an archive containing @kokole 's entire GSC rip in decompiled form.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.

Very nice.

Btw, some mistakes I found in _zm.gsc

[Image: 012ddb75291fd0d76d1d8f1f5e5985d9.png]

The code inside the if, there's a continue, so the loop is a for.

[Image: 35a743b0b63c7b9b86798bcb4228388d.png]

I don't think that it's supposed to be like that Tongue

[Image: ba6e8ec0bc7e59583af6621577314943.png]

That is (i + 1) and not i + 1.

Thanks for the bug reports. Although, adding a continue there would still make the code incorrect because you'd be essentially skipping the "player_index++" statement which is crucial for the while loop to work so I can't really fix this until I properly implement a full for loop. I guess I can add a little "extra" code that's not really there to simulate the real thing.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.

One question, are there gsc mods for BO2?

Hawt, something I found in gun.gsc addguntoprogression( "ballista_mp+is" );

Wait is that how attachments are handled by BO2? A freaking +?
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]

Alright, updated to v1.1. Thanks @kokole and @DidUknowiPwn for pointing out bugs.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.

(02-28-2014, 23:16)Yamato Wrote: One question, are there gsc mods for BO2?

Decompiler != Compiler.

(03-01-2014, 08:13)dtx12 Wrote:
(02-28-2014, 23:16)Yamato Wrote: One question, are there gsc mods for BO2?

Decompiler != Compiler.

He isn't stupid. xD
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click

Nice. Bit too late though Sad
[Image: MaEIQ.png]

(03-01-2014, 13:46)Pozzuh Wrote: Nice. Bit too late though Sad

Too soon for BO3 Troll

Another bug, in _utility.gsc:

[Image: 8abf052a79eab8ced867f2043e02f97d.png]

Btw my decompiler says that the stack is corrupted at the end of decompilation of that function.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] Lua Decompiler 30mba 12 12,905 04-24-2020, 13:23
Last Post: Nekochan
  [Release] Black Ops II GSC Decompiler v1.0 dtx12 79 59,891 06-25-2016, 11:57
Last Post: STriVE MoDz
  [Request] GSC Decompiler hanso123 2 4,402 07-20-2015, 05:21
Last Post: TheNiceUb3r

Forum Jump:

Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.