ReactOS  0.4.12-dev-57-g7050ac4
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 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.

Referenced by _CmdWndProc(), and OnInitMenu().

◆ LOADHIVE_KEYNAMELENGTH

#define LOADHIVE_KEYNAMELENGTH   128

Definition at line 295 of file framewnd.c.

Referenced by LoadHive(), and LoadHive_KeyNameInHookProc().

Typedef Documentation

◆ PFILTERPAIR

Function Documentation

◆ _CmdWndProc()

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

Definition at line 1029 of file framewnd.c.

Referenced by FrameWndProc().

1030 {
1031  HKEY hKeyRoot = 0, hKey = 0;
1032  LPCWSTR keyPath;
1033  LPCWSTR valueName;
1034  BOOL result = TRUE;
1035  REGSAM regsam = KEY_READ;
1036  int item;
1037 
1040 
1041  switch (LOWORD(wParam))
1042  {
1043  case ID_REGISTRY_LOADHIVE:
1044  LoadHive(hWnd);
1045  return TRUE;
1047  UnloadHive(hWnd);
1048  return TRUE;
1050  ImportRegistryFile(hWnd);
1051  return TRUE;
1053  ExportRegistryFile(hWnd);
1054  return TRUE;
1056  {
1057  IDsObjectPicker *ObjectPicker;
1058  WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1059  HRESULT hRet;
1060 
1061  hRet = CoInitialize(NULL);
1062  if (SUCCEEDED(hRet))
1063  {
1064  hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
1065  if (SUCCEEDED(hRet))
1066  {
1067  hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
1068  hWnd,
1069  szComputerName,
1070  COUNT_OF(szComputerName));
1071  if (hRet == S_OK)
1072  {
1073  /* FIXME - connect to the registry */
1074  }
1075 
1076  FreeObjectPicker(ObjectPicker);
1077  }
1078 
1079  CoUninitialize();
1080  }
1081 
1082  return TRUE;
1083  }
1085  return TRUE;
1086  case ID_REGISTRY_PRINT:
1087  PrintRegistryHive(hWnd, L"");
1088  return TRUE;
1089  case ID_REGISTRY_EXIT:
1090  DestroyWindow(hWnd);
1091  return TRUE;
1092  case ID_VIEW_STATUSBAR:
1094  return TRUE;
1095  case ID_HELP_HELPTOPICS:
1096  WinHelpW(hWnd, getAppName(), HELP_FINDER, 0);
1097  return TRUE;
1098  case ID_HELP_ABOUT:
1099  ShowAboutBox(hWnd);
1100  return TRUE;
1101  case ID_VIEW_SPLIT:
1102  {
1103  RECT rt;
1104  POINT pt, pts;
1106  pt.x = rt.left + g_pChildWnd->nSplitPos;
1107  pt.y = (rt.bottom / 2);
1108  pts = pt;
1109  if(ClientToScreen(g_pChildWnd->hWnd, &pts))
1110  {
1111  SetCursorPos(pts.x, pts.y);
1114  }
1115  return TRUE;
1116  }
1117  case ID_EDIT_RENAME:
1118  case ID_EDIT_MODIFY:
1119  case ID_EDIT_MODIFY_BIN:
1120  case ID_EDIT_DELETE:
1121  regsam |= KEY_WRITE;
1122  break;
1123  }
1124 
1125  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1126  valueName = GetValueName(g_pChildWnd->hListWnd, -1);
1127  if (keyPath)
1128  {
1129  if (RegOpenKeyExW(hKeyRoot, keyPath, 0, regsam, &hKey) != ERROR_SUCCESS)
1130  hKey = 0;
1131  }
1132 
1133  switch (LOWORD(wParam))
1134  {
1135  case ID_EDIT_MODIFY:
1136  if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
1137  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1138  break;
1139  case ID_EDIT_MODIFY_BIN:
1140  if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
1141  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1142  break;
1143  case ID_EDIT_RENAME:
1144  if (GetFocus() == g_pChildWnd->hListWnd)
1145  {
1147  {
1149  if(item > -1)
1150  {
1152  }
1153  }
1154  }
1155  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1156  {
1157  /* Get focused entry of treeview (if any) */
1159  if (hItem != NULL)
1161  }
1162  break;
1163  case ID_EDIT_DELETE:
1164  {
1165  if (GetFocus() == g_pChildWnd->hListWnd && hKey)
1166  {
1168  if(nSelected >= 1)
1169  {
1170  WCHAR msg[128], caption[128];
1171  LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
1172  LoadStringW(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, COUNT_OF(msg));
1173  if(MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
1174  {
1175  int ni, errs;
1176 
1177  item = -1;
1178  errs = 0;
1179  while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
1180  {
1181  valueName = GetValueName(g_pChildWnd->hListWnd, item);
1182  if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
1183  {
1184  errs++;
1185  }
1186  item = ni;
1187  }
1188 
1189  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1190  if(errs > 0)
1191  {
1192  LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
1194  MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
1195  }
1196  }
1197  }
1198  }
1199  else if (GetFocus() == g_pChildWnd->hTreeWnd)
1200  {
1201  if (keyPath == NULL || *keyPath == UNICODE_NULL)
1202  {
1204  }
1205  else if (DeleteKey(hWnd, hKeyRoot, keyPath))
1206  {
1209  }
1210  }
1211  break;
1212  }
1214  CreateNewValue(hKeyRoot, keyPath, REG_SZ);
1215  break;
1217  CreateNewValue(hKeyRoot, keyPath, REG_BINARY);
1218  break;
1220  CreateNewValue(hKeyRoot, keyPath, REG_DWORD);
1221  break;
1223  CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ);
1224  break;
1226  CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ);
1227  break;
1228  case ID_EDIT_FIND:
1229  FindDialog(hWnd);
1230  break;
1231  case ID_EDIT_FINDNEXT:
1232  FindNext(hWnd);
1233  break;
1234  case ID_EDIT_COPYKEYNAME:
1235  CopyKeyName(hWnd, hKeyRoot, keyPath);
1236  break;
1237  case ID_EDIT_PERMISSIONS:
1238  RegKeyEditPermissions(hWnd, hKeyRoot, NULL, keyPath);
1239  break;
1241  /*PRINTDLG pd;*/
1242  /*PrintDlg(&pd);*/
1243  /*PAGESETUPDLG psd;*/
1244  /*PageSetupDlg(&psd);*/
1245  break;
1246  case ID_REGISTRY_OPENLOCAL:
1247  break;
1248 
1249  case ID_VIEW_REFRESH:
1251  keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
1252  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
1253  break;
1254  /*case ID_OPTIONS_TOOLBAR:*/
1255  /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
1256  /* break;*/
1257  case ID_EDIT_NEW_KEY:
1259  break;
1260  default:
1262  {
1263  HMENU hMenu;
1264  MENUITEMINFOW mii;
1265  WCHAR szFavorite[512];
1266 
1267  hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION);
1268 
1269  memset(&mii, 0, sizeof(mii));
1270  mii.cbSize = sizeof(mii);
1271  mii.fMask = MIIM_TYPE;
1272  mii.fType = MFT_STRING;
1273  mii.dwTypeData = szFavorite;
1274  mii.cch = COUNT_OF(szFavorite);
1275 
1276  if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
1277  {
1278  ChooseFavorite(szFavorite);
1279  }
1280  }
1281  else
1282  {
1283  result = FALSE;
1284  }
1285  break;
1286  }
1287 
1288  if(hKey)
1289  RegCloseKey(hKey);
1290  return result;
1291 }
#define IDC_SIZEWE
Definition: winuser.h:689
#define MB_ICONHAND
Definition: winuser.h:782
#define ID_REGISTRY_IMPORTREGISTRYFILE
Definition: resource.h:70
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
Definition: tftpd.h:59
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
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:47
long y
Definition: polytest.cpp:48
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:106
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
BOOL ExportRegistryFile(HWND hWnd)
Definition: framewnd.c:586
#define IDYES
Definition: winuser.h:829
#define ID_EDIT_COPYKEYNAME
Definition: resource.h:61
void ShowAboutBox(HWND hWnd)
Definition: about.c:25
long x
Definition: polytest.cpp:48
#define REG_BINARY
Definition: nt_native.h:1496
#define ID_EDIT_NEW_EXPANDABLESTRINGVALUE
Definition: resource.h:149
#define ID_FAVORITES_MAX
Definition: resource.h:296
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define pt(x, y)
Definition: drawing.c:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct netconfig_info ni
Definition: getnetconfig.c:158
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3471
HWND hTreeWnd
Definition: main.h:60
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define ID_EDIT_FIND
Definition: resource.h:62
HWND hListWnd
Definition: main.h:61
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPWSTR dwTypeData
Definition: winuser.h:3211
#define ID_EDIT_FINDNEXT
Definition: resource.h:63
#define LVNI_SELECTED
Definition: commctrl.h:2394
#define MB_ICONSTOP
Definition: winuser.h:797
BOOL FindNext(HWND hWnd)
Definition: find.c:631
LONG left
Definition: windef.h:296
#define IDS_QUERY_DELETE_MORE
Definition: resource.h:136
static HRESULT InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
Definition: framewnd.c:900
#define ID_HELP_HELPTOPICS
Definition: resource.h:76
static void ChooseFavorite(LPCWSTR pszFavorite)
Definition: framewnd.c:768
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:351
#define ID_EDIT_NEW_BINARYVALUE
Definition: resource.h:67
#define HELP_FINDER
Definition: winuser.h:2373
int nSplitPos
Definition: main.h:65
static VOID FreeObjectPicker(IN IDsObjectPicker *pDsObjectPicker)
Definition: framewnd.c:1017
#define ID_REGISTRY_EXIT
Definition: resource.h:53
#define ID_VIEW_STATUSBAR
Definition: resource.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2679
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
static BOOL UnloadHive(HWND hWnd)
Definition: framewnd.c:408
#define ID_EDIT_DELETE
Definition: resource.h:59
#define REG_MULTI_SZ
Definition: nt_native.h:1501
LPCWSTR GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
Definition: framewnd.c:790
#define ID_HELP_ABOUT
Definition: resource.h:77
#define ID_REGISTRY_CONNECTNETWORKREGISTRY
Definition: resource.h:72
#define ID_EDIT_PERMISSIONS
Definition: resource.h:152
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
#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:959
#define IDS_QUERY_DELETE_ONE
Definition: resource.h:135
#define ID_EDIT_RENAME
Definition: resource.h:60
BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:102
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCWSTR valueName, BOOL EditBin)
Definition: edit.c:1072
#define IDS_ERR_DELVAL_CAPTION
Definition: resource.h:138
#define GetMenuItemInfo
Definition: winuser.h:5654
#define KEY_WRITE
Definition: nt_native.h:1031
#define ID_VIEW_REFRESH
Definition: resource.h:58
#define COUNT_OF(a)
Definition: main.h:33
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3440
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:440
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
LONG HRESULT
Definition: typedefs.h:77
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:107
HWND hWnd
Definition: main.h:59
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
HWND hStatusBar
Definition: main.cpp:35
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY
Definition: resource.h:73
#define ID_FAVORITES_MIN
Definition: resource.h:295
#define ID_EDIT_NEW_KEY
Definition: resource.h:65
static const WCHAR L[]
Definition: oid.c:1087
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
#define ID_REGISTRY_OPENLOCAL
Definition: resource.h:104
#define MIIM_TYPE
Definition: winuser.h:720
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
#define ID_REGISTRY_EXPORTREGISTRYFILE
Definition: resource.h:71
void FindDialog(HWND hWnd)
Definition: find.c:813
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define ID_EDIT_NEW_DWORDVALUE
Definition: resource.h:68
BOOL WINAPI MessageBeep(_In_ UINT)
#define ID_EDIT_MODIFY
Definition: resource.h:64
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ID_EDIT_NEW_STRINGVALUE
Definition: resource.h:66
#define S_OK
Definition: intsafe.h:59
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL PrintRegistryHive(HWND hWnd, LPWSTR path)
Definition: framewnd.c:696
static ATOM item
Definition: dde.c:856
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2368
#define ID_VIEW_SPLIT
Definition: resource.h:57
#define ID_REGISTRY_PRINT
Definition: resource.h:74
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1994
#define ID_REGISTRY_PRINTERSETUP
Definition: resource.h:112
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:187
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:139
ACCESS_MASK REGSAM
Definition: winreg.h:69
LPCWSTR getAppName(void)
Definition: regedit.c:61
BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
Definition: treeview.c:571
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1900
HWND WINAPI GetFocus(void)
Definition: window.c:1860
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG bottom
Definition: windef.h:299
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:839
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:124
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:539
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:825
#define LOWORD(l)
Definition: pedump.c:82
#define ID_EDIT_NEW_MULTISTRINGVALUE
Definition: resource.h:148
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2510
#define IDS_QUERY_DELETE_CONFIRM
Definition: resource.h:137
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define REG_SZ
Definition: layer.c:22

◆ BuildFilterStrings()

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

Definition at line 249 of file framewnd.c.

Referenced by InitOpenFileName(), and LoadHive().

250 {
251  int i, c;
252 
253  c = 0;
254  for(i = 0; i < PairCount; i++)
255  {
256  c += LoadStringW(hInst, Pairs[i].DisplayID, &Filter[c], 255);
257  Filter[++c] = L'\0';
258  c += LoadStringW(hInst, Pairs[i].FilterID, &Filter[c], 255);
259  Filter[++c] = L'\0';
260  }
261  Filter[++c] = L'\0';
262 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
static const WCHAR L[]
Definition: oid.c:1087
HINSTANCE hInst
Definition: dxdiag.c:13
#define c
Definition: ke_i.h:80

◆ CheckCommDlgError()

static BOOL CheckCommDlgError ( HWND  hWnd)
static

Definition at line 197 of file framewnd.c.

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

198 {
199  DWORD dwErrorCode = CommDlgExtendedError();
201  switch (dwErrorCode)
202  {
203  case CDERR_DIALOGFAILURE:
204  break;
206  break;
207  case CDERR_NOHINSTANCE:
208  break;
210  break;
211  case CDERR_NOHOOK:
212  break;
214  break;
215  case CDERR_NOTEMPLATE:
216  break;
218  break;
219  case CDERR_STRUCTSIZE:
220  break;
222  break;
224  break;
226  break;
228  break;
230  break;
232  break;
233  default:
234  break;
235  }
236  return TRUE;
237 }
#define TRUE
Definition: types.h:120
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CDERR_NOHINSTANCE
Definition: cderr.h:9
#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:139
#define FNERR_INVALIDFILENAME
Definition: cderr.h:36

◆ ChooseFavorite()

static void ChooseFavorite ( LPCWSTR  pszFavorite)
static

Definition at line 768 of file framewnd.c.

Referenced by _CmdWndProc().

769 {
770  HKEY hKey = NULL;
771  WCHAR szFavoritePath[512];
772  DWORD cbData, dwType;
773 
775  goto done;
776 
777  cbData = sizeof(szFavoritePath);
778  memset(szFavoritePath, 0, sizeof(szFavoritePath));
779  if (RegQueryValueExW(hKey, pszFavorite, NULL, &dwType, (LPBYTE) szFavoritePath, &cbData) != ERROR_SUCCESS)
780  goto done;
781 
782  if (dwType == REG_SZ)
783  SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
784 
785 done:
786  if (hKey)
787  RegCloseKey(hKey);
788 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hTreeWnd
Definition: main.h:60
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:665
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define memset(x, y, z)
Definition: compat.h:39
#define REG_SZ
Definition: layer.c:22

◆ CopyKeyName()

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

Definition at line 790 of file framewnd.c.

Referenced by _CmdWndProc(), and ChildWnd_CmdWndProc().

791 {
792  BOOL bClipboardOpened = FALSE;
793  BOOL bSuccess = FALSE;
794  WCHAR szBuffer[512];
795  HGLOBAL hGlobal;
796  LPWSTR s;
797 
798  if (!OpenClipboard(hWnd))
799  goto done;
800  bClipboardOpened = TRUE;
801 
802  if (!EmptyClipboard())
803  goto done;
804 
805  if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
806  goto done;
807 
808  hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
809  if (!hGlobal)
810  goto done;
811 
812  s = GlobalLock(hGlobal);
813  wcscpy(s, szBuffer);
814  GlobalUnlock(hGlobal);
815 
817  bSuccess = TRUE;
818 
819 done:
820  if (bClipboardOpened)
821  CloseClipboard();
822  return bSuccess;
823 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
static BOOLEAN bSuccess
Definition: drive.cpp:419
#define CF_UNICODETEXT
Definition: constants.h:408
#define COUNT_OF(a)
Definition: main.h:33
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
unsigned int BOOL
Definition: ntddk_ex.h:94
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
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define GMEM_MOVEABLE
Definition: winbase.h:291
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

◆ CreateNewValue()

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

Definition at line 825 of file framewnd.c.

Referenced by _CmdWndProc().

826 {
827  WCHAR szNewValueFormat[128];
828  WCHAR szNewValue[128];
829  int iIndex = 1;
830  BYTE data[128];
831  DWORD dwExistingType, cbData;
832  LONG lResult;
833  HKEY hKey;
834  LVFINDINFO lvfi;
835 
836  if (RegOpenKeyExW(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE,
837  &hKey) != ERROR_SUCCESS)
838  return FALSE;
839 
840  LoadStringW(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat));
841 
842  do
843  {
844  wsprintf(szNewValue, szNewValueFormat, iIndex++);
845  cbData = sizeof(data);
846  lResult = RegQueryValueExW(hKey, szNewValue, NULL, &dwExistingType, data, &cbData);
847  }
848  while(lResult == ERROR_SUCCESS);
849 
850  switch(dwType)
851  {
852  case REG_DWORD:
853  cbData = sizeof(DWORD);
854  break;
855  case REG_SZ:
856  case REG_EXPAND_SZ:
857  cbData = sizeof(WCHAR);
858  break;
859  case REG_MULTI_SZ:
860  /*
861  * WARNING: An empty multi-string has only one null char.
862  * Indeed, multi-strings are built in the following form:
863  * str1\0str2\0...strN\0\0
864  * where each strI\0 is a null-terminated string, and it
865  * ends with a terminating empty string.
866  * Therefore an empty multi-string contains only the terminating
867  * empty string, that is, one null char.
868  */
869  cbData = sizeof(WCHAR);
870  break;
871  case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
872  cbData = sizeof(DWORDLONG); // == sizeof(DWORD) * 2;
873  break;
874  default:
875  cbData = 0;
876  break;
877  }
878  memset(data, 0, cbData);
879  lResult = RegSetValueExW(hKey, szNewValue, 0, dwType, data, cbData);
880  RegCloseKey(hKey);
881  if (lResult != ERROR_SUCCESS)
882  {
883  return FALSE;
884  }
885 
886  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
887 
888  /* locate the newly added value, and get ready to rename it */
889  memset(&lvfi, 0, sizeof(lvfi));
890  lvfi.flags = LVFI_STRING;
891  lvfi.psz = szNewValue;
892  iIndex = ListView_FindItem(g_pChildWnd->hListWnd, -1, &lvfi);
893  if (iIndex >= 0)
895 
896  return TRUE;
897 }
#define TRUE
Definition: types.h:120
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:47
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
HWND hListWnd
Definition: main.h:61
#define WCHAR
Definition: msvc.h:43
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
smooth NULL
Definition: ftsmooth.c:416
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:4917
#define COUNT_OF(a)
Definition: main.h:33
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
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:670
unsigned char BYTE
Definition: ntddk_ex.h:96
HINSTANCE hInst
Definition: dxdiag.c:13
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define LVFINDINFO
Definition: commctrl.h:2433
unsigned long long DWORDLONG
Definition: intsafe.h:99
#define LVFI_STRING
Definition: commctrl.h:2407
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2440
#define REG_QWORD
Definition: sdbapi.c:540
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define IDS_NEW_VALUE
Definition: resource.h:192
#define wsprintf
Definition: winuser.h:5731
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:539
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2510
#define REG_SZ
Definition: layer.c:22

◆ EnablePrivilege()

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

Definition at line 321 of file framewnd.c.

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

322 {
323  BOOL bRet = FALSE;
324  HANDLE hToken = NULL;
325 
328  &hToken))
329  {
331 
332  tp.PrivilegeCount = 1;
333  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
334 
335  if (LookupPrivilegeValueW(lpszSystemName,
336  lpszPrivilegeName,
337  &tp.Privileges[0].Luid))
338  {
339  bRet = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
340 
342  bRet = FALSE;
343  }
344 
345  CloseHandle(hToken);
346  }
347 
348  return bRet;
349 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
$ULONG PrivilegeCount
Definition: setypes.h:969
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2630
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:372
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:292
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
#define ERROR_NOT_ALL_ASSIGNED
Definition: winerror.h:782
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876

◆ ExportRegistryFile()

BOOL ExportRegistryFile ( HWND  hWnd)

Definition at line 586 of file framewnd.c.

Referenced by _CmdWndProc(), and ChildWnd_CmdWndProc().

587 {
588  BOOL bRet = FALSE;
590  WCHAR ExportKeyPath[_MAX_PATH] = {0};
591  WCHAR Caption[128], szTitle[512], szText[512];
592  HKEY hKeyRoot;
593  LPCWSTR pszKeyPath;
594 
595  /* Figure out which key path we are exporting */
596  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
597  GetKeyName(ExportKeyPath, COUNT_OF(ExportKeyPath), hKeyRoot, pszKeyPath);
598 
599  InitOpenFileName(hWnd, &ofn);
600  LoadStringW(hInst, IDS_EXPORT_REG_FILE, Caption, COUNT_OF(Caption));
601  ofn.lpstrTitle = Caption;
602 
603  /* Only set the path if a key (not the root node) is selected */
604  if (hKeyRoot != 0)
605  {
606  ofn.lCustData = (LPARAM) ExportKeyPath;
607  }
611  if (GetSaveFileName(&ofn))
612  {
613  switch (ofn.nFilterIndex)
614  {
615  case 2: /* Registry Hive Files */
616  {
617  LONG lResult;
618  HKEY hSubKey;
619 
620  /* Open the subkey */
621  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_READ, &hSubKey);
622  if (lResult == ERROR_SUCCESS)
623  {
624  /* Enable the 'backup' privilege, save the hive then disable the privilege */
626  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
627  if (lResult == ERROR_ALREADY_EXISTS)
628  {
629  /*
630  * We are here, that means that we already said "yes" to the confirmation dialog.
631  * So we absolutely want to replace the hive file.
632  */
633  if (DeleteFileW(ofn.lpstrFile))
634  {
635  /* Try again */
636  lResult = RegSaveKeyW(hSubKey, ofn.lpstrFile, NULL);
637  }
638  }
640 
641  if (lResult != ERROR_SUCCESS)
642  {
643  /*
644  * If we are here, it's because RegSaveKeyW has failed for any reason.
645  * The problem is that even if it has failed, it has created or
646  * replaced the exported hive file with a new empty file. We don't
647  * want to keep this file, so we delete it.
648  */
649  DeleteFileW(ofn.lpstrFile);
650  }
651 
652  /* Close the subkey */
653  RegCloseKey(hSubKey);
654  }
655 
656  /* Set the return value */
657  bRet = (lResult == ERROR_SUCCESS);
658 
659  /* Display error, if any */
660  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
661 
662  break;
663  }
664 
665  case 1: /* Windows Registry Editor Version 5.00 */
666  case 3: /* REGEDIT4 */
667  default: /* All files ==> use Windows Registry Editor Version 5.00 */
668  {
669  if (!export_registry_key(ofn.lpstrFile, ExportKeyPath,
670  (ofn.nFilterIndex == 3 ? REG_FORMAT_4
671  : REG_FORMAT_5)))
672  {
673  /* Error creating the file */
674  LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
675  LoadStringW(hInst, IDS_EXPORT_ERROR, szText, COUNT_OF(szText));
676  InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
677  bRet = FALSE;
678  }
679  else
680  {
681  bRet = TRUE;
682  }
683 
684  break;
685  }
686  }
687  }
688  else
689  {
690  CheckCommDlgError(hWnd);
691  }
692 
693  return bRet;
694 }
#define OFN_EXPLORER
Definition: commdlg.h:104
#define TRUE
Definition: types.h:120
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
LPARAM lCustData
Definition: commdlg.h:346
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SE_BACKUP_NAME
HWND hTreeWnd
Definition: main.h:60
OPENFILENAME ofn
Definition: main.cpp:37
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
static const WCHAR szText[]
Definition: dialog.c:139
long LONG
Definition: pedump.c:60
#define IDS_EXPORT_REG_FILE
Definition: resource.h:133
#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:532
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:321
smooth NULL
Definition: ftsmooth.c:416
#define IDD_EXPORTRANGE
Definition: resource.h:41
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define COUNT_OF(a)
Definition: main.h:33
LONG WINAPI RegSaveKeyW(HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: reg.c:4649
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_FORMAT_5
Definition: regproc.h:24
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:197
#define MB_ICONERROR
Definition: winuser.h:781
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define REG_FORMAT_4
Definition: regproc.h:25
#define MB_OK
Definition: winuser.h:784
BOOL export_registry_key(WCHAR *file_name, WCHAR *reg_key_name, DWORD format)
Definition: regproc.c:1310
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define IDS_EXPORT_ERROR
Definition: resource.h:198
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#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:264
#define LPARAM
Definition: msvc.h:38
DWORD Flags
Definition: commdlg.h:342
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588

◆ ExportRegistryFile_OFNHookProc()

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

Definition at line 532 of file framewnd.c.

Referenced by ExportRegistryFile().

533 {
534  HWND hwndExportAll;
535  HWND hwndExportBranch;
536  HWND hwndExportBranchText;
537  UINT_PTR iResult = 0;
538  OPENFILENAME *pOfn;
539  LPWSTR pszSelectedKey;
540  OFNOTIFY *pOfnNotify;
541 
543 
544  switch(uiMsg)
545  {
546  case WM_INITDIALOG:
547  pOfn = (OPENFILENAME *) lParam;
548  pszSelectedKey = (LPWSTR) pOfn->lCustData;
549 
550  hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
551  if (hwndExportAll)
552  SendMessageW(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
553 
554  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
555  if (hwndExportBranch)
556  SendMessageW(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
557 
558  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
559  if (hwndExportBranchText)
560  SetWindowTextW(hwndExportBranchText, pszSelectedKey);
561  break;
562 
563  case WM_NOTIFY:
564  if (((NMHDR *) lParam)->code == CDN_FILEOK)
565  {
566  pOfnNotify = (OFNOTIFY *) lParam;
567  pszSelectedKey = (LPWSTR) pOfnNotify->lpOFN->lCustData;
568 
569  hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
570  hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
571  if (hwndExportBranch && hwndExportBranchText
572  && (SendMessageW(hwndExportBranch, BM_GETCHECK, 0, 0) == BST_CHECKED))
573  {
574  GetWindowTextW(hwndExportBranchText, pszSelectedKey, _MAX_PATH);
575  }
576  else
577  {
578  pszSelectedKey[0] = L'\0';
579  }
580  }
581  break;
582  }
583  return iResult;
584 }
LPARAM lCustData
Definition: commdlg.h:346
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define IDC_EXPORT_ALL
Definition: resource.h:259
#define IDC_EXPORT_BRANCH
Definition: resource.h:260
WPARAM wParam
Definition: combotst.c:138
#define IDC_EXPORT_BRANCH_TEXT
Definition: resource.h:261
#define _MAX_PATH
Definition: utility.h:77
#define BM_GETCHECK
Definition: winuser.h:1879
LPOPENFILENAMEA lpOFN
Definition: commdlg.h:407
#define BM_SETCHECK
Definition: winuser.h:1882
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CDN_FILEOK
Definition: commdlg.h:38
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
static const WCHAR L[]
Definition: oid.c:1087
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
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:1715
LPARAM lParam
Definition: combotst.c:139
#define WM_NOTIFY
Definition: richedit.h:61

◆ FrameWndProc()

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

Definition at line 1304 of file framewnd.c.

Referenced by InitInstance().

1305 {
1306  switch (message)
1307  {
1308  case WM_CREATE:
1309  // For now, the Help dialog item is disabled because of lacking of HTML Help support
1313  hWnd, (HMENU)0, hInst, 0);
1314  break;
1315  case WM_COMMAND:
1316  if (!_CmdWndProc(hWnd, message, wParam, lParam))
1317  return DefWindowProcW(hWnd, message, wParam, lParam);
1318  break;
1319  case WM_ACTIVATE:
1320  if (LOWORD(hWnd) && g_pChildWnd)
1322  break;
1323  case WM_SIZE:
1324  resize_frame_client(hWnd);
1325  break;
1326  case WM_TIMER:
1327  break;
1328  case WM_INITMENU:
1329  OnInitMenu(hWnd);
1330  break;
1331  case WM_ENTERMENULOOP:
1332  OnEnterMenuLoop(hWnd);
1333  break;
1334  case WM_EXITMENULOOP:
1335  OnExitMenuLoop(hWnd);
1336  break;
1337  case WM_MENUSELECT:
1339  break;
1340  case WM_SYSCOLORCHANGE:
1341  /* Forward WM_SYSCOLORCHANGE to common controls */
1344  break;
1345  case WM_DESTROY:
1346  WinHelpW(hWnd, getAppName(), HELP_QUIT, 0);
1347  SaveSettings();
1348  PostQuitMessage(0);
1349  default:
1350  return DefWindowProcW(hWnd, message, wParam, lParam);
1351  }
1352  return 0;
1353 }
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
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:135
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:61
#define HELP_QUIT
Definition: winuser.h:2368
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:143
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_CHILD
Definition: pedump.c:617
#define ID_HELP_HELPTOPICS
Definition: resource.h:76
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void SaveSettings(void)
Definition: settings.c:113
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_ENTERMENULOOP
Definition: winuser.h:1780
#define WM_MENUSELECT
Definition: winuser.h:1723
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_EXITMENULOOP
Definition: winuser.h:1781
smooth NULL
Definition: ftsmooth.c:416
#define WM_DESTROY
Definition: winuser.h:1591
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:123
#define WM_SIZE
Definition: winuser.h:1593
HWND hWnd
Definition: main.h:59
#define WM_TIMER
Definition: winuser.h:1718
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1029
static void OnInitMenu(HWND hWnd)
Definition: framewnd.c:71
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:40
#define WM_COMMAND
Definition: winuser.h:1716
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_INITMENU
Definition: winuser.h:1721
#define WM_ACTIVATE
Definition: winuser.h:1594
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCWSTR getAppName(void)
Definition: regedit.c:61
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
#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)

◆ FreeObjectPicker()

static VOID FreeObjectPicker ( IN IDsObjectPicker *  pDsObjectPicker)
static

Definition at line 1017 of file framewnd.c.

Referenced by _CmdWndProc(), and SecurityPageProc().

1018 {
1019  pDsObjectPicker->lpVtbl->Release(pDsObjectPicker);
1020 }

◆ ImportRegistryFile()

static BOOL ImportRegistryFile ( HWND  hWnd)
static

Definition at line 440 of file framewnd.c.

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

441 {
442  BOOL bRet = FALSE;
444  WCHAR Caption[128], szTitle[512], szText[512];
445  HKEY hKeyRoot;
446  LPCWSTR pszKeyPath;
447 
448  /* Figure out in which key path we are importing */
449  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
450 
451  InitOpenFileName(hWnd, &ofn);
452  LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
453  ofn.lpstrTitle = Caption;
454  ofn.Flags |= OFN_ENABLESIZING;
455  /* ofn.lCustData = ;*/
456  if (GetOpenFileName(&ofn))
457  {
458  /* Look at the extension of the file to determine its type */
459  if (ofn.nFileExtension >= 1 &&
460  _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
461  {
462  /* Open the file */
463  FILE* fp = _wfopen(ofn.lpstrFile, L"r");
464 
465  /* Import it */
466  if (fp == NULL || !import_registry_file(fp))
467  {
468  /* Error opening the file */
469  LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
470  LoadStringW(hInst, IDS_IMPORT_ERROR, szText, COUNT_OF(szText));
471  InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
472  bRet = FALSE;
473  }
474  else
475  {
476  /* Show successful import */
477  LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
478  LoadStringW(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
479  InfoMessageBox(hWnd, MB_OK | MB_ICONINFORMATION, szTitle, szText, ofn.lpstrFile);
480  bRet = TRUE;
481  }
482 
483  /* Close the file */
484  if (fp) fclose(fp);
485  }
486  else /* Registry Hive Files */
487  {
490 
491  /* Display a confirmation message */
492  if (MessageBoxW(g_pChildWnd->hWnd, szText, szTitle, MB_ICONWARNING | MB_YESNO) == IDYES)
493  {
494  LONG lResult;
495  HKEY hSubKey;
496 
497  /* Open the subkey */
498  lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
499  if (lResult == ERROR_SUCCESS)
500  {
501  /* Enable the 'restore' privilege, restore the hive then disable the privilege */
503  lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
505 
506  /* Flush the subkey and close it */
507  RegFlushKey(hSubKey);
508  RegCloseKey(hSubKey);
509  }
510 
511  /* Set the return value */
512  bRet = (lResult == ERROR_SUCCESS);
513 
514  /* Display error, if any */
515  if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
516  }
517  }
518  }
519  else
520  {
521  CheckCommDlgError(hWnd);
522  }
523 
524  /* refresh tree and list views */
526  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
527  RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath);
528 
529  return bRet;
530 }
#define TRUE
Definition: types.h:120
#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
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hTreeWnd
Definition: main.h:60
#define IDS_QUERY_IMPORT_HIVE_MSG
Definition: resource.h:143
HWND hListWnd
Definition: main.h:61
OPENFILENAME ofn
Definition: main.cpp:37
#define IDS_QUERY_IMPORT_HIVE_CAPTION
Definition: resource.h:142
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2988
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR szText[]
Definition: dialog.c:139
#define IDS_IMPORT_REG_FILE
Definition: resource.h:132
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:321
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define KEY_WRITE
Definition: nt_native.h:1031
#define COUNT_OF(a)
Definition: main.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND hWnd
Definition: main.h:59
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:197
#define MB_ICONINFORMATION
Definition: winuser.h:796
static const WCHAR L[]
Definition: oid.c:1087
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
#define MB_ICONERROR
Definition: winuser.h:781
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define IDS_IMPORT_ERROR
Definition: resource.h:197
#define REG_FORCE_RESTORE
Definition: cmtypes.h:109
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define IDS_IMPORT_OK
Definition: resource.h:196
#define MB_OK
Definition: winuser.h:784
#define IDS_APP_TITLE
Definition: resource.h:10
LPCSTR lpstrTitle
Definition: commdlg.h:341
BOOL import_registry_file(FILE *reg_file)
Definition: regproc.c:1405
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:264
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD Flags
Definition: commdlg.h:342

◆ InitializeRemoteRegistryPicker()

static HRESULT InitializeRemoteRegistryPicker ( OUT IDsObjectPicker **  pDsObjectPicker)
static

Definition at line 900 of file framewnd.c.

Referenced by _CmdWndProc().

901 {
902  HRESULT hRet;
903 
904  *pDsObjectPicker = NULL;
905 
906  hRet = CoCreateInstance(&CLSID_DsObjectPicker,
907  NULL,
908  CLSCTX_INPROC_SERVER,
909  &IID_IDsObjectPicker,
910  (LPVOID*)pDsObjectPicker);
911  if (SUCCEEDED(hRet))
912  {
913  DSOP_INIT_INFO InitInfo;
914  static DSOP_SCOPE_INIT_INFO Scopes[] =
915  {
916  {
917  sizeof(DSOP_SCOPE_INIT_INFO),
922  0,
923  {
924  {
926  0,
927  0
928  },
930  },
931  NULL,
932  NULL,
933  S_OK
934  },
935  };
936 
937  InitInfo.cbSize = sizeof(InitInfo);
938  InitInfo.pwzTargetComputer = NULL;
939  InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
940  InitInfo.aDsScopeInfos = Scopes;
941  InitInfo.flOptions = 0;
942  InitInfo.cAttributesToFetch = 0;
943  InitInfo.apwzAttributeNames = NULL;
944 
945  hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
946  &InitInfo);
947 
948  if (FAILED(hRet))
949  {
950  /* delete the object picker in case initialization failed! */
951  (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
952  }
953  }
954 
955  return hRet;
956 }
#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
ULONG cbSize
Definition: objsel.h:109
smooth NULL
Definition: ftsmooth.c:416
struct _DSOP_SCOPE_INIT_INFO DSOP_SCOPE_INIT_INFO
#define COUNT_OF(a)
Definition: main.h:33
LONG HRESULT
Definition: typedefs.h:77
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:3237
#define DSOP_SCOPE_TYPE_WORKGROUP
Definition: objsel.h:128
#define S_OK
Definition: intsafe.h:59
#define DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
Definition: objsel.h:122
#define DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
Definition: objsel.h:127
#define DSOP_FILTER_COMPUTERS
Definition: objsel.h:41
#define DSOP_DOWNLEVEL_FILTER_COMPUTERS
Definition: objsel.h:54
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
Definition: objsel.h:129

◆ InitOpenFileName()

static BOOL InitOpenFileName ( HWND  hWnd,
OPENFILENAME pofn 
)
static

Definition at line 264 of file framewnd.c.

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

265 {
266  FILTERPAIR FilterPairs[4];
267  static WCHAR Filter[1024];
268 
269  memset(pofn, 0, sizeof(OPENFILENAME));
270  pofn->lStructSize = sizeof(OPENFILENAME);
271  pofn->hwndOwner = hWnd;
272  pofn->hInstance = hInst;
273 
274  /* create filter string */
275  FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
276  FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
277  FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
278  FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
279  FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
280  FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
281  FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
282  FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
283  BuildFilterStrings(Filter, FilterPairs, COUNT_OF(FilterPairs));
284 
285  pofn->lpstrFilter = Filter;
286  pofn->lpstrFile = FileNameBuffer;
287  pofn->nMaxFile = _MAX_PATH;
289  pofn->nMaxFileTitle = _MAX_PATH;
290  pofn->Flags = OFN_HIDEREADONLY;
291  pofn->lpstrDefExt = L"reg";
292  return TRUE;
293 }
#define TRUE
Definition: types.h:120
WCHAR FileTitleBuffer[_MAX_PATH]
Definition: framewnd.c:240
#define IDS_FLT_HIVFILES
Definition: resource.h:166
UINT FilterID
Definition: framewnd.c:245
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hWnd
Definition: settings.c:17
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nMaxFile
Definition: commdlg.h:337
UINT DisplayID
Definition: framewnd.c:244
#define IDS_FLT_ALLFILES
Definition: resource.h:170
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define _MAX_PATH
Definition: utility.h:77
HINSTANCE hInstance
Definition: commdlg.h:331
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define COUNT_OF(a)
Definition: main.h:33
DWORD lStructSize
Definition: commdlg.h:329
#define IDS_FLT_REGEDIT4_FLT
Definition: resource.h:169
static const WCHAR L[]
Definition: oid.c:1087
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:249
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:171
#define IDS_FLT_HIVFILES_FLT
Definition: resource.h:167
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDS_FLT_REGEDIT4
Definition: resource.h:168
LPSTR lpstrFile
Definition: commdlg.h:336
#define IDS_FLT_REGFILES_FLT
Definition: resource.h:165
LPCSTR lpstrFilter
Definition: commdlg.h:332
WCHAR FileNameBuffer[_MAX_PATH]
Definition: framewnd.c:239
#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:164

◆ InvokeRemoteRegistryPickerDialog()

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

Definition at line 959 of file framewnd.c.

Referenced by _CmdWndProc().

963 {
964  IDataObject *pdo = NULL;
965  HRESULT hRet;
966 
967  hRet = pDsObjectPicker->lpVtbl->InvokeDialog(pDsObjectPicker,
968  hwndParent,
969  &pdo);
970  if (hRet == S_OK)
971  {
972  STGMEDIUM stm;
973  FORMATETC fe;
974 
975  fe.cfFormat = (CLIPFORMAT) RegisterClipboardFormatW(CFSTR_DSOP_DS_SELECTION_LIST);
976  fe.ptd = NULL;
977  fe.dwAspect = DVASPECT_CONTENT;
978  fe.lindex = -1;
979  fe.tymed = TYMED_HGLOBAL;
980 
981  hRet = pdo->lpVtbl->GetData(pdo,
982  &fe,
983  &stm);
984  if (SUCCEEDED(hRet))
985  {
986  PDS_SELECTION_LIST SelectionList = (PDS_SELECTION_LIST)GlobalLock(stm.hGlobal);
987  if (SelectionList != NULL)
988  {
989  if (SelectionList->cItems == 1)
990  {
991  size_t nlen = wcslen(SelectionList->aDsSelection[0].pwzName);
992  if (nlen >= uSize)
993  {
994  nlen = uSize - 1;
995  }
996 
998  SelectionList->aDsSelection[0].pwzName,
999  nlen * sizeof(WCHAR));
1000 
1001  lpBuffer[nlen] = L'\0';
1002  }
1003 
1004  GlobalUnlock(stm.hGlobal);
1005  }
1006 
1007  ReleaseStgMedium(&stm);
1008  }
1009 
1010  pdo->lpVtbl->Release(pdo);
1011  }
1012 
1013  return hRet;
1014 }
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2024
struct _DS_SELECTION_LIST * PDS_SELECTION_LIST
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define CFSTR_DSOP_DS_SELECTION_LIST
Definition: objsel.h:27
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:163
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR L[]
Definition: oid.c:1087
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:59
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PWSTR pwzName
Definition: objsel.h:134
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ LoadHive()

static BOOL LoadHive ( HWND  hWnd)
static

Definition at line 351 of file framewnd.c.

Referenced by _CmdWndProc().

352 {
354  WCHAR Caption[128];
355  LPCWSTR pszKeyPath;
357  HKEY hRootKey;
358  WCHAR Filter[1024];
360  /* get the item key to load the hive in */
361  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
362  /* initialize the "open file" dialog */
363  InitOpenFileName(hWnd, &ofn);
364  /* build the "All Files" filter up */
365  filter.DisplayID = IDS_FLT_ALLFILES;
367  BuildFilterStrings(Filter, &filter, 1);
368  ofn.lpstrFilter = Filter;
369  /* load and set the caption and flags for dialog */
370  LoadStringW(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption));
371  ofn.lpstrTitle = Caption;
372  ofn.Flags |= OFN_ENABLESIZING;
373  /* ofn.lCustData = ;*/
374  /* now load the hive */
375  if (GetOpenFileName(&ofn))
376  {
379  {
380  LONG regLoadResult;
381 
382  /* Enable the 'restore' privilege, load the hive, disable the privilege */
384  regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile);
386 
387  if(regLoadResult == ERROR_SUCCESS)
388  {
389  /* refresh tree and list views */
391  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
392  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
393  }
394  else
395  {
396  ErrorMessageBox(hWnd, Caption, regLoadResult);
397  return FALSE;
398  }
399  }
400  }
401  else
402  {
403  CheckCommDlgError(hWnd);
404  }
405  return TRUE;
406 }
#define TRUE
Definition: types.h:120
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
UINT FilterID
Definition: framewnd.c:245
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
OPENFILENAME ofn
Definition: main.cpp:37
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
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
UINT DisplayID
Definition: framewnd.c:244
#define IDS_FLT_ALLFILES
Definition: resource.h:170
long LONG
Definition: pedump.c:60
LONG_PTR LPARAM
Definition: windef.h:208
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:321
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define IDD_LOADHIVE
Definition: resource.h:263
#define COUNT_OF(a)
Definition: main.h:33
static INT_PTR CALLBACK LoadHive_KeyNameInHookProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:297
static BOOL CheckCommDlgError(HWND hWnd)
Definition: framewnd.c:197
#define IDS_LOAD_HIVE
Definition: resource.h:145
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
void BuildFilterStrings(WCHAR *Filter, PFILTERPAIR Pairs, int PairCount)
Definition: framewnd.c:249
#define IDS_FLT_ALLFILES_FLT
Definition: resource.h:171
HINSTANCE hInst
Definition: dxdiag.c:13
LPSTR lpstrFile
Definition: commdlg.h:336
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:295
LPCSTR lpstrFilter
Definition: commdlg.h:332
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:306
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn)
Definition: framewnd.c:264
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:3116
DWORD Flags
Definition: commdlg.h:342

◆ LoadHive_KeyNameInHookProc()

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

Definition at line 297 of file framewnd.c.

Referenced by LoadHive().

298 {
299  static LPWSTR sKey = NULL;
300  switch(uMsg)
301  {
302  case WM_INITDIALOG:
303  sKey = (LPWSTR)lParam;
304  break;
305  case WM_COMMAND:
306  switch(LOWORD(wParam))
307  {
308  case IDOK:
310  return EndDialog(hWndDlg, -1);
311  else
312  return EndDialog(hWndDlg, 0);
313  case IDCANCEL:
314  return EndDialog(hWndDlg, 0);
315  }
316  break;
317  }
318  return FALSE;
319 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
#define IDOK
Definition: winuser.h:824
#define IDC_EDIT_KEY
Definition: resource.h:264
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define WM_COMMAND
Definition: winuser.h:1716
#define LOADHIVE_KEYNAMELENGTH
Definition: framewnd.c:295
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ OnEnterMenuLoop()

static void OnEnterMenuLoop ( HWND  hWnd)
static

Definition at line 123 of file framewnd.c.

Referenced by FrameWndProc().

124 {
125  int nParts;
127 
128  /* Update the status bar pane sizes */
129  nParts = -1;
130  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
131  bInMenuLoop = TRUE;
133 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UINT_PTR WPARAM
Definition: windef.h:207
LONG_PTR LPARAM
Definition: windef.h:208
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1912
static const WCHAR L[]
Definition: oid.c:1087
static BOOL bInMenuLoop
Definition: framewnd.c:35
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1924

◆ OnExitMenuLoop()

static void OnExitMenuLoop ( HWND  hWnd)
static

Definition at line 135 of file framewnd.c.

Referenced by FrameWndProc().

136 {
137  bInMenuLoop = FALSE;
138  /* Update the status bar pane sizes*/
139  SetupStatusBar(hWnd, TRUE);
140  UpdateStatusBar();
141 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:167
#define TRUE
Definition: types.h:120
void UpdateStatusBar(void)
Definition: framewnd.c:179
static BOOL bInMenuLoop
Definition: framewnd.c:35

◆ OnInitMenu()

static void OnInitMenu ( HWND  hWnd)
static

Definition at line 71 of file framewnd.c.

Referenced by FrameWndProc().

72 {
73  LONG lResult;
74  HKEY hKey = NULL;
75  DWORD dwIndex, cbValueName, cbValueData, dwType;
76  WCHAR szValueName[256];
77  BYTE abValueData[256];
78  static int s_nFavoriteMenuSubPos = -1;
79  HMENU hMenu;
80  BOOL bDisplayedAny = FALSE;
81 
82  /* Find Favorites menu and clear it out */
84  if (!hMenu)
85  goto done;
86  if (s_nFavoriteMenuSubPos < 0)
87  {
88  s_nFavoriteMenuSubPos = GetMenuItemCount(hMenu);
89  }
90  else
91  {
92  while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION)) ;
93  }
94 
96  if (lResult != ERROR_SUCCESS)
97  goto done;
98 
99  dwIndex = 0;
100  do
101  {
102  cbValueName = COUNT_OF(szValueName);
103  cbValueData = sizeof(abValueData);
104  lResult = RegEnumValueW(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData);
105  if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ))
106  {
107  if (!bDisplayedAny)
108  {
109  AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
110  bDisplayedAny = TRUE;
111  }
112  AppendMenu(hMenu, 0, ID_FAVORITES_MIN + GetMenuItemCount(hMenu), szValueName);
113  }
114  dwIndex++;
115  }
116  while(lResult == ERROR_SUCCESS);
117 
118 done:
119  if (hKey)
120  RegCloseKey(hKey);
121 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static WCHAR s_szFavoritesRegKey[]
Definition: framewnd.c:33
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:3311
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:2867
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
#define COUNT_OF(a)
Definition: main.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
#define AppendMenu
Definition: winuser.h:5597
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ID_FAVORITES_MIN
Definition: resource.h:295
#define FAVORITES_MENU_POSITION
Definition: framewnd.c:31
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
unsigned char BYTE
Definition: ntddk_ex.h:96
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
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 REG_SZ
Definition: layer.c:22

◆ OnMenuSelect()

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

Definition at line 143 of file framewnd.c.

Referenced by FrameWndProc().

144 {
145  WCHAR str[100];
146 
147  wcscpy(str, L"");
148  if (nFlags & MF_POPUP)
149  {
150  if (hSysMenu != GetMenu(hWnd))
151  {
152  if (nItemID == 2) nItemID = 5;
153  }
154  }
155  if (LoadStringW(hInst, nItemID, str, 100))
156  {
157  /* load appropriate string*/
158  LPWSTR lpsz = str;
159  /* first newline terminates actual string*/
160  lpsz = wcschr(lpsz, L'\n');
161  if (lpsz != NULL)
162  *lpsz = L'\0';
163  }
165 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LONG_PTR LPARAM
Definition: windef.h:208
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1912
#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)
static const WCHAR L[]
Definition: oid.c:1087
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HMENU WINAPI GetMenu(_In_ HWND)

◆ PrintRegistryHive()

BOOL PrintRegistryHive ( HWND  hWnd,
LPWSTR  path 
)

Definition at line 696 of file framewnd.c.

Referenced by _CmdWndProc().

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

◆ resize_frame_client()

static void resize_frame_client ( HWND  hWnd)
static

Definition at line 61 of file framewnd.c.

Referenced by FrameWndProc(), and toggle_child().

62 {
63  RECT rect;
64 
65  GetClientRect(hWnd, &rect);
66  resize_frame_rect(hWnd, &rect);
67 }
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:41
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

◆ resize_frame_rect()

static void resize_frame_rect ( HWND  hWnd,
PRECT  prect 
)
static

Definition at line 41 of file framewnd.c.

Referenced by resize_frame_client().

42 {
43  RECT rt;
44  /*
45  if (IsWindowVisible(hToolBar)) {
46  SendMessageW(hToolBar, WM_SIZE, 0, 0);
47  GetClientRect(hToolBar, &rt);
48  prect->top = rt.bottom+3;
49  prect->bottom -= rt.bottom+3;
50  }
51  */
53  {
54  SetupStatusBar(hWnd, TRUE);
56  prect->bottom -= rt.bottom - rt.top;
57  }
58  MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
59 }
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:167
#define TRUE
Definition: types.h:120
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
HWND hWnd
Definition: main.h:59
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:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

◆ SetupStatusBar()

void SetupStatusBar ( HWND  hWnd,
BOOL  bResize 
)

Definition at line 167 of file framewnd.c.

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

168 {
169  RECT rc;
170  int nParts;
171  GetClientRect(hWnd, &rc);
172  nParts = rc.right;
173  /* nParts = -1;*/
174  if (bResize)
176  SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
177 }
LONG right
Definition: windef.h:298
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SIZE
Definition: winuser.h:1593
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:1924

◆ toggle_child()

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

Definition at line 187 of file framewnd.c.

Referenced by _CmdWndProc().

188 {
189  BOOL vis = IsWindowVisible(hchild);
190  HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
191 
193  ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
194  resize_frame_client(hWnd);
195 }
#define MF_BYCOMMAND
Definition: winuser.h:202
Definition: ftp_var.h:139
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:61
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:769
#define MF_CHECKED
Definition: winuser.h:132
unsigned int BOOL
Definition: ntddk_ex.h:94
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:32
BOOL WINAPI IsWindowVisible(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ UnloadHive()

static BOOL UnloadHive ( HWND  hWnd)
static

Definition at line 408 of file framewnd.c.

Referenced by _CmdWndProc().

409 {
410  WCHAR Caption[128];
411  LPCWSTR pszKeyPath;
412  HKEY hRootKey;
413  LONG regUnloadResult;
414 
415  /* get the item key to unload */
416  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
417  /* load and set the caption and flags for dialog */
418  LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
419 
420  /* Enable the 'restore' privilege, unload the hive, disable the privilege */
422  regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
424 
425  if(regUnloadResult == ERROR_SUCCESS)
426  {
427  /* refresh tree and list views */
429  pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
430  RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
431  }
432  else
433  {
434  ErrorMessageBox(hWnd, Caption, regUnloadResult);
435  return FALSE;
436  }
437  return TRUE;
438 }
#define TRUE
Definition: types.h:120
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hTreeWnd
Definition: main.h:60
HWND hListWnd
Definition: main.h:61
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
long LONG
Definition: pedump.c:60
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, LPCWSTR lpszSystemName, BOOL bEnablePrivilege)
Definition: framewnd.c:321
#define IDS_UNLOAD_HIVE
Definition: resource.h:146
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
#define COUNT_OF(a)
Definition: main.h:33
LONG WINAPI RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
Definition: reg.c:5114
#define SE_RESTORE_NAME
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
Definition: listview.c:670
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL RefreshTreeView(HWND hWndTV)
Definition: treeview.c:306

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 179 of file framewnd.c.

Referenced by OnExitMenuLoop().

180 {
181  HKEY hKeyRoot;
182  LPCWSTR pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
183 
184  SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)pszKeyPath);
185 }
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
HWND hTreeWnd
Definition: main.h:60
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LONG_PTR LPARAM
Definition: windef.h:208
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:83
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXTW
Definition: commctrl.h:1912
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

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 240 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().