Live data from Hacker News

Xbox360 –> Windows Executable Converter (2017)

github.com

31–40 of 57 posts

Re: Xbox360 –> Windows Executable Converter (2017)

#32
post #18

Earlier quoted context omitted.

The main README explains their approach. It disassembles PPC, generates equivalent C++ and compiles that into the target ISA (amd64).

Is it not completely crazy that this is even possible? This sounds like wizardry to me.

Well, think about it this way - suppose you have a block of C code and you compile it to object code, like:

    if (hitByMissile == True) {
      lives--;
      if (lives == 0) playing = False;
    }
    ; next address is 0x8f02
it might turn into:

    ld a, (4011h)
    jr z, 8f02h
    ld a, (4020h)
    dec a
    ld (4020h), a
    jr z, 8f02h
    xor a, a
    ld (0x4021h), a
    ; next address is 8f02h
That might disassemble back to C as:

    if (var4011 != 0) {
      var4020--;
      if (var4020 == 0) {
        var4021 == 0;
      }
    }
like that. Less readable, because we have no variable names, and not identical to the source code but probably close enough, but the important thing is we don't care if we understand it or not. If we declare a variable that our original code stores at 4020h in a 16-bit address space, but it ends up somewhere wildly different in our 32-bit address space because we're recompiling on a newer machine, we don't care - we just care that the name gets used consistently.

If you then read through the disassembled source you could start to piece together what the variables are, though.

Re: Xbox360 –> Windows Executable Converter (2017)

#33
post #18

Earlier quoted context omitted.

Is it not completely crazy that this is even possible? This sounds like wizardry to me.

Well, think about it this way - suppose you have a block of C code and you compile it to object code, like: if (hitByMissile == True) { lives--; if (lives == 0) playing = False; } ; next address is 0x8f02 it might turn into: ld a, (4011h) jr z, 8f02h ld a, (4020h) dec a ld (4020h), a jr z, 8f02h xor a, a ld (0x4021h), a ; next address is 8f02h That might disassemble back to C as: if (var4011 != 0) { var4020--; if (va…

It's not so much the variables, but that compilation must be a lossy process. There may be many ways to interpret the assembly, and the compiler might generate different asm than the one that was decompiled.

Re: Xbox360 –> Windows Executable Converter (2017)

#34
post #33

Earlier quoted context omitted.

Well, think about it this way - suppose you have a block of C code and you compile it to object code, like: if (hitByMissile == True) { lives--; if (lives == 0) playing = False; } ; next address is 0x8f02 it might turn into: ld a, (4011h) jr z, 8f02h ld a, (4020h) dec a ld (4020h), a jr z, 8f02h xor a, a ld (0x4021h), a ; next address is 8f02h That might disassemble back to C as: if (var4011 != 0) { var4020--; if (va…

It's not so much the variables, but that compilation must be a lossy process. There may be many ways to interpret the assembly, and the compiler might generate different asm than the one that was decompiled.

Much less lossy than you probably would think if you've never dug through what your typical compiler outputs. There usually aren't that many ways to interpret the assembly and it doesn't matter whether it generates different assembly as long as it does the same thing.

The typical code generator for a compiler uses all kinds of boilerplate for common constructs (loops, function calls, data access) and once you know about these you can usually recognize them on sight.

Re: Xbox360 –> Windows Executable Converter (2017)

#35
Is it HN’s gaming emulators day? 4 posts in the last 12 hours regarding emulators.

Xbox360 –> Windows Executable Converter (2017) https://news.ycombinator.com/item?id=36705223

The Simpsons Hit and Run leaked source code https://news.ycombinator.com/item?id=36703711

PCSX2 is an open source PS2 Emulator https://news.ycombinator.com/item?id=36702084

Xenia: Xbox 360 Emulator https://news.ycombinator.com/item?id=36702731

Re: Xbox360 –> Windows Executable Converter (2017)

#36
post #26
post #18

Earlier quoted context omitted.

Is it not completely crazy that this is even possible? This sounds like wizardry to me.

Qemu does something similar. And Box86 does that while keeping 3D acceleration on converting X86->ARM linux binaries. https://github.com/ptitSeb/box86

It also depends on how strictly you want preserve the behaviour of the asm.

Re: Xbox360 –> Windows Executable Converter (2017)

#37
post #35

Is it HN’s gaming emulators day? 4 posts in the last 12 hours regarding emulators. Xbox360 –> Windows Executable Converter (2017) https://news.ycombinator.com/item?id=36705223 The Simpsons Hit and Run leaked source code https://news.ycombinator.com/item?id=36703711 PCSX2 is an open source PS2 Emulator https://news.ycombinator.com/item?id=36702084 Xenia: Xbox 360 Emulator https://news.ycombinator.com/item?id=36702731

The Simpsons Hit and Run got an official PC release

Re: Xbox360 –> Windows Executable Converter (2017)

#38
post #33

Earlier quoted context omitted.

It's not so much the variables, but that compilation must be a lossy process. There may be many ways to interpret the assembly, and the compiler might generate different asm than the one that was decompiled.

Much less lossy than you probably would think if you've never dug through what your typical compiler outputs. There usually aren't that many ways to interpret the assembly and it doesn't matter whether it generates different assembly as long as it does the same thing. The typical code generator for a compiler uses all kinds of boilerplate for common constructs (loops, function calls, data access) and once you know ab…

Hmm, that's interesting, thanks Jaques.

Re: Xbox360 –> Windows Executable Converter (2017)

#39
post #17
post #8

Related: Recompiler: Porting Xbox360 Executables to Windows - https://news.ycombinator.com/item?id=15474393 - Oct 2017 (58 comments)

At this point, is it still worth it to post these manually? Checking all post submissions, keeping only the ones with sufficient engagement, and a little summary line "7 other submissions ignored, the oldest dating from Oct 2018" Maybe I'm too lazy, but that really sounds like something I would let a computer automatically do.

Just like in database, deduplication is incredibly hard in practice.
Post reply on HN