コード例 #1
0
EXPORT UNSIGNED32 STDCALL TaggantValidateSignature(__in PTAGGANTOBJ pTaggantObj, __in PTAGGANT pTaggant, __in PVOID pRootCert)
{
    UNSIGNED32 res = TNOTIMPLEMENTED;

    if (!lib_initialized)
    {
        return TLIBNOTINIT;
    }

    switch (get_lib_version(pTaggantObj))
    {
    case TAGGANT_LIBRARY_VERSION1:
        res = taggant_validate_signature(pTaggantObj->tagObj1, pTaggant->pTag1, pRootCert);
        break;
    case TAGGANT_LIBRARY_VERSION2:
        res = taggant2_validate_signature(pTaggantObj->tagObj2, pTaggant->pTag2, pRootCert);
        break;
    }

    return res;
}
コード例 #2
0
EXPORT UNSIGNED32 STDCALL TaggantAddHashRegion(__inout PTAGGANTOBJ pTaggantObj, UNSIGNED64 uOffset, UNSIGNED64 uLength)
{
    UNSIGNED32 res = TNOTIMPLEMENTED;

    if (!lib_initialized)
    {
        return TLIBNOTINIT;
    }

    switch (get_lib_version(pTaggantObj))
    {
    case TAGGANT_LIBRARY_VERSION1:
        res = taggant_add_hash_region(pTaggantObj->tagObj1, uOffset, uLength);
        break;
    case TAGGANT_LIBRARY_VERSION2:
        res = taggant2_add_hash_region(pTaggantObj->tagObj2, uOffset, uLength);
        break;
    }

    return res;
}
コード例 #3
0
ファイル: crash.c プロジェクト: rustyangel/claws-mail
/*!
 *\brief	show crash dialog
 *
 *\param	text Description
 *\param	debug_output Output text by gdb
 *
 *\return	GtkWidget * Dialog widget
 */
static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output)
{
    GtkWidget *window1;
    GtkWidget *vbox1;
    GtkWidget *hbox1;
    GtkWidget *label1;
    GtkWidget *frame1;
    GtkWidget *scrolledwindow1;
    GtkWidget *text1;
    GtkWidget *hbuttonbox3;
    GtkWidget *hbuttonbox4;
    GtkWidget *button3;
    GtkWidget *button4;
    GtkWidget *button5;
    gchar	  *crash_report;

    window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(window1), 5);
    gtk_window_set_title(GTK_WINDOW(window1), _("Sylpheed has crashed"));
    gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
    gtk_window_set_modal(GTK_WINDOW(window1), TRUE);
    gtk_window_set_default_size(GTK_WINDOW(window1), 460, 272);


    vbox1 = gtk_vbox_new(FALSE, 2);
    gtk_widget_show(vbox1);
    gtk_container_add(GTK_CONTAINER(window1), vbox1);

    hbox1 = gtk_hbox_new(FALSE, 4);
    gtk_widget_show(hbox1);
    gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4);

    label1 = gtk_label_new
             (g_strdup_printf(_("%s.\nPlease file a bug report and include the information below."), text));
    gtk_widget_show(label1);
    gtk_box_pack_start(GTK_BOX(hbox1), label1, TRUE, TRUE, 0);
    gtk_misc_set_alignment(GTK_MISC(label1), 7.45058e-09, 0.5);

    frame1 = gtk_frame_new(_("Debug log"));
    gtk_widget_show(frame1);
    gtk_box_pack_start(GTK_BOX(vbox1), frame1, TRUE, TRUE, 0);

    scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_show(scrolledwindow1);
    gtk_container_add(GTK_CONTAINER(frame1), scrolledwindow1);
    gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow1), 3);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
                                   GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

    text1 = gtk_text_new(NULL, NULL);
    gtk_text_set_editable(GTK_TEXT(text1), FALSE);
    gtk_widget_show(text1);
    gtk_container_add(GTK_CONTAINER(scrolledwindow1), text1);

    crash_report = g_strdup_printf(
                       "Sylpheed version %s\nGTK+ version %d.%d.%d\nFeatures:%s\nOperating system: %s\nC Library: %s\n--\n%s",
                       VERSION,
                       gtk_major_version, gtk_minor_version, gtk_micro_version,
                       get_compiled_in_features(),
                       get_operating_system(),
                       get_lib_version(),
                       debug_output);

    gtk_text_insert(GTK_TEXT(text1), NULL, NULL, NULL, crash_report, -1);

    hbuttonbox3 = gtk_hbutton_box_new();
    gtk_widget_show(hbuttonbox3);
    gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox3, FALSE, FALSE, 0);

    hbuttonbox4 = gtk_hbutton_box_new();
    gtk_widget_show(hbuttonbox4);
    gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox4, FALSE, FALSE, 0);

    button3 = gtk_button_new_with_label(_("Close"));
    gtk_widget_show(button3);
    gtk_container_add(GTK_CONTAINER(hbuttonbox4), button3);
    GTK_WIDGET_SET_FLAGS(button3, GTK_CAN_DEFAULT);

    button4 = gtk_button_new_with_label(_("Save..."));
    gtk_widget_show(button4);
    gtk_container_add(GTK_CONTAINER(hbuttonbox4), button4);
    GTK_WIDGET_SET_FLAGS(button4, GTK_CAN_DEFAULT);

    button5 = gtk_button_new_with_label(_("Create bug report"));
    gtk_widget_show(button5);
    gtk_container_add(GTK_CONTAINER(hbuttonbox4), button5);
    GTK_WIDGET_SET_FLAGS(button5, GTK_CAN_DEFAULT);

    gtk_signal_connect(GTK_OBJECT(window1), "delete_event",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
    gtk_signal_connect(GTK_OBJECT(button3),   "clicked",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
    gtk_signal_connect(GTK_OBJECT(button4), "clicked",
                       GTK_SIGNAL_FUNC(crash_save_crash_log),
                       crash_report);
    gtk_signal_connect(GTK_OBJECT(button5), "clicked",
                       GTK_SIGNAL_FUNC(crash_create_bug_report),
                       NULL);

    gtk_widget_show(window1);

    gtk_main();
    return window1;
}
コード例 #4
0
EXPORT UNSIGNED32 STDCALL TaggantComputeHashes(__in PTAGGANTCONTEXT pCtx, __inout PTAGGANTOBJ pTaggantObj, __in PFILEOBJECT hFile,
        UNSIGNED64 uObjectEnd, UNSIGNED64 uFileEnd, UNSIGNED32 uTaggantSize)
{
    PE_ALL_HEADERS peh;
    UNSIGNED32 res = TINVALIDPEFILE;
    UNSIGNED64 objectend, fileend = uFileEnd;
    PTAGGANT1 taggant1 = NULL;
    PTAGGANT2 taggant2 = NULL;
    int found = 0;
    EVP_MD_CTX evp;
    UNSIGNED8 prevtag;

    if (!lib_initialized)
    {
        return TLIBNOTINIT;
    }

    switch (get_lib_version(pTaggantObj))
    {
    case TAGGANT_LIBRARY_VERSION1:
        /* Check if the file is correct win_pe file */
        if (winpe_is_correct_pe_file(pCtx, hFile, &peh))
        {
            /* Compute default hash */
            res = taggant_compute_default_hash(pCtx, &pTaggantObj->tagObj1->pTagBlob->Hash.FullFile, hFile, &peh, uObjectEnd, fileend, uTaggantSize);
            if (res == TNOERR && pTaggantObj->tagObj1->pTagBlob->Hash.Hashmap.Entries > 0)
            {
                /* Compute hashmap */
                res = taggant_compute_hash_map(pCtx, hFile, pTaggantObj->tagObj1->pTagBlob);
            }
        }
        else
        {
            res = TINVALIDPEFILE;
        }
        break;
    case TAGGANT_LIBRARY_VERSION2:		
        switch (pTaggantObj->tagObj2->tagganttype)
        {
        case TAGGANT_JSFILE:
        {
            /* It is a JavaScript file */
            if (!fileend)
            {
                fileend = get_file_size(pCtx, hFile);
            }
            /* Get the file end exclude existing taggants
            * Walk through all taggants in file and take offset of the file without taggants
            * Take offset and size of the latest taggant to include it into hash map
            */
            res = TNOERR;
            found = 0;
            while (res == TNOERR && taggant2_read_textual(pCtx, hFile, fileend, &taggant2, TAGGANT_JSFILE, JS_COMMENT_BEGIN, strlen(JS_COMMENT_BEGIN), JS_COMMENT_END, strlen(JS_COMMENT_END)) == TNOERR)
            {
                fileend -= strlen(JS_COMMENT_BEGIN) + taggant2->Header.TaggantLength + strlen(JS_COMMENT_END);
                /* Get the offset and size of the first found taggant to add it into hashmap */
                if (!found)
                {
                    /* remember that there is a previous taggant in the file */
                    prevtag = 1;                    
                    if ((res = taggant2_put_extrainfo(&pTaggantObj->tagObj2->tagBlob.Extrablob, ETAGPREV, sizeof(prevtag), (char*)&prevtag)) == TNOERR)
                    {
                        /* add a hash region of the previous taggant */
                        if ((res = taggant2_add_hash_region(pTaggantObj->tagObj2, fileend, strlen(JS_COMMENT_BEGIN) + taggant2->Header.TaggantLength + strlen(JS_COMMENT_END))) == TNOERR)
                        {
                            found++;
                        }
                    }
                }
                /* Free the taggant object */
                taggant2_free_taggant(taggant2);
            }
            if (res == TNOERR)
            {
                res = taggant2_compute_hash_raw(pCtx, &pTaggantObj->tagObj2->tagBlob.Hash, hFile, fileend, pTaggantObj->tagObj2->tagBlob.pHashMapDoubles);
            }
            break;
        }
        case TAGGANT_TXTFILE:
        {
            /* It is a text file */
            if (!fileend)
            {
                fileend = get_file_size(pCtx, hFile);
            }
            /* Get the file end exclude existing taggants
            * Walk through all taggants in file and take offset of the file without taggants
            * Take offset and size of the latest taggant to include it into hash map
            */
            res = TNOERR;
            found = 0;
            while (res == TNOERR && taggant2_read_textual(pCtx, hFile, fileend, &taggant2, TAGGANT_TXTFILE, NULL, 0, NULL, 0) == TNOERR)
            {
                fileend -= taggant2->Header.TaggantLength;
                /* Get the offset and size of the first found taggant to add it into hashmap */
                if (!found)
                {
                    /* remember that there is a previous taggant in the file */
                    prevtag = 1;
                    if ((res = taggant2_put_extrainfo(&pTaggantObj->tagObj2->tagBlob.Extrablob, ETAGPREV, sizeof(prevtag), (char*)&prevtag)) == TNOERR)
                    {
                        /* add a hash region of the previous taggant */
                        if ((res = taggant2_add_hash_region(pTaggantObj->tagObj2, fileend, taggant2->Header.TaggantLength)) == TNOERR)
                        {
                            found++;
                        }
                    }
                }
                /* Free the taggant object */
                taggant2_free_taggant(taggant2);
            }
            if (res == TNOERR)
            {
                res = taggant2_compute_hash_raw(pCtx, &pTaggantObj->tagObj2->tagBlob.Hash, hFile, fileend, pTaggantObj->tagObj2->tagBlob.pHashMapDoubles);
            }
            break;
        }
        case TAGGANT_PEFILE:
        {
            /* Assume it is PE file and make sure it is correct */
            if (winpe_is_correct_pe_file(pCtx, hFile, &peh))
            {
                /* Get the object end of PE file */
                objectend = winpe2_object_end(pCtx, hFile, &peh);
                /* Get the file end excluding existing taggants
                * Walk through all taggants in file and take offset of the file without taggants
                * Take offset and size of the latest taggant to include it into hash map
                */
                if (!fileend)
                {
                    fileend = get_file_size(pCtx, hFile);
                }
                res = TNOERR;
                found = 0;
                while (res == TNOERR && taggant2_read_binary(pCtx, hFile, fileend, &taggant2, TAGGANT_PEFILE) == TNOERR)
                {
                    fileend -= taggant2->Header.TaggantLength;
                    /* Get the offset and size of the first found taggant to add it into hashmap */
                    if (!found)
                    {
                        /* remember that there is a previous taggant in the file */
                        prevtag = 1;
                        if ((res = taggant2_put_extrainfo(&pTaggantObj->tagObj2->tagBlob.Extrablob, ETAGPREV, sizeof(prevtag), (char*)&prevtag)) == TNOERR)
                        {
                            /* add a hash region of the previous taggant */
                            if ((res = taggant2_add_hash_region(pTaggantObj->tagObj2, fileend, taggant2->Header.TaggantLength)) == TNOERR)
                            {
                                found++;
                            }
                        }
                    }
                    /* Free the taggant object */
                    taggant2_free_taggant(taggant2);
                }
                if (res == TNOERR)
                {
                    /* if taggant v2 is not found, try to find taggant v1 to add it to hashmap */
                    if (!found)
                    {
                        if (taggant_read_binary(pCtx, hFile, &taggant1) == TNOERR)
                        {
                            /* remember that there is a previous taggant in the file */
                            prevtag = 1;
                            if ((res = taggant2_put_extrainfo(&pTaggantObj->tagObj2->tagBlob.Extrablob, ETAGPREV, sizeof(prevtag), (char*)&prevtag)) == TNOERR)
                            {
                                /* add a hash region of the previous taggant */
                                if ((res = taggant2_add_hash_region(pTaggantObj->tagObj2, taggant1->offset, (UNSIGNED64)taggant1->Header.TaggantLength)) == TNOERR)
                                {
                                    found++;
                                }
                            }
                            /* Free the taggant object */
                            taggant_free_taggant(taggant1);
                        }
                    }
                    if (res == TNOERR)
                    {
                        /* compute file hashes */
                        if (fileend >= uObjectEnd)
                        {
                            /* Compute hash */
                            EVP_MD_CTX_init(&evp);
                            EVP_DigestInit_ex(&evp, EVP_sha256(), NULL);
                            /* Compute default hash */
                            if ((res = taggant2_compute_default_hash_pe(&evp, pCtx, &pTaggantObj->tagObj2->tagBlob.Hash.FullFile.DefaultHash, hFile, &peh, objectend)) == TNOERR)
                            {
                                /* Compute extended hash */
                                if ((res = taggant2_compute_extended_hash_pe(&evp, pCtx, &pTaggantObj->tagObj2->tagBlob.Hash.FullFile.ExtendedHash, hFile, objectend, fileend)) == TNOERR)
                                {
                                    if (pTaggantObj->tagObj2->tagBlob.Hash.Hashmap.Entries > 0)
                                    {
                                        /* Compute hashmap */
                                        res = taggant2_compute_hash_map(pCtx, hFile, &pTaggantObj->tagObj2->tagBlob.Hash.Hashmap, pTaggantObj->tagObj2->tagBlob.pHashMapDoubles);
                                    }
                                }
                            }
                            /* Clean hash context */
                            EVP_MD_CTX_cleanup(&evp);
                        }
                        else
                        {
                            res = TFILEERROR;
                        }
                    }
                }
            }
            else
            {
                res = TINVALIDPEFILE;
            }
            break;
        }
        case TAGGANT_BINFILE:
        {
            /* Get the file end excluding existing taggants
            * Walk through all taggants in file and take offset of the file without taggants
            * Take offset and size of the latest taggant to include it into hash map
            */
            if (!fileend)
            {
                fileend = get_file_size(pCtx, hFile);
            }
            res = TNOERR;
            found = 0;
            while (res == TNOERR && taggant2_read_binary(pCtx, hFile, fileend, &taggant2, TAGGANT_BINFILE) == TNOERR)
            {
                fileend -= taggant2->Header.TaggantLength;
                /* Get the offset and size of the first found taggant to add it into hashmap */
                if (!found)
                {
                    /* remember that there is a previous taggant in the file */
                    prevtag = 1;
                    if ((res = taggant2_put_extrainfo(&pTaggantObj->tagObj2->tagBlob.Extrablob, ETAGPREV, sizeof(prevtag), (char*)&prevtag)) == TNOERR)
                    {
                        /* add a hash region of the previous taggant */
                        if ((res = taggant2_add_hash_region(pTaggantObj->tagObj2, fileend, taggant2->Header.TaggantLength)) == TNOERR)
                        {
                            found++;
                        }
                    }
                }
                /* Free the taggant object */
                taggant2_free_taggant(taggant2);
            }
            if (res == TNOERR)
            {
                res = taggant2_compute_hash_raw(pCtx, &pTaggantObj->tagObj2->tagBlob.Hash, hFile, fileend, pTaggantObj->tagObj2->tagBlob.pHashMapDoubles);
            }
            break;
        }
        default:
        {
            res = TTYPE;
        }
        }
        break;
    default:
        res = TNOTIMPLEMENTED;
        break;
    }

    return res;
}
コード例 #5
0
ファイル: crash.c プロジェクト: SpOOnman/claws
/*!
 *\brief	show crash dialog
 *
 *\param	text Description
 *\param	debug_output Output text by gdb
 *
 *\return	GtkWidget * Dialog widget
 */
static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output)
{
	GtkWidget *window1;
	GtkWidget *vbox1;
	GtkWidget *hbox1;
	GtkWidget *label1;
	GtkWidget *frame1;
	GtkWidget *scrolledwindow1;
	GtkWidget *text1;
	GtkWidget *hbuttonbox3;
	GtkWidget *hbuttonbox4;
	GtkWidget *button3;
	GtkWidget *button4;
	GtkWidget *button5;
	gchar	  *crash_report;
	GtkTextBuffer *buffer;
	GtkTextIter iter;

	window1 = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "crash");
	gtk_container_set_border_width(GTK_CONTAINER(window1), 5);
	gtk_window_set_title(GTK_WINDOW(window1), _("Claws Mail has crashed"));
	gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
	gtk_window_set_modal(GTK_WINDOW(window1), TRUE);
	gtk_window_set_default_size(GTK_WINDOW(window1), 460, 272);


	vbox1 = gtk_vbox_new(FALSE, 2);
	gtk_widget_show(vbox1);
	gtk_container_add(GTK_CONTAINER(window1), vbox1);

	hbox1 = gtk_hbox_new(FALSE, 4);
	gtk_widget_show(hbox1);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4);

	label1 = gtk_label_new
	    (g_strdup_printf(_("%s.\nPlease file a bug report and include the information below."), text));
	gtk_widget_show(label1);
	gtk_box_pack_start(GTK_BOX(hbox1), label1, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(label1), 7.45058e-09, 0.5);

	frame1 = gtk_frame_new(_("Debug log"));
	gtk_widget_show(frame1);
	gtk_box_pack_start(GTK_BOX(vbox1), frame1, TRUE, TRUE, 0);

	scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow1);
	gtk_container_add(GTK_CONTAINER(frame1), scrolledwindow1);
	gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow1), 3);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
				       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

	text1 = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text1), FALSE);
	gtk_widget_show(text1);
	gtk_container_add(GTK_CONTAINER(scrolledwindow1), text1);
	
	crash_report = g_strdup_printf(
		"Claws Mail version %s\n"
		"GTK+ version %d.%d.%d / GLib %d.%d.%d\n"
		"Locale: %s (charset: %s)\n"
		"Features:%s\n"
		"Operating system: %s\n"
		"C Library: %s\n--\n%s",
		VERSION,
		gtk_major_version, gtk_minor_version, gtk_micro_version,
		glib_major_version, glib_minor_version, glib_micro_version,
		conv_get_current_locale(), conv_get_locale_charset_str(),
		get_compiled_in_features(),
		get_operating_system(),
		get_lib_version(),
		debug_output);

	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text1));
	gtk_text_buffer_get_start_iter(buffer, &iter);
	gtk_text_buffer_insert(buffer, &iter, crash_report, -1);

	hbuttonbox3 = gtk_hbutton_box_new();
	gtk_widget_show(hbuttonbox3);
	gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox3, FALSE, FALSE, 0);

	hbuttonbox4 = gtk_hbutton_box_new();
	gtk_widget_show(hbuttonbox4);
	gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox4, FALSE, FALSE, 0);

	button3 = gtk_button_new_with_label(_("Close"));
	gtk_widget_show(button3);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button3);
	gtkut_widget_set_can_default(button3, TRUE);

	button4 = gtk_button_new_with_label(_("Save..."));
	gtk_widget_show(button4);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button4);
	gtkut_widget_set_can_default(button4, TRUE);

	button5 = gtk_button_new_with_label(_("Create bug report"));
	gtk_widget_show(button5);
	gtk_container_add(GTK_CONTAINER(hbuttonbox4), button5);
	gtkut_widget_set_can_default(button5, TRUE);
	
	g_signal_connect(G_OBJECT(window1), "delete_event",
			 G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(button3),   "clicked",
			 G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(button4), "clicked",
			 G_CALLBACK(crash_save_crash_log), crash_report);
	g_signal_connect(G_OBJECT(button5), "clicked",
			 G_CALLBACK(crash_create_bug_report), NULL);

	MANAGE_WINDOW_SIGNALS_CONNECT(window1);

	gtk_widget_show(window1);

	gtk_main();
	return window1;
}
コード例 #6
0
ファイル: yssloader.cpp プロジェクト: cyberwarriorx/yssloader
void load_sh2_data(linput_t *li)
{
	int version;
	int csize;
	ea_t result;
	sh2regs_struct sh2regs;

	if (!load_header(li))
		return;

	if (StateCheckRetrieveHeader(li, "CART", &version, &csize) != 0)
	{
		error("Invalid CART chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "CS2 ", &version, &csize) != 0)
	{
		error("Invalid CS2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "MSH2", &version, &csize) != 0)
	{
		error("Invalid MSH2 chunk");
		return;
	}
	SH2LoadState(li, false, &sh2regs, csize);

	if (StateCheckRetrieveHeader(li, "SSH2", &version, &csize) != 0)
	{
		error("Invalid SSH2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "SCSP", &version, &csize) != 0)
	{
		error("Invalid SCSP chunk");
		return;
	}
	SoundLoadState(li, NULL, csize);

	if (StateCheckRetrieveHeader(li, "SCU ", &version, &csize) != 0)
	{
		error("Invalid SCU chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "SMPC", &version, &csize) != 0)
	{
		error("Invalid SMPC chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "VDP1", &version, &csize) != 0)
	{
		error("Invalid VDP1 chunk");
		return;
	}
	Vdp1LoadState(li, csize);

	if (StateCheckRetrieveHeader(li, "VDP2", &version, &csize) != 0)
	{
		error("Invalid VDP2 chunk");
		return;
	}
	Vdp2LoadState(li, csize);

	if (StateCheckRetrieveHeader(li, "OTHR", &version, &csize) != 0)
	{
		error("Invalid OTHR chunk");
		return;
	}

	qlseek(li, 0x10000, SEEK_CUR); // BUP Ram
	create_load_seg(li, 0x06000000, 0x06100000, 2, "HWRAM");
	create_load_seg(li, 0x00200000, 0x00300000, 2, "LWRAM");
	identify_vector_table();
	find_bios_funcs();
	find_parse_ip(0x06000C00, false);
	find_parse_ip(0x06002000, true);

	// Look for SBL/SGL and load correct sig if available
	if ((result = find_string("GFS_SGL ")) != BADADDR)
	{
		char version_str[512];
		get_lib_version(result, 8, version_str, sizeof(version_str));
	   msg("SGL detected\n");

		if (atof(version_str) <= 2.10)
			plan_to_apply_idasgn("sgl20a.sig");
		else if (atof(version_str) == 2.11)
		{
			// SGL 2.1, 3.00, 3.02j
			plan_to_apply_idasgn("sgl302j.sig");
		}
		else if (atof(version_str) >= 2.12)
	      plan_to_apply_idasgn("sgl302j.sig");

		if ((result = find_string("CPK Version")) != BADADDR)
		{
			get_lib_version(result, 4, version_str, sizeof(version_str));
			plan_to_apply_idasgn("cpksgl.sig");
		}
	}
	else if ((result = find_string("GFS_SBL ")) != BADADDR)
	{
		char version_str[512];
		get_lib_version(result, 8, version_str, sizeof(version_str));
		msg("SBL detected\n");
		plan_to_apply_idasgn("sbl601.sig");

		if ((result = find_string("CPK Version")) != BADADDR)
		{
			get_lib_version(result, 4, version_str, sizeof(version_str));
			plan_to_apply_idasgn("cpksbl.sig");
		}
	}

	// move cursor to current MSH2 PC
	jumpto(sh2regs.PC);
}