ReactOS  0.4.12-dev-51-ge94618b
main.c File Reference
#include "regedit.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define MAX_LOADSTRING   100
 

Functions

BOOL ProcessCmdLine (LPWSTR lpCmdLine)
 
BOOL InitInstance (HINSTANCE hInstance, int nCmdShow)
 
void DestroyMainMenu ()
 
void ExitInstance (HINSTANCE hInstance)
 
BOOL TranslateChildTabMessage (PMSG msg)
 
int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 

Variables

HINSTANCE hInst
 
HWND hFrameWnd
 
HWND hStatusBar
 
HMENU hMenuFrame
 
HMENU hPopupMenus = 0
 
UINT nClipboardFormat
 
LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT"
 
WCHAR szTitle [MAX_LOADSTRING]
 
WCHAR szFrameClass [MAX_LOADSTRING]
 
WCHAR szChildClass [MAX_LOADSTRING]
 

Macro Definition Documentation

◆ MAX_LOADSTRING

#define MAX_LOADSTRING   100

Definition at line 37 of file main.c.

Referenced by WinMain().

Function Documentation

◆ DestroyMainMenu()

void DestroyMainMenu ( void  )

Definition at line 157 of file main.c.

Referenced by ChildWndProc().

158 {
160 }
BOOL WINAPI DestroyMenu(_In_ HMENU)
HMENU hMenuFrame
Definition: main.c:32

◆ ExitInstance()

void ExitInstance ( HINSTANCE  hInstance)

Definition at line 164 of file main.c.

Referenced by WinMain(), and wWinMain().

165 {
166  UnregisterHexEditorClass(hInstance);
167 
169  UnloadAclUiDll();
170 }
BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:90
HMENU hPopupMenus
Definition: main.c:33
BOOL WINAPI DestroyMenu(_In_ HMENU)
VOID UnloadAclUiDll(VOID)
Definition: security.c:830

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 56 of file main.c.

Referenced by WinMain(), and wWinMain().

57 {
58  BOOL AclUiAvailable;
59  HMENU hEditMenu;
60 
61  WNDCLASSEXW wcFrame;
62  WNDCLASSEXW wcChild;
63  ATOM hFrameWndClass;
64 
65  ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
66  wcFrame.cbSize = sizeof(WNDCLASSEXW);
67  wcFrame.lpfnWndProc = FrameWndProc;
68  wcFrame.hInstance = hInstance;
69  wcFrame.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
70  wcFrame.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
73  wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
74  wcFrame.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
75  wcFrame.lpszClassName = szFrameClass;
76 
77  hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
78 
79  ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
80  wcChild.cbSize = sizeof(WNDCLASSEXW);
81  wcChild.lpfnWndProc = ChildWndProc;
82  wcChild.cbWndExtra = sizeof(HANDLE);
83  wcChild.hInstance = hInstance;
84  wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
85  wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
86  wcChild.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
87  wcChild.lpszClassName = szChildClass;
88  wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
91 
92  RegisterClassExW(&wcChild); /* register child windows class */
93 
94  RegisterHexEditorClass(hInstance);
95 
98 
99  /* Initialize the Windows Common Controls DLL */
100  // TODO: Replace this call by InitCommonControlsEx(_something_)
102 
103  hEditMenu = GetSubMenu(hMenuFrame, 1);
104 
105  AclUiAvailable = InitializeAclUiDll();
106  if(!AclUiAvailable)
107  {
108  /* hide the Edit/Permissions... menu entry */
109  if(hEditMenu != NULL)
110  {
112  /* remove the separator after the menu item */
113  RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
114  }
115  }
116 
117  if(hEditMenu != NULL)
119 
121  /* if (nClipboardFormat == 0) {
122  DWORD dwError = GetLastError();
123  } */
124 
128  NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
129 
130  if (!hFrameWnd)
131  {
132  return FALSE;
133  }
134 
135  /* Create the status bar */
138  if (hStatusBar)
139  {
140  /* Create the status bar panes */
143  }
144 
145  LoadSettings();
147  return TRUE;
148 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:385
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
static HICON
Definition: imagelist.c:84
#define IDI_REGEDIT
Definition: resource.h:35
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:167
#define TRUE
Definition: types.h:120
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define MF_BYCOMMAND
Definition: winuser.h:202
int cbWndExtra
Definition: winuser.h:3173
WORD ATOM
Definition: dimm.idl:113
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
BOOL InitializeAclUiDll(VOID)
Definition: security.c:811
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
BOOL WINAPI UpdateWindow(_In_ HWND)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ZeroMemory
Definition: winbase.h:1635
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hIcon
Definition: winuser.h:3175
#define WS_CHILD
Definition: pedump.c:617
struct _WNDCLASSEXW WNDCLASSEXW
#define WS_CLIPCHILDREN
Definition: pedump.c:619
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define ID_VIEW_STATUSBAR
Definition: resource.h:56
#define COLOR_3DFACE
Definition: winuser.h:919
void LoadSettings(void)
Definition: settings.c:53
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define MF_BYPOSITION
Definition: winuser.h:203
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
#define CW_USEDEFAULT
Definition: winuser.h:225
#define ID_EDIT_PERMISSIONS
Definition: resource.h:152
smooth NULL
Definition: ftsmooth.c:416
static HANDLE(WINAPI *pGetProcessHandleFromHwnd)(HWND)
HWND hStatusBar
Definition: main.c:31
LPCWSTR lpszClassName
Definition: winuser.h:3179
#define MF_CHECKED
Definition: winuser.h:132
#define UlongToPtr(ul)
Definition: basetsd.h:98
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
HMENU hPopupMenus
Definition: main.c:33
#define IDR_REGEDIT_MENU
Definition: resource.h:40
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
HINSTANCE hInstance
Definition: main.c:36
HINSTANCE hInstance
Definition: winuser.h:3174
#define SM_CXSMICON
Definition: winuser.h:1002
static const WCHAR L[]
Definition: oid.c:1087
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define ID_VIEW_MENU
Definition: resource.h:25
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
HCURSOR hCursor
Definition: winuser.h:3176
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define STATUS_WINDOW
Definition: main.h:26
WNDPROC lpfnWndProc
Definition: winuser.h:3171
ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:69
#define ID_EDIT_MODIFY
Definition: resource.h:64
HWND hFrameWnd
Definition: main.c:30
#define IDR_POPUP_MENUS
Definition: resource.h:47
HMENU hMenuFrame
Definition: main.c:32
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1304
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HICON hIconSm
Definition: winuser.h:3180
#define IDC_ARROW
Definition: winuser.h:682
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SBT_NOBORDERS
Definition: commctrl.h:1941
UINT nClipboardFormat
Definition: main.c:34
LPCWSTR strClipboardFormat
Definition: main.c:35

◆ ProcessCmdLine()

BOOL ProcessCmdLine ( LPWSTR  lpCmdLine)

Definition at line 281 of file regedit.c.

Referenced by wWinMain().

282 {
283  BOOL silent = FALSE;
285  LPWSTR s = lpCmdLine; /* command line pointer */
286  WCHAR ch = *s; /* current character */
287 
288  while (ch && ((ch == L'-') || (ch == L'/')))
289  {
290  WCHAR chu;
291  WCHAR ch2;
292 
293  s++;
294  ch = *s;
295  ch2 = *(s + 1);
296  chu = towupper(ch);
297  if (!ch2 || iswspace(ch2))
298  {
299  if (chu == L'S')
300  {
301  /* Silence dialogs */
302  silent = TRUE;
303  }
304  else if (chu == L'V')
305  {
306  /* Ignore this switch */
307  }
308  else
309  {
310  switch (chu)
311  {
312  case L'D':
313  action = ACTION_DELETE;
314  break;
315  case L'E':
316  action = ACTION_EXPORT;
317  break;
318  case L'?':
320  exit(3);
321  break;
322  default:
323  error_unknown_switch(chu, s);
324  break;
325  }
326  }
327  s++;
328  }
329  else
330  {
331  if (ch2 == L':')
332  {
333  switch (chu)
334  {
335  case L'L':
336  /* fall through */
337  case L'R':
338  s += 2;
339  while (*s && !iswspace(*s))
340  {
341  s++;
342  }
343  break;
344  default:
345  error_unknown_switch(chu, s);
346  break;
347  }
348  }
349  else
350  {
351  /* this is a file name, starting from '/' */
352  s--;
353  break;
354  }
355  }
356  /* skip spaces to the next parameter */
357  ch = *s;
358  while (ch && iswspace(ch))
359  {
360  s++;
361  ch = *s;
362  }
363  }
364 
365  if (*s && action == ACTION_UNDEF)
366  action = ACTION_ADD;
367 
368  if (action != ACTION_UNDEF)
369  return PerformRegAction(action, s, silent);
370  else
371  return FALSE;
372 }
#define TRUE
Definition: types.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
#define iswspace(_c)
Definition: ctype.h:669
#define MB_ICONINFORMATION
Definition: winuser.h:796
BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent)
Definition: regedit.c:135
static const WCHAR L[]
Definition: oid.c:1087
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble s
Definition: gl.h:2039
REGEDIT_ACTION
Definition: regedit.c:55
const WCHAR * action
Definition: action.c:7779
#define MB_OK
Definition: winuser.h:784
static void error_unknown_switch(WCHAR chu, LPWSTR s)
Definition: regedit.c:267
#define towupper(c)
Definition: wctype.h:99
void exit(int exitcode)
Definition: _exit.c:33
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ TranslateChildTabMessage()

BOOL TranslateChildTabMessage ( PMSG  msg)

Definition at line 172 of file main.c.

Referenced by wWinMain().

173 {
174  if (msg->message != WM_KEYDOWN) return FALSE;
175 
176  /* Allow Ctrl+A on address bar */
177  if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
178  (msg->message == WM_KEYDOWN) &&
179  (msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
180  {
181  SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
182  return TRUE;
183  }
184 
185  if (msg->wParam != VK_TAB) return FALSE;
186  if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
188  return TRUE;
189 }
#define ID_SWITCH_PANELS
Definition: resource.h:151
#define TRUE
Definition: types.h:120
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
WPARAM wParam
Definition: winuser.h:3069
#define VK_TAB
Definition: winuser.h:2153
#define WM_KEYDOWN
Definition: winuser.h:1691
SHORT WINAPI GetKeyState(_In_ int)
HWND hWnd
Definition: main.h:59
#define EM_SETSEL
Definition: winuser.h:1979
static const WCHAR L[]
Definition: oid.c:1087
#define WM_COMMAND
Definition: winuser.h:1716
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND hwnd
Definition: winuser.h:3067
#define VK_CONTROL
Definition: winuser.h:2157
HWND hAddressBarWnd
Definition: main.h:62
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT message
Definition: winuser.h:3068

◆ wWinMain()

int APIENTRY wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 191 of file main.c.

195 {
196  MSG msg;
197  HACCEL hAccel;
198 
199  UNREFERENCED_PARAMETER(hPrevInstance);
200 
201  /* Initialize global strings */
205 
206  if (ProcessCmdLine(lpCmdLine))
207  {
208  return 0;
209  }
210 
211  switch (GetUserDefaultUILanguage())
212  {
215  break;
216 
217  default:
218  break;
219  }
220  /* Store instance handle in our global variable */
221  hInst = hInstance;
222 
223  /* Perform application initialization */
224  if (!InitInstance(hInstance, nCmdShow))
225  {
226  return 0;
227  }
228  hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(ID_ACCEL));
229 
230  /* Main message loop */
231  while (GetMessageW(&msg, NULL, 0, 0))
232  {
233  if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg) &&
235  {
236  TranslateMessage(&msg);
237  DispatchMessageW(&msg);
238  }
239  }
240 
241  ExitInstance(hInstance);
242  return (int)msg.wParam;
243 }
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:561
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void ExitInstance(HINSTANCE hInstance)
Definition: main.c:164
#define LAYOUT_RTL
Definition: wingdi.h:1352
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define LANG_HEBREW
Definition: nls.h:67
HINSTANCE hInst
Definition: main.c:29
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HACCEL hAccel
Definition: main.c:47
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
#define COUNT_OF(a)
Definition: main.h:33
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
#define IDC_REGEDIT
Definition: resource.h:38
HINSTANCE hInstance
Definition: main.c:36
#define IDC_REGEDIT_FRAME
Definition: resource.h:39
BOOL TranslateChildTabMessage(PMSG msg)
Definition: main.c:172
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
BOOL ProcessCmdLine(LPWSTR lpCmdLine)
Definition: regedit.c:281
HWND hFrameWnd
Definition: main.c:30
#define IDS_APP_TITLE
Definition: resource.h:10
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define msg(x)
Definition: auth_time.c:54
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:56
#define ID_ACCEL
Definition: resources.h:13
#define MAKELANGID(p, s)
Definition: nls.h:15
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Variable Documentation

◆ hFrameWnd

◆ hInst

HINSTANCE hInst

Definition at line 29 of file main.c.

Referenced by DllMain(), and wWinMain().

◆ hMenuFrame

◆ hPopupMenus

HMENU hPopupMenus = 0

Definition at line 33 of file main.c.

Referenced by ChildWndProc(), ExitInstance(), HEXEDIT_WM_CONTEXTMENU(), and InitInstance().

◆ hStatusBar

HWND hStatusBar

Definition at line 31 of file main.c.

◆ nClipboardFormat

UINT nClipboardFormat

Definition at line 34 of file main.c.

Referenced by InitInstance().

◆ strClipboardFormat

LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT"

Definition at line 35 of file main.c.

Referenced by InitInstance().

◆ szChildClass

WCHAR szChildClass[MAX_LOADSTRING]

Definition at line 40 of file main.c.

Referenced by CBTProc(), FrameWndProc(), InitChildWindow(), InitInstance(), WinMain(), and wWinMain().

◆ szFrameClass

WCHAR szFrameClass[MAX_LOADSTRING]

Definition at line 39 of file main.c.

Referenced by InitInstance(), WinMain(), and wWinMain().

◆ szTitle