ReactOS 0.4.16-dev-188-g678aa63
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 14 of file framewnd.c.

◆ LOADHIVE_KEYNAMELENGTH

#define LOADHIVE_KEYNAMELENGTH   128

Definition at line 294 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 1127 of file framewnd.c.

1128{
1129 HKEY hKeyRoot = 0, hKey = 0;
1130 LPCWSTR keyPath;
1131 LPCWSTR valueName;
1132 BOOL result = TRUE;
1133 REGSAM regsam = KEY_READ;
1134 int item;
1135
1138
1139 switch (LOWORD(wParam))
1140 {
1142 LoadHive(hWnd);
1143 return TRUE;
1146 return TRUE;
1149 return TRUE;
1152 return TRUE;
1154 {
1155 IDsObjectPicker *ObjectPicker;
1156 WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1157 HRESULT hRet;
1158
1159 hRet = CoInitialize(NULL);
1160 if (SUCCEEDED(hRet))
1161 {
1162 hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
1163 if (SUCCEEDED(hRet))
1164 {
1165 hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
1166 hWnd,
1167 szComputerName,
1168 ARRAY_SIZE(szComputerName));
1169 if (hRet == S_OK)
1170 {
1171 // FIXME - connect to the registry
1172 }
1173
1174 FreeObjectPicker(ObjectPicker);
1175 }
1176
1178 }
1179
1180 return TRUE;
1181 }
1183 return TRUE;
1184 case ID_REGISTRY_PRINT:
1186 return TRUE;
1187 case ID_REGISTRY_EXIT:
1189 return TRUE;
1190 case ID_VIEW_STATUSBAR:
1192 return TRUE;
1195 return TRUE;
1196 case ID_HELP_HELPTOPICS:
1197 WinHelpW(hWnd, L"regedit", HELP_FINDER, 0);
1198 return TRUE;
1199 case ID_HELP_ABOUT:
1201 return TRUE;
1202 case ID_VIEW_SPLIT:
1203 {
1204 RECT rt;
1205 POINT pt, pts;
1207 pt.x = rt.left + g_pChildWnd->nSplitPos;
1208 pt.y = (rt.bottom / 2);
1209 pts = pt;
1210 if(ClientToScreen(g_pChildWnd->hWnd, &pts))
1211 {
1212 SetCursorPos(pts.x, pts.y);
1215 }
1216 return TRUE;
1217 }
1218 case ID_EDIT_RENAME:
1219 case ID_EDIT_MODIFY:
1220 case ID_EDIT_MODIFY_BIN:
1221 case ID_EDIT_DELETE:
1222 regsam |= KEY_WRITE;
1223 break;
1224 }
1225
1226 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1227 valueName = GetValueName(g_pChildWnd->hListWnd, -1);
1228 if (keyPath)
1229 {
1230 if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
1231 hKey = 0;
1232 }
1233
1234 switch (LOWORD(wParam))
1235 {
1236 case ID_EDIT_MODIFY:
1237 if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
1238 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1239 break;
1240 case ID_EDIT_MODIFY_BIN:
1241 if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
1242 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1243 break;
1244 case ID_EDIT_RENAME:
1245 if (GetFocus() == g_pChildWnd->hListWnd)
1246 {
1248 {
1250 if(item > -1)
1251 {
1253 }
1254 }
1255 }
1256 else if (GetFocus() == g_pChildWnd->hTreeWnd)
1257 {
1258 /* Get focused entry of treeview (if any) */
1260 if (hItem != NULL)
1262 }
1263 break;
1264 case ID_EDIT_DELETE:
1265 {
1266 if (GetFocus() == g_pChildWnd->hListWnd && hKey)
1267 {
1269 if(nSelected >= 1)
1270 {
1271 WCHAR msg[128], caption[128];
1275 {
1276 int ni, errs;
1277
1278 item = -1;
1279 errs = 0;
1281 {
1282 valueName = GetValueName(g_pChildWnd->hListWnd, item);
1283 if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
1284 {
1285 errs++;
1286 }
1287 item = ni;
1288 }
1289
1290 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, FALSE);
1291 if(errs > 0)
1292 {
1296 }
1297 }
1298 }
1299 }
1300 else if (GetFocus() == g_pChildWnd->hTreeWnd)
1301 {
1302 if (keyPath == NULL || *keyPath == UNICODE_NULL)
1303 {
1305 }
1306 else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1307 {
1310 }
1311 }
1312 break;
1313 }
1315 CreateNewValue(hKeyRoot, keyPath, REG_SZ);
1316 break;
1318 CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
1319 break;
1321 CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
1322 break;
1324 CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
1325 break;
1327 CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
1328 break;
1329 case ID_EDIT_FIND:
1331 break;
1332 case ID_EDIT_FINDNEXT:
1334 break;
1336 CopyKeyName(hWnd, hKeyRoot, keyPath);
1337 break;
1339 RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1340 break;
1341 case ID_VIEW_REFRESH:
1343 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1344 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, TRUE);
1345 break;
1346 //case ID_OPTIONS_TOOLBAR:
1347 // toggle_child(hWnd, LOWORD(wParam), hToolBar);
1348 // break;
1349 case ID_EDIT_NEW_KEY:
1351 break;
1354 break;
1357 break;
1358 case ID_TREE_RENAME:
1361 break;
1362 case ID_TREE_DELETE:
1364 if (keyPath == 0 || *keyPath == 0)
1366 else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1368 break;
1369 case ID_TREE_EXPORT:
1371 break;
1374 RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1375 break;
1376 case ID_SWITCH_PANELS:
1377 {
1378 BOOL bShiftDown = GetKeyState(VK_SHIFT) < 0;
1379 HWND hwndItem = GetNextDlgTabItem(g_pChildWnd->hWnd, GetFocus(), bShiftDown);
1380 if (hwndItem == g_pChildWnd->hAddressBarWnd)
1381 PostMessageW(hwndItem, EM_SETSEL, 0, -1);
1382 SetFocus(hwndItem);
1383 }
1384 break;
1385 case ID_ADDRESS_FOCUS:
1388 break;
1389 default:
1391 {
1392 HMENU hMenu;
1393 MENUITEMINFOW mii;
1394 WCHAR szFavorite[512];
1395
1397
1398 memset(&mii, 0, sizeof(mii));
1399 mii.cbSize = sizeof(mii);
1400 mii.fMask = MIIM_TYPE;
1401 mii.fType = MFT_STRING;
1402 mii.dwTypeData = szFavorite;
1403 mii.cch = ARRAY_SIZE(szFavorite);
1404
1405 if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
1406 {
1407 ChooseFavorite(szFavorite);
1408 }
1409 }
1411 {
1412 WORD wID = LOWORD(wParam);
1414 while(wID > ID_TREE_SUGGESTION_MIN)
1415 {
1416 if (*s)
1417 s += wcslen(s) + 1;
1418 wID--;
1419 }
1421 }
1422 else
1423 {
1424 result = FALSE;
1425 }
1426 break;
1427 }
1428
1429 if(hKey)
1431 return result;
1432}
#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:12
ChildWnd * g_pChildWnd
Definition: childwnd.c:13
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
Definition: edit.c:1522
BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
Definition: edit.c:1938
void FindNextMessageBox(HWND hWnd)
Definition: find.c:799
void FindDialog(HWND hWnd)
Definition: find.c:811
static HRESULT InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: framewnd.c:1061
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
Definition: framewnd.c:885
static BOOL UnloadHive(HWND hWnd)
Definition: framewnd.c:407
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
Definition: framewnd.c:708
static HRESULT InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
Definition: framewnd.c:1002
static INT_PTR CALLBACK AddToFavoritesDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:824
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:14
static void ChooseFavorite(LPCWSTR pszFavorite)
Definition: framewnd.c:780
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:173
BOOL ExportRegistryFile(HWND hWnd)
Definition: framewnd.c:585
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1119
WCHAR Suggestions[256]
Definition: childwnd.c:17
static BOOL LoadHive(HWND hWnd)
Definition: framewnd.c:350
static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
Definition: framewnd.c:922
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:439
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath, BOOL bSelectNone)
Definition: listview.c:657
WCHAR * GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:42
HWND hStatusBar
Definition: main.c:23
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:766
#define ARRAY_SIZE(A)
Definition: main.h:20
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:73
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:793
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:303
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:563
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:109
#define ID_REGISTRY_EXPORTREGISTRYFILE
Definition: resource.h:55
#define ID_EDIT_COPYKEYNAME
Definition: resource.h:45
#define IDS_ERR_DELETEVALUE
Definition: resource.h:90
#define ID_EDIT_MODIFY
Definition: resource.h:48
#define ID_VIEW_STATUSBAR
Definition: resource.h:40
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:65
#define ID_FAVOURITES_ADDTOFAVOURITES
Definition: resource.h:38
#define ID_REGISTRY_PRINT
Definition: resource.h:58
#define ID_TREE_PERMISSIONS
Definition: resource.h:112
#define ID_EDIT_DELETE
Definition: resource.h:43
#define IDS_QUERY_DELETE_CONFIRM
Definition: resource.h:88
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:62
#define ID_VIEW_REFRESH
Definition: resource.h:42
#define IDD_ADDFAVORITES
Definition: resource.h:33
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:63
#define ID_EDIT_NEW_MULTISTRINGVALUE
Definition: resource.h:99
#define ID_VIEW_SPLIT
Definition: resource.h:41
#define ID_REGISTRY_CONNECTNETWORKREGISTRY
Definition: resource.h:56
#define ID_EDIT_NEW_STRINGVALUE
Definition: resource.h:50
#define IDS_ERR_DELVAL_CAPTION
Definition: resource.h:89
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY
Definition: resource.h:57
#define ID_ADDRESS_FOCUS
Definition: resource.h:113
#define IDS_QUERY_DELETE_ONE
Definition: resource.h:86
#define ID_HELP_HELPTOPICS
Definition: resource.h:60
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:75
#define ID_EDIT_NEW_EXPANDABLESTRINGVALUE
Definition: resource.h:100
#define ID_SWITCH_PANELS
Definition: resource.h:102
#define ID_EDIT_NEW_KEY
Definition: resource.h:49
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:110
#define ID_EDIT_RENAME
Definition: resource.h:44
#define ID_TREE_EXPORT
Definition: resource.h:111
#define ID_FAVORITES_MAX
Definition: resource.h:317
#define ID_EDIT_FINDNEXT
Definition: resource.h:47
#define ID_EDIT_NEW_DWORDVALUE
Definition: resource.h:52
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:64
#define ID_FAVORITES_MIN
Definition: resource.h:316
#define ID_HELP_ABOUT
Definition: resource.h:61
#define ID_REGISTRY_EXIT
Definition: resource.h:37
#define ID_TREE_RENAME
Definition: resource.h:105
#define ID_TREE_DELETE
Definition: resource.h:104
#define ID_EDIT_PERMISSIONS
Definition: resource.h:103
#define IDS_QUERY_DELETE_MORE
Definition: resource.h:87
#define ID_EDIT_NEW_BINARYVALUE
Definition: resource.h:51
#define ID_EDIT_FIND
Definition: resource.h:46
#define ID_REGISTRY_IMPORTREGISTRYFILE
Definition: resource.h:54
#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:3425
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2545
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3478
#define TVE_EXPAND
Definition: commctrl.h:3428
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2714
#define TVE_COLLAPSE
Definition: commctrl.h:3427
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3509
#define REG_DWORD
Definition: sdbapi.c:596
#define memset(x, y, z)
Definition: compat.h:39
int nSplitPos
Definition: main.h:56
HWND hTreeWnd
Definition: main.h:50
HWND hListWnd
Definition: main.h:51
HWND hAddressBarWnd
Definition: main.h:52
HWND hWnd
Definition: main.h:49
Definition: tftpd.h:60
LPWSTR dwTypeData
Definition: winuser.h:3272
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:4011
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONHAND
Definition: winuser.h:791
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:4402
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:1779
#define MB_YESNO
Definition: winuser.h:820
BOOL WINAPI MessageBeep(_In_ UINT uType)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2714
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2157
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:2422
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:2021
#define MB_ICONQUESTION
Definition: winuser.h:792
#define MB_ICONSTOP
Definition: winuser.h:806
#define VK_SHIFT
Definition: winuser.h:2205
#define MFT_STRING
Definition: winuser.h:749
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:838
#define IDC_SIZEWE
Definition: winuser.h:694
#define GetMenuItemInfo
Definition: winuser.h:5800
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MIIM_TYPE
Definition: winuser.h:728
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 824 of file framewnd.c.

825{
828 switch (uMsg)
829 {
830 case WM_INITDIALOG:
831 {
832 TVITEM tvi;
833 tvi.mask = TVIF_HANDLE | TVIF_TEXT;
835 tvi.pszText = name;
836 tvi.cchTextMax = _countof(name);
838 tvi.pszText[0] = UNICODE_NULL;
839 SetWindowTextW(hName, tvi.pszText);
840 SendMessageW(hName, EM_LIMITTEXT, _countof(name) - 1, 0);
841 return TRUE;
842 }
843 case WM_COMMAND:
844 switch (LOWORD(wParam))
845 {
846 case IDOK:
847 {
848 LPWSTR path;
849 HKEY hKey;
850 DWORD err;
851 if (!GetWindowTextW(hName, name, _countof(name)))
852 {
853 err = GetLastError();
854 goto failed;
855 }
857 if (!path)
858 {
860 goto failed;
861 }
864 if (err)
865 goto failed;
866 err = RegSetValueExW(hKey, name, 0, REG_SZ, (BYTE*)path, (lstrlenW(path) + 1) * sizeof(WCHAR));
868 if (err) failed:
869 ErrorBox(hWnd, err);
870 free(path);
871 return EndDialog(hWnd, err);
872 }
873 case IDCANCEL:
875 case IDC_FAVORITENAME:
876 if (HIWORD(wParam) == EN_UPDATE)
878 break;
879 }
880 break;
881 }
882 return FALSE;
883}
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:15
static UINT ErrorBox(HWND hWnd, UINT Error)
Definition: framewnd.c:19
static LPWSTR GetItemFullPath(HTREEITEM hTI)
Definition: framewnd.c:802
#define IDC_FAVORITENAME
Definition: resource.h:245
#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:3370
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TVIF_HANDLE
Definition: commctrl.h:3275
#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:2003
#define IDCANCEL
Definition: winuser.h:834
#define EN_UPDATE
Definition: winuser.h:2031
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
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 234 of file framewnd.c.

235{
236 int i, c;
237
238 c = 0;
239 for(i = 0; i < PairCount; i++)
240 {
241 c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
242 Filter[++c] = L'\0';
243 c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
244 Filter[++c] = L'\0';
245 }
246 Filter[++c] = L'\0';
247}
_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 183 of file framewnd.c.

184{
185 DWORD dwErrorCode = CommDlgExtendedError();
187 switch (dwErrorCode)
188 {
190 break;
192 break;
194 break;
196 break;
197 case CDERR_NOHOOK:
198 break;
200 break;
201 case CDERR_NOTEMPLATE:
202 break;
204 break;
205 case CDERR_STRUCTSIZE:
206 break;
208 break;
210 break;
212 break;
214 break;
216 break;
218 break;
219 default:
220 break;
221 }
222 return TRUE;
223}
#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 780 of file framewnd.c.

781{
782 HKEY hKey = NULL;
783 WCHAR szFavoritePath[512];
784 DWORD cbData, dwType;
785
787 goto done;
788
789 cbData = sizeof(szFavoritePath);
790 memset(szFavoritePath, 0, sizeof(szFavoritePath));
791 if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
792 goto done;
793
794 if (dwType == REG_SZ)
795 SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
796
797done:
798 if (hKey)
800}
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 885 of file framewnd.c.

886{
887 BOOL bClipboardOpened = FALSE;
889 WCHAR szBuffer[512];
890 HGLOBAL hGlobal;
891 LPWSTR s;
892 SIZE_T cbGlobal;
893
894 if (!OpenClipboard(hWnd))
895 goto done;
896 bClipboardOpened = TRUE;
897
898 if (!EmptyClipboard())
899 goto done;
900
901 if (!GetKeyName(szBuffer, ARRAY_SIZE(szBuffer), hRootKey, keyName))
902 goto done;
903
904 cbGlobal = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
905 hGlobal = GlobalAlloc(GMEM_MOVEABLE, cbGlobal);
906 if (!hGlobal)
907 goto done;
908
909 s = GlobalLock(hGlobal);
910 StringCbCopyW(s, cbGlobal, szBuffer);
911 GlobalUnlock(hGlobal);
912
914 bSuccess = TRUE;
915
916done:
917 if (bClipboardOpened)
919 return bSuccess;
920}
#define CF_UNICODETEXT
Definition: constants.h:408
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:2072
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 922 of file framewnd.c.

923{
924 WCHAR szNewValueFormat[128];
925 WCHAR szNewValue[128];
926 int iIndex = 1;
927 BYTE data[128];
928 DWORD dwExistingType, cbData;
929 LONG lResult;
930 HKEY hKey;
931 LVFINDINFO lvfi;
932
933 if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
934 &hKey) != ERROR_SUCCESS)
935 return FALSE;
936
937 LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, ARRAY_SIZE(szNewValueFormat));
938
939 do
940 {
941 wsprintf(szNewValue, szNewValueFormat, iIndex++);
942 cbData = sizeof(data);
943 lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
944 }
945 while(lResult == ERROR_SUCCESS);
946
947 switch(dwType)
948 {
949 case REG_DWORD:
950 cbData = sizeof(DWORD);
951 break;
952 case REG_SZ:
953 case REG_EXPAND_SZ:
954 cbData = sizeof(WCHAR);
955 break;
956 case REG_MULTI_SZ:
957 /*
958 * WARNING: An empty multi-string has only one null char.
959 * Indeed, multi-strings are built in the following form:
960 * str1\0str2\0...strN\0\0
961 * where each strI\0 is a null-terminated string, and it
962 * ends with a terminating empty string.
963 * Therefore an empty multi-string contains only the terminating
964 * empty string, that is, one null char.
965 */
966 cbData = sizeof(WCHAR);
967 break;
968 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
969 cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
970 break;
971 default:
972 cbData = 0;
973 break;
974 }
975 memset(data, 0, cbData);
976 lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
978 if (lResult != ERROR_SUCCESS)
979 {
980 return FALSE;
981 }
982
983 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
984
985 /* locate the newly added value, and get ready to rename it */
986 memset(&lvfi, 0, sizeof(lvfi));
987 lvfi.flags = LVFI_STRING;
988 lvfi.psz = szNewValue;
989 iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
990 if (iIndex >= 0)
991 {
996 }
997
998 return TRUE;
999}
#define IDS_NEW_VALUE
Definition: resource.h:146
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:2678
#define LVFINDINFO
Definition: commctrl.h:2468
#define LVFI_STRING
Definition: commctrl.h:2442
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVIS_FOCUSED
Definition: commctrl.h:2323
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2475
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2524
#define REG_QWORD
Definition: sdbapi.c:597
#define wsprintf
Definition: winuser.h:5877

Referenced by _CmdWndProc().

◆ EnablePrivilege()

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

Definition at line 320 of file framewnd.c.

321{
322 BOOL bRet = FALSE;
323 HANDLE hToken = NULL;
324
327 &hToken))
328 {
330
331 tp.PrivilegeCount = 1;
332 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
333
334 if (LookupPrivilegeValueW(lpszSystemName,
335 lpszPrivilegeName,
336 &tp.Privileges[0].Luid))
337 {
338 bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
339
341 bRet = FALSE;
342 }
343
344 CloseHandle(hToken);
345 }
346
347 return bRet;
348}
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 19 of file framewnd.c.

20{
21 WCHAR buf[400];
23 NULL, Error, 0, buf, _countof(buf), NULL))
24 *(UINT*)buf = L'?';
26 return Error;
27}
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 585 of file framewnd.c.

586{
587 BOOL bRet = FALSE;
589 WCHAR ExportKeyPath[_MAX_PATH] = {0};
590 WCHAR Caption[128], szTitle[512], szText[512];
591 HKEY hKeyRoot;
592 LPCWSTR pszKeyPath;
593
594 /* Figure out which key path we are exporting */
595 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
596 GetKeyName(ExportKeyPath, ARRAY_SIZE(ExportKeyPath), hKeyRoot, pszKeyPath);
597
599 LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
600 ofn.lpstrTitle = Caption;
601
602 /* Only set the path if a key (not the root node) is selected */
603 if (hKeyRoot != 0)
604 {
605 ofn.lCustData = (LPARAM) ExportKeyPath;
606 }
610 if (GetSaveFileName(&ofn))
611 {
612 switch (ofn.nFilterIndex)
613 {
614 case 2: /* Registry Hive Files */
615 {
616 LONG lResult;
617 HKEY hSubKey;
618
619 /* Open the subkey */
620 lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
621 if (lResult == ERROR_SUCCESS)
622 {
623 /* Enable the 'backup' privilege, save the hive then disable the privilege */
625 lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
626 if (lResult == ERROR_ALREADY_EXISTS)
627 {
628 /*
629 * We are here, that means that we already said "yes" to the confirmation dialog.
630 * So we absolutely want to replace the hive file.
631 */
633 {
634 /* Try again */
635 lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
636 }
637 }
639
640 if (lResult != ERROR_SUCCESS)
641 {
642 /*
643 * If we are here, it's because RegSaveKeyW has failed for any reason.
644 * The problem is that even if it has failed, it has created or
645 * replaced the exported hive file with a new empty file. We don't
646 * want to keep this file, so we delete it.
647 */
649 }
650
651 /* Close the subkey */
652 RegCloseKey(hSubKey);
653 }
654
655 /* Set the return value */
656 bRet = (lResult == ERROR_SUCCESS);
657
658 /* Display error, if any */
659 if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
660
661 break;
662 }
663
664 case 1: /* Windows Registry Editor Version 5.00 */
665 case 3: /* REGEDIT4 */
666 default: /* All files ==> use Windows Registry Editor Version 5.00 */
667 {
668 if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
670 : REG_FORMAT_5)))
671 {
672 /* Error creating the file */
674 LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
676 bRet = FALSE;
677 }
678 else
679 {
680 bRet = TRUE;
681 }
682
683 break;
684 }
685
686 case 4: /* Text File */
687 {
688 bRet = txt_export_registry_key(ofn.lpstrFile, ExportKeyPath);
689 if (!bRet)
690 {
691 /* Error creating the file */
693 LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
695 }
696 break;
697 }
698 }
699 }
700 else
701 {
703 }
704
705 return bRet;
706}
#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:38
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:11
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:183
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn, BOOL bSave)
Definition: framewnd.c:249
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:320
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:531
#define REG_FORMAT_5
Definition: main.h:31
#define REG_FORMAT_4
Definition: main.h:32
BOOL export_registry_key(WCHAR *file_name, WCHAR *path, DWORD format)
Definition: regproc.c:1566
BOOL txt_export_registry_key(LPCWSTR file_name, LPCWSTR path)
Definition: txtproc.c:401
#define IDS_EXPORT_REG_FILE
Definition: resource.h:84
#define IDS_EXPORT_ERROR
Definition: resource.h:152
#define IDD_EXPORTRANGE
Definition: resource.h:29
#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:790
#define MB_OK
Definition: winuser.h:793

Referenced by _CmdWndProc().

◆ ExportRegistryFile_OFNHookProc()

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

Definition at line 531 of file framewnd.c.

532{
533 HWND hwndExportAll;
534 HWND hwndExportBranch;
535 HWND hwndExportBranchText;
536 UINT_PTR iResult = 0;
537 OPENFILENAME *pOfn;
538 LPWSTR pszSelectedKey;
539 OFNOTIFY *pOfnNotify;
540
542
543 switch(uiMsg)
544 {
545 case WM_INITDIALOG:
546 pOfn = (OPENFILENAME *) lParam;
547 pszSelectedKey = (LPWSTR) pOfn->lCustData;
548
549 hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
550 if (hwndExportAll)
551 SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
552
553 hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
554 if (hwndExportBranch)
555 SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
556
557 hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
558 if (hwndExportBranchText)
559 SetWindowTextW(hwndExportBranchText, pszSelectedKey);
560 break;
561
562 case WM_NOTIFY:
563 if (((NMHDR *) lParam)->code == CDN_FILEOK)
564 {
565 pOfnNotify = (OFNOTIFY *) lParam;
566 pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
567
568 hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
569 hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
570 if (hwndExportBranch && hwndExportBranchText
571 && (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
572 {
573 GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
574 }
575 else if (pszSelectedKey)
576 {
577 pszSelectedKey[0] = L'\0';
578 }
579 }
580 break;
581 }
582 return iResult;
583}
#define IDC_EXPORT_ALL
Definition: resource.h:238
#define IDC_EXPORT_BRANCH
Definition: resource.h:239
#define IDC_EXPORT_BRANCH_TEXT
Definition: resource.h:240
#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:1924
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1921

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 1440 of file framewnd.c.

1441{
1442 RECT rc;
1443 switch (message)
1444 {
1445 case WM_CREATE:
1446 // For now, the Help dialog item is disabled because of lacking of HTML Help support
1448 GetClientRect(hWnd, &rc);
1450 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
1451 hWnd, (HMENU)0, hInst, 0);
1452 break;
1453 case WM_COMMAND:
1456 break;
1457 case WM_ACTIVATE:
1460 break;
1461 case WM_SIZE:
1463 break;
1464 case WM_INITMENU:
1466 break;
1467 case WM_ENTERMENULOOP:
1469 break;
1470 case WM_EXITMENULOOP:
1472 break;
1473 case WM_MENUSELECT:
1475 break;
1476 case WM_SYSCOLORCHANGE:
1477 /* Forward WM_SYSCOLORCHANGE to common controls */
1480 break;
1481 case WM_DESTROY:
1482 WinHelpW(hWnd, L"regedit", HELP_QUIT, 0);
1483 SaveSettings();
1484 PostQuitMessage(0);
1485 default:
1487 }
1488 return 0;
1489}
void SaveSettings(void)
Definition: settings.c:115
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:42
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:109
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:129
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1127
static void OnExitMenuLoop(HWND hWnd)
Definition: framewnd.c:121
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:50
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:32
#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:2417
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1614
#define WM_INITMENU
Definition: winuser.h:1748
#define WA_INACTIVE
Definition: winuser.h:2625
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1629
#define WM_ACTIVATE
Definition: winuser.h:1615
#define WM_ENTERMENULOOP
Definition: winuser.h:1807
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:1808
#define WM_DESTROY
Definition: winuser.h:1612
#define WM_MENUSELECT
Definition: winuser.h:1750
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 1119 of file framewnd.c.

1120{
1121 pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
1122}

Referenced by _CmdWndProc(), and SecurityPageProc().

◆ GetItemFullPath()

static LPWSTR GetItemFullPath ( HTREEITEM  hTI)
static

Definition at line 802 of file framewnd.c.

803{
804 HKEY hRoot;
805 WCHAR rootname[MAX_PATH], *buffer;
806 SIZE_T rootlen, subkeylen;
807 LPCWSTR subkey = GetItemPath(g_pChildWnd->hTreeWnd, hTI, &hRoot);
808 if (!subkey || !hRoot)
809 return NULL;
810 if (!GetKeyName(rootname, ARRAY_SIZE(rootname), hRoot, L""))
811 return NULL;
812 rootlen = lstrlenW(rootname) + 1; // + 1 for '\\'
813 subkeylen = lstrlenW(subkey);
814 buffer = (WCHAR*)malloc((rootlen + subkeylen + 1) * sizeof(WCHAR));
815 if (buffer)
816 {
817 lstrcpyW(buffer, rootname);
818 buffer[rootlen - 1] = '\\';
819 lstrcpyW(buffer + rootlen, subkey);
820 }
821 return buffer;
822}
#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:383

Referenced by AddToFavoritesDlgProc().

◆ ImportRegistryFile()

static BOOL ImportRegistryFile ( HWND  hWnd)
static

Definition at line 439 of file framewnd.c.

440{
441 BOOL bRet = FALSE;
443 WCHAR Caption[128], szTitle[512], szText[512];
444 HKEY hKeyRoot;
445 LPCWSTR pszKeyPath;
446
447 /* Figure out in which key path we are importing */
448 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
449
451 LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
452 ofn.lpstrTitle = Caption;
454
455 if (GetOpenFileName(&ofn))
456 {
457 /* Look at the extension of the file to determine its type */
458 if (ofn.nFileExtension >= 1 &&
459 _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
460 {
461 /* Open the file */
462 FILE* fp = _wfopen(ofn.lpstrFile, L"rb");
463
464 /* Import it */
465 if (fp == NULL || !import_registry_file(fp))
466 {
467 /* Error opening the file */
469 LoadStringW(hInst, IDS_IMPORT_ERROR, szText, ARRAY_SIZE(szText));
471 bRet = FALSE;
472 }
473 else
474 {
475 /* Show successful import */
477 LoadStringW(hInst, IDS_IMPORT_OK, szText, ARRAY_SIZE(szText));
479 bRet = TRUE;
480 }
481
482 /* Close the file */
483 if (fp) fclose(fp);
484 }
485 else /* Registry Hive Files */
486 {
489
490 /* Display a confirmation message */
492 {
493 LONG lResult;
494 HKEY hSubKey;
495
496 /* Open the subkey */
497 lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
498 if (lResult == ERROR_SUCCESS)
499 {
500 /* Enable the 'restore' privilege, restore the hive then disable the privilege */
502 lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
504
505 /* Flush the subkey and close it */
506 RegFlushKey(hSubKey);
507 RegCloseKey(hSubKey);
508 }
509
510 /* Set the return value */
511 bRet = (lResult == ERROR_SUCCESS);
512
513 /* Display error, if any */
514 if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
515 }
516 }
517 }
518 else
519 {
521 }
522
523 /* refresh tree and list views */
525 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
526 RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath, TRUE);
527
528 return bRet;
529}
#define SE_RESTORE_NAME
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1041
#define IDS_QUERY_IMPORT_HIVE_MSG
Definition: resource.h:94
#define IDS_IMPORT_OK
Definition: resource.h:150
#define IDS_IMPORT_REG_FILE
Definition: resource.h:83
#define IDS_QUERY_IMPORT_HIVE_CAPTION
Definition: resource.h:93
#define IDS_IMPORT_ERROR
Definition: resource.h:151
#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:789
#define MB_ICONINFORMATION
Definition: winuser.h:805
#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 1002 of file framewnd.c.

1003{
1004 HRESULT hRet;
1005
1006 *pDsObjectPicker = NULL;
1007
1008 hRet = CoCreateInstance(&CLSID_DsObjectPicker,
1009 NULL,
1010 CLSCTX_INPROC_SERVER,
1011 &IID_IDsObjectPicker,
1012 (LPVOID*)pDsObjectPicker);
1013 if (SUCCEEDED(hRet))
1014 {
1015 DSOP_INIT_INFO InitInfo;
1016 static DSOP_SCOPE_INIT_INFO Scopes[] =
1017 {
1018 {
1019 sizeof(DSOP_SCOPE_INIT_INFO),
1024 0,
1025 {
1026 {
1028 0,
1029 0
1030 },
1032 },
1033 NULL,
1034 NULL,
1035 S_OK
1036 },
1037 };
1038
1039 InitInfo.cbSize = sizeof(InitInfo);
1040 InitInfo.pwzTargetComputer = NULL;
1041 InitInfo.cDsScopeInfos = ARRAY_SIZE(Scopes);
1042 InitInfo.aDsScopeInfos = Scopes;
1043 InitInfo.flOptions = 0;
1044 InitInfo.cAttributesToFetch = 0;
1045 InitInfo.apwzAttributeNames = NULL;
1046
1047 hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
1048 &InitInfo);
1049
1050 if (FAILED(hRet))
1051 {
1052 /* delete the object picker in case initialization failed! */
1053 (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
1054 }
1055 }
1056
1057 return hRet;
1058}
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 249 of file framewnd.c.

250{
251 FILTERPAIR FilterPairs[5];
252 static WCHAR Filter[1024];
253
254 memset(pofn, 0, sizeof(OPENFILENAME));
255 pofn->lStructSize = sizeof(OPENFILENAME);
256 pofn->hwndOwner = hWnd;
257 pofn->hInstance = hInst;
258
259 /* create filter string */
260 FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
261 FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
262 FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
263 FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
264 FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
265 FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
266 if (bSave)
267 {
268 FilterPairs[3].DisplayID = IDS_FLT_TXTFILES;
269 FilterPairs[3].FilterID = IDS_FLT_TXTFILES_FLT;
270 FilterPairs[4].DisplayID = IDS_FLT_ALLFILES;
271 FilterPairs[4].FilterID = IDS_FLT_ALLFILES_FLT;
272 }
273 else
274 {
275 FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
276 FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
277 }
278
279 BuildFilterStrings(Filter, FilterPairs, ARRAY_SIZE(FilterPairs) - !bSave);
280
281 pofn->lpstrFilter = Filter;
285 pofn->lpstrDefExt = L"reg";
286 if (bSave)
288 else
289 pofn->Flags |= OFN_FILEMUSTEXIST;
290
291 return TRUE;
292}
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:234
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:225
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:123
#define IDS_FLT_REGEDIT4
Definition: resource.h:120
#define IDS_FLT_REGEDIT4_FLT
Definition: resource.h:121
#define IDS_FLT_HIVFILES_FLT
Definition: resource.h:119
#define IDS_FLT_ALLFILES
Definition: resource.h:122
#define IDS_FLT_REGFILES
Definition: resource.h:116
#define IDS_FLT_REGFILES_FLT
Definition: resource.h:117
#define IDS_FLT_TXTFILES
Definition: resource.h:124
#define IDS_FLT_HIVFILES
Definition: resource.h:118
#define IDS_FLT_TXTFILES_FLT
Definition: resource.h:125
#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:230
UINT DisplayID
Definition: framewnd.c:229
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 1061 of file framewnd.c.

1065{
1066 IDataObject *pdo = NULL;
1067 HRESULT hRet;
1068
1069 hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
1070 hwndParent,
1071 &pdo);
1072 if (hRet == S_OK)
1073 {
1074 STGMEDIUM stm;
1075 FORMATETC fe;
1076
1077 fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
1078 fe.ptd = NULL;
1079 fe.dwAspect = DVASPECT_CONTENT;
1080 fe.lindex = -1;
1081 fe.tymed = TYMED_HGLOBAL;
1082
1083 hRet = pdo->lpVtbl->GetData(pdo,
1084 &fe,
1085 &stm);
1086 if (SUCCEEDED(hRet))
1087 {
1088 PDS_SELECTION_LIST SelectionList = (PDS_SELECTION_LIST)GlobalLock(stm.hGlobal);
1089 if (SelectionList != NULL)
1090 {
1091 if (SelectionList->cItems == 1)
1092 {
1093 size_t nlen = wcslen(SelectionList->aDsSelection[0].pwzName);
1094 if (nlen >= uSize)
1095 {
1096 nlen = uSize - 1;
1097 }
1098
1100 SelectionList->aDsSelection[0].pwzName,
1101 nlen * sizeof(WCHAR));
1102
1103 lpBuffer[nlen] = L'\0';
1104 }
1105
1106 GlobalUnlock(stm.hGlobal);
1107 }
1108
1109 ReleaseStgMedium(&stm);
1110 }
1111
1112 pdo->lpVtbl->Release(pdo);
1113 }
1114
1115 return hRet;
1116}
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 350 of file framewnd.c.

351{
353 WCHAR Caption[128];
354 LPCWSTR pszKeyPath;
356 HKEY hRootKey;
357 WCHAR Filter[1024];
359 /* get the item key to load the hive in */
360 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
361 /* initialize the "open file" dialog */
363 /* build the "All Files" filter up */
364 filter.DisplayID = IDS_FLT_ALLFILES;
365 filter.FilterID = IDS_FLT_ALLFILES_FLT;
368 /* load and set the caption and flags for dialog */
369 LoadStringW(hInst, IDS_LOAD_HIVE, Caption, ARRAY_SIZE(Caption));
370 ofn.lpstrTitle = Caption;
372
373 /* now load the hive */
374 if (GetOpenFileName(&ofn))
375 {
378 {
379 LONG regLoadResult;
380
381 /* Enable the 'restore' privilege, load the hive, disable the privilege */
383 regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
385
386 if(regLoadResult == ERROR_SUCCESS)
387 {
388 /* refresh tree and list views */
390 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
391 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
392 }
393 else
394 {
395 ErrorMessageBox(hWnd, Caption, regLoadResult);
396 return FALSE;
397 }
398 }
399 }
400 else
401 {
403 }
404 return TRUE;
405}
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:296
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:294
#define IDD_LOADHIVE
Definition: resource.h:242
#define IDS_LOAD_HIVE
Definition: resource.h:96
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 296 of file framewnd.c.

297{
298 static LPWSTR sKey = NULL;
299 switch(uMsg)
300 {
301 case WM_INITDIALOG:
302 sKey = (LPWSTR)lParam;
303 break;
304 case WM_COMMAND:
305 switch(LOWORD(wParam))
306 {
307 case IDOK:
309 return EndDialog(hWndDlg, -1);
310 else
311 return EndDialog(hWndDlg, 0);
312 case IDCANCEL:
313 return EndDialog(hWndDlg, 0);
314 }
315 break;
316 }
317 return FALSE;
318}
#define IDC_EDIT_KEY
Definition: resource.h:243
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 109 of file framewnd.c.

110{
111 int nParts;
113
114 /* Update the status bar pane sizes */
115 nParts = -1;
119}
static BOOL bInMenuLoop
Definition: framewnd.c:16
#define SB_SETPARTS
Definition: commctrl.h:1959
#define SB_SETTEXTW
Definition: commctrl.h:1947
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by FrameWndProc().

◆ OnExitMenuLoop()

static void OnExitMenuLoop ( HWND  hWnd)
static

Definition at line 121 of file framewnd.c.

122{
124 /* Update the status bar pane sizes*/
127}
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:153
void UpdateStatusBar(void)
Definition: framewnd.c:165

Referenced by FrameWndProc().

◆ OnInitMenu()

static void OnInitMenu ( HWND  hWnd)
static

Definition at line 50 of file framewnd.c.

51{
52 LONG lResult;
53 HKEY hKey = NULL;
54 DWORD dwIndex, cbValueName, cbValueData, dwType;
55 WCHAR szValueName[256];
56 BYTE abValueData[256];
57 static int s_nFavoriteMenuSubPos = -1;
58 HMENU hMenu;
59 BOOL bDisplayedAny = FALSE;
60 HTREEITEM hSelTreeItem;
61 BOOL bCanAddFav;
62
63 /* Find Favorites menu and clear it out */
65 if (!hMenu)
66 goto done;
67 if (s_nFavoriteMenuSubPos < 0)
68 {
69 s_nFavoriteMenuSubPos = GetMenuItemCount(hMenu);
70 }
71 else
72 {
73 while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION)) ;
74 }
75
77 bCanAddFav = TreeView_GetParent(g_pChildWnd->hTreeWnd, hSelTreeItem) != NULL;
79 MF_BYCOMMAND | (bCanAddFav ? MF_ENABLED : MF_GRAYED));
80
82 if (lResult != ERROR_SUCCESS)
83 goto done;
84
85 dwIndex = 0;
86 do
87 {
88 cbValueName = ARRAY_SIZE(szValueName);
89 cbValueData = sizeof(abValueData);
90 lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
91 if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
92 {
93 if (!bDisplayedAny)
94 {
95 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
96 bDisplayedAny = TRUE;
97 }
98 AppendMenu(hMenu, 0, ID_FAVORITES_MIN + GetMenuItemCount(hMenu), szValueName);
99 }
100 dwIndex++;
101 }
102 while(lResult == ERROR_SUCCESS);
103
104done:
105 if (hKey)
107}
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:3474
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define AppendMenu
Definition: winuser.h:5743
#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 129 of file framewnd.c.

130{
131 WCHAR str[100];
132
133 str[0] = UNICODE_NULL;
134 if (nFlags & MF_POPUP)
135 {
136 if (hSysMenu != GetMenu(hWnd))
137 {
138 if (nItemID == 2) nItemID = 5;
139 }
140 }
141 if (LoadStringW(hInst, nItemID, str, 100))
142 {
143 /* load appropriate string*/
144 LPWSTR lpsz = str;
145 /* first newline terminates actual string*/
146 lpsz = wcschr(lpsz, L'\n');
147 if (lpsz != NULL)
148 *lpsz = L'\0';
149 }
151}
#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 708 of file framewnd.c.

709{
710#if 1
711 PRINTDLG pd;
713
714 ZeroMemory(&pd, sizeof(PRINTDLG));
715 pd.lStructSize = sizeof(PRINTDLG);
716 pd.hwndOwner = hWnd;
717 pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
718 pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
720 pd.nCopies = 1;
721 pd.nFromPage = 0xFFFF;
722 pd.nToPage = 0xFFFF;
723 pd.nMinPage = 1;
724 pd.nMaxPage = 0xFFFF;
725 if (PrintDlg(&pd))
726 {
727 /* GDI calls to render output. */
728 DeleteDC(pd.hDC); /* Delete DC when done.*/
729 }
730#else
731 HRESULT hResult;
732 PRINTDLGEX pd;
733
734 hResult = PrintDlgEx(&pd);
735 if (hResult == S_OK)
736 {
737 switch (pd.dwResultAction)
738 {
739 case PD_RESULT_APPLY:
740 /*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. */
741 break;
742 case PD_RESULT_CANCEL:
743 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
744 break;
745 case PD_RESULT_PRINT:
746 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
747 break;
748 default:
749 break;
750 }
751 }
752 else
753 {
754 switch (hResult)
755 {
756 case E_OUTOFMEMORY:
757 /*Insufficient memory. */
758 break;
759 case E_INVALIDARG:
760 /* One or more arguments are invalid. */
761 break;
762 case E_POINTER:
763 /*Invalid pointer. */
764 break;
765 case E_HANDLE:
766 /*Invalid handle. */
767 break;
768 case E_FAIL:
769 /*Unspecified error. */
770 break;
771 default:
772 break;
773 }
774 return FALSE;
775 }
776#endif
777 return TRUE;
778}
#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 42 of file framewnd.c.

43{
44 RECT rect;
45
48}
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:29
& 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 29 of file framewnd.c.

30{
32 {
33 RECT rt;
34
37 prect->bottom -= rt.bottom - rt.top;
38 }
39 MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
40}
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 153 of file framewnd.c.

154{
155 RECT rc;
156 int nParts;
157 GetClientRect(hWnd, &rc);
158 nParts = rc.right;
159 /* nParts = -1;*/
160 if (bResize)
163}

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

◆ toggle_child()

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

Definition at line 173 of file framewnd.c.

174{
175 BOOL vis = IsWindowVisible(hchild);
177
179 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
181}
HMENU hMenuFrame
Definition: main.c:24
#define ID_VIEW_MENU
Definition: resource.h:12
Definition: ftp_var.h:139
#define SW_HIDE
Definition: winuser.h:771
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:778

Referenced by _CmdWndProc().

◆ UnloadHive()

static BOOL UnloadHive ( HWND  hWnd)
static

Definition at line 407 of file framewnd.c.

408{
409 WCHAR Caption[128];
410 LPCWSTR pszKeyPath;
411 HKEY hRootKey;
412 LONG regUnloadResult;
413
414 /* get the item key to unload */
415 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
416 /* load and set the caption and flags for dialog */
417 LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, ARRAY_SIZE(Caption));
418
419 /* Enable the 'restore' privilege, unload the hive, disable the privilege */
421 regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
423
424 if(regUnloadResult == ERROR_SUCCESS)
425 {
426 /* refresh tree and list views */
428 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
429 RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath, TRUE);
430 }
431 else
432 {
433 ErrorMessageBox(hWnd, Caption, regUnloadResult);
434 return FALSE;
435 }
436 return TRUE;
437}
#define IDS_UNLOAD_HIVE
Definition: resource.h:97
LONG WINAPI RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
Definition: reg.c:5078

Referenced by _CmdWndProc().

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 165 of file framewnd.c.

166{
167 HKEY hKeyRoot;
168 LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
169
170 SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
171}

Referenced by OnExitMenuLoop().

Variable Documentation

◆ bInMenuLoop

BOOL bInMenuLoop = FALSE
static

Definition at line 16 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 15 of file framewnd.c.

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

◆ Suggestions

WCHAR Suggestions[256]
extern

Definition at line 17 of file childwnd.c.

Referenced by _CmdWndProc(), and ChildWndProc().