darknesswind / NutCracker

fork from DamianXVI's squirrel decompiler
22 stars 11 forks source link

Mods to decompile wide strings (unicode) #30

Open pabloko opened 5 years ago

pabloko commented 5 years ago

I was looking at some .nut file and found NutCracker, as its advised on the readme, it doesn't work, luckily i have some experience on lua so i quickly fixed it to dump the files.

First thing to add NutScript.cpp > LoadFromStream if (reader.ReadInt32() != sizeof(uint16_t))... using wide string you will use 2 bytes for each char

BinaryParser.h > ReadSQString

        static char* buff;
        static std::vector<char> buf;
        int len = ReadInt32()*2;
        if (len < 0)
            len = 0;
        if (buf.size() < (size_t)len)
            buf.resize(len);
        buff = (char*)malloc(len/2);
        Read((void*)buf.data(), len, true);
        WideCharToMultiByte(/*CP_ACP*/0, 0, (wchar_t*)buf.data(), len, buff, len/2, 0, 0);
        str.assign(buff, len/2);
        delete buff;

dirty code, note len is multiplied by 2 and then WideCharToMultiByte is used to convert text to ansi representation. You should include windows.h on BinaryParser.h in order to use encoding api.

MishaIac commented 4 years ago