ReactOS  0.4.15-dev-5606-gf34e425
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 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)
 
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)
 
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]
 
WCHAR FileTitleBuffer [_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 289 of file framewnd.c.

Typedef Documentation

◆ PFILTERPAIR

Function Documentation

◆ _CmdWndProc()

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

Definition at line 1023 of file framewnd.c.

1024 {
1025  HKEY hKeyRoot = 0, hKey = 0;
1026  LPCWSTR keyPath;
1027  LPCWSTR valueName;
1028  BOOL result = TRUE;
1029  REGSAM regsam = KEY_READ;
1030  int item;
1031 
1034 
1035  switch (LOWORD(wParam))
1036  {
1037  case ID_REGISTRY_LOADHIVE:
1038  LoadHive(hWnd);
1039  return TRUE;
1041  UnloadHive(hWnd);
1042  return TRUE;
1045  return TRUE;
1048  return TRUE;
1050  {
1051  IDsObjectPicker *ObjectPicker;
1052  WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1053  HRESULT hRet;
1054 
1055  hRet = CoInitialize(NULL);
1056  if (SUCCEEDED(hRet))
1057  {
1058  hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
1059  if (SUCCEEDED(hRet))
1060  {
1061  hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
1062  hWnd,
1063  szComputerName,
1064  ARRAY_SIZE(szComputerName));
1065  if (hRet == S_OK)
1066  {
1067  /* FIXME - connect to the registry */
1068  }
1069 
1070  FreeObjectPicker(ObjectPicker);
1071  }
1072 
1073  CoUninitialize();
1074  }
1075 
1076  return TRUE;
1077  }
1079  return TRUE;
1080  case ID_REGISTRY_PRINT:
1081  PrintRegistryHive(hWnd, L"");
1082  return TRUE;
1083  case ID_REGISTRY_EXIT:
1085  return TRUE;
1086  case ID_VIEW_STATUSBAR:
1088  return TRUE;
1089  case ID_HELP_HELPTOPICS:
1090  WinHelpW(hWnd, L"regedit", HELP_FINDER, 0);
1091  return TRUE;
1092  case ID_HELP_ABOUT:
1093  ShowAboutBox(hWnd);
1094  return TRUE;
1095  case ID_VIEW_SPLIT:
1096  {
1097  RECT rt;
1098  POINT pt, pts;
1100  pt.x = rt.left + g_pChildWnd->nSplitPos;
1101  pt.y = (rt.bottom / 2);
1102  pts = pt;
1103  if(ClientToScreen(g_pChildWnd->hWnd, &pts))
1104  {
1105  SetCursorPos(pts.x, pts.y);
1108  }
1109  return TRUE;
1110  }
1111  case ID_EDIT_RENAME:
1112  case ID_EDIT_MODIFY:
1113  case ID_EDIT_MODIFY_BIN:
1114  case ID_EDIT_DELETE:
1115  regsam |= KEY_WRITE;
1116  break;
1117  }
1118 
1119  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1120  valueName = GetValueName(g_pChildWnd->hListWnd, -1);
1121  if (keyPath)
1122  {
1123  if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
1124  hKey = 0;
1125  }
1126 
1127  switch (LOWORD(wParam))
1128  {
1129  case ID_EDIT_MODIFY:
1130  if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
1131  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1132  break;
1133  case ID_EDIT_MODIFY_BIN:
1134  if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
1135  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1136  break;
1137  case ID_EDIT_RENAME:
1138  if (GetFocus() == g_pChildWnd->hListWnd)
1139  {
1141  {
1143  if(item > -1)
1144  {
1146  }
1147  }
1148  }
1149  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1150  {
1151  /* Get focused entry of treeview (if any) */
1153  if (hItem != NULL)
1155  }
1156  break;
1157  case ID_EDIT_DELETE:
1158  {
1159  if (GetFocus() == g_pChildWnd->hListWnd && hKey)
1160  {
1162  if(nSelected >= 1)
1163  {
1164  WCHAR msg[128], caption[128];
1168  {
1169  int ni, errs;
1170 
1171  item = -1;
1172  errs = 0;
1174  {
1175  valueName = GetValueName(g_pChildWnd->hListWnd, item);
1176  if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
1177  {
1178  errs++;
1179  }
1180  item = ni;
1181  }
1182 
1183  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1184  if(errs > 0)
1185  {
1186  LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, ARRAY_SIZE(caption));
1189  }
1190  }
1191  }
1192  }
1193  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1194  {
1195  if (keyPath == NULL || *keyPath == UNICODE_NULL)
1196  {
1198  }
1199  else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1200  {
1203  }
1204  }
1205  break;
1206  }
1208  CreateNewValue(hKeyRoot, keyPath, REG_SZ);
1209  break;
1211  CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
1212  break;
1214  CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
1215  break;
1217  CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
1218  break;
1220  CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
1221  break;
1222  case ID_EDIT_FIND:
1223  FindDialog(hWnd);
1224  break;
1225  case ID_EDIT_FINDNEXT:
1227  break;
1228  case ID_EDIT_COPYKEYNAME:
1229  CopyKeyName(hWnd, hKeyRoot, keyPath);
1230  break;
1231  case ID_EDIT_PERMISSIONS:
1232  RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1233  break;
1235  /*PRINTDLG pd;*/
1236  /*PrintDlg(&pd);*/
1237  /*PAGESETUPDLG psd;*/
1238  /*PageSetupDlg(&psd);*/
1239  break;
1240  case ID_REGISTRY_OPENLOCAL:
1241  break;
1242 
1243  case ID_VIEW_REFRESH:
1245  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1246  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1247  break;
1248  /*case ID_OPTIONS_TOOLBAR:*/
1249  /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
1250  /* break;*/
1251  case ID_EDIT_NEW_KEY:
1253  break;
1254 
1255  case ID_TREE_EXPANDBRANCH:
1257  break;
1260  break;
1261  case ID_TREE_RENAME:
1264  break;
1265  case ID_TREE_DELETE:
1267  if (keyPath == 0 || *keyPath == 0)
1268  {
1270  }
1271  else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1273  break;
1274  case ID_TREE_EXPORT:
1276  break;
1277  case ID_TREE_PERMISSIONS:
1279  RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1280  break;
1281  case ID_SWITCH_PANELS:
1282  {
1283  BOOL bShiftDown = GetKeyState(VK_SHIFT) < 0;
1284  HWND hwndItem = GetNextDlgTabItem(g_pChildWnd->hWnd, GetFocus(), bShiftDown);
1285  if (hwndItem == g_pChildWnd->hAddressBarWnd)
1286  PostMessageW(hwndItem, EM_SETSEL, 0, -1);
1287  SetFocus(hwndItem);
1288  }
1289  break;
1290 
1291  case ID_ADDRESS_FOCUS:
1294  break;
1295 
1296  default:
1298  {
1299  HMENU hMenu;
1300  MENUITEMINFOW mii;
1301  WCHAR szFavorite[512];
1302 
1304 
1305  memset(&mii, 0, sizeof(mii));
1306  mii.cbSize = sizeof(mii);
1307  mii.fMask = MIIM_TYPE;
1308  mii.fType = MFT_STRING;
1309  mii.dwTypeData = szFavorite;
1310  mii.cch = ARRAY_SIZE(szFavorite);
1311 
1312  if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
1313  {
1314  ChooseFavorite(szFavorite);
1315  }
1316  }
1318  {
1319  WORD wID = LOWORD(wParam);
1320  LPCWSTR s = Suggestions;
1321  while(wID > ID_TREE_SUGGESTION_MIN)
1322  {
1323  if (*s)
1324  s += wcslen(s) + 1;
1325  wID--;
1326  }
1328  }
1329  else
1330  {
1331  result = FALSE;
1332  }
1333  break;
1334  }
1335 
1336  if(hKey)
1337  RegCloseKey(hKey);
1338  return result;
1339 }
#define IDC_SIZEWE
Definition: winuser.h:689
#define MB_ICONHAND
Definition: winuser.h:782
#define ID_REGISTRY_IMPORTREGISTRYFILE
Definition: resource.h:68
#define ID_TREE_RENAME
Definition: resource.h:152
#define ID_SWITCH_PANELS
Definition: resource.h:149
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
Definition: tftpd.h:59
#define MFT_STRING
Definition: winuser.h:741
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:95
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
long y
Definition: polytest.cpp:48
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:104
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
BOOL ExportRegistryFile(HWND hWnd)
Definition: framewnd.c:580
#define IDYES
Definition: winuser.h:829
GLuint64EXT * result
Definition: glext.h:11304
#define ID_EDIT_COPYKEYNAME
Definition: resource.h:59
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
void ShowAboutBox(HWND hWnd)
Definition: about.c:25
long x
Definition: polytest.cpp:48
#define REG_BINARY
Definition: nt_native.h:1496
#define ID_TREE_EXPORT
Definition: resource.h:158
#define ID_EDIT_NEW_EXPANDABLESTRINGVALUE
Definition: resource.h:147
#define ID_FAVORITES_MAX
Definition: resource.h:295
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define pt(x, y)
Definition: drawing.c:79
static struct netconfig_info ni
Definition: getnetconfig.c:158
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3504
HWND hTreeWnd
Definition: main.h:63
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define ID_EDIT_FIND
Definition: resource.h:60
HWND hListWnd
Definition: main.h:64
HWND hWnd
Definition: settings.c:17
BOOL WINAPI MessageBeep(_In_ UINT uType)
WCHAR * GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
HWND WINAPI SetFocus(_In_opt_ HWND)
LPWSTR dwTypeData
Definition: winuser.h:3259
#define ID_EDIT_FINDNEXT
Definition: resource.h:61
#define LVNI_SELECTED
Definition: commctrl.h:2424
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONSTOP
Definition: winuser.h:797
LONG left
Definition: windef.h:306
#define IDS_QUERY_DELETE_MORE
Definition: resource.h:134
static HRESULT InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
Definition: framewnd.c:894
#define ID_HELP_HELPTOPICS
Definition: resource.h:74
static void ChooseFavorite(LPCWSTR pszFavorite)
Definition: framewnd.c:762
HWND WINAPI GetNextDlgTabItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WPARAM wParam
Definition: combotst.c:138
static BOOL LoadHive(HWND hWnd)
Definition: framewnd.c:345
#define ID_EDIT_NEW_BINARYVALUE
Definition: resource.h:65
#define HELP_FINDER
Definition: winuser.h:2409
int nSplitPos
Definition: main.h:69
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1011
#define ID_REGISTRY_EXIT
Definition: resource.h:51
#define L(x)
Definition: ntvdm.h:50
#define ID_VIEW_STATUSBAR
Definition: resource.h:54
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
static BOOL UnloadHive(HWND hWnd)
Definition: framewnd.c:402
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:156
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ID_EDIT_DELETE
Definition: resource.h:57
if SUCCEEDED(hr)
#define REG_MULTI_SZ
Definition: nt_native.h:1501
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
Definition: framewnd.c:784
#define VK_SHIFT
Definition: winuser.h:2192
#define ID_HELP_ABOUT
Definition: resource.h:75
#define ID_REGISTRY_CONNECTNETWORKREGISTRY
Definition: resource.h:70
#define ID_EDIT_PERMISSIONS
Definition: resource.h:150
WCHAR Suggestions[256]
Definition: childwnd.c:27
#define TVE_COLLAPSE
Definition: commctrl.h:3422
#define MB_ICONQUESTION
Definition: winuser.h:783
static HRESULT InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker *pDsObjectPicker, IN HWND hwndParent OPTIONAL, OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: framewnd.c:953
#define IDS_QUERY_DELETE_ONE
Definition: resource.h:133
#define ID_EDIT_RENAME
Definition: resource.h:58
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
Definition: edit.c:1072
SHORT WINAPI GetKeyState(_In_ int)
#define IDS_ERR_DELVAL_CAPTION
Definition: resource.h:136
#define GetMenuItemInfo
Definition: winuser.h:5778
#define KEY_WRITE
Definition: nt_native.h:1031
#define ID_VIEW_REFRESH
Definition: resource.h:56
void FindNextMessageBox(HWND hWnd)
Definition: find.c:822
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:157
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:434
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:105
HWND hWnd
Definition: main.h:62
#define ID_TREE_PERMISSIONS
Definition: resource.h:159
#define EM_SETSEL
Definition: winuser.h:2008
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2631
unsigned short WORD
Definition: ntddk_ex.h:93
HWND hStatusBar
Definition: main.cpp:35
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define TVE_EXPAND
Definition: commctrl.h:3423
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY
Definition: resource.h:71
#define ID_FAVORITES_MIN
Definition: resource.h:294
#define ID_EDIT_NEW_KEY
Definition: resource.h:63
static __inline VOID DeleteNode(NODE *node)
Definition: text.h:48
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:671
#define ID_REGISTRY_OPENLOCAL
Definition: resource.h:102
#define MIIM_TYPE
Definition: winuser.h:720
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
#define ID_REGISTRY_EXPORTREGISTRYFILE
Definition: resource.h:69
GLdouble s
Definition: gl.h:2039
void FindDialog(HWND hWnd)
Definition: find.c:834
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define ID_EDIT_NEW_DWORDVALUE
Definition: resource.h:66
#define ID_EDIT_MODIFY
Definition: resource.h:62
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:243
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ID_EDIT_NEW_STRINGVALUE
Definition: resource.h:64
#define S_OK
Definition: intsafe.h:52
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
Definition: framewnd.c:690
static ATOM item
Definition: dde.c:856
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
#define ID_VIEW_SPLIT
Definition: resource.h:55
#define ID_REGISTRY_PRINT
Definition: resource.h:72
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
FxAutoRegKey hKey
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ID_REGISTRY_PRINTERSETUP
Definition: resource.h:110
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:181
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
Definition: edit.c:1456
#define IDS_ERR_DELETEVALUE
Definition: resource.h:137
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:93
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:573
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI GetFocus(void)
Definition: window.c:1894
HWND hAddressBarWnd
Definition: main.h:65
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:773
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG bottom
Definition: windef.h:309
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:839
#define ID_TREE_DELETE
Definition: resource.h:151
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:311
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:122
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
static BOOL CreateNewValue(HKEY hRootKey, LPCWSTR pszKeyPath, DWORD dwType)
Definition: framewnd.c:819
#define LOWORD(l)
Definition: pedump.c:82
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ID_EDIT_NEW_MULTISTRINGVALUE
Definition: resource.h:146
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2540
#define IDS_QUERY_DELETE_CONFIRM
Definition: resource.h:135
#define ID_ADDRESS_FOCUS
Definition: resource.h:160
#define REG_SZ
Definition: layer.c:22

Referenced by FrameWndProc().

◆ BuildFilterStrings()

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

Definition at line 243 of file framewnd.c.

244 {
245  int i, c;
246 
247  c = 0;
248  for(i = 0; i < PairCount; i++)
249  {
250  c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
251  Filter[++c] = L'\0';
252  c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
253  Filter[++c] = L'\0';
254  }
255  Filter[++c] = L'\0';
256 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
const GLubyte * c
Definition: glext.h:8905
HINSTANCE hInst
Definition: dxdiag.c:13
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 191 of file framewnd.c.

192 {
193  DWORD dwErrorCode = CommDlgExtendedError();
195  switch (dwErrorCode)
196  {
197  case CDERR_DIALOGFAILURE:
198  break;
200  break;
201  case CDERR_NOHINSTANCE:
202  break;
204  break;
205  case CDERR_NOHOOK:
206  break;
208  break;
209  case CDERR_NOTEMPLATE:
210  break;
212  break;
213  case CDERR_STRUCTSIZE:
214  break;
216  break;
218  break;
220  break;
222  break;
224  break;
226  break;
227  default:
228  break;
229  }
230  return TRUE;
231 }
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CDERR_NOHINSTANCE
Definition: cderr.h:9
HWND hWnd
Definition: settings.c:17
#define FNERR_SUBCLASSFAILURE
Definition: cderr.h:35
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
#define CDERR_LOADSTRFAILURE
Definition: cderr.h:10
#define CDERR_LOCKRESFAILURE
Definition: cderr.h:13
#define CDERR_INITIALIZATION
Definition: cderr.h:7
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CDERR_NOHOOK
Definition: cderr.h:16
#define CDERR_NOTEMPLATE
Definition: cderr.h:8
#define CDERR_MEMLOCKFAILURE
Definition: cderr.h:15
#define FNERR_BUFFERTOOSMALL
Definition: cderr.h:37
#define CDERR_MEMALLOCFAILURE
Definition: cderr.h:14
#define CDERR_DIALOGFAILURE
Definition: cderr.h:4
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
#define FNERR_INVALIDFILENAME
Definition: cderr.h:36

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

◆ ChooseFavorite()

static void ChooseFavorite ( LPCWSTR  pszFavorite)
static

Definition at line 762 of file framewnd.c.

763 {
764  HKEY hKey = NULL;
765  WCHAR szFavoritePath[512];
766  DWORD cbData, dwType;
767 
769  goto done;
770 
771  cbData = sizeof(szFavoritePath);
772  memset(szFavoritePath, 0, sizeof(szFavoritePath));
773  if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
774  goto done;
775 
776  if (dwType == REG_SZ)
777  SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
778 
779 done:
780  if (hKey)
781  RegCloseKey(hKey);
782 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hTreeWnd
Definition: main.h:63
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:773
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define memset(x, y, z)
Definition: compat.h:39
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

Referenced by _CmdWndProc().

◆ CopyKeyName()

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

Definition at line 784 of file framewnd.c.

785 {
786  BOOL bClipboardOpened = FALSE;
787  BOOL bSuccess = FALSE;
788  WCHAR szBuffer[512];
789  HGLOBAL hGlobal;
790  LPWSTR s;
791 
792  if (!OpenClipboard(hWnd))
793  goto done;
794  bClipboardOpened = TRUE;
795 
796  if (!EmptyClipboard())
797  goto done;
798 
799  if (!GetKeyName(szBuffer, ARRAY_SIZE(szBuffer), hRootKey, keyName))
800  goto done;
801 
802  hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
803  if (!hGlobal)
804  goto done;
805 
806  s = GlobalLock(hGlobal);
807  wcscpy(s, szBuffer);
808  GlobalUnlock(hGlobal);
809 
811  bSuccess = TRUE;
812 
813 done:
814  if (bClipboardOpened)
815  CloseClipboard();
816  return bSuccess;
817 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
static BOOLEAN bSuccess
Definition: drive.cpp:433
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CF_UNICODETEXT
Definition: constants.h:408
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
GLdouble s
Definition: gl.h:2039
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GMEM_MOVEABLE
Definition: winbase.h:294
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

Referenced by _CmdWndProc().

◆ CreateNewValue()

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

Definition at line 819 of file framewnd.c.

820 {
821  WCHAR szNewValueFormat[128];
822  WCHAR szNewValue[128];
823  int iIndex = 1;
824  BYTE data[128];
825  DWORD dwExistingType, cbData;
826  LONG lResult;
827  HKEY hKey;
828  LVFINDINFO lvfi;
829 
830  if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
831  &hKey) != ERROR_SUCCESS)
832  return FALSE;
833 
834  LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, ARRAY_SIZE(szNewValueFormat));
835 
836  do
837  {
838  wsprintf(szNewValue, szNewValueFormat, iIndex++);
839  cbData = sizeof(data);
840  lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
841  }
842  while(lResult == ERROR_SUCCESS);
843 
844  switch(dwType)
845  {
846  case REG_DWORD:
847  cbData = sizeof(DWORD);
848  break;
849  case REG_SZ:
850  case REG_EXPAND_SZ:
851  cbData = sizeof(WCHAR);
852  break;
853  case REG_MULTI_SZ:
854  /*
855  * WARNING: An empty multi-string has only one null char.
856  * Indeed, multi-strings are built in the following form:
857  * str1\0str2\0...strN\0\0
858  * where each strI\0 is a null-terminated string, and it
859  * ends with a terminating empty string.
860  * Therefore an empty multi-string contains only the terminating
861  * empty string, that is, one null char.
862  */
863  cbData = sizeof(WCHAR);
864  break;
865  case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
866  cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
867  break;
868  default:
869  cbData = 0;
870  break;
871  }
872  memset(data, 0, cbData);
873  lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
874  RegCloseKey(hKey);
875  if (lResult != ERROR_SUCCESS)
876  {
877  return FALSE;
878  }
879 
880  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
881 
882  /* locate the newly added value, and get ready to rename it */
883  memset(&lvfi, 0, sizeof(lvfi));
884  lvfi.flags = LVFI_STRING;
885  lvfi.psz = szNewValue;
886  iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
887  if (iIndex >= 0)
889 
890  return TRUE;
891 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TRUE
Definition: types.h:120
HWND hListWnd
Definition: main.h:64
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
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:4900
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:671
unsigned char BYTE
Definition: xxhash.c:193
HINSTANCE hInst
Definition: dxdiag.c:13
FxAutoRegKey hKey
#define ARRAY_SIZE(a)
Definition: main.h:24
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
#define LVFINDINFO
Definition: commctrl.h:2463
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define LVFI_STRING
Definition: commctrl.h:2437
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
#define REG_QWORD
Definition: sdbapi.c:597
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define IDS_NEW_VALUE
Definition: resource.h:191
#define wsprintf
Definition: winuser.h:5855
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2540
#define REG_SZ
Definition: layer.c:22

Referenced by _CmdWndProc().

◆ EnablePrivilege()

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

Definition at line 315 of file framewnd.c.

316 {
317  BOOL bRet = FALSE;
318  HANDLE hToken = NULL;
319 
322  &hToken))
323  {
325 
326  tp.PrivilegeCount = 1;
327  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
328 
329  if (LookupPrivilegeValueW(lpszSystemName,
330  lpszPrivilegeName,
331  &tp.Privileges[0].Luid))
332  {
333  bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
334 
336  bRet = FALSE;
337  }
338 
339  CloseHandle(hToken);
340  }
341 
342  return bRet;
343 }
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
#define GetCurrentProcess()
Definition: compat.h:759
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define ERROR_NOT_ALL_ASSIGNED
Definition: winerror.h:782
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:926

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

◆ ExportRegistryFile()

BOOL ExportRegistryFile ( HWND  hWnd)

Definition at line 580 of file framewnd.c.

581 {
582  BOOL bRet = FALSE;
584  WCHAR ExportKeyPath[_MAX_PATH] = {0};
585  WCHAR Caption[128], szTitle[512], szText[512];
586  HKEY hKeyRoot;
587  LPCWSTR pszKeyPath;
588 
589  /* Figure out which key path we are exporting */
590  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
591  GetKeyName(ExportKeyPath, ARRAY_SIZE(ExportKeyPath), hKeyRoot, pszKeyPath);
592 
594  LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
595  ofn.lpstrTitle = Caption;
596 
597  /* Only set the path if a key (not the root node) is selected */
598  if (hKeyRoot != 0)
599  {
600  ofn.lCustData = (LPARAM) ExportKeyPath;
601  }
605  if (GetSaveFileName(&ofn))
606  {
607  switch (ofn.nFilterIndex)
608  {
609  case 2: /* Registry Hive Files */
610  {
611  LONG lResult;
612  HKEY hSubKey;
613 
614  /* Open the subkey */
615  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
616  if (lResult == ERROR_SUCCESS)
617  {
618  /* Enable the 'backup' privilege, save the hive then disable the privilege */
620  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
621  if (lResult == ERROR_ALREADY_EXISTS)
622  {
623  /*
624  * We are here, that means that we already said "yes" to the confirmation dialog.
625  * So we absolutely want to replace the hive file.
626  */
628  {
629  /* Try again */
630  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
631  }
632  }
634 
635  if (lResult != ERROR_SUCCESS)
636  {
637  /*
638  * If we are here, it's because RegSaveKeyW has failed for any reason.
639  * The problem is that even if it has failed, it has created or
640  * replaced the exported hive file with a new empty file. We don't
641  * want to keep this file, so we delete it.
642  */
644  }
645 
646  /* Close the subkey */
647  RegCloseKey(hSubKey);
648  }
649 
650  /* Set the return value */
651  bRet = (lResult == ERROR_SUCCESS);
652 
653  /* Display error, if any */
654  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
655 
656  break;
657  }
658 
659  case 1: /* Windows Registry Editor Version 5.00 */
660  case 3: /* REGEDIT4 */
661  default: /* All files ==> use Windows Registry Editor Version 5.00 */
662  {
663  if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
665  : REG_FORMAT_5)))
666  {
667  /* Error creating the file */
669  LoadStringW(hInst, IDS_EXPORT_ERROR, szText, ARRAY_SIZE(szText));
671  bRet = FALSE;
672  }
673  else
674  {
675  bRet = TRUE;
676  }
677 
678  break;
679  }
680  }
681  }
682  else
683  {
685  }
686 
687  return bRet;
688 }
#define REG_FORMAT_4
Definition: main.h:45
#define OFN_EXPLORER
Definition: commdlg.h:104
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPARAM lCustData
Definition: commdlg.h:346
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define SE_BACKUP_NAME
HWND hTreeWnd
Definition: main.h:63
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
LPCSTR lpTemplateName
Definition: commdlg.h:348
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetSaveFileName
Definition: commdlg.h:666
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define IDS_EXPORT_REG_FILE
Definition: resource.h:131
#define _MAX_PATH
Definition: utility.h:77
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:526
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:315
LONG_PTR LPARAM
Definition: windef.h:208
#define IDD_EXPORTRANGE
Definition: resource.h:42
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
LONG WINAPI RegSaveKeyW(HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: reg.c:4635
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL export_registry_key(WCHAR *file_name, WCHAR *path, DWORD format)
Definition: regproc.c:1548
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:191
#define MB_ICONERROR
Definition: winuser.h:781
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define ARRAY_SIZE(a)
Definition: main.h:24
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define IDS_EXPORT_ERROR
Definition: resource.h:197
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
DWORD nFilterIndex
Definition: commdlg.h:335
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:258
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_FORMAT_5
Definition: main.h:44
DWORD Flags
Definition: commdlg.h:342
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

Referenced by _CmdWndProc().

◆ ExportRegistryFile_OFNHookProc()

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

Definition at line 526 of file framewnd.c.

527 {
528  HWND hwndExportAll;
529  HWND hwndExportBranch;
530  HWND hwndExportBranchText;
531  UINT_PTR iResult = 0;
532  OPENFILENAME *pOfn;
533  LPWSTR pszSelectedKey;
534  OFNOTIFY *pOfnNotify;
535 
537 
538  switch(uiMsg)
539  {
540  case WM_INITDIALOG:
541  pOfn = (OPENFILENAME *) lParam;
542  pszSelectedKey = (LPWSTR) pOfn->lCustData;
543 
544  hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
545  if (hwndExportAll)
546  SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
547 
548  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
549  if (hwndExportBranch)
550  SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
551 
552  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
553  if (hwndExportBranchText)
554  SetWindowTextW(hwndExportBranchText, pszSelectedKey);
555  break;
556 
557  case WM_NOTIFY:
558  if (((NMHDR *) lParam)->code == CDN_FILEOK)
559  {
560  pOfnNotify = (OFNOTIFY *) lParam;
561  pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
562 
563  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
564  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
565  if (hwndExportBranch && hwndExportBranchText
566  && (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
567  {
568  GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
569  }
570  else
571  {
572  pszSelectedKey[0] = L'\0';
573  }
574  }
575  break;
576  }
577  return iResult;
578 }
LPARAM lCustData
Definition: commdlg.h:346
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define IDC_EXPORT_ALL
Definition: resource.h:258
#define IDC_EXPORT_BRANCH
Definition: resource.h:259
WPARAM wParam
Definition: combotst.c:138
#define L(x)
Definition: ntvdm.h:50
#define IDC_EXPORT_BRANCH_TEXT
Definition: resource.h:260
#define _MAX_PATH
Definition: utility.h:77
#define BM_GETCHECK
Definition: winuser.h:1908
LPOPENFILENAMEA lpOFN
Definition: commdlg.h:407
#define BM_SETCHECK
Definition: winuser.h:1911
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CDN_FILEOK
Definition: commdlg.h:38
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
Definition: inflate.c:139
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by ExportRegistryFile().

◆ FrameWndProc()

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

Definition at line 1352 of file framewnd.c.

1353 {
1354  RECT rc;
1355  switch (message)
1356  {
1357  case WM_CREATE:
1358  // For now, the Help dialog item is disabled because of lacking of HTML Help support
1360  GetClientRect(hWnd, &rc);
1362  rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
1363  hWnd, (HMENU)0, hInst, 0);
1364  break;
1365  case WM_COMMAND:
1368  break;
1369  case WM_ACTIVATE:
1370  if (LOWORD(hWnd) && g_pChildWnd)
1372  break;
1373  case WM_SIZE:
1375  break;
1376  case WM_TIMER:
1377  break;
1378  case WM_INITMENU:
1379  OnInitMenu(hWnd);
1380  break;
1381  case WM_ENTERMENULOOP:
1383  break;
1384  case WM_EXITMENULOOP:
1386  break;
1387  case WM_MENUSELECT:
1389  break;
1390  case WM_SYSCOLORCHANGE:
1391  /* Forward WM_SYSCOLORCHANGE to common controls */
1394  break;
1395  case WM_DESTROY:
1396  WinHelpW(hWnd, L"regedit", HELP_QUIT, 0);
1397  SaveSettings();
1398  PostQuitMessage(0);
1399  default:
1401  }
1402  return 0;
1403 }
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1616
Definition: tftpd.h:59
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define MF_BYCOMMAND
Definition: winuser.h:202
static void OnExitMenuLoop(HWND hWnd)
Definition: framewnd.c:129
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:55
#define HELP_QUIT
Definition: winuser.h:2404
HWND hTreeWnd
Definition: main.h:63
HWND hListWnd
Definition: main.h:64
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:137
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
#define ID_HELP_HELPTOPICS
Definition: resource.h:74
LONG right
Definition: windef.h:308
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void SaveSettings(void)
Definition: settings.c:115
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_ENTERMENULOOP
Definition: winuser.h:1794
#define WM_MENUSELECT
Definition: winuser.h:1737
#define WM_EXITMENULOOP
Definition: winuser.h:1795
#define WM_DESTROY
Definition: winuser.h:1599
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:117
#define WM_SIZE
Definition: winuser.h:1601
HWND hWnd
Definition: main.h:62
#define WM_TIMER
Definition: winuser.h:1732
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1023
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:65
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)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:45
#define WM_COMMAND
Definition: winuser.h:1730
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_INITMENU
Definition: winuser.h:1735
#define WM_ACTIVATE
Definition: winuser.h:1602
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
#define WM_CREATE
Definition: winuser.h:1598
#define HIWORD(l)
Definition: typedefs.h:247
LONG bottom
Definition: windef.h:309
#define MF_GRAYED
Definition: winuser.h:129
#define WS_VISIBLE
Definition: pedump.c:620
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by InitInstance().

◆ FreeObjectPicker()

static VOID FreeObjectPicker ( IN IDsObjectPicker *  pDsObjectPicker)
static

Definition at line 1011 of file framewnd.c.

1012 {
1013  pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
1014 }

Referenced by _CmdWndProc(), and SecurityPageProc().

◆ ImportRegistryFile()

static BOOL ImportRegistryFile ( HWND  hWnd)
static

Definition at line 434 of file framewnd.c.

435 {
436  BOOL bRet = FALSE;
438  WCHAR Caption[128], szTitle[512], szText[512];
439  HKEY hKeyRoot;
440  LPCWSTR pszKeyPath;
441 
442  /* Figure out in which key path we are importing */
443  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
444 
446  LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, ARRAY_SIZE(Caption));
447  ofn.lpstrTitle = Caption;
449  /* ofn.lCustData = ;*/
450  if (GetOpenFileName(&ofn))
451  {
452  /* Look at the extension of the file to determine its type */
453  if (ofn.nFileExtension >= 1 &&
454  _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
455  {
456  /* Open the file */
457  FILE* fp = _wfopen(ofn.lpstrFile, L"rb");
458 
459  /* Import it */
460  if (fp == NULL || !import_registry_file(fp))
461  {
462  /* Error opening the file */
464  LoadStringW(hInst, IDS_IMPORT_ERROR, szText, ARRAY_SIZE(szText));
466  bRet = FALSE;
467  }
468  else
469  {
470  /* Show successful import */
472  LoadStringW(hInst, IDS_IMPORT_OK, szText, ARRAY_SIZE(szText));
474  bRet = TRUE;
475  }
476 
477  /* Close the file */
478  if (fp) fclose(fp);
479  }
480  else /* Registry Hive Files */
481  {
484 
485  /* Display a confirmation message */
487  {
488  LONG lResult;
489  HKEY hSubKey;
490 
491  /* Open the subkey */
492  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
493  if (lResult == ERROR_SUCCESS)
494  {
495  /* Enable the 'restore' privilege, restore the hive then disable the privilege */
497  lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
499 
500  /* Flush the subkey and close it */
501  RegFlushKey(hSubKey);
502  RegCloseKey(hSubKey);
503  }
504 
505  /* Set the return value */
506  bRet = (lResult == ERROR_SUCCESS);
507 
508  /* Display error, if any */
509  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
510  }
511  }
512  }
513  else
514  {
516  }
517 
518  /* refresh tree and list views */
520  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
521  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath);
522 
523  return bRet;
524 }
#define RegRestoreKey
Definition: winreg.h:526
WORD nFileExtension
Definition: commdlg.h:344
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
#define TRUE
Definition: types.h:120
HWND hTreeWnd
Definition: main.h:63
#define IDS_QUERY_IMPORT_HIVE_MSG
Definition: resource.h:141
HWND hListWnd
Definition: main.h:64
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
#define IDS_QUERY_IMPORT_HIVE_CAPTION
Definition: resource.h:140
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetOpenFileName
Definition: commdlg.h:665
#define MB_ICONWARNING
Definition: winuser.h:780
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define IDS_IMPORT_REG_FILE
Definition: resource.h:130
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:315
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hWnd
Definition: main.h:62
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1049
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:191
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:671
#define MB_ICONERROR
Definition: winuser.h:781
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define IDS_IMPORT_ERROR
Definition: resource.h:196
#define REG_FORCE_RESTORE
Definition: cmtypes.h:109
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define ARRAY_SIZE(a)
Definition: main.h:24
#define IDS_IMPORT_OK
Definition: resource.h:195
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:311
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:258
#define RegCloseKey(hKey)
Definition: registry.h:47
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD Flags
Definition: commdlg.h:342

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

◆ InitializeRemoteRegistryPicker()

static HRESULT InitializeRemoteRegistryPicker ( OUT IDsObjectPicker **  pDsObjectPicker)
static

Definition at line 894 of file framewnd.c.

895 {
896  HRESULT hRet;
897 
898  *pDsObjectPicker = NULL;
899 
900  hRet = CoCreateInstance(&CLSID_DsObjectPicker,
901  NULL,
902  CLSCTX_INPROC_SERVER,
903  &IID_IDsObjectPicker,
904  (LPVOID*)pDsObjectPicker);
905  if (SUCCEEDED(hRet))
906  {
907  DSOP_INIT_INFO InitInfo;
908  static DSOP_SCOPE_INIT_INFO Scopes[] =
909  {
910  {
911  sizeof(DSOP_SCOPE_INIT_INFO),
916  0,
917  {
918  {
920  0,
921  0
922  },
924  },
925  NULL,
926  NULL,
927  S_OK
928  },
929  };
930 
931  InitInfo.cbSize = sizeof(InitInfo);
932  InitInfo.pwzTargetComputer = NULL;
933  InitInfo.cDsScopeInfos = ARRAY_SIZE(Scopes);
934  InitInfo.aDsScopeInfos = Scopes;
935  InitInfo.flOptions = 0;
936  InitInfo.cAttributesToFetch = 0;
937  InitInfo.apwzAttributeNames = NULL;
938 
939  hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
940  &InitInfo);
941 
942  if (FAILED(hRet))
943  {
944  /* delete the object picker in case initialization failed! */
945  (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
946  }
947  }
948 
949  return hRet;
950 }
#define DSOP_SCOPE_TYPE_GLOBAL_CATALOG
Definition: objsel.h:125
ULONG cAttributesToFetch
Definition: objsel.h:114
PCWSTR * apwzAttributeNames
Definition: objsel.h:115
PCWSTR pwzTargetComputer
Definition: objsel.h:110
ULONG cDsScopeInfos
Definition: objsel.h:111
if SUCCEEDED(hr)
ULONG cbSize
Definition: objsel.h:109
struct _DSOP_SCOPE_INIT_INFO DSOP_SCOPE_INIT_INFO
LONG HRESULT
Definition: typedefs.h:79
PDSOP_SCOPE_INIT_INFO aDsScopeInfos
Definition: objsel.h:112
#define DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
Definition: objsel.h:126
#define DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
Definition: objsel.h:123
#define DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
Definition: objsel.h:130
ULONG flOptions
Definition: objsel.h:113
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define DSOP_SCOPE_TYPE_WORKGROUP
Definition: objsel.h:128
#define S_OK
Definition: intsafe.h:52
#define DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
Definition: objsel.h:122
#define ARRAY_SIZE(a)
Definition: main.h:24
#define DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
Definition: objsel.h:127
#define NULL
Definition: types.h:112
#define DSOP_FILTER_COMPUTERS
Definition: objsel.h:41
#define DSOP_DOWNLEVEL_FILTER_COMPUTERS
Definition: objsel.h:54
#define DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
Definition: objsel.h:129

Referenced by _CmdWndProc().

◆ InitOpenFileName()

static BOOL InitOpenFileName ( HWND  hWnd,
OPENFILENAME pofn 
)
static

Definition at line 258 of file framewnd.c.

259 {
260  FILTERPAIR FilterPairs[4];
261  static WCHAR Filter[1024];
262 
263  memset(pofn, 0, sizeof(OPENFILENAME));
264  pofn->lStructSize = sizeof(OPENFILENAME);
265  pofn->hwndOwner = hWnd;
266  pofn->hInstance = hInst;
267 
268  /* create filter string */
269  FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
270  FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
271  FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
272  FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
273  FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
274  FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
275  FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
276  FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
277  BuildFilterStrings(Filter, FilterPairs, ARRAY_SIZE(FilterPairs));
278 
279  pofn->lpstrFilter = Filter;
280  pofn->lpstrFile = FileNameBuffer;
281  pofn->nMaxFile = _MAX_PATH;
283  pofn->nMaxFileTitle = _MAX_PATH;
285  pofn->lpstrDefExt = L"reg";
286  return TRUE;
287 }
#define OFN_EXPLORER
Definition: commdlg.h:104
WCHAR FileTitleBuffer[_MAX_PATH]
Definition: framewnd.c:234
#define IDS_FLT_HIVFILES
Definition: resource.h:165
UINT FilterID
Definition: framewnd.c:239
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nMaxFile
Definition: commdlg.h:337
UINT DisplayID
Definition: framewnd.c:238
#define IDS_FLT_ALLFILES
Definition: resource.h:169
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define _MAX_PATH
Definition: utility.h:77
HINSTANCE hInstance
Definition: commdlg.h:331
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD lStructSize
Definition: commdlg.h:329
#define IDS_FLT_REGEDIT4_FLT
Definition: resource.h:168
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:243
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:170
#define IDS_FLT_HIVFILES_FLT
Definition: resource.h:166
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDS_FLT_REGEDIT4
Definition: resource.h:167
LPSTR lpstrFile
Definition: commdlg.h:336
#define ARRAY_SIZE(a)
Definition: main.h:24
#define IDS_FLT_REGFILES_FLT
Definition: resource.h:164
LPCSTR lpstrFilter
Definition: commdlg.h:332
WCHAR FileNameBuffer[_MAX_PATH]
Definition: framewnd.c:233
#define memset(x, y, z)
Definition: compat.h:39
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
#define IDS_FLT_REGFILES
Definition: resource.h:163

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

957 {
958  IDataObject *pdo = NULL;
959  HRESULT hRet;
960 
961  hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
962  hwndParent,
963  &pdo);
964  if (hRet == S_OK)
965  {
966  STGMEDIUM stm;
967  FORMATETC fe;
968 
969  fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
970  fe.ptd = NULL;
971  fe.dwAspect = DVASPECT_CONTENT;
972  fe.lindex = -1;
973  fe.tymed = TYMED_HGLOBAL;
974 
975  hRet = pdo->lpVtbl->GetData(pdo,
976  &fe,
977  &stm);
978  if (SUCCEEDED(hRet))
979  {
980  PDS_SELECTION_LIST SelectionList = (PDS_SELECTION_LIST)GlobalLock(stm.hGlobal);
981  if (SelectionList != NULL)
982  {
983  if (SelectionList->cItems == 1)
984  {
985  size_t nlen = wcslen(SelectionList->aDsSelection[0].pwzName);
986  if (nlen >= uSize)
987  {
988  nlen = uSize - 1;
989  }
990 
992  SelectionList->aDsSelection[0].pwzName,
993  nlen * sizeof(WCHAR));
994 
995  lpBuffer[nlen] = L'\0';
996  }
997 
998  GlobalUnlock(stm.hGlobal);
999  }
1000 
1001  ReleaseStgMedium(&stm);
1002  }
1003 
1004  pdo->lpVtbl->Release(pdo);
1005  }
1006 
1007  return hRet;
1008 }
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
struct _DS_SELECTION_LIST * PDS_SELECTION_LIST
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define CFSTR_DSOP_DS_SELECTION_LIST
Definition: objsel.h:27
#define L(x)
Definition: ntvdm.h:50
if SUCCEEDED(hr)
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
ULONG Release()
static HWND hwndParent
Definition: cryptui.c:300
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DS_SELECTION aDsSelection[ANYSIZE_ARRAY]
Definition: objsel.h:146
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PWSTR pwzName
Definition: objsel.h:134

Referenced by _CmdWndProc().

◆ LoadHive()

static BOOL LoadHive ( HWND  hWnd)
static

Definition at line 345 of file framewnd.c.

346 {
348  WCHAR Caption[128];
349  LPCWSTR pszKeyPath;
351  HKEY hRootKey;
352  WCHAR Filter[1024];
354  /* get the item key to load the hive in */
355  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
356  /* initialize the "open file" dialog */
358  /* build the "All Files" filter up */
359  filter.DisplayID = IDS_FLT_ALLFILES;
360  filter.FilterID = IDS_FLT_ALLFILES_FLT;
363  /* load and set the caption and flags for dialog */
364  LoadStringW(hInst, IDS_LOAD_HIVE, Caption, ARRAY_SIZE(Caption));
365  ofn.lpstrTitle = Caption;
367  /* ofn.lCustData = ;*/
368  /* now load the hive */
369  if (GetOpenFileName(&ofn))
370  {
373  {
374  LONG regLoadResult;
375 
376  /* Enable the 'restore' privilege, load the hive, disable the privilege */
378  regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
380 
381  if(regLoadResult == ERROR_SUCCESS)
382  {
383  /* refresh tree and list views */
385  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
386  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
387  }
388  else
389  {
390  ErrorMessageBox(hWnd, Caption, regLoadResult);
391  return FALSE;
392  }
393  }
394  }
395  else
396  {
398  }
399  return TRUE;
400 }
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
HWND hTreeWnd
Definition: main.h:63
HWND hListWnd
Definition: main.h:64
HWND hWnd
Definition: settings.c:17
OPENFILENAME ofn
Definition: main.cpp:37
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetOpenFileName
Definition: commdlg.h:665
#define IDS_FLT_ALLFILES
Definition: resource.h:169
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:315
LONG_PTR LPARAM
Definition: windef.h:208
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
#define IDD_LOADHIVE
Definition: resource.h:262
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:291
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:191
#define IDS_LOAD_HIVE
Definition: resource.h:143
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:671
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:243
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:170
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define ARRAY_SIZE(a)
Definition: main.h:24
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:289
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define NULL
Definition: types.h:112
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:311
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:258
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
LONG WINAPI RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
Definition: reg.c:3102
DWORD Flags
Definition: commdlg.h:342

Referenced by _CmdWndProc().

◆ LoadHive_KeyNameInHookProc()

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

Definition at line 291 of file framewnd.c.

292 {
293  static LPWSTR sKey = NULL;
294  switch(uMsg)
295  {
296  case WM_INITDIALOG:
297  sKey = (LPWSTR)lParam;
298  break;
299  case WM_COMMAND:
300  switch(LOWORD(wParam))
301  {
302  case IDOK:
304  return EndDialog(hWndDlg, -1);
305  else
306  return EndDialog(hWndDlg, 0);
307  case IDCANCEL:
308  return EndDialog(hWndDlg, 0);
309  }
310  break;
311  }
312  return FALSE;
313 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define IDOK
Definition: winuser.h:824
#define IDC_EDIT_KEY
Definition: resource.h:263
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define WM_COMMAND
Definition: winuser.h:1730
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:289
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by LoadHive().

◆ OnEnterMenuLoop()

static void OnEnterMenuLoop ( HWND  hWnd)
static

Definition at line 117 of file framewnd.c.

118 {
119  int nParts;
121 
122  /* Update the status bar pane sizes */
123  nParts = -1;
124  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
125  bInMenuLoop = TRUE;
127 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
HWND hWnd
Definition: settings.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define L(x)
Definition: ntvdm.h:50
LONG_PTR LPARAM
Definition: windef.h:208
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1942
static BOOL bInMenuLoop
Definition: framewnd.c:35
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1954

Referenced by FrameWndProc().

◆ OnExitMenuLoop()

static void OnExitMenuLoop ( HWND  hWnd)
static

Definition at line 129 of file framewnd.c.

130 {
131  bInMenuLoop = FALSE;
132  /* Update the status bar pane sizes*/
134  UpdateStatusBar();
135 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:161
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
void UpdateStatusBar(void)
Definition: framewnd.c:173
#define FALSE
Definition: types.h:117
static BOOL bInMenuLoop
Definition: framewnd.c:35

Referenced by FrameWndProc().

◆ OnInitMenu()

static void OnInitMenu ( HWND  hWnd)
static

Definition at line 65 of file framewnd.c.

66 {
67  LONG lResult;
68  HKEY hKey = NULL;
69  DWORD dwIndex, cbValueName, cbValueData, dwType;
70  WCHAR szValueName[256];
71  BYTE abValueData[256];
72  static int s_nFavoriteMenuSubPos = -1;
73  HMENU hMenu;
74  BOOL bDisplayedAny = FALSE;
75 
76  /* Find Favorites menu and clear it out */
78  if (!hMenu)
79  goto done;
80  if (s_nFavoriteMenuSubPos < 0)
81  {
82  s_nFavoriteMenuSubPos = GetMenuItemCount(hMenu);
83  }
84  else
85  {
86  while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION)) ;
87  }
88 
90  if (lResult != ERROR_SUCCESS)
91  goto done;
92 
93  dwIndex = 0;
94  do
95  {
96  cbValueName = ARRAY_SIZE(szValueName);
97  cbValueData = sizeof(abValueData);
98  lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
99  if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
100  {
101  if (!bDisplayedAny)
102  {
103  AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
104  bDisplayedAny = TRUE;
105  }
106  AppendMenu(hMenu, 0, ID_FAVORITES_MIN + GetMenuItemCount(hMenu), szValueName);
107  }
108  dwIndex++;
109  }
110  while(lResult == ERROR_SUCCESS);
111 
112 done:
113  if (hKey)
114  RegCloseKey(hKey);
115 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define MF_BYPOSITION
Definition: winuser.h:203
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
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:2853
#define MF_SEPARATOR
Definition: winuser.h:137
#define AppendMenu
Definition: winuser.h:5721
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ID_FAVORITES_MIN
Definition: resource.h:294
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
unsigned char BYTE
Definition: xxhash.c:193
FxAutoRegKey hKey
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define NULL
Definition: types.h:112
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

Referenced by FrameWndProc().

◆ OnMenuSelect()

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

Definition at line 137 of file framewnd.c.

138 {
139  WCHAR str[100];
140 
141  wcscpy(str, L"");
142  if (nFlags & MF_POPUP)
143  {
144  if (hSysMenu != GetMenu(hWnd))
145  {
146  if (nItemID == 2) nItemID = 5;
147  }
148  }
149  if (LoadStringW(hInst, nItemID, str, 100))
150  {
151  /* load appropriate string*/
152  LPWSTR lpsz = str;
153  /* first newline terminates actual string*/
154  lpsz = wcschr(lpsz, L'\n');
155  if (lpsz != NULL)
156  *lpsz = L'\0';
157  }
159 }
HWND hWnd
Definition: settings.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1942
#define MF_POPUP
Definition: winuser.h:136
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HMENU WINAPI GetMenu(_In_ HWND)

Referenced by FrameWndProc().

◆ PrintRegistryHive()

BOOL PrintRegistryHive ( HWND  hWnd,
LPWSTR  path 
)

Definition at line 690 of file framewnd.c.

691 {
692 #if 1
693  PRINTDLG pd;
695 
696  ZeroMemory(&pd, sizeof(PRINTDLG));
697  pd.lStructSize = sizeof(PRINTDLG);
698  pd.hwndOwner = hWnd;
699  pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/
700  pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/
702  pd.nCopies = 1;
703  pd.nFromPage = 0xFFFF;
704  pd.nToPage = 0xFFFF;
705  pd.nMinPage = 1;
706  pd.nMaxPage = 0xFFFF;
707  if (PrintDlg(&pd))
708  {
709  /* GDI calls to render output. */
710  DeleteDC(pd.hDC); /* Delete DC when done.*/
711  }
712 #else
713  HRESULT hResult;
714  PRINTDLGEX pd;
715 
716  hResult = PrintDlgEx(&pd);
717  if (hResult == S_OK)
718  {
719  switch (pd.dwResultAction)
720  {
721  case PD_RESULT_APPLY:
722  /*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. */
723  break;
724  case PD_RESULT_CANCEL:
725  /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
726  break;
727  case PD_RESULT_PRINT:
728  /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
729  break;
730  default:
731  break;
732  }
733  }
734  else
735  {
736  switch (hResult)
737  {
738  case E_OUTOFMEMORY:
739  /*Insufficient memory. */
740  break;
741  case E_INVALIDARG:
742  /* One or more arguments are invalid. */
743  break;
744  case E_POINTER:
745  /*Invalid pointer. */
746  break;
747  case E_HANDLE:
748  /*Invalid handle. */
749  break;
750  case E_FAIL:
751  /*Unspecified error. */
752  break;
753  default:
754  break;
755  }
756  return FALSE;
757  }
758 #endif
759  return TRUE;
760 }
WORD nMaxPage
Definition: commdlg.h:474
#define E_HANDLE
Definition: winerror.h:2850
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
HWND hWnd
Definition: settings.c:17
#define ZeroMemory
Definition: winbase.h:1670
WORD nCopies
Definition: commdlg.h:475
#define E_FAIL
Definition: ddrawi.h:102
WORD nMinPage
Definition: commdlg.h:473
#define PrintDlg
Definition: commdlg.h:668
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
#define E_INVALIDARG
Definition: ddrawi.h:101
WORD nFromPage
Definition: commdlg.h:471
#define PD_RETURNDC
Definition: commdlg.h:155
LONG HRESULT
Definition: typedefs.h:79
#define PD_RESULT_PRINT
Definition: commdlg.h:202
HGLOBAL hDevMode
Definition: commdlg.h:467
#define PD_RESULT_APPLY
Definition: commdlg.h:203
HWND hwndOwner
Definition: commdlg.h:466
#define S_OK
Definition: intsafe.h:52
BOOL WINAPI DeleteDC(_In_ HDC)
HGLOBAL hDevNames
Definition: commdlg.h:468
#define NULL
Definition: types.h:112
#define PD_RESULT_CANCEL
Definition: commdlg.h:201
DWORD lStructSize
Definition: commdlg.h:465
WORD nToPage
Definition: commdlg.h:472
PRINTDLGA PRINTDLG
Definition: commdlg.h:660
DWORD Flags
Definition: commdlg.h:470
#define E_POINTER
Definition: winerror.h:2365
HDC hDC
Definition: commdlg.h:469

Referenced by _CmdWndProc().

◆ resize_frame_client()

static void resize_frame_client ( HWND  hWnd)
static

Definition at line 55 of file framewnd.c.

56 {
57  RECT rect;
58 
61 }
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:42
HWND hWnd
Definition: settings.c:17
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by FrameWndProc(), and toggle_child().

◆ resize_frame_rect()

static void resize_frame_rect ( HWND  hWnd,
PRECT  prect 
)
static

Definition at line 42 of file framewnd.c.

43 {
45  {
46  RECT rt;
47 
50  prect->bottom -= rt.bottom - rt.top;
51  }
52  MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
53 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:161
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HWND hWnd
Definition: main.h:62
HWND hStatusBar
Definition: main.cpp:35
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by resize_frame_client().

◆ SetupStatusBar()

void SetupStatusBar ( HWND  hWnd,
BOOL  bResize 
)

Definition at line 161 of file framewnd.c.

162 {
163  RECT rc;
164  int nParts;
165  GetClientRect(hWnd, &rc);
166  nParts = rc.right;
167  /* nParts = -1;*/
168  if (bResize)
170  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
171 }
HWND hWnd
Definition: settings.c:17
LONG right
Definition: windef.h:308
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SIZE
Definition: winuser.h:1601
HWND hStatusBar
Definition: main.cpp:35
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1954

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

◆ toggle_child()

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

Definition at line 181 of file framewnd.c.

182 {
183  BOOL vis = IsWindowVisible(hchild);
184  HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
185 
187  ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
189 }
#define MF_BYCOMMAND
Definition: winuser.h:202
Definition: ftp_var.h:139
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:55
#define SW_HIDE
Definition: winuser.h:762
HWND hWnd
Definition: settings.c:17
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SW_SHOW
Definition: winuser.h:769
#define MF_CHECKED
Definition: winuser.h:132
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_VIEW_MENU
Definition: resource.h:25
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HMENU hMenuFrame
Definition: main.c:37
BOOL WINAPI IsWindowVisible(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by _CmdWndProc().

◆ UnloadHive()

static BOOL UnloadHive ( HWND  hWnd)
static

Definition at line 402 of file framewnd.c.

403 {
404  WCHAR Caption[128];
405  LPCWSTR pszKeyPath;
406  HKEY hRootKey;
407  LONG regUnloadResult;
408 
409  /* get the item key to unload */
410  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
411  /* load and set the caption and flags for dialog */
412  LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, ARRAY_SIZE(Caption));
413 
414  /* Enable the 'restore' privilege, unload the hive, disable the privilege */
416  regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
418 
419  if(regUnloadResult == ERROR_SUCCESS)
420  {
421  /* refresh tree and list views */
423  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
424  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
425  }
426  else
427  {
428  ErrorMessageBox(hWnd, Caption, regUnloadResult);
429  return FALSE;
430  }
431  return TRUE;
432 }
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode,...)
Definition: error.c:24
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
HWND hTreeWnd
Definition: main.h:63
HWND hListWnd
Definition: main.h:64
HWND hWnd
Definition: settings.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:315
#define IDS_UNLOAD_HIVE
Definition: resource.h:144
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
Definition: reg.c:5096
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:671
HINSTANCE hInst
Definition: dxdiag.c:13
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:311

Referenced by _CmdWndProc().

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 173 of file framewnd.c.

174 {
175  HKEY hKeyRoot;
176  LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
177 
178  SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
179 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HWND hTreeWnd
Definition: main.h:63
LONG_PTR LPARAM
Definition: windef.h:208
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1942
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by OnExitMenuLoop().

Variable Documentation

◆ bInMenuLoop

BOOL bInMenuLoop = FALSE
static

Definition at line 35 of file framewnd.c.

Referenced by OnEnterMenuLoop(), and OnExitMenuLoop().

◆ FileNameBuffer

◆ FileTitleBuffer

WCHAR FileTitleBuffer[_MAX_PATH]

Definition at line 234 of file framewnd.c.

Referenced by InitOpenFileName().

◆ s_szFavoritesRegKey

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

Definition at line 33 of file framewnd.c.

Referenced by ChooseFavorite(), and OnInitMenu().

◆ Suggestions

WCHAR Suggestions[256]

Definition at line 27 of file childwnd.c.

Referenced by _CmdWndProc(), and ChildWndProc().