ReactOS 0.4.15-dev-8434-g155a7c7
framewnd.c File Reference
#include "regedit.h"
#include <commdlg.h>
#include <cderr.h>
#include <objsel.h>
Include dependency graph for framewnd.c:

Go to the source code of this file.

Classes

struct  FILTERPAIR
 

Macros

#define FAVORITES_MENU_POSITION   3
 
#define LOADHIVE_KEYNAMELENGTH   128
 

Typedefs

typedef struct FILTERPAIRPFILTERPAIR
 

Functions

static UINT ErrorBox (HWND hWnd, UINT Error)
 
static void resize_frame_rect (HWND hWnd, PRECT prect)
 
static void resize_frame_client (HWND hWnd)
 
static void OnInitMenu (HWND hWnd)
 
static void OnEnterMenuLoop (HWND hWnd)
 
static void OnExitMenuLoop (HWND hWnd)
 
static void OnMenuSelect (HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
 
void SetupStatusBar (HWND hWnd, BOOL bResize)
 
void UpdateStatusBar (void)
 
static void toggle_child (HWND hWnd, UINT cmd, HWND hchild)
 
static BOOL CheckCommDlgError (HWND hWnd)
 
void BuildFilterStrings (WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
 
static BOOL InitOpenFileName (HWND hWnd, OPENFILENAME *pofn, BOOL bSave)
 
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc (HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL EnablePrivilege (LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
 
static BOOL LoadHive (HWND hWnd)
 
static BOOL UnloadHive (HWND hWnd)
 
static BOOL ImportRegistryFile (HWND hWnd)
 
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
 
BOOL ExportRegistryFile (HWND hWnd)
 
BOOL PrintRegistryHive (HWND hWnd, LPWSTR path)
 
static void ChooseFavorite (LPCWSTR pszFavorite)
 
static LPWSTR GetItemFullPath (HTREEITEM hTI)
 
static INT_PTR CALLBACK AddToFavoritesDlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL CopyKeyName (HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
 
static BOOL CreateNewValue (HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
 
static HRESULT InitializeRemoteRegistryPicker (OUT IDsObjectPicker **pDsObjectPicker)
 
static HRESULT InvokeRemoteRegistryPickerDialog (IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
 
static VOID FreeObjectPicker (IN IDsObjectPicker *pDsObjectPicker)
 
static BOOL _CmdWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK FrameWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

static WCHAR s_szFavoritesRegKey [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"
 
static BOOL bInMenuLoop = FALSE
 
WCHAR Suggestions [256]
 
WCHAR FileNameBuffer [MAX_PATH]
 

Macro Definition Documentation

◆ FAVORITES_MENU_POSITION

#define FAVORITES_MENU_POSITION   3

Definition at line 31 of file framewnd.c.

◆ LOADHIVE_KEYNAMELENGTH

#define LOADHIVE_KEYNAMELENGTH   128

Definition at line 319 of file framewnd.c.

Typedef Documentation

◆ PFILTERPAIR

Function Documentation

◆ _CmdWndProc()

static BOOL _CmdWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

PURPOSE: Processes WM_COMMAND messages for the main frame window.

Definition at line 1152 of file framewnd.c.

1153{
1154 HKEY hKeyRoot = 0, hKey = 0;
1155 LPCWSTR keyPath;
1156 LPCWSTR valueName;
1157 BOOL result = TRUE;
1158 REGSAM regsam = KEY_READ;
1159 int item;
1160
1163
1164 switch (LOWORD(wParam))
1165 {
1167 LoadHive(hWnd);
1168 return TRUE;
1171 return TRUE;
1174 return TRUE;
1177 return TRUE;
1179 {
1180 IDsObjectPicker *ObjectPicker;
1181 WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1182 HRESULT hRet;
1183
1184 hRet = CoInitialize(NULL);
1185 if (SUCCEEDED(hRet))
1186 {
1187 hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
1188 if (SUCCEEDED(hRet))
1189 {
1190 hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
1191 hWnd,
1192 szComputerName,
1193 ARRAY_SIZE(szComputerName));
1194 if (hRet == S_OK)
1195 {
1196 /* FIXME - connect to the registry */
1197 }
1198
1199 FreeObjectPicker(ObjectPicker);
1200 }
1201
1203 }
1204
1205 return TRUE;
1206 }
1208 return TRUE;
1209 case ID_REGISTRY_PRINT:
1211 return TRUE;
1212 case ID_REGISTRY_EXIT:
1214 return TRUE;
1215 case ID_VIEW_STATUSBAR:
1217 return TRUE;
1220 return TRUE;
1221 case ID_HELP_HELPTOPICS:
1222 WinHelpW(hWnd, L"regedit", HELP_FINDER, 0);
1223 return TRUE;
1224 case ID_HELP_ABOUT:
1226 return TRUE;
1227 case ID_VIEW_SPLIT:
1228 {
1229 RECT rt;
1230 POINT pt, pts;
1232 pt.x = rt.left + g_pChildWnd->nSplitPos;
1233 pt.y = (rt.bottom / 2);
1234 pts = pt;
1235 if(ClientToScreen(g_pChildWnd->hWnd, &pts))
1236 {
1237 SetCursorPos(pts.x, pts.y);
1240 }
1241 return TRUE;
1242 }
1243 case ID_EDIT_RENAME:
1244 case ID_EDIT_MODIFY:
1245 case ID_EDIT_MODIFY_BIN:
1246 case ID_EDIT_DELETE:
1247 regsam |= KEY_WRITE;
1248 break;
1249 }
1250
1251 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1252 valueName = GetValueName(g_pChildWnd->hListWnd, -1);
1253 if (keyPath)
1254 {
1255 if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
1256 hKey = 0;
1257 }
1258
1259 switch (LOWORD(wParam))
1260 {
1261 case ID_EDIT_MODIFY:
1262 if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
1263 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1264 break;
1265 case ID_EDIT_MODIFY_BIN:
1266 if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
1267 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1268 break;
1269 case ID_EDIT_RENAME:
1270 if (GetFocus() == g_pChildWnd->hListWnd)
1271 {
1273 {
1275 if(item > -1)
1276 {
1278 }
1279 }
1280 }
1281 else if (GetFocus() == g_pChildWnd->hTreeWnd)
1282 {
1283 /* Get focused entry of treeview (if any) */
1285 if (hItem != NULL)
1287 }
1288 break;
1289 case ID_EDIT_DELETE:
1290 {
1291 if (GetFocus() == g_pChildWnd->hListWnd && hKey)
1292 {
1294 if(nSelected >= 1)
1295 {
1296 WCHAR msg[128], caption[128];
1300 {
1301 int ni, errs;
1302
1303 item = -1;
1304 errs = 0;
1306 {
1307 valueName = GetValueName(g_pChildWnd->hListWnd, item);
1308 if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
1309 {
1310 errs++;
1311 }
1312 item = ni;
1313 }
1314
1315 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1316 if(errs > 0)
1317 {
1321 }
1322 }
1323 }
1324 }
1325 else if (GetFocus() == g_pChildWnd->hTreeWnd)
1326 {
1327 if (keyPath == NULL || *keyPath == UNICODE_NULL)
1328 {
1330 }
1331 else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1332 {
1335 }
1336 }
1337 break;
1338 }
1340 CreateNewValue(hKeyRoot, keyPath, REG_SZ);
1341 break;
1343 CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
1344 break;
1346 CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
1347 break;
1349 CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
1350 break;
1352 CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
1353 break;
1354 case ID_EDIT_FIND:
1356 break;
1357 case ID_EDIT_FINDNEXT:
1359 break;
1361 CopyKeyName(hWnd, hKeyRoot, keyPath);
1362 break;
1364 RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1365 break;
1367 //PRINTDLG pd;
1368 //PrintDlg(&pd);
1369 //PAGESETUPDLG psd;
1370 //PageSetupDlg(&psd);
1371 break;
1373 break;
1374 case ID_VIEW_REFRESH:
1376 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1377 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, TRUE);
1378 break;
1379 //case ID_OPTIONS_TOOLBAR:
1380 // toggle_child(hWnd, LOWORD(wParam), hToolBar);
1381 // break;
1382 case ID_EDIT_NEW_KEY:
1384 break;
1387 break;
1390 break;
1391 case ID_TREE_RENAME:
1394 break;
1395 case ID_TREE_DELETE:
1397 if (keyPath == 0 || *keyPath == 0)
1399 else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1401 break;
1402 case ID_TREE_EXPORT:
1404 break;
1407 RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1408 break;
1409 case ID_SWITCH_PANELS:
1410 {
1411 BOOL bShiftDown = GetKeyState(VK_SHIFT) < 0;
1412 HWND hwndItem = GetNextDlgTabItem(g_pChildWnd->hWnd, GetFocus(), bShiftDown);
1413 if (hwndItem == g_pChildWnd->hAddressBarWnd)
1414 PostMessageW(hwndItem, EM_SETSEL, 0, -1);
1415 SetFocus(hwndItem);
1416 }
1417 break;
1418 case ID_ADDRESS_FOCUS:
1421 break;
1422 default:
1424 {
1425 HMENU hMenu;
1426 MENUITEMINFOW mii;
1427 WCHAR szFavorite[512];
1428
1430
1431 memset(&mii, 0, sizeof(mii));
1432 mii.cbSize = sizeof(mii);
1433 mii.fMask = MIIM_TYPE;
1434 mii.fType = MFT_STRING;
1435 mii.dwTypeData = szFavorite;
1436 mii.cch = ARRAY_SIZE(szFavorite);
1437
1438 if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
1439 {
1440 ChooseFavorite(szFavorite);
1441 }
1442 }
1444 {
1445 WORD wID = LOWORD(wParam);
1447 while(wID > ID_TREE_SUGGESTION_MIN)
1448 {
1449 if (*s)
1450 s += wcslen(s) + 1;
1451 wID--;
1452 }
1454 }
1455 else
1456 {
1457 result = FALSE;
1458 }
1459 break;
1460 }
1461
1462 if(hKey)
1464 return result;
1465}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
static __inline VOID DeleteNode(NODE *node)
Definition: text.h:48
void ShowAboutBox(HWND hWnd)
Definition: about.c:25
ChildWnd * g_pChildWnd
Definition: childwnd.c:26
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
Definition: edit.c:1544
BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
Definition: edit.c:1960
void FindNextMessageBox(HWND hWnd)
Definition: find.c:812
void FindDialog(HWND hWnd)
Definition: find.c:824
static HRESULT InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: framewnd.c:1086
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
Definition: framewnd.c:910
static BOOL UnloadHive(HWND hWnd)
Definition: framewnd.c:432
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
Definition: framewnd.c:733
static HRESULT InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
Definition: framewnd.c:1027
static INT_PTR CALLBACK AddToFavoritesDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:849
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
static void ChooseFavorite(LPCWSTR pszFavorite)
Definition: framewnd.c:805
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:198
BOOL ExportRegistryFile(HWND hWnd)
Definition: framewnd.c:610
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1144
WCHAR Suggestions[256]
Definition: childwnd.c:30
static BOOL LoadHive(HWND hWnd)
Definition: framewnd.c:375
static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
Definition: framewnd.c:947
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:464
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath, BOOL bSelectNone)
Definition: listview.c:671
WCHAR * GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
HWND hStatusBar
Definition: main.c:36
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:787
#define ARRAY_SIZE(A)
Definition: main.h:33
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:838
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:322
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:584
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:156
#define ID_REGISTRY_EXPORTREGISTRYFILE
Definition: resource.h:69
#define ID_REGISTRY_OPENLOCAL
Definition: resource.h:102
#define ID_EDIT_COPYKEYNAME
Definition: resource.h:59
#define IDS_ERR_DELETEVALUE
Definition: resource.h:137
#define ID_EDIT_MODIFY
Definition: resource.h:62
#define ID_VIEW_STATUSBAR
Definition: resource.h:54
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:105
#define ID_FAVOURITES_ADDTOFAVOURITES
Definition: resource.h:52
#define ID_REGISTRY_PRINT
Definition: resource.h:72
#define ID_REGISTRY_PRINTERSETUP
Definition: resource.h:110
#define ID_TREE_PERMISSIONS
Definition: resource.h:159
#define ID_EDIT_DELETE
Definition: resource.h:57
#define IDS_QUERY_DELETE_CONFIRM
Definition: resource.h:135
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:93
#define ID_VIEW_REFRESH
Definition: resource.h:56
#define IDD_ADDFAVORITES
Definition: resource.h:46
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:95
#define ID_EDIT_NEW_MULTISTRINGVALUE
Definition: resource.h:146
#define ID_VIEW_SPLIT
Definition: resource.h:55
#define ID_REGISTRY_CONNECTNETWORKREGISTRY
Definition: resource.h:70
#define ID_EDIT_NEW_STRINGVALUE
Definition: resource.h:64
#define IDS_ERR_DELVAL_CAPTION
Definition: resource.h:136
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY
Definition: resource.h:71
#define ID_ADDRESS_FOCUS
Definition: resource.h:160
#define IDS_QUERY_DELETE_ONE
Definition: resource.h:133
#define ID_HELP_HELPTOPICS
Definition: resource.h:74
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:122
#define ID_EDIT_NEW_EXPANDABLESTRINGVALUE
Definition: resource.h:147
#define ID_SWITCH_PANELS
Definition: resource.h:149
#define ID_EDIT_NEW_KEY
Definition: resource.h:63
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:157
#define ID_EDIT_RENAME
Definition: resource.h:58
#define ID_TREE_EXPORT
Definition: resource.h:158
#define ID_FAVORITES_MAX
Definition: resource.h:365
#define ID_EDIT_FINDNEXT
Definition: resource.h:61
#define ID_EDIT_NEW_DWORDVALUE
Definition: resource.h:66
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:104
#define ID_FAVORITES_MIN
Definition: resource.h:364
#define ID_HELP_ABOUT
Definition: resource.h:75
#define ID_REGISTRY_EXIT
Definition: resource.h:51
#define ID_TREE_RENAME
Definition: resource.h:152
#define ID_TREE_DELETE
Definition: resource.h:151
#define ID_EDIT_PERMISSIONS
Definition: resource.h:150
#define IDS_QUERY_DELETE_MORE
Definition: resource.h:134
#define ID_EDIT_NEW_BINARYVALUE
Definition: resource.h:65
#define ID_EDIT_FIND
Definition: resource.h:60
#define ID_REGISTRY_IMPORTREGISTRYFILE
Definition: resource.h:68
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define pt(x, y)
Definition: drawing.c:79
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
static struct netconfig_info ni
Definition: getnetconfig.c:158
GLdouble s
Definition: gl.h:2039
GLuint64EXT * result
Definition: glext.h:11304
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define REG_SZ
Definition: layer.c:22
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2540
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TVE_EXPAND
Definition: commctrl.h:3423
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define TVE_COLLAPSE
Definition: commctrl.h:3422
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3504
#define REG_DWORD
Definition: sdbapi.c:596
#define memset(x, y, z)
Definition: compat.h:39
int nSplitPos
Definition: main.h:69
HWND hTreeWnd
Definition: main.h:63
HWND hListWnd
Definition: main.h:64
HWND hAddressBarWnd
Definition: main.h:65
HWND hWnd
Definition: main.h:62
Definition: tftpd.h:60
LPWSTR dwTypeData
Definition: winuser.h:3269
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG bottom
Definition: windef.h:309
LONG left
Definition: windef.h:306
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:243
ACCESS_MASK REGSAM
Definition: winreg.h:69
HWND WINAPI GetFocus(void)
Definition: window.c:1865
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONHAND
Definition: winuser.h:788
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define MB_YESNO
Definition: winuser.h:817
BOOL WINAPI MessageBeep(_In_ UINT uType)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2706
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149
HWND WINAPI GetNextDlgTabItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define HELP_FINDER
Definition: winuser.h:2419
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETSEL
Definition: winuser.h:2018
#define MB_ICONQUESTION
Definition: winuser.h:789
#define MB_ICONSTOP
Definition: winuser.h:803
#define VK_SHIFT
Definition: winuser.h:2202
#define MFT_STRING
Definition: winuser.h:746
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:835
#define IDC_SIZEWE
Definition: winuser.h:694
#define GetMenuItemInfo
Definition: winuser.h:5797
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MIIM_TYPE
Definition: winuser.h:725
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HMENU WINAPI GetMenu(_In_ HWND)
SHORT WINAPI GetKeyState(_In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by FrameWndProc().

◆ AddToFavoritesDlgProc()

static INT_PTR CALLBACK AddToFavoritesDlgProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 849 of file framewnd.c.

850{
853 switch (uMsg)
854 {
855 case WM_INITDIALOG:
856 {
857 TVITEM tvi;
858 tvi.mask = TVIF_HANDLE | TVIF_TEXT;
860 tvi.pszText = name;
861 tvi.cchTextMax = _countof(name);
863 tvi.pszText[0] = UNICODE_NULL;
864 SetWindowTextW(hName, tvi.pszText);
865 SendMessageW(hName, EM_LIMITTEXT, _countof(name) - 1, 0);
866 return TRUE;
867 }
868 case WM_COMMAND:
869 switch (LOWORD(wParam))
870 {
871 case IDOK:
872 {
873 LPWSTR path;
874 HKEY hKey;
875 DWORD err;
876 if (!GetWindowTextW(hName, name, _countof(name)))
877 {
878 err = GetLastError();
879 goto failed;
880 }
882 if (!path)
883 {
885 goto failed;
886 }
889 if (err)
890 goto failed;
891 err = RegSetValueExW(hKey, name, 0, REG_SZ, (BYTE*)path, (lstrlenW(path) + 1) * sizeof(WCHAR));
893 if (err) failed:
894 ErrorBox(hWnd, err);
895 free(path);
896 return EndDialog(hWnd, err);
897 }
898 case IDCANCEL:
900 case IDC_FAVORITENAME:
901 if (HIWORD(wParam) == EN_UPDATE)
903 break;
904 }
905 break;
906 }
907 return FALSE;
908}
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
static UINT ErrorBox(HWND hWnd, UINT Error)
Definition: framewnd.c:42
static LPWSTR GetItemFullPath(HTREEITEM hTI)
Definition: framewnd.c:827
#define IDC_FAVORITENAME
Definition: resource.h:293
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define free
Definition: debug_ros.c:5
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TVITEM
Definition: commctrl.h:3365
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define err(...)
#define _countof(array)
Definition: sndvol32.h:70
Definition: name.c:39
#define HIWORD(l)
Definition: typedefs.h:247
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_CANCELLED
Definition: winerror.h:726
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define EM_LIMITTEXT
Definition: winuser.h:2000
#define IDCANCEL
Definition: winuser.h:831
#define EN_UPDATE
Definition: winuser.h:2028
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
int WINAPI GetWindowTextLengthW(_In_ HWND)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193

Referenced by _CmdWndProc().

◆ BuildFilterStrings()

void BuildFilterStrings ( WCHAR Filter,
PFILTERPAIR  Pairs,
int  PairCount 
)

Definition at line 259 of file framewnd.c.

260{
261 int i, c;
262
263 c = 0;
264 for(i = 0; i < PairCount; i++)
265 {
266 c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
267 Filter[++c] = L'\0';
268 c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
269 Filter[++c] = L'\0';
270 }
271 Filter[++c] = L'\0';
272}
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define c
Definition: ke_i.h:80

Referenced by InitOpenFileName(), and LoadHive().

◆ CheckCommDlgError()

static BOOL CheckCommDlgError ( HWND  hWnd)
static

Definition at line 208 of file framewnd.c.

209{
210 DWORD dwErrorCode = CommDlgExtendedError();
212 switch (dwErrorCode)
213 {
215 break;
217 break;
219 break;
221 break;
222 case CDERR_NOHOOK:
223 break;
225 break;
226 case CDERR_NOTEMPLATE:
227 break;
229 break;
230 case CDERR_STRUCTSIZE:
231 break;
233 break;
235 break;
237 break;
239 break;
241 break;
243 break;
244 default:
245 break;
246 }
247 return TRUE;
248}
#define CDERR_MEMLOCKFAILURE
Definition: cderr.h:15
#define FNERR_SUBCLASSFAILURE
Definition: cderr.h:35
#define CDERR_MEMALLOCFAILURE
Definition: cderr.h:14
#define FNERR_BUFFERTOOSMALL
Definition: cderr.h:37
#define CDERR_NOHINSTANCE
Definition: cderr.h:9
#define CDERR_LOADSTRFAILURE
Definition: cderr.h:10
#define CDERR_NOHOOK
Definition: cderr.h:16
#define FNERR_INVALIDFILENAME
Definition: cderr.h:36
#define CDERR_INITIALIZATION
Definition: cderr.h:7
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define CDERR_NOTEMPLATE
Definition: cderr.h:8
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
#define CDERR_LOCKRESFAILURE
Definition: cderr.h:13
#define CDERR_DIALOGFAILURE
Definition: cderr.h:4
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148

Referenced by ExportRegistryFile(), ImportRegistryFile(), and LoadHive().

◆ ChooseFavorite()

static void ChooseFavorite ( LPCWSTR  pszFavorite)
static

Definition at line 805 of file framewnd.c.

806{
807 HKEY hKey = NULL;
808 WCHAR szFavoritePath[512];
809 DWORD cbData, dwType;
810
812 goto done;
813
814 cbData = sizeof(szFavoritePath);
815 memset(szFavoritePath, 0, sizeof(szFavoritePath));
816 if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
817 goto done;
818
819 if (dwType == REG_SZ)
820 SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
821
822done:
823 if (hKey)
825}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by _CmdWndProc().

◆ CopyKeyName()

BOOL CopyKeyName ( HWND  hWnd,
HKEY  hRootKey,
LPCWSTR  keyName 
)

Definition at line 910 of file framewnd.c.

911{
912 BOOL bClipboardOpened = FALSE;
914 WCHAR szBuffer[512];
915 HGLOBAL hGlobal;
916 LPWSTR s;
917 SIZE_T cbGlobal;
918
919 if (!OpenClipboard(hWnd))
920 goto done;
921 bClipboardOpened = TRUE;
922
923 if (!EmptyClipboard())
924 goto done;
925
926 if (!GetKeyName(szBuffer, ARRAY_SIZE(szBuffer), hRootKey, keyName))
927 goto done;
928
929 cbGlobal = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
930 hGlobal = GlobalAlloc(GMEM_MOVEABLE, cbGlobal);
931 if (!hGlobal)
932 goto done;
933
934 s = GlobalLock(hGlobal);
935 StringCbCopyW(s, cbGlobal, szBuffer);
936 GlobalUnlock(hGlobal);
937
939 bSuccess = TRUE;
940
941done:
942 if (bClipboardOpened)
944 return bSuccess;
945}
#define CF_UNICODETEXT
Definition: constants.h:408
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:2094
static BOOLEAN bSuccess
Definition: drive.cpp:477
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define GMEM_MOVEABLE
Definition: winbase.h:294
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190

Referenced by _CmdWndProc().

◆ CreateNewValue()

static BOOL CreateNewValue ( HKEY  hRootKey,
LPCWSTR  pszKeyPath,
DWORD  dwType 
)
static

Definition at line 947 of file framewnd.c.

948{
949 WCHAR szNewValueFormat[128];
950 WCHAR szNewValue[128];
951 int iIndex = 1;
952 BYTE data[128];
953 DWORD dwExistingType, cbData;
954 LONG lResult;
955 HKEY hKey;
956 LVFINDINFO lvfi;
957
958 if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
959 &hKey) != ERROR_SUCCESS)
960 return FALSE;
961
962 LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, ARRAY_SIZE(szNewValueFormat));
963
964 do
965 {
966 wsprintf(szNewValue, szNewValueFormat, iIndex++);
967 cbData = sizeof(data);
968 lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
969 }
970 while(lResult == ERROR_SUCCESS);
971
972 switch(dwType)
973 {
974 case REG_DWORD:
975 cbData = sizeof(DWORD);
976 break;
977 case REG_SZ:
978 case REG_EXPAND_SZ:
979 cbData = sizeof(WCHAR);
980 break;
981 case REG_MULTI_SZ:
982 /*
983 * WARNING: An empty multi-string has only one null char.
984 * Indeed, multi-strings are built in the following form:
985 * str1\0str2\0...strN\0\0
986 * where each strI\0 is a null-terminated string, and it
987 * ends with a terminating empty string.
988 * Therefore an empty multi-string contains only the terminating
989 * empty string, that is, one null char.
990 */
991 cbData = sizeof(WCHAR);
992 break;
993 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
994 cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
995 break;
996 default:
997 cbData = 0;
998 break;
999 }
1000 memset(data, 0, cbData);
1001 lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
1003 if (lResult != ERROR_SUCCESS)
1004 {
1005 return FALSE;
1006 }
1007
1008 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
1009
1010 /* locate the newly added value, and get ready to rename it */
1011 memset(&lvfi, 0, sizeof(lvfi));
1012 lvfi.flags = LVFI_STRING;
1013 lvfi.psz = szNewValue;
1014 iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
1015 if (iIndex >= 0)
1016 {
1021 }
1022
1023 return TRUE;
1024}
#define IDS_NEW_VALUE
Definition: resource.h:193
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
#define LVFINDINFO
Definition: commctrl.h:2463
#define LVFI_STRING
Definition: commctrl.h:2437
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2519
#define REG_QWORD
Definition: sdbapi.c:597
#define wsprintf
Definition: winuser.h:5874

Referenced by _CmdWndProc().

◆ EnablePrivilege()

static BOOL EnablePrivilege ( LPCWSTR  lpszPrivilegeName,
LPCWSTR  lpszSystemName,
BOOL  bEnablePrivilege 
)
static

Definition at line 345 of file framewnd.c.

346{
347 BOOL bRet = FALSE;
348 HANDLE hToken = NULL;
349
352 &hToken))
353 {
355
356 tp.PrivilegeCount = 1;
357 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
358
359 if (LookupPrivilegeValueW(lpszSystemName,
360 lpszPrivilegeName,
361 &tp.Privileges[0].Luid))
362 {
363 bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
364
366 bRet = FALSE;
367 }
368
369 CloseHandle(hToken);
370 }
371
372 return bRet;
373}
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
#define ERROR_NOT_ALL_ASSIGNED
Definition: winerror.h:782
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by ExportRegistryFile(), ImportRegistryFile(), LoadHive(), and UnloadHive().

◆ ErrorBox()

static UINT ErrorBox ( HWND  hWnd,
UINT  Error 
)
static

Definition at line 42 of file framewnd.c.

43{
44 WCHAR buf[400];
46 NULL, Error, 0, buf, _countof(buf), NULL))
47 *(UINT*)buf = L'?';
49 return Error;
50}
BOOL Error
Definition: chkdsk.c:66
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:420
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423

Referenced by AddToFavoritesDlgProc().

◆ ExportRegistryFile()

BOOL ExportRegistryFile ( HWND  hWnd)

Definition at line 610 of file framewnd.c.

611{
612 BOOL bRet = FALSE;
614 WCHAR ExportKeyPath[_MAX_PATH] = {0};
615 WCHAR Caption[128], szTitle[512], szText[512];
616 HKEY hKeyRoot;
617 LPCWSTR pszKeyPath;
618
619 /* Figure out which key path we are exporting */
620 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
621 GetKeyName(ExportKeyPath, ARRAY_SIZE(ExportKeyPath), hKeyRoot, pszKeyPath);
622
624 LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
625 ofn.lpstrTitle = Caption;
626
627 /* Only set the path if a key (not the root node) is selected */
628 if (hKeyRoot != 0)
629 {
630 ofn.lCustData = (LPARAM) ExportKeyPath;
631 }
635 if (GetSaveFileName(&ofn))
636 {
637 switch (ofn.nFilterIndex)
638 {
639 case 2: /* Registry Hive Files */
640 {
641 LONG lResult;
642 HKEY hSubKey;
643
644 /* Open the subkey */
645 lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
646 if (lResult == ERROR_SUCCESS)
647 {
648 /* Enable the 'backup' privilege, save the hive then disable the privilege */
650 lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
651 if (lResult == ERROR_ALREADY_EXISTS)
652 {
653 /*
654 * We are here, that means that we already said "yes" to the confirmation dialog.
655 * So we absolutely want to replace the hive file.
656 */
658 {
659 /* Try again */
660 lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
661 }
662 }
664
665 if (lResult != ERROR_SUCCESS)
666 {
667 /*
668 * If we are here, it's because RegSaveKeyW has failed for any reason.
669 * The problem is that even if it has failed, it has created or
670 * replaced the exported hive file with a new empty file. We don't
671 * want to keep this file, so we delete it.
672 */
674 }
675
676 /* Close the subkey */
677 RegCloseKey(hSubKey);
678 }
679
680 /* Set the return value */
681 bRet = (lResult == ERROR_SUCCESS);
682
683 /* Display error, if any */
684 if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
685
686 break;
687 }
688
689 case 1: /* Windows Registry Editor Version 5.00 */
690 case 3: /* REGEDIT4 */
691 default: /* All files ==> use Windows Registry Editor Version 5.00 */
692 {
693 if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
695 : REG_FORMAT_5)))
696 {
697 /* Error creating the file */
699 LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
701 bRet = FALSE;
702 }
703 else
704 {
705 bRet = TRUE;
706 }
707
708 break;
709 }
710
711 case 4: /* Text File */
712 {
713 bRet = txt_export_registry_key(ofn.lpstrFile, ExportKeyPath);
714 if (!bRet)
715 {
716 /* Error creating the file */
718 LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
720 }
721 break;
722 }
723 }
724 }
725 else
726 {
728 }
729
730 return bRet;
731}
#define SE_BACKUP_NAME
#define IDS_APP_TITLE
Definition: resource.h:10
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:208
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn, BOOL bSave)
Definition: framewnd.c:274
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:345
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:556
#define REG_FORMAT_5
Definition: main.h:44
#define REG_FORMAT_4
Definition: main.h:45
BOOL export_registry_key(WCHAR *file_name, WCHAR *path, DWORD format)
Definition: regproc.c:1579
BOOL txt_export_registry_key(LPCWSTR file_name, LPCWSTR path)
Definition: txtproc.c:401
#define IDS_EXPORT_REG_FILE
Definition: resource.h:131
#define IDS_EXPORT_ERROR
Definition: resource.h:199
#define IDD_EXPORTRANGE
Definition: resource.h:42
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
LONG WINAPI RegSaveKeyW(HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: reg.c:4617
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define _MAX_PATH
Definition: utility.h:77
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
OPENFILENAME ofn
Definition: sndrec32.cpp:56
LPARAM lCustData
Definition: commdlg.h:346
LPCSTR lpTemplateName
Definition: commdlg.h:348
DWORD nFilterIndex
Definition: commdlg.h:335
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
LONG_PTR LPARAM
Definition: windef.h:208
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790

Referenced by _CmdWndProc().

◆ ExportRegistryFile_OFNHookProc()

static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc ( HWND  hdlg,
UINT  uiMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 556 of file framewnd.c.

557{
558 HWND hwndExportAll;
559 HWND hwndExportBranch;
560 HWND hwndExportBranchText;
561 UINT_PTR iResult = 0;
562 OPENFILENAME *pOfn;
563 LPWSTR pszSelectedKey;
564 OFNOTIFY *pOfnNotify;
565
567
568 switch(uiMsg)
569 {
570 case WM_INITDIALOG:
571 pOfn = (OPENFILENAME *) lParam;
572 pszSelectedKey = (LPWSTR) pOfn->lCustData;
573
574 hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
575 if (hwndExportAll)
576 SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
577
578 hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
579 if (hwndExportBranch)
580 SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
581
582 hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
583 if (hwndExportBranchText)
584 SetWindowTextW(hwndExportBranchText, pszSelectedKey);
585 break;
586
587 case WM_NOTIFY:
588 if (((NMHDR *) lParam)->code == CDN_FILEOK)
589 {
590 pOfnNotify = (OFNOTIFY *) lParam;
591 pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
592
593 hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
594 hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
595 if (hwndExportBranch && hwndExportBranchText
596 && (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
597 {
598 GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
599 }
600 else if (pszSelectedKey)
601 {
602 pszSelectedKey[0] = L'\0';
603 }
604 }
605 break;
606 }
607 return iResult;
608}
#define IDC_EXPORT_ALL
Definition: resource.h:286
#define IDC_EXPORT_BRANCH
Definition: resource.h:287
#define IDC_EXPORT_BRANCH_TEXT
Definition: resource.h:288
#define CDN_FILEOK
Definition: commdlg.h:38
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WM_NOTIFY
Definition: richedit.h:61
LPOPENFILENAMEA lpOFN
Definition: commdlg.h:407
Definition: inflate.c:139
#define BST_UNCHECKED
Definition: winuser.h:199
#define BM_SETCHECK
Definition: winuser.h:1921
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918

Referenced by ExportRegistryFile().

◆ FrameWndProc()

LRESULT CALLBACK FrameWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

PURPOSE: Processes messages for the main frame window

WM_COMMAND - process the application menu WM_DESTROY - post a quit message and return

Definition at line 1473 of file framewnd.c.

1474{
1475 RECT rc;
1476 switch (message)
1477 {
1478 case WM_CREATE:
1479 // For now, the Help dialog item is disabled because of lacking of HTML Help support
1481 GetClientRect(hWnd, &rc);
1483 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
1484 hWnd, (HMENU)0, hInst, 0);
1485 break;
1486 case WM_COMMAND:
1489 break;
1490 case WM_ACTIVATE:
1493 break;
1494 case WM_SIZE:
1496 break;
1497 case WM_INITMENU:
1499 break;
1500 case WM_ENTERMENULOOP:
1502 break;
1503 case WM_EXITMENULOOP:
1505 break;
1506 case WM_MENUSELECT:
1508 break;
1509 case WM_SYSCOLORCHANGE:
1510 /* Forward WM_SYSCOLORCHANGE to common controls */
1513 break;
1514 case WM_DESTROY:
1515 WinHelpW(hWnd, L"regedit", HELP_QUIT, 0);
1516 SaveSettings();
1517 PostQuitMessage(0);
1518 default:
1520 }
1521 return 0;
1522}
void SaveSettings(void)
Definition: settings.c:115
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:65
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:134
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:154
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1152
static void OnExitMenuLoop(HWND hWnd)
Definition: framewnd.c:146
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:75
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:45
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
LONG right
Definition: windef.h:308
LONG top
Definition: windef.h:307
#define MF_BYCOMMAND
Definition: winuser.h:202
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HELP_QUIT
Definition: winuser.h:2414
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1611
#define WM_INITMENU
Definition: winuser.h:1745
#define WA_INACTIVE
Definition: winuser.h:2622
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1626
#define WM_ACTIVATE
Definition: winuser.h:1612
#define WM_ENTERMENULOOP
Definition: winuser.h:1804
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WM_EXITMENULOOP
Definition: winuser.h:1805
#define WM_DESTROY
Definition: winuser.h:1609
#define WM_MENUSELECT
Definition: winuser.h:1747
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by InitInstance().

◆ FreeObjectPicker()

static VOID FreeObjectPicker ( IN IDsObjectPicker *  pDsObjectPicker)
static

Definition at line 1144 of file framewnd.c.

1145{
1146 pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
1147}

Referenced by _CmdWndProc(), and SecurityPageProc().

◆ GetItemFullPath()

static LPWSTR GetItemFullPath ( HTREEITEM  hTI)
static

Definition at line 827 of file framewnd.c.

828{
829 HKEY hRoot;
830 WCHAR rootname[MAX_PATH], *buffer;
831 SIZE_T rootlen, subkeylen;
832 LPCWSTR subkey = GetItemPath(g_pChildWnd->hTreeWnd, hTI, &hRoot);
833 if (!subkey || !hRoot)
834 return NULL;
835 if (!GetKeyName(rootname, ARRAY_SIZE(rootname), hRoot, L""))
836 return NULL;
837 rootlen = lstrlenW(rootname) + 1; // + 1 for '\\'
838 subkeylen = lstrlenW(subkey);
839 buffer = (WCHAR*)malloc((rootlen + subkeylen + 1) * sizeof(WCHAR));
840 if (buffer)
841 {
842 lstrcpyW(buffer, rootname);
843 buffer[rootlen - 1] = '\\';
844 lstrcpyW(buffer + rootlen, subkey);
845 }
846 return buffer;
847}
#define malloc
Definition: debug_ros.c:4
#define lstrcpyW
Definition: compat.h:749
GLuint buffer
Definition: glext.h:5915
static HTREEITEM hRoot
Definition: treeview.c:381

Referenced by AddToFavoritesDlgProc().

◆ ImportRegistryFile()

static BOOL ImportRegistryFile ( HWND  hWnd)
static

Definition at line 464 of file framewnd.c.

465{
466 BOOL bRet = FALSE;
468 WCHAR Caption[128], szTitle[512], szText[512];
469 HKEY hKeyRoot;
470 LPCWSTR pszKeyPath;
471
472 /* Figure out in which key path we are importing */
473 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
474
476 LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
477 ofn.lpstrTitle = Caption;
479
480 if (GetOpenFileName(&ofn))
481 {
482 /* Look at the extension of the file to determine its type */
483 if (ofn.nFileExtension >= 1 &&
484 _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
485 {
486 /* Open the file */
487 FILE* fp = _wfopen(ofn.lpstrFile, L"rb");
488
489 /* Import it */
490 if (fp == NULL || !import_registry_file(fp))
491 {
492 /* Error opening the file */
494 LoadStringW(hInst, IDS_IMPORT_ERROR, szText, ARRAY_SIZE(szText));
496 bRet = FALSE;
497 }
498 else
499 {
500 /* Show successful import */
502 LoadStringW(hInst, IDS_IMPORT_OK, szText, ARRAY_SIZE(szText));
504 bRet = TRUE;
505 }
506
507 /* Close the file */
508 if (fp) fclose(fp);
509 }
510 else /* Registry Hive Files */
511 {
514
515 /* Display a confirmation message */
517 {
518 LONG lResult;
519 HKEY hSubKey;
520
521 /* Open the subkey */
522 lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
523 if (lResult == ERROR_SUCCESS)
524 {
525 /* Enable the 'restore' privilege, restore the hive then disable the privilege */
527 lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
529
530 /* Flush the subkey and close it */
531 RegFlushKey(hSubKey);
532 RegCloseKey(hSubKey);
533 }
534
535 /* Set the return value */
536 bRet = (lResult == ERROR_SUCCESS);
537
538 /* Display error, if any */
539 if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
540 }
541 }
542 }
543 else
544 {
546 }
547
548 /* refresh tree and list views */
550 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
551 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath, TRUE);
552
553 return bRet;
554}
#define SE_RESTORE_NAME
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1054
#define IDS_QUERY_IMPORT_HIVE_MSG
Definition: resource.h:141
#define IDS_IMPORT_OK
Definition: resource.h:197
#define IDS_IMPORT_REG_FILE
Definition: resource.h:130
#define IDS_QUERY_IMPORT_HIVE_CAPTION
Definition: resource.h:140
#define IDS_IMPORT_ERROR
Definition: resource.h:198
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define GetOpenFileName
Definition: commdlg.h:665
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WORD nFileExtension
Definition: commdlg.h:344
#define RegRestoreKey
Definition: winreg.h:526
#define MB_ICONWARNING
Definition: winuser.h:786
#define MB_ICONINFORMATION
Definition: winuser.h:802
#define REG_FORCE_RESTORE
Definition: cmtypes.h:109

Referenced by _CmdWndProc(), main(), and UpdateRegistry().

◆ InitializeRemoteRegistryPicker()

static HRESULT InitializeRemoteRegistryPicker ( OUT IDsObjectPicker **  pDsObjectPicker)
static

Definition at line 1027 of file framewnd.c.

1028{
1029 HRESULT hRet;
1030
1031 *pDsObjectPicker = NULL;
1032
1033 hRet = CoCreateInstance(&CLSID_DsObjectPicker,
1034 NULL,
1035 CLSCTX_INPROC_SERVER,
1036 &IID_IDsObjectPicker,
1037 (LPVOID*)pDsObjectPicker);
1038 if (SUCCEEDED(hRet))
1039 {
1040 DSOP_INIT_INFO InitInfo;
1041 static DSOP_SCOPE_INIT_INFO Scopes[] =
1042 {
1043 {
1044 sizeof(DSOP_SCOPE_INIT_INFO),
1049 0,
1050 {
1051 {
1053 0,
1054 0
1055 },
1057 },
1058 NULL,
1059 NULL,
1060 S_OK
1061 },
1062 };
1063
1064 InitInfo.cbSize = sizeof(InitInfo);
1065 InitInfo.pwzTargetComputer = NULL;
1066 InitInfo.cDsScopeInfos = ARRAY_SIZE(Scopes);
1067 InitInfo.aDsScopeInfos = Scopes;
1068 InitInfo.flOptions = 0;
1069 InitInfo.cAttributesToFetch = 0;
1070 InitInfo.apwzAttributeNames = NULL;
1071
1072 hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
1073 &InitInfo);
1074
1075 if (FAILED(hRet))
1076 {
1077 /* delete the object picker in case initialization failed! */
1078 (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
1079 }
1080 }
1081
1082 return hRet;
1083}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
ULONG Release()
#define FAILED(hr)
Definition: intsafe.h:51
#define DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
Definition: objsel.h:127
#define DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
Definition: objsel.h:123
#define DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
Definition: objsel.h:130
#define DSOP_SCOPE_TYPE_GLOBAL_CATALOG
Definition: objsel.h:125
#define DSOP_DOWNLEVEL_FILTER_COMPUTERS
Definition: objsel.h:54
#define DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
Definition: objsel.h:129
#define DSOP_SCOPE_TYPE_WORKGROUP
Definition: objsel.h:128
#define DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
Definition: objsel.h:126
#define DSOP_FILTER_COMPUTERS
Definition: objsel.h:41
#define DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
Definition: objsel.h:122
struct _DSOP_SCOPE_INIT_INFO DSOP_SCOPE_INIT_INFO
ULONG cAttributesToFetch
Definition: objsel.h:114
ULONG cbSize
Definition: objsel.h:109
PCWSTR * apwzAttributeNames
Definition: objsel.h:115
PDSOP_SCOPE_INIT_INFO aDsScopeInfos
Definition: objsel.h:112
ULONG cDsScopeInfos
Definition: objsel.h:111
PCWSTR pwzTargetComputer
Definition: objsel.h:110
ULONG flOptions
Definition: objsel.h:113

Referenced by _CmdWndProc().

◆ InitOpenFileName()

static BOOL InitOpenFileName ( HWND  hWnd,
OPENFILENAME pofn,
BOOL  bSave 
)
static

Definition at line 274 of file framewnd.c.

275{
276 FILTERPAIR FilterPairs[5];
277 static WCHAR Filter[1024];
278
279 memset(pofn, 0, sizeof(OPENFILENAME));
280 pofn->lStructSize = sizeof(OPENFILENAME);
281 pofn->hwndOwner = hWnd;
282 pofn->hInstance = hInst;
283
284 /* create filter string */
285 FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
286 FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
287 FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
288 FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
289 FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
290 FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
291 if (bSave)
292 {
293 FilterPairs[3].DisplayID = IDS_FLT_TXTFILES;
294 FilterPairs[3].FilterID = IDS_FLT_TXTFILES_FLT;
295 FilterPairs[4].DisplayID = IDS_FLT_ALLFILES;
296 FilterPairs[4].FilterID = IDS_FLT_ALLFILES_FLT;
297 }
298 else
299 {
300 FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
301 FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
302 }
303
304 BuildFilterStrings(Filter, FilterPairs, ARRAY_SIZE(FilterPairs) - !bSave);
305
306 pofn->lpstrFilter = Filter;
310 pofn->lpstrDefExt = L"reg";
311 if (bSave)
313 else
314 pofn->Flags |= OFN_FILEMUSTEXIST;
315
316 return TRUE;
317}
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:259
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:250
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:170
#define IDS_FLT_REGEDIT4
Definition: resource.h:167
#define IDS_FLT_REGEDIT4_FLT
Definition: resource.h:168
#define IDS_FLT_HIVFILES_FLT
Definition: resource.h:166
#define IDS_FLT_ALLFILES
Definition: resource.h:169
#define IDS_FLT_REGFILES
Definition: resource.h:163
#define IDS_FLT_REGFILES_FLT
Definition: resource.h:164
#define IDS_FLT_TXTFILES
Definition: resource.h:171
#define IDS_FLT_HIVFILES
Definition: resource.h:165
#define IDS_FLT_TXTFILES_FLT
Definition: resource.h:172
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
UINT FilterID
Definition: framewnd.c:255
UINT DisplayID
Definition: framewnd.c:254
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
HINSTANCE hInstance
Definition: commdlg.h:331
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337

Referenced by ExportRegistryFile(), ImportRegistryFile(), and LoadHive().

◆ InvokeRemoteRegistryPickerDialog()

static HRESULT InvokeRemoteRegistryPickerDialog ( IN IDsObjectPicker *  pDsObjectPicker,
IN HWND hwndParent  OPTIONAL,
OUT LPWSTR  lpBuffer,
IN UINT  uSize 
)
static

Definition at line 1086 of file framewnd.c.

1090{
1091 IDataObject *pdo = NULL;
1092 HRESULT hRet;
1093
1094 hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
1095 hwndParent,
1096 &pdo);
1097 if (hRet == S_OK)
1098 {
1099 STGMEDIUM stm;
1100 FORMATETC fe;
1101
1102 fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
1103 fe.ptd = NULL;
1104 fe.dwAspect = DVASPECT_CONTENT;
1105 fe.lindex = -1;
1106 fe.tymed = TYMED_HGLOBAL;
1107
1108 hRet = pdo->lpVtbl->GetData(pdo,
1109 &fe,
1110 &stm);
1111 if (SUCCEEDED(hRet))
1112 {
1113 PDS_SELECTION_LIST SelectionList = (PDS_SELECTION_LIST)GlobalLock(stm.hGlobal);
1114 if (SelectionList != NULL)
1115 {
1116 if (SelectionList->cItems == 1)
1117 {
1118 size_t nlen = wcslen(SelectionList->aDsSelection[0].pwzName);
1119 if (nlen >= uSize)
1120 {
1121 nlen = uSize - 1;
1122 }
1123
1125 SelectionList->aDsSelection[0].pwzName,
1126 nlen * sizeof(WCHAR));
1127
1128 lpBuffer[nlen] = L'\0';
1129 }
1130
1131 GlobalUnlock(stm.hGlobal);
1132 }
1133
1134 ReleaseStgMedium(&stm);
1135 }
1136
1137 pdo->lpVtbl->Release(pdo);
1138 }
1139
1140 return hRet;
1141}
static HWND hwndParent
Definition: cryptui.c:300
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _DS_SELECTION_LIST * PDS_SELECTION_LIST
#define CFSTR_DSOP_DS_SELECTION_LIST
Definition: objsel.h:27
DS_SELECTION aDsSelection[ANYSIZE_ARRAY]
Definition: objsel.h:146
PWSTR pwzName
Definition: objsel.h:134
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

Referenced by _CmdWndProc().

◆ LoadHive()

static BOOL LoadHive ( HWND  hWnd)
static

Definition at line 375 of file framewnd.c.

376{
378 WCHAR Caption[128];
379 LPCWSTR pszKeyPath;
381 HKEY hRootKey;
382 WCHAR Filter[1024];
384 /* get the item key to load the hive in */
385 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
386 /* initialize the "open file" dialog */
388 /* build the "All Files" filter up */
389 filter.DisplayID = IDS_FLT_ALLFILES;
390 filter.FilterID = IDS_FLT_ALLFILES_FLT;
393 /* load and set the caption and flags for dialog */
394 LoadStringW(hInst, IDS_LOAD_HIVE, Caption, ARRAY_SIZE(Caption));
395 ofn.lpstrTitle = Caption;
397
398 /* now load the hive */
399 if (GetOpenFileName(&ofn))
400 {
403 {
404 LONG regLoadResult;
405
406 /* Enable the 'restore' privilege, load the hive, disable the privilege */
408 regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
410
411 if(regLoadResult == ERROR_SUCCESS)
412 {
413 /* refresh tree and list views */
415 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
416 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
417 }
418 else
419 {
420 ErrorMessageBox(hWnd, Caption, regLoadResult);
421 return FALSE;
422 }
423 }
424 }
425 else
426 {
428 }
429 return TRUE;
430}
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:321
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:319
#define IDD_LOADHIVE
Definition: resource.h:290
#define IDS_LOAD_HIVE
Definition: resource.h:143
LONG WINAPI RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
Definition: reg.c:3079
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by _CmdWndProc().

◆ LoadHive_KeyNameInHookProc()

static INT_PTR CALLBACK LoadHive_KeyNameInHookProc ( HWND  hWndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 321 of file framewnd.c.

322{
323 static LPWSTR sKey = NULL;
324 switch(uMsg)
325 {
326 case WM_INITDIALOG:
327 sKey = (LPWSTR)lParam;
328 break;
329 case WM_COMMAND:
330 switch(LOWORD(wParam))
331 {
332 case IDOK:
334 return EndDialog(hWndDlg, -1);
335 else
336 return EndDialog(hWndDlg, 0);
337 case IDCANCEL:
338 return EndDialog(hWndDlg, 0);
339 }
340 break;
341 }
342 return FALSE;
343}
#define IDC_EDIT_KEY
Definition: resource.h:291
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263

Referenced by LoadHive().

◆ OnEnterMenuLoop()

static void OnEnterMenuLoop ( HWND  hWnd)
static

Definition at line 134 of file framewnd.c.

135{
136 int nParts;
138
139 /* Update the status bar pane sizes */
140 nParts = -1;
144}
static BOOL bInMenuLoop
Definition: framewnd.c:35
#define SB_SETPARTS
Definition: commctrl.h:1954
#define SB_SETTEXTW
Definition: commctrl.h:1942
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by FrameWndProc().

◆ OnExitMenuLoop()

static void OnExitMenuLoop ( HWND  hWnd)
static

Definition at line 146 of file framewnd.c.

147{
149 /* Update the status bar pane sizes*/
152}
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:178
void UpdateStatusBar(void)
Definition: framewnd.c:190

Referenced by FrameWndProc().

◆ OnInitMenu()

static void OnInitMenu ( HWND  hWnd)
static

Definition at line 75 of file framewnd.c.

76{
77 LONG lResult;
78 HKEY hKey = NULL;
79 DWORD dwIndex, cbValueName, cbValueData, dwType;
80 WCHAR szValueName[256];
81 BYTE abValueData[256];
82 static int s_nFavoriteMenuSubPos = -1;
83 HMENU hMenu;
84 BOOL bDisplayedAny = FALSE;
85 HTREEITEM hSelTreeItem;
86 BOOL bCanAddFav;
87
88 /* Find Favorites menu and clear it out */
90 if (!hMenu)
91 goto done;
92 if (s_nFavoriteMenuSubPos < 0)
93 {
94 s_nFavoriteMenuSubPos = GetMenuItemCount(hMenu);
95 }
96 else
97 {
98 while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION)) ;
99 }
100
102 bCanAddFav = TreeView_GetParent(g_pChildWnd->hTreeWnd, hSelTreeItem) != NULL;
104 MF_BYCOMMAND | (bCanAddFav ? MF_ENABLED : MF_GRAYED));
105
107 if (lResult != ERROR_SUCCESS)
108 goto done;
109
110 dwIndex = 0;
111 do
112 {
113 cbValueName = ARRAY_SIZE(szValueName);
114 cbValueData = sizeof(abValueData);
115 lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
116 if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
117 {
118 if (!bDisplayedAny)
119 {
120 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
121 bDisplayedAny = TRUE;
122 }
123 AppendMenu(hMenu, 0, ID_FAVORITES_MIN + GetMenuItemCount(hMenu), szValueName);
124 }
125 dwIndex++;
126 }
127 while(lResult == ERROR_SUCCESS);
128
129done:
130 if (hKey)
132}
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define AppendMenu
Definition: winuser.h:5740
#define MF_ENABLED
Definition: winuser.h:128
#define MF_SEPARATOR
Definition: winuser.h:137
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)

Referenced by FrameWndProc().

◆ OnMenuSelect()

static void OnMenuSelect ( HWND  hWnd,
UINT  nItemID,
UINT  nFlags,
HMENU  hSysMenu 
)
static

Definition at line 154 of file framewnd.c.

155{
156 WCHAR str[100];
157
158 str[0] = UNICODE_NULL;
159 if (nFlags & MF_POPUP)
160 {
161 if (hSysMenu != GetMenu(hWnd))
162 {
163 if (nItemID == 2) nItemID = 5;
164 }
165 }
166 if (LoadStringW(hInst, nItemID, str, 100))
167 {
168 /* load appropriate string*/
169 LPWSTR lpsz = str;
170 /* first newline terminates actual string*/
171 lpsz = wcschr(lpsz, L'\n');
172 if (lpsz != NULL)
173 *lpsz = L'\0';
174 }
176}
#define wcschr
Definition: compat.h:17
const WCHAR * str
#define MF_POPUP
Definition: winuser.h:136

Referenced by FrameWndProc().

◆ PrintRegistryHive()

BOOL PrintRegistryHive ( HWND  hWnd,
LPWSTR  path 
)

Definition at line 733 of file framewnd.c.

734{
735#if 1
736 PRINTDLG pd;
738
739 ZeroMemory(&pd, sizeof(PRINTDLG));
740 pd.lStructSize = sizeof(PRINTDLG);
741 pd.hwndOwner = hWnd;
742 pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
743 pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
745 pd.nCopies = 1;
746 pd.nFromPage = 0xFFFF;
747 pd.nToPage = 0xFFFF;
748 pd.nMinPage = 1;
749 pd.nMaxPage = 0xFFFF;
750 if (PrintDlg(&pd))
751 {
752 /* GDI calls to render output. */
753 DeleteDC(pd.hDC); /* Delete DC when done.*/
754 }
755#else
756 HRESULT hResult;
757 PRINTDLGEX pd;
758
759 hResult = PrintDlgEx(&pd);
760 if (hResult == S_OK)
761 {
762 switch (pd.dwResultAction)
763 {
764 case PD_RESULT_APPLY:
765 /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
766 break;
767 case PD_RESULT_CANCEL:
768 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
769 break;
770 case PD_RESULT_PRINT:
771 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
772 break;
773 default:
774 break;
775 }
776 }
777 else
778 {
779 switch (hResult)
780 {
781 case E_OUTOFMEMORY:
782 /*Insufficient memory. */
783 break;
784 case E_INVALIDARG:
785 /* One or more arguments are invalid. */
786 break;
787 case E_POINTER:
788 /*Invalid pointer. */
789 break;
790 case E_HANDLE:
791 /*Invalid handle. */
792 break;
793 case E_FAIL:
794 /*Unspecified error. */
795 break;
796 default:
797 break;
798 }
799 return FALSE;
800 }
801#endif
802 return TRUE;
803}
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define PD_RESULT_CANCEL
Definition: commdlg.h:201
#define PrintDlg
Definition: commdlg.h:668
#define PD_RETURNDC
Definition: commdlg.h:155
#define PD_RESULT_PRINT
Definition: commdlg.h:202
#define PD_RESULT_APPLY
Definition: commdlg.h:203
PRINTDLGA PRINTDLG
Definition: commdlg.h:660
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
WORD nMaxPage
Definition: commdlg.h:474
HDC hDC
Definition: commdlg.h:469
DWORD Flags
Definition: commdlg.h:470
WORD nCopies
Definition: commdlg.h:475
WORD nFromPage
Definition: commdlg.h:471
HGLOBAL hDevMode
Definition: commdlg.h:467
WORD nToPage
Definition: commdlg.h:472
WORD nMinPage
Definition: commdlg.h:473
HGLOBAL hDevNames
Definition: commdlg.h:468
HWND hwndOwner
Definition: commdlg.h:466
DWORD lStructSize
Definition: commdlg.h:465
#define ZeroMemory
Definition: winbase.h:1712
#define E_HANDLE
Definition: winerror.h:2850
#define E_POINTER
Definition: winerror.h:2365
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by _CmdWndProc().

◆ resize_frame_client()

static void resize_frame_client ( HWND  hWnd)
static

Definition at line 65 of file framewnd.c.

66{
67 RECT rect;
68
71}
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:52
& rect
Definition: startmenu.cpp:1413

Referenced by FrameWndProc(), and toggle_child().

◆ resize_frame_rect()

static void resize_frame_rect ( HWND  hWnd,
PRECT  prect 
)
static

Definition at line 52 of file framewnd.c.

53{
55 {
56 RECT rt;
57
60 prect->bottom -= rt.bottom - rt.top;
61 }
62 MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
63}
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by resize_frame_client().

◆ SetupStatusBar()

void SetupStatusBar ( HWND  hWnd,
BOOL  bResize 
)

Definition at line 178 of file framewnd.c.

179{
180 RECT rc;
181 int nParts;
182 GetClientRect(hWnd, &rc);
183 nParts = rc.right;
184 /* nParts = -1;*/
185 if (bResize)
188}

Referenced by InitInstance(), OnExitMenuLoop(), and resize_frame_rect().

◆ toggle_child()

static void toggle_child ( HWND  hWnd,
UINT  cmd,
HWND  hchild 
)
static

Definition at line 198 of file framewnd.c.

199{
200 BOOL vis = IsWindowVisible(hchild);
202
204 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
206}
HMENU hMenuFrame
Definition: main.c:37
#define ID_VIEW_MENU
Definition: resource.h:25
Definition: ftp_var.h:139
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define MF_CHECKED
Definition: winuser.h:132
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SW_SHOW
Definition: winuser.h:775

Referenced by _CmdWndProc().

◆ UnloadHive()

static BOOL UnloadHive ( HWND  hWnd)
static

Definition at line 432 of file framewnd.c.

433{
434 WCHAR Caption[128];
435 LPCWSTR pszKeyPath;
436 HKEY hRootKey;
437 LONG regUnloadResult;
438
439 /* get the item key to unload */
440 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
441 /* load and set the caption and flags for dialog */
442 LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, ARRAY_SIZE(Caption));
443
444 /* Enable the 'restore' privilege, unload the hive, disable the privilege */
446 regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
448
449 if(regUnloadResult == ERROR_SUCCESS)
450 {
451 /* refresh tree and list views */
453 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
454 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
455 }
456 else
457 {
458 ErrorMessageBox(hWnd, Caption, regUnloadResult);
459 return FALSE;
460 }
461 return TRUE;
462}
#define IDS_UNLOAD_HIVE
Definition: resource.h:144
LONG WINAPI RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
Definition: reg.c:5078

Referenced by _CmdWndProc().

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 190 of file framewnd.c.

191{
192 HKEY hKeyRoot;
193 LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
194
195 SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
196}

Referenced by OnExitMenuLoop().

Variable Documentation

◆ bInMenuLoop

BOOL bInMenuLoop = FALSE
static

Definition at line 35 of file framewnd.c.

Referenced by OnEnterMenuLoop(), and OnExitMenuLoop().

◆ FileNameBuffer

◆ s_szFavoritesRegKey

WCHAR s_szFavoritesRegKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"
static

Definition at line 33 of file framewnd.c.

Referenced by AddToFavoritesDlgProc(), ChooseFavorite(), and OnInitMenu().

◆ Suggestions

WCHAR Suggestions[256]
extern

Definition at line 30 of file childwnd.c.

Referenced by _CmdWndProc(), and ChildWndProc().