Пример #1
0
INT_PTR CALLBACK SettingsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
	{
		//
		// If this isn't a 64-bit build, disable the RIP-relative option
		//
#ifndef _WIN64
		EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_RELADDR), FALSE);
#endif // ndef _WIN64

		// Update all checkbox settings
		#define CHECK(x) ((x) ? BST_CHECKED : BST_UNCHECKED)
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_TRIM), BM_SETCHECK, CHECK(Settings::TrimSignatures), 0);
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_NOWILDCARD), BM_SETCHECK, CHECK(Settings::DisableWildcards), 0);
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_SHORTEST), BM_SETCHECK, CHECK(Settings::ShortestSignatures), 0);
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_SHORTJMP), BM_SETCHECK, CHECK(Settings::IncludeShortJumps), 0);
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_MEMREFS), BM_SETCHECK, CHECK(Settings::IncludeMemRefences), 0);
		SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_RELADDR), BM_SETCHECK, CHECK(Settings::IncludeRelAddresses), 0);
	}
	break;

	case WM_CLOSE:
	{
		CLOSE_WINDOW(hwndDlg, g_SettingsDialog);
		return TRUE;
	}
	break;

	case WM_COMMAND:
	{
		switch (LOWORD(wParam))
		{
		case IDC_SETTINGS_OK:
			// Update each checkbox setting at once
			Settings::TrimSignatures		= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_TRIM), BM_GETCHECK, 0, 0) == BST_CHECKED;
			Settings::DisableWildcards		= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_NOWILDCARD), BM_GETCHECK, 0, 0) == BST_CHECKED;
			Settings::ShortestSignatures	= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_SHORTEST), BM_GETCHECK, 0, 0) == BST_CHECKED;
			Settings::IncludeShortJumps		= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_SHORTJMP), BM_GETCHECK, 0, 0) == BST_CHECKED;
			Settings::IncludeMemRefences	= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_MEMREFS), BM_GETCHECK, 0, 0) == BST_CHECKED;
			Settings::IncludeRelAddresses	= SendMessage(GetDlgItem(hwndDlg, IDC_SETTINGS_RELADDR), BM_GETCHECK, 0, 0) == BST_CHECKED;

			// Save options
			Settings::Save();

			// Close dialog
			CLOSE_WINDOW(hwndDlg, g_SettingsDialog);
			break;

		case IDC_SETTINGS_CANCEL:
			CLOSE_WINDOW(hwndDlg, g_SettingsDialog);
			break;
		}
	}
	break;
	}

	return FALSE;
}
Пример #2
0
INT_PTR CALLBACK MakeSigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
	{
		//
		// Check if the user has any code selected
		//
		MakeSigDialogInit(hwndDlg);

		//
		// TODO: CRC disabled until I can find a good piece of code for it
		//
		EnableWindow(GetDlgItem(hwndDlg, IDC_SIGMAKE_CRC), FALSE);

		// Update the initial signature type selection button
		switch (Settings::LastType)
		{
		case SIG_CODE:
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CODE), BM_SETCHECK, BST_CHECKED, 0);
			break;

		case SIG_IDA:
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_IDA), BM_SETCHECK, BST_CHECKED, 0);
			break;

		case SIG_PEID:
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_PEID), BM_SETCHECK, BST_CHECKED, 0);
			break;

		case SIG_CRC:
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CRC), BM_SETCHECK, BST_CHECKED, 0);
			break;
		}
	}
	break;

	case WM_CLOSE:
	{
		CLOSE_WINDOW(hwndDlg, g_SigMakeDialog);
		return TRUE;
	}
	break;

	case WM_COMMAND:
	{
		switch (LOWORD(wParam))
		{
		case IDC_SIGMAKE_SCAN:
			// Scan for the signature
			MakeSigDialogExecute(hwndDlg);

			CLOSE_WINDOW(hwndDlg, g_SigMakeDialog);
			break;

		case IDC_SIGMAKE_CANCEL:
			// Cancel button; close dialog
			CLOSE_WINDOW(hwndDlg, g_SigMakeDialog);
			break;

		case IDC_SIGMAKE_CODE:
			// Convert sig
			MakeSigDialogConvert(hwndDlg, SIG_CODE, Settings::LastType);

			// Uncheck the other radio button and update last set variable
			Settings::LastType = SIG_CODE;

			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_IDA), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_PEID), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CRC), BM_SETCHECK, BST_UNCHECKED, 0);
			break;

		case IDC_SIGMAKE_IDA:
			// Convert sig
			MakeSigDialogConvert(hwndDlg, SIG_IDA, Settings::LastType);

			// Uncheck the other radio button and update last set variable
			Settings::LastType = SIG_IDA;

			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CODE), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_PEID), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CRC), BM_SETCHECK, BST_UNCHECKED, 0);
			break;

		case IDC_SIGMAKE_PEID:
			// Convert sig
			MakeSigDialogConvert(hwndDlg, SIG_PEID, Settings::LastType);

			// Uncheck the other radio button and update last set variable
			Settings::LastType = SIG_PEID;

			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CODE), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_IDA), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CRC), BM_SETCHECK, BST_UNCHECKED, 0);
			break;

		case IDC_SIGMAKE_CRC:
			// Convert sig
			MakeSigDialogConvert(hwndDlg, SIG_CRC, Settings::LastType);

			// Uncheck the other radio button and update last set variable
			Settings::LastType = SIG_CRC;

			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_CODE), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_PEID), BM_SETCHECK, BST_UNCHECKED, 0);
			SendMessage(GetDlgItem(hwndDlg, IDC_SIGMAKE_IDA), BM_SETCHECK, BST_UNCHECKED, 0);
			break;
		}
	}
	break;
	}

	return FALSE;
}