Beispiel #1
0
ALWAYS_INLINE char *
int_to_string(ssize_t value,
              char buffer[INT_TO_STR_BUFFER_SIZE],
              size_t *len)
{
    if (value < 0) {
        char *p = uint_to_string((size_t) -value, buffer, len);
        *--p = '-';
        ++*len;

        return p;
    }

    return uint_to_string((size_t) value, buffer, len);
}
Beispiel #2
0
void dump_registers(unsigned int *reg_pointer, char *hdr, unsigned int cnt)
{
    unsigned int reg_count;
    char buffer[10];

    for (reg_count = 0; reg_count < cnt; reg_count++)
    {
        ubc_serial_write_str(hdr);

        uint_to_string(reg_count, buffer);
        ubc_serial_write_str(buffer);

        ubc_serial_write_str(" == 0x");

        uint_to_string(*(reg_pointer - reg_count), buffer);
        ubc_serial_write_str(buffer);

        ubc_serial_write_str(";\r\n");
    }
}
Beispiel #3
0
std::string
rich_suggestions_json_array(vp_t& suggestions) {
    std::string ret = "[";
    ret.reserve(OUTPUT_SIZE_RESERVE);
    for (vp_t::iterator i = suggestions.begin(); i != suggestions.end(); ++i) {
        escape_special_chars(i->phrase);
        std::string snippet = i->snippet;
        escape_special_chars(snippet);

        std::string trailer = i + 1 == suggestions.end() ? "\n" : ",\n";
        ret += " { \"phrase\": \"" + i->phrase + "\", \"score\": " + uint_to_string(i->weight) + 
            (snippet.empty() ? "" : ", \"snippet\": \"" + snippet + "\"") + "}" + trailer;
    }
    ret += "]";
    return ret;
}
Beispiel #4
0
int dc_main(void)
{
    unsigned long bin_size = 0xfeedbeef;
    char tmp_str[8];

    vid_init(vid_check_cable(), DM_640x480, PM_RGB565);
    vid_clear(0,100,0);

    /* Relocate the 1st_read.bin */
    bin_size = *((unsigned long *) REAL_LOAD_POINT);
    uint_to_string(bin_size, tmp_str);
    bfont_draw_str(vram_s+10*640+20, 640, "bin_size = ");
    bfont_draw_str(vram_s+50*640+20, 640, tmp_str);
    memmove((unsigned char *) REAL_LOAD_POINT, (unsigned char *) LOADED_POINT, bin_size);

    dbr_set(ubc_works);
    vbr_set(vbr_buffer);

    *UBC_R_BARA = (unsigned int) BREAKPOINT;
    *UBC_R_BAMRA = (1<<2);
    *UBC_R_BBRA = (1<<5) | (1<<4) | (1<<3) | (1<<2);
    *UBC_R_BRCR = (1<<10) | (1<<15) | 1;

    ubc_wait();
    ubc_wait();
    ubc_wait();
    ubc_wait();   

    vid_clear(50,0,50);

    disable_cache();
    (*(void (*)()) REAL_LOAD_POINT) ();

    vid_init(vid_check_cable(), DM_640x480, PM_RGB565);
    vid_clear(100,0,0);
    bfont_draw_str(vram_s+100*640+20, 640, "[UBC] DANGER! We're returned from the game!");
    while(1);
}
Beispiel #5
0
std::string
humanized_time_difference(time_t prev, time_t curr) {
    std::string ret = "";
    if (prev > curr) {
        std::swap(prev, curr);
    }

    if (prev == curr) {
        return "just now";
    }

    int sec = curr - prev;
    ret = uint_to_string(sec % 60, 2) + ret;

    int minute = sec / 60;
    ret = uint_to_string(minute % 60, 2) + ":" + ret;

    int hour = minute / 60;
    ret = uint_to_string(hour % 24, 2) + ":" + ret;

    int day = hour / 24;
    if (day) {
        ret = uint_to_string(day % 7) + pluralize(" day", day%7) + " " + ret;
    }

    int week = day / 7;
    if (week) {
        ret = uint_to_string(week % 4) + pluralize(" day", week%4) + " " + ret;
    }

    int month = week / 4;
    if (month) {
        ret = uint_to_string(month) + pluralize(" month", month) + " " + ret;
    }

    return ret;
}
Beispiel #6
0
void ubc_break_work(void)
{
    char num_buffer[10];
    volatile short *p1_health = (unsigned short *) 0x8CCF6284;
    //unsigned short *p2_health = (unsigned short *) 0x8CCF7402;
    unsigned char *mem_start = (unsigned char *) 0x8C010000;
    unsigned char *mem_end = (unsigned char *) 0x8CFFFFFF;

    ubc_serial_init(57600);
    ubc_serial_flush();
    ubc_serial_write_str("[UBC] Hit from 0x");
    uint_to_string(spc(), num_buffer);
    ubc_serial_write_str(num_buffer);
    ubc_serial_write_str("\r\n");
    
#if 0

    /* Today we're scanning for the customized VR information */
    if (*p1_health < 500 && *p1_health > 50)
    {
        /* Search for the byte signature: */
        unsigned char prototem_sig[] = {
            0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3,
            0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E, 0x38, 0xE3, 0x8E,
        };
        unsigned char *cur_loc;
        unsigned long did_find;

        ubc_serial_write_str("[UBC] Starting prototem search\n\r");

        did_find = 0;
        for (cur_loc = mem_start; cur_loc < mem_end; cur_loc++)
        {
            if (*cur_loc == prototem_sig[0])
            {
                if(!memcmp(cur_loc, prototem_sig, sizeof(prototem_sig)))
                {
                    unsigned char *check_loc;
                    char num_buffer[10];

                    /* MATCH */
                    ubc_serial_write_str("[UBC] Prototem match confirmed @ 0x");
                    uint_to_string((unsigned int) cur_loc, num_buffer);
                    ubc_serial_write_str(num_buffer);
                    ubc_serial_write_str("\r\n");

                    ubc_serial_write_str("[UBC] Writing ");
                    check_loc = cur_loc + (3*5);
                    for (; cur_loc <= check_loc; cur_loc++)
                    {
                        ubc_serial_write_str(".");
                        *cur_loc = 0xFF;
                    }
                    ubc_serial_write_str(" done!\r\n");

                    cur_loc += 1024 - (3*5);

                    did_find = (unsigned long) cur_loc;
                }
            }
        }
        ubc_serial_write_str("[UBC] Prototem search complete.\r\n");

#ifdef POINTER_FIND
        if (did_find)
        {
            ubc_serial_write_str("[UBC] Starting pointer search.\r\n");
            /* Now scan for the pointer in memory */
            for (cur_loc = mem_start; cur_loc < mem_end; cur_loc += 4)
            {
                if (*((unsigned long *) cur_loc) == did_find)
                {
                    char num_buffer[10];

                    ubc_serial_write_str("[UBC] Pointer match confirmed @ 0x");
                    uint_to_string((unsigned int) cur_loc, num_buffer);
                    ubc_serial_write_str(num_buffer);
                    ubc_serial_write_str("\r\n");
                }
            }
            ubc_serial_write_str("[UBC] Pointer search complete.\r\n");
        }
#endif
        
        ubc_serial_write_str("[UBC] All searches complete.\r\n");
        *p1_health = 1000;
    }
#endif
}