コード例 #1
0
bool disasmispossiblestring(uint addr)
{
    unsigned char data[11];
    memset(data, 0, sizeof(data));
    if(!MemRead(addr, data, sizeof(data) - 3))
        return false;
    uint test = 0;
    memcpy(&test, data, sizeof(uint));
    if(isasciistring(data, sizeof(data)) || isunicodestring(data, _countof(data)))
        return true;
    return false;
}
コード例 #2
0
ファイル: disasm_helper.cpp プロジェクト: StGlolry/x64dbg
bool disasmispossiblestring(uint addr)
{
    unsigned char data[11];
    memset(data, 0, sizeof(data));
    if(!MemRead((void*)addr, data, sizeof(data) - 3, 0))
        return false;
    uint test = 0;
    memcpy(&test, data, sizeof(uint));
    if(MemIsValidReadPtr(test)) //imports/pointers
        return false;
    if(isasciistring(data, sizeof(data)) or isunicodestring(data, _countof(data)))
        return true;
    return false;
}
コード例 #3
0
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
{
    if(type)
        *type = str_none;
    if(!disasmispossiblestring(addr))
        return false;
    Memory<unsigned char*> data((maxlen + 1) * 2, "disasmgetstringat:data");
    if(!MemRead(addr, data(), (maxlen + 1) * 2))
        return false;
    uint test = 0;
    memcpy(&test, data(), sizeof(uint));
    if(MemIsValidReadPtr(test))
        return false;
    if(isasciistring(data(), maxlen))
    {
        if(type)
            *type = str_ascii;
        int len = (int)strlen((const char*)data());
        for(int i = 0, j = 0; i < len; i++)
        {
            switch(data()[i])
            {
            case '\t':
                j += sprintf(ascii + j, "\\t");
                break;
            case '\f':
                j += sprintf(ascii + j, "\\f");
                break;
            case '\v':
                j += sprintf(ascii + j, "\\v");
                break;
            case '\n':
                j += sprintf(ascii + j, "\\n");
                break;
            case '\r':
                j += sprintf(ascii + j, "\\r");
                break;
            case '\\':
                j += sprintf(ascii + j, "\\\\");
                break;
            case '\"':
                j += sprintf(ascii + j, "\\\"");
                break;
            default:
                j += sprintf(ascii + j, "%c", data()[i]);
                break;
            }
        }
        return true;
    }
    else if(isunicodestring(data(), maxlen))
    {
        if(type)
            *type = str_unicode;
        int len = (int)wcslen((const wchar_t*)data());
        for(int i = 0, j = 0; i < len * 2; i += 2)
        {
            switch(data()[i])
            {
            case '\t':
                j += sprintf(unicode + j, "\\t");
                break;
            case '\f':
                j += sprintf(unicode + j, "\\f");
                break;
            case '\v':
                j += sprintf(unicode + j, "\\v");
                break;
            case '\n':
                j += sprintf(unicode + j, "\\n");
                break;
            case '\r':
                j += sprintf(unicode + j, "\\r");
                break;
            case '\\':
                j += sprintf(unicode + j, "\\\\");
                break;
            case '\"':
                j += sprintf(unicode + j, "\\\"");
                break;
            default:
                j += sprintf(unicode + j, "%c", data()[i]);
                break;
            }
        }
        return true;
    }
    return false;
}