ReactOS 0.4.15-dev-8021-g7ce96fd
RegistryExplorer.cpp File Reference
#include "ph.h"
#include "RegistryExplorer.h"
#include "Console.h"
#include "RegistryKey.h"
#include "RegistryTree.h"
#include "SecurityDescriptor.h"
#include "ArgumentParser.h"
#include "ShellCommandsLinkedList.h"
#include "ShellCommandExit.h"
#include "ShellCommandVersion.h"
#include "ShellCommandHelp.h"
#include "ShellCommandDir.h"
#include "ShellCommandChangeKey.h"
#include "ShellCommandValue.h"
#include "ShellCommandOwner.h"
#include "ShellCommandDACL.h"
#include "ShellCommandSACL.h"
#include "ShellCommandConnect.h"
#include "ShellCommandNewKey.h"
#include "ShellCommandDeleteKey.h"
#include "ShellCommandSetValue.h"
#include "ShellCommandDeleteValue.h"
#include "Prompt.h"
#include "Settings.h"
Include dependency graph for RegistryExplorer.cpp:

Go to the source code of this file.

Macros

#define INPUT_BUFFER_SIZE   1024
 

Functions

BOOL WINAPI HandlerRoutine (DWORD dwCtrlType)
 
int main ()
 

Variables

TCHAR pchCurrentKey [PROMPT_BUFFER_SIZE]
 
CRegistryTree Tree
 
CConsole Console
 
BOOL blnCommandExecutionInProgress = FALSE
 

Macro Definition Documentation

◆ INPUT_BUFFER_SIZE

#define INPUT_BUFFER_SIZE   1024

Function Documentation

◆ HandlerRoutine()

BOOL WINAPI HandlerRoutine ( DWORD  dwCtrlType)

Definition at line 58 of file RegistryExplorer.cpp.

59{
60 switch(dwCtrlType)
61 {
62 case CTRL_C_EVENT:
65 {
66/* Beep(1000,100);
67 Beep(2000,100);
68 Beep(3000,100);
69 Beep(4000,100);
70 Beep(5000,100);
71 Beep(4000,100);
72 Beep(3000,100);
73 Beep(2000,100);
74 Beep(1000,100);*/
75 Console.Write(_T("\n"));
77 }
78 return TRUE;
79 default:
80 return FALSE;
81 }
82}
BOOL blnCommandExecutionInProgress
CConsole Console
void DisableWrite()
Definition: Console.cpp:1064
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _T(x)
Definition: vfdio.h:22
#define CTRL_C_EVENT
Definition: wincon.h:68
#define CTRL_BREAK_EVENT
Definition: wincon.h:69

Referenced by AddConsoleCtrlHandler(), main(), RemoveConsoleCtrlHandler(), and SetConsoleCtrlHandler().

◆ main()

int main ( void  )

Definition at line 85 of file RegistryExplorer.cpp.

86{
87 int nRetCode = 0;
88
89 HRESULT hr;
90
91 CSettings *pSettings = NULL;
92 CPrompt *pPrompt = NULL;
93
95
97 CommandsList.AddCommand(&ExitCommand);
98
99 CShellCommandVersion VersionCommand;
100 CommandsList.AddCommand(&VersionCommand);
101
102 CShellCommandHelp HelpCommand(CommandsList);
103 CommandsList.AddCommand(&HelpCommand);
104
105 CShellCommandDir DirCommand(Tree);
106 CommandsList.AddCommand(&DirCommand);
107
108 CShellCommandChangeKey ChangeKeyCommand(Tree);
109 CommandsList.AddCommand(&ChangeKeyCommand);
110
111 CShellCommandValue ValueCommand(Tree);
112 CommandsList.AddCommand(&ValueCommand);
113
114 CShellCommandOwner OwnerCommand(Tree);
115 CommandsList.AddCommand(&OwnerCommand);
116
117 CShellCommandDACL DACLCommand(Tree);
118 CommandsList.AddCommand(&DACLCommand);
119
120 CShellCommandSACL SACLCommand(Tree);
121 CommandsList.AddCommand(&SACLCommand);
122
123 CShellCommandConnect ConnectCommand(Tree);
124 CommandsList.AddCommand(&ConnectCommand);
125
126 CShellCommandNewKey NewKeyCommand(Tree);
127 CommandsList.AddCommand(&NewKeyCommand);
128
129 CShellCommandDeleteKey DeleteKeyCommand(Tree);
130 CommandsList.AddCommand(&DeleteKeyCommand);
131
132 CShellCommandSetValue SetValueCommand(Tree);
133 CommandsList.AddCommand(&SetValueCommand);
134
135 CShellCommandDeleteValue DeleteValueCommand(Tree);
136 CommandsList.AddCommand(&DeleteValueCommand);
137
138 CArgumentParser Parser;
139
140 pSettings = new (std::nothrow) CSettings();
141 if (!pSettings)
142 {
143 _ftprintf(stderr,_T("Cannot initialize settings. Out of memory.\n"));
144 goto Abort;
145 }
146
147 hr = pSettings->Load(SETTINGS_REGISTRY_KEY);
148 if (FAILED(hr))
149 {
150 _ftprintf(stderr,_T("Cannot load settings. Error is 0x%X.\n"),(unsigned int)hr);
151 goto Abort;
152 }
153
154 pPrompt = new (std::nothrow) CPrompt(Tree,hr);
155 if (!pPrompt)
156 {
157 _ftprintf(stderr,_T("Cannot initialize prompt. Out of memory.\n"));
158 goto Abort;
159 }
160
161 if (FAILED(hr))
162 {
163 _ftprintf(stderr,_T("Cannot initialize prompt. Error is 0x%X.\n"),(unsigned int)hr);
164 goto Abort;
165 }
166
167// input buffer size in chars
168#define INPUT_BUFFER_SIZE 1024
169//#define INPUT_BUFFER_SIZE 128
170//#define INPUT_BUFFER_SIZE 10
171
172 TCHAR *pchCommand;
173
174 pchCommand = Console.Init(INPUT_BUFFER_SIZE,10);
175 if (pchCommand == NULL)
176 {
177 _ftprintf(stderr,_T("Cannot initialize console.\n"));
178 nRetCode = 1;
179 goto Exit;
180 }
181
183
184 WORD wOldConsoleAttribute;
185 if (!Console.GetTextAttribute(wOldConsoleAttribute)) goto Abort;
186
187 Console.SetTitle(_T("Registry Explorer"));
189
191
193 //(_L(__TIMESTAMP__))
194 )) goto Abort;
195
196 //Tree.SetDesiredOpenKeyAccess(KEY_READ);
197
198 hr = pPrompt->SetPrompt(pSettings->GetPrompt());
199 if (FAILED(hr))
200 {
201 _ftprintf(stderr,_T("Cannot initialize prompt. Error is 0x%X.\n"),(unsigned int)hr);
202 goto Abort;
203 }
204
205GetCommand:
206 // prompt
207 // TODO: make prompt user-customizable
209 pPrompt->ShowPrompt(Console);
211
213
214 // Set command line color
216 if (!Console.ReadLine())
217 goto Abort;
218
219 // Set normal color
221
224
225 // Parse command line (1st step - convert to multi sz)
226 Parser.SetArgumentList(pchCommand);
227
228 int nCommandReturnValue;
229 switch(CommandsList.Execute(Parser,nCommandReturnValue))
230 {
231 case -1: // not recognized command
232 {
233 Parser.ResetArgumentIteration();
234 TCHAR *pchCommandItself = Parser.GetNextArgument();
235 size_t cmdlen = _tcslen(pchCommandItself);
236 if ((!cmdlen)||
237 (pchCommandItself[cmdlen-1] != _T('\\'))||
238 (Parser.GetNextArgument())||
239 (!Tree.ChangeCurrentKey(pchCommandItself)))
240 {
241 Console.Write(_T("Unknown command \""));
242 Console.Write(pchCommandItself);
243 Console.Write(_T("\"\n"));
244 }
245 }
246 case -2: // empty line
247 goto GetCommand;
248 case 0: // exit command
249 nRetCode = 0;
250 Console.SetTextAttribute(wOldConsoleAttribute);
251 goto Exit;
252 default:
253 Console.Write(_T("\n"));
254 goto GetCommand;
255 }
256
257Abort:
258 _ftprintf(stderr,_T("Abnormal program termination.\nPlease report bugs to ") EMAIL _T("\n"));
259 nRetCode = 1;
260
261Exit:
262
263 if (pSettings)
264 delete pSettings;
265
266 if (pPrompt)
267 delete pPrompt;
268
269 return nRetCode;
270}
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
#define INPUT_BUFFER_SIZE
CRegistryTree Tree
#define EMAIL
#define HELLO_MSG
#define SETTINGS_REGISTRY_KEY
DWORD WINAPI ExitCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: context.c:252
DWORD WINAPI HelpCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: help.c:116
void SetArgumentList(TCHAR *pchArguments)
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL SetTitle(const TCHAR *p)
Definition: Console.cpp:222
BOOL FlushInputBuffer()
Definition: Console.cpp:243
void BeginScrollingOperation()
Definition: Console.cpp:1007
BOOL SetTextAttribute(WORD wAttributes)
Definition: Console.cpp:227
TCHAR * Init(DWORD dwBufferSize, DWORD dwMaxHistoryLines=0)
Definition: Console.cpp:870
BOOL GetTextAttribute(WORD &rwAttributes)
Definition: Console.cpp:858
BOOL ReadLine()
Definition: Console.cpp:249
void EnableWrite()
Definition: Console.cpp:1080
void SetReplaceCompletionCallback(ReplaceCompletionCallback pfCallback)
Definition: Console.cpp:1058
Definition: Prompt.h:8
void ShowPrompt(CConsole &rConsole)
Definition: Prompt.cpp:67
HRESULT SetPrompt(LPCTSTR pszPrompt)
Definition: Prompt.cpp:44
BOOL ChangeCurrentKey(const TCHAR *pchRelativePath)
HRESULT Load(LPCTSTR pszLoadKey)
Definition: Settings.cpp:56
LPCTSTR GetPrompt()
Definition: Settings.cpp:132
WORD GetCommandTextAttributes()
Definition: Settings.cpp:142
WORD GetNormalTextAttributes()
Definition: Settings.cpp:137
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2109
unsigned short WORD
Definition: ntddk_ex.h:93
#define stderr
Definition: stdio.h:100
#define _ftprintf
Definition: tchar.h:518
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
static void Exit(void)
Definition: sock.c:1330
#define VERIFY(e)
Definition: ph.h:34
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:237
char TCHAR
Definition: xmlstorage.h:189
#define _tcslen
Definition: xmlstorage.h:198

Variable Documentation

◆ blnCommandExecutionInProgress

BOOL blnCommandExecutionInProgress = FALSE

Definition at line 56 of file RegistryExplorer.cpp.

Referenced by HandlerRoutine(), and main().

◆ Console

CConsole Console

Definition at line 54 of file RegistryExplorer.cpp.

Referenced by AddInputEvents(), BfClearScreen(), BlDisplaySetScreenResolution(), CON_API(), CON_API_NOCONSOLE(), ConDrvAttachTerminal(), ConDrvChangeScreenBufferAttributes(), ConDrvCreateScreenBuffer(), ConDrvDeinitInputBuffer(), ConDrvDeleteConsole(), ConDrvDeleteScreenBuffer(), ConDrvDetachTerminal(), ConDrvFillConsoleOutput(), ConDrvFlushConsoleInputBuffer(), ConDrvGetActiveScreenBuffer(), ConDrvGetConsoleCP(), ConDrvGetConsoleCursorInfo(), ConDrvGetConsoleInput(), ConDrvGetConsoleMode(), ConDrvGetConsoleNumberOfInputEvents(), ConDrvGetConsoleScreenBufferInfo(), ConDrvInitConsole(), ConDrvInitInputBuffer(), ConDrvInvalidateBitMapRect(), ConDrvPause(), ConDrvReadConsole(), ConDrvReadConsoleOutput(), ConDrvReadConsoleOutputString(), ConDrvScrollConsoleScreenBuffer(), ConDrvSetConsoleActiveScreenBuffer(), ConDrvSetConsoleCP(), ConDrvSetConsoleCursorInfo(), ConDrvSetConsoleCursorPosition(), ConDrvSetConsoleMode(), ConDrvSetConsolePalette(), ConDrvSetConsoleScreenBufferSize(), ConDrvSetConsoleTextAttribute(), ConDrvSetConsoleWindowInfo(), ConDrvUnpause(), ConDrvValidateConsoleState(), ConDrvValidateConsoleUnsafe(), ConDrvWriteConsole(), ConDrvWriteConsoleInput(), ConDrvWriteConsoleOutput(), ConDrvWriteConsoleOutputString(), ConDrvWriteConsoleOutputVDM(), ConioAddInputEvents(), ConioDrawConsole(), ConioEffectiveCursorSize(), ConioInputEventToAnsi(), ConioInputEventToUnicode(), ConioPause(), ConioProcessInputEvent(), ConioProcessKey(), ConioResizeBuffer(), ConioSetActiveScreenBuffer(), ConioUnpause(), ConioWriteConsole(), CONSOLE_SCREEN_BUFFER_Initialize(), ConsoleFirmwareGraphicalClear(), ConsoleFirmwareTextClear(), ConsoleGraphicalClearPixels(), ConsoleGraphicalClearText(), ConsoleGraphicalDestruct(), ConsoleGraphicalEnable(), ConsoleGraphicalGetGraphicalResolution(), ConsoleGraphicalGetOriginalResolution(), ConsoleGraphicalIsEnabled(), ConsoleGraphicalReinitialize(), ConsoleGraphicalSetTextState(), ConsoleInputBaseConstruct(), ConsoleInputBaseEraseBuffer(), ConsoleInputBaseReinitialize(), ConsoleInputLocalDestruct(), ConsoleInputLocalEraseBuffer(), ConsoleTextLocalClearText(), ConsoleTextLocalSetTextState(), ConSrvAllocateConsole(), ConSrvApplyUserSettings(), ConSrvCloseHandle(), ConSrvConsoleProcessCtrlEvent(), ConSrvDeleteConsole(), ConSrvGetConsole(), ConSrvGetConsoleLeaderProcess(), ConSrvGetConsoleProcessList(), ConSrvInheritConsole(), ConSrvInitConsole(), ConSrvInitObject(), ConSrvInitProcessHandles(), ConSrvReleaseConsole(), ConSrvRemoveConsole(), ConSrvSetConsoleProcessFocus(), ConSrvTermInitTerminal(), ConSrvTermReadStream(), ConSrvValidateConsole(), ConvertInputAnsiToUnicode(), ConvertInputUnicodeToAnsi(), ConWndProc(), CreatePopupWindow(), DoEcho(), DoLineMode(), DoLineModeSpecial(), DoWriteConsole(), GetThreadConsoleDesktop(), GRAPHICS_BUFFER_Initialize(), GuiApplyUserSettings(), GuiConsoleInputThread(), GuiConsoleShowConsoleProperties(), GuiConsoleSwitchFullScreen(), GuiInitFrontEnd(), GuiPaintCaret(), GuiPaintGraphicsBuffer(), GuiPaintTextModeBuffer(), GuiPasteToTextModeBuffer(), HandlerRoutine(), HistoryAddEntry(), HistoryCurrentBuffer(), HistoryDeleteBuffers(), HistoryDeleteCurrentBuffer(), HistoryDisplayCurrentHistory(), HistoryFindBuffer(), HistoryFindEntryByPrefix(), HistoryGetCurrentEntry(), HistoryRecallHistory(), HistoryReshapeAllBuffers(), InsertConsole(), IntCreateAliasEntry(), IntCreateAliasHeader(), IntDeleteAllAliases(), IntFindAliasHeader(), IntGetAliasEntry(), IntReadConsoleOutputStringChars(), IntWriteConsoleOutputStringChars(), LineInputEdit(), LineInputKeyDown(), LineInputRecallHistory(), LineInputSetPos(), main(), OnClose(), OnCommand(), OnDropFiles(), OnFocus(), OnGetMinMaxInfo(), OnKey(), OnMouse(), OnNcCreate(), OnScroll(), OnSize(), OnTimer(), PaletteRGBFromAttrib(), PasteText(), PostprocessInput(), PreprocessInput(), RemoveConsoleByPointer(), ResetTerminal(), SendMenuEvent(), SwitchFullScreen(), telProcessConsole(), TEXTMODE_BUFFER_Initialize(), UpdateSelection(), and WaitBeforeReading().

◆ pchCurrentKey

TCHAR pchCurrentKey[PROMPT_BUFFER_SIZE]

Definition at line 51 of file RegistryExplorer.cpp.

◆ Tree