avast / avast/retdec

Unicode strings are displayed incorrectly in output for MIPS

Open
#481 1 comment 0 reactions 0 assignees View on GitHub
bug P-output
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I have a MIPS PE executable for Windows CE6.
IDA7 correctly displays references to Unicode strings and their contents.
But, decompilation output of Retdec is unreadable. For example, IDA7:
```lui $t1, %hi(aMgrtskChangede) # "MgrTsk_ChangeDebugLevel"
lui $t2, %hi(aApplinkS) # "[AppLink] %s: "
addiu $a1, $t1, %lo(aMgrtskChangede) # "MgrTsk_ChangeDebugLevel"
jal NKDbgPrintfW
addiu $a0, $t2, %lo(aApplinkS) # "[AppLink] %s: "
lui $a0, %hi(aFailInvalidInp) # "fail, invalid input\r\n"
jal NKDbgPrintfW
la $a0, %lo(aFailInvalidInp) # "fail, invalid input\r\n"
```

Retdec output:

``` // 0x403dc
NKDbgPrintfW((int32_t)"[\x00\x41\x00p\x00p\x00L\x00i\x00n\x00k", (int32_t)"C\x00S\x00y\x00s\x00t\x00\x65\x00m\x00\x45\x00n\x00v\x00:\x00:\x00R");
int32_t v5 = v1 + 1; // 0x403f0
NKDbgPrintfW((int32_t)"S\x00M\x00\x41\x00R\x00T\x00P\x00H\x00O\x00N\x00\x45\x00_\x00L\x00I\x00N\x00K\x00_\x00\x41\x00P", v5);
```

I tried changing `NKDbgPrintfW` prototype, but that didn't help. Also, VA arguments and their count are wrong, I'll probably file a separate issue about that.

Contributor guide

No contributing guide indexed for this repository

Research direction

No source file or test is named. Start by reproducing the issue with the supplied MIPS PE executable and trace how RetDec decodes and prints Unicode string references in decompilation output, comparing the result with IDA7; done means readable Unicode strings are emitted and the existing prototype change is no longer needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.