Exemple #1
0
BOOL ModifyHexViewData(HWND hwndHV, int nOperation, BYTE * operand, size_w nLength, int nType, BOOL fEndian)
{
	size_w start, offset;
	size_w remaining = nLength;
	size_w length	 = nLength;

	BYTE buf[0x100];

	HexView_GetSelStart(hwndHV, &start);
	offset = start;

	// turn off redraw so the cursor/display doesn't update whilst we are
	// writing data to the hexview
	SendMessage(hwndHV, WM_SETREDRAW, FALSE, 0);

	while(nLength > 0)
	{
		ULONG len = (ULONG)min(nLength, 0x100);

		// get data at current cursor position!
		if(HexView_GetData(hwndHV, offset, buf, len))
		{
			// do the operation!
			if(ModifyData(buf, len, nOperation, operand, nType, fEndian))
			{
				// write the data back to the hexview
				HexView_SetData(hwndHV, offset, buf, len);
			}
		}
		else
		{
			return FALSE;
		}

		offset += len;
		nLength -= len;
	}

	HexView_SetSelStart(hwndHV, start);
	HexView_SetSelEnd(hwndHV, start+length);

	SendMessage(hwndHV, WM_SETREDRAW, TRUE, 0);
	
	return TRUE;
}
Exemple #2
0
INT_PTR CALLBACK HighlightDlgProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	static BOOL fMask = FALSE;

	static HWND	hwndHV;
	size_w	offset, length;
	BOOKMARK bm = {0};

	static TCHAR title[100];
	static TCHAR text[200];
	static int count;
	static HBOOKMARK hbm;

	switch (iMsg)
	{
	case WM_INITDIALOG:

		hwndHV = GetActiveHexView(GetParent(hwnd));
		//	GetOwner(hwnd);//

		SendDlgItemMessage(hwnd, IDC_NAME, EM_SETCUEBANNER, TRUE, (LPARAM)TEXT("Enter some descriptive text here"));
		SendDlgItemMessage(hwnd, IDC_ANNOTATION, EM_SETCUEBANNER, 0, (LPARAM)TEXT("Enter some descriptive text here"));

		//MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO1), fgcollist, fgtextlist, 16);
		MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO4), bgcollist, bgtextlist, 16);

		hbm = (HBOOKMARK)lParam;

		if(hbm == 0)
		{
			HexView_GetSelStart(hwndHV, &offset);
			HexView_GetSelSize(hwndHV, &length);

			wsprintf(title, TEXT("bookmark-%03d"), ++count);
			//lstrcpy(title, TEXT(""));//TEXT("Enter some descriptive text here"));
			lstrcpy(text, TEXT(""));//TEXT("Enter some descriptive text here"));
		}
		else
		{
			HBOOKMARK hbm = (HBOOKMARK)lParam;
			BOOKMARK bm;

			HexView_GetBookmark(hwndHV, hbm, &bm);

			offset = bm.offset;
			length = bm.length;
			lstrcpy(title, bm.pszTitle);
			lstrcpy(text, bm.pszText);

			// Set the selected color
			for (int i = 0; i < 16; i++)
			{
				if (bm.backcol == bgcollist[i])
				{
					SendMessage(GetDlgItem(hwnd, IDC_COMBO4), CB_SETCURSEL, i, 0);
					break;
				}
			}
		}

		SetDlgItemBaseInt(hwnd, IDC_OFFSET, offset, 16, 1);
		SetDlgItemBaseInt(hwnd, IDC_LENGTH, length, 16, 1);
		SetDlgItemText(hwnd, IDC_NAME, title);
		SetDlgItemText(hwnd, IDC_ANNOTATION, text);
	
	//ClientToScreen(hwndParent, &pt);
		//GetCursorPos(&pt);
		//SetWindowPos(hwnd, 0, pt.x, pt.y, 0, 0, SWP_NOSIZE);
		CenterWindow(hwnd);
		return TRUE;
			
	case WM_CLOSE:
		EndDialog(hwnd, FALSE);
		return TRUE;
	
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:
	
			GetDlgItemText(hwnd, IDC_ANNOTATION, text, 200);
			GetDlgItemText(hwnd, IDC_NAME, title, 100);

			bm.col		= 0;
			bm.backcol	= GetColourComboRGB(GetDlgItem(hwnd, IDC_COMBO4));//RGB(rand()+128, rand()+128, rand()+128);//0xffffff;
			bm.pszText	= text;
			bm.pszTitle = title;
			bm.offset	= GetDlgItemBaseInt(hwnd, IDC_OFFSET, 16);
			bm.length	= GetDlgItemBaseInt(hwnd, IDC_LENGTH, 16);
		
			if(hbm == 0)
			{
				HexView_AddBookmark(hwndHV, &bm);
			}
			else
			{
				HexView_SetBookmark(hwndHV, hbm, &bm);
			}
//
			DockWnd_UpdateContent(g_hwndMain, DWID_HIGHLIGHT);
			///UpdateHighlights(hwndHV, hwndGridView);

			EndDialog(hwnd, TRUE);
			return 0;

		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return 0;

		default:
			return FALSE;
		}

	default:
		break;
	}
	return FALSE;

}