Since I just had the question on Steam, I thought we can collect all the quirks of converting decompiled source to working code.
For the beginning, I made this screenshot, which shows the working version and the decompiled one:
Left = working version = https://github.com/kungfooman/libcod...bcod.cpp#L1920
Right = decompiled version = http://pastebin.com/a2ydu2NH
Since something like is internally for HexRays fully correct, it's not helpful in a shared library, since we cannot just tell LD (the linker) to place this variable to that memory location. Hence we need to dereference it like
PHP Code:
*(int *)0x08571428
I made a macro for this in config.hpp: https://github.com/kungfooman/libcod...ter/config.hpp
PHP Code:
#define INT(address) (*(int*)(address))
So we can just write:
PHP Code:
INT(0x08571428)
// so this is all the same:
dword_8571428
*(int *)0x08571428
INT(0x08571428)
There are many other types, which can be treated equally, but nobody ever added macros for them, but the principle will be the same. A nice list:
PHP Code:
#include <cstdint>
typedef uint8_t CHAR;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int8_t BYTE;
typedef int16_t SHORT;
typedef int32_t LONG;
typedef LONG INT;
typedef INT BOOL;
So you don't need much conversion, when HexRays gives you something like this:
PHP Code:
*(_WORD *)(a2 + 8) + 50;
More conversion rules, questions etc. all welcome