mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
some work on editing binary registry values (not working yet)
svn path=/trunk/; revision=9752
This commit is contained in:
parent
17bdc6a18d
commit
8cbe40b0ad
7 changed files with 325 additions and 4 deletions
|
@ -156,6 +156,20 @@ BEGIN
|
|||
PUSHBUTTON "Cancel",IDCANCEL,196,154,50,14
|
||||
END
|
||||
|
||||
IDD_EDIT_BIN_DATA DIALOG 32, 24, 252, 174
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_3DLOOK | DS_CONTEXTHELP |
|
||||
WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Edit Binary Value"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Value &name:",IDC_STATIC,6,6,134,8
|
||||
EDITTEXT IDC_VALUE_NAME,6,17,240,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "&Value data:",IDC_STATIC,6,35,161,8
|
||||
CONTROL "",IDC_VALUE_DATA,"HexEdit32",WS_VSCROLL | WS_BORDER | WS_TABSTOP,6,46,240,102
|
||||
DEFPUSHBUTTON "OK",IDOK,142,154,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,196,154,50,14
|
||||
END
|
||||
|
||||
|
||||
IDD_EDIT_DWORD DIALOG 32, 24, 252, 104
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_3DLOOK | DS_CONTEXTHELP |
|
||||
|
|
|
@ -260,6 +260,68 @@ LRESULT CALLBACK DwordEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR
|
|||
return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
TCHAR* valueData;
|
||||
HWND hwndValue;
|
||||
int len;
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
if(editValueName && _tcscmp(editValueName, _T("")))
|
||||
{
|
||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, _T("(Default)"));
|
||||
}
|
||||
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
|
||||
return FALSE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA)))
|
||||
{
|
||||
if ((len = GetWindowTextLength(hwndValue)))
|
||||
{
|
||||
if (stringValueData)
|
||||
{
|
||||
if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR))))
|
||||
{
|
||||
stringValueData = valueData;
|
||||
if (!GetWindowText(hwndValue, stringValueData, len + 1))
|
||||
*stringValueData = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR))))
|
||||
{
|
||||
stringValueData = valueData;
|
||||
if (!GetWindowText(hwndValue, stringValueData, len + 1))
|
||||
*stringValueData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stringValueData)
|
||||
*stringValueData = 0;
|
||||
}
|
||||
}
|
||||
EndDialog(hwndDlg, IDOK);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, IDCANCEL);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -569,6 +631,22 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
|
|||
result = TRUE;
|
||||
}
|
||||
}
|
||||
else if (type == REG_NONE || type == REG_BINARY)
|
||||
{
|
||||
lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen);
|
||||
if (lRet != ERROR_SUCCESS)
|
||||
{
|
||||
error(hwnd, IDS_BAD_VALUE, valueName);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK)
|
||||
{
|
||||
lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)&dwordValueData, sizeof(DWORD));
|
||||
if (lRet == ERROR_SUCCESS)
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error(hwnd, IDS_UNSUPPORTED_TYPE, type);
|
||||
|
|
207
reactos/subsys/system/regedit/hexedit.c
Normal file
207
reactos/subsys/system/regedit/hexedit.c
Normal file
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Hex editor control
|
||||
*
|
||||
* Copyright (C) 2004 Thomas Weidenmueller <w3seek@reactos.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "hexedit.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hWndSelf;
|
||||
HWND hWndParent;
|
||||
HLOCAL hData;
|
||||
DWORD style;
|
||||
INT LineHeight;
|
||||
INT CharWidth;
|
||||
HFONT hFont;
|
||||
INT LeftMargin;
|
||||
INT TopMargin;
|
||||
INT CaretX;
|
||||
INT CaretY;
|
||||
} HEXEDIT_DATA, *PHEXEDIT_DATA;
|
||||
|
||||
LRESULT WINAPI HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
ATOM
|
||||
STDCALL
|
||||
RegisterHexEditorClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX WndClass;
|
||||
|
||||
ZeroMemory(&WndClass, sizeof(WNDCLASSEX));
|
||||
WndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
WndClass.style = CS_DBLCLKS | CS_PARENTDC;
|
||||
WndClass.lpfnWndProc = (WNDPROC)HexEditWndProc;
|
||||
WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA);
|
||||
WndClass.hInstance = hInstance;
|
||||
WndClass.hCursor = LoadCursor(0, IDC_IBEAM);
|
||||
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
WndClass.lpszClassName = HEX_EDIT_CLASS_NAME;
|
||||
|
||||
return RegisterClassEx(&WndClass);
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
UnregisterHexEditorClass(HINSTANCE hInstance)
|
||||
{
|
||||
return UnregisterClass(HEX_EDIT_CLASS_NAME, hInstance);
|
||||
}
|
||||
|
||||
/*** Helper functions *********************************************************/
|
||||
|
||||
static VOID
|
||||
HEXEDIT_MoveCaret(PHEXEDIT_DATA hed, INT Col, INT Line)
|
||||
{
|
||||
/* FIXME - include the scroll position */
|
||||
SetCaretPos(hed->LeftMargin + (Col * hed->CharWidth), hed->TopMargin + (Line * hed->LineHeight));
|
||||
}
|
||||
|
||||
/*** Message Proc *************************************************************/
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_NCCREATE(HWND hWnd, CREATESTRUCT *cs)
|
||||
{
|
||||
PHEXEDIT_DATA hed;
|
||||
|
||||
if(!(hed = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEXEDIT_DATA))))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hed->hWndSelf = hWnd;
|
||||
hed->hWndParent = cs->hwndParent;
|
||||
hed->style = cs->style;
|
||||
|
||||
SetWindowLong(hWnd, 0, (LONG)hed);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_NCDESTROY(PHEXEDIT_DATA hed)
|
||||
{
|
||||
if(hed->hData)
|
||||
{
|
||||
while(LocalUnlock(hed->hData));
|
||||
LocalFree(hed->hData);
|
||||
}
|
||||
|
||||
SetWindowLong(hed->hWndSelf, 0, 0);
|
||||
HeapFree(GetProcessHeap(), 0, hed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_CREATE(PHEXEDIT_DATA hed)
|
||||
{
|
||||
hed->LeftMargin = 2;
|
||||
hed->TopMargin = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_SETFOCUS(PHEXEDIT_DATA hed)
|
||||
{
|
||||
CreateCaret(hed->hWndSelf, 0, 2, hed->LineHeight);
|
||||
HEXEDIT_MoveCaret(hed, 0, 0);
|
||||
ShowCaret(hed->hWndSelf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_KILLFOCUS(PHEXEDIT_DATA hed)
|
||||
{
|
||||
DestroyCaret();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
HEXEDIT_WM_SETFONT(PHEXEDIT_DATA hed, HFONT hFont, BOOL bRedraw)
|
||||
{
|
||||
HDC hDC;
|
||||
TEXTMETRIC tm;
|
||||
HFONT hOldFont = 0;
|
||||
|
||||
hed->hFont = hFont;
|
||||
hDC = GetDC(hed->hWndSelf);
|
||||
if(hFont)
|
||||
{
|
||||
hOldFont = SelectObject(hDC, hFont);
|
||||
}
|
||||
GetTextMetrics(hDC, &tm);
|
||||
hed->LineHeight = tm.tmHeight;
|
||||
hed->CharWidth = tm.tmAveCharWidth;
|
||||
if(hOldFont)
|
||||
{
|
||||
SelectObject(hDC, hOldFont);
|
||||
}
|
||||
ReleaseDC(hed->hWndSelf, hDC);
|
||||
|
||||
if(bRedraw)
|
||||
{
|
||||
InvalidateRect(hed->hWndSelf, NULL, TRUE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT
|
||||
WINAPI
|
||||
HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PHEXEDIT_DATA hed;
|
||||
|
||||
hed = (PHEXEDIT_DATA)GetWindowLong(hWnd, 0);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_SETFOCUS:
|
||||
return HEXEDIT_WM_SETFOCUS(hed);
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
return HEXEDIT_WM_KILLFOCUS(hed);
|
||||
|
||||
case WM_SETFONT:
|
||||
return HEXEDIT_WM_SETFONT(hed, (HFONT)wParam, (BOOL)LOWORD(lParam));
|
||||
|
||||
case WM_CREATE:
|
||||
return HEXEDIT_WM_CREATE(hed);
|
||||
|
||||
case WM_NCCREATE:
|
||||
if(!hed)
|
||||
{
|
||||
return HEXEDIT_WM_NCCREATE(hWnd, (CREATESTRUCT*)lParam);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
if(hed)
|
||||
{
|
||||
return HEXEDIT_WM_NCDESTROY(hed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(DefWindowProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
16
reactos/subsys/system/regedit/hexedit.h
Normal file
16
reactos/subsys/system/regedit/hexedit.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __HEXEDIT_H
|
||||
#define __HEXEDIT_H
|
||||
|
||||
#define HEX_EDIT_CLASS_NAME _T("HexEdit32")
|
||||
|
||||
ATOM STDCALL
|
||||
RegisterHexEditorClass(HINSTANCE hInstance);
|
||||
BOOL STDCALL
|
||||
UnregisterHexEditorClass(HINSTANCE hInstance);
|
||||
|
||||
/* styles */
|
||||
#define HES_READONLY (0x800)
|
||||
#define HES_LOWERCASE (0x10)
|
||||
#define HES_UPPERCASE (0x8)
|
||||
|
||||
#endif /* __HEXEDIT_H */
|
|
@ -28,6 +28,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "hexedit.h"
|
||||
|
||||
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
||||
|
@ -102,6 +103,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
};
|
||||
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
|
||||
hChildWndClass = hChildWndClass; /* warning eater */
|
||||
|
||||
RegisterHexEditorClass(hInstance);
|
||||
|
||||
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
|
||||
hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS));
|
||||
|
@ -138,8 +141,9 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
void ExitInstance(void)
|
||||
void ExitInstance(HINSTANCE hInstance)
|
||||
{
|
||||
UnregisterHexEditorClass(hInstance);
|
||||
DestroyMenu(hMenuFrame);
|
||||
}
|
||||
|
||||
|
@ -191,6 +195,6 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
ExitInstance();
|
||||
ExitInstance(hInstance);
|
||||
return msg.wParam;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ TARGET_APPTYPE = windows
|
|||
|
||||
TARGET_NAME = regedit
|
||||
|
||||
TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
|
||||
TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
|
||||
|
||||
TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32
|
||||
|
||||
|
@ -20,9 +20,10 @@ TARGET_OBJECTS = \
|
|||
about.o \
|
||||
childwnd.o \
|
||||
edit.o \
|
||||
main.o \
|
||||
framewnd.o \
|
||||
hexedit.o \
|
||||
listview.o \
|
||||
main.o \
|
||||
regedit.o \
|
||||
regproc.o \
|
||||
treeview.o
|
||||
|
|
|
@ -121,5 +121,6 @@
|
|||
#define IDC_FORMAT_DEC 2005
|
||||
|
||||
#define IDD_EDIT_MULTI_STRING 2006
|
||||
#define IDD_EDIT_BIN_DATA 2007
|
||||
|
||||
#define IDC_STATIC -1
|
||||
|
|
Loading…
Reference in a new issue