예제 #1
0
void LabelCacheLoad(JSON Root)
{
    EXCLUSIVE_ACQUIRE(LockLabels);

    // Inline lambda to parse each JSON entry
    auto AddLabels = [](const JSON Object, bool Manual)
    {
        size_t i;
        JSON value;

        json_array_foreach(Object, i, value)
        {
            LABELSINFO labelInfo;
            memset(&labelInfo, 0, sizeof(LABELSINFO));

            // Module
            const char* mod = json_string_value(json_object_get(value, "module"));

            if(mod && strlen(mod) < MAX_MODULE_SIZE)
                strcpy_s(labelInfo.mod, mod);
            else
                labelInfo.mod[0] = '\0';

            // Address/Manual
            labelInfo.addr = (uint)json_hex_value(json_object_get(value, "address"));
            labelInfo.manual = Manual;

            // Text string
            const char* text = json_string_value(json_object_get(value, "text"));

            if(text)
                strcpy_s(labelInfo.text, text);
            else
            {
                // Skip empty strings
                continue;
            }

            // Go through the string replacing '&' with spaces
            for(char* ptr = labelInfo.text; ptr[0] != '\0'; ptr++)
            {
                if(ptr[0] == '&')
                    ptr[0] = ' ';
            }

            // Finally insert the data
            const uint key = ModHashFromName(labelInfo.mod) + labelInfo.addr;

            labels.insert(std::make_pair(key, labelInfo));
        }
    };
예제 #2
0
void FunctionCacheLoad(JSON Root)
{
    EXCLUSIVE_ACQUIRE(LockFunctions);

    // Delete existing entries
    functions.clear();

    // Inline lambda to enumerate all JSON array indices
    auto InsertFunctions = [](const JSON Object, bool Manual)
    {
        size_t i;
        JSON value;
        json_array_foreach(Object, i, value)
        {
            FUNCTIONSINFO functionInfo;
            memset(&functionInfo, 0, sizeof(FUNCTIONSINFO));

            // Copy module name
            const char* mod = json_string_value(json_object_get(value, "module"));

            if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
                strcpy_s(functionInfo.mod, mod);

            // Function address
            functionInfo.start = (uint)json_hex_value(json_object_get(value, "start"));
            functionInfo.end = (uint)json_hex_value(json_object_get(value, "end"));
            functionInfo.manual = Manual;

            // Sanity check
            if(functionInfo.end < functionInfo.start)
                continue;

            const uint key = ModHashFromName(functionInfo.mod);
            functions.insert(std::make_pair(ModuleRange(key, Range(functionInfo.start, functionInfo.end)), functionInfo));
        }
    };
예제 #3
0
파일: loop.cpp 프로젝트: 0x4e38/x64dbg
void LoopCacheLoad(JSON Root)
{
    EXCLUSIVE_ACQUIRE(LockLoops);

    // Inline lambda to parse each JSON entry
    auto AddLoops = [](const JSON Object, bool Manual)
    {
        size_t i;
        JSON value;

        json_array_foreach(Object, i, value)
        {
            LOOPSINFO loopInfo;
            memset(&loopInfo, 0, sizeof(LOOPSINFO));

            // Module name
            const char* mod = json_string_value(json_object_get(value, "module"));

            if(mod && strlen(mod) < MAX_MODULE_SIZE)
                strcpy_s(loopInfo.mod, mod);

            // All other variables
            loopInfo.start = (duint)json_hex_value(json_object_get(value, "start"));
            loopInfo.end = (duint)json_hex_value(json_object_get(value, "end"));
            loopInfo.depth = (int)json_integer_value(json_object_get(value, "depth"));
            loopInfo.parent = (duint)json_hex_value(json_object_get(value, "parent"));
            loopInfo.manual = Manual;

            // Sanity check: Make sure the loop starts before it ends
            if(loopInfo.end < loopInfo.start)
                continue;

            // Insert into global list
            loops.insert(std::make_pair(DepthModuleRange(loopInfo.depth, ModuleRange(ModHashFromName(loopInfo.mod), Range(loopInfo.start, loopInfo.end))), loopInfo));
        }
    };
예제 #4
0
파일: comment.cpp 프로젝트: bughoho/x64dbg
void CommentCacheLoad(JSON Root)
{
    EXCLUSIVE_ACQUIRE(LockComments);

    // Inline lambda to parse each JSON entry
    auto AddComments = [](const JSON Object, bool Manual)
    {
        size_t i;
        JSON value;

        json_array_foreach(Object, i, value)
        {
            COMMENTSINFO commentInfo;
            memset(&commentInfo, 0, sizeof(COMMENTSINFO));

            // Module
            const char* mod = json_string_value(json_object_get(value, "module"));

            if(mod && strlen(mod) < MAX_MODULE_SIZE)
                strcpy_s(commentInfo.mod, mod);
            else
                commentInfo.mod[0] = '\0';

            // Address/Manual
            commentInfo.addr = (uint)json_hex_value(json_object_get(value, "address"));
            commentInfo.manual = Manual;

            // String value
            const char* text = json_string_value(json_object_get(value, "text"));

            if(text)
                strcpy_s(commentInfo.text, text);
            else
            {
                // Skip blank comments
                continue;
            }

            const uint key = ModHashFromName(commentInfo.mod) + commentInfo.addr;
            comments.insert(std::make_pair(key, commentInfo));
        }
    };