Reactos
at master 253 lines 7.0 kB view raw
1/* 2 * regexpl - Console Registry Explorer 3 * 4 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; see the file COPYING. If not, write to 18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 * Boston, MA 02111-1307, USA. 20 */ 21 22// ShellCommandDOKA.cpp: implementation of the CShellCommandDOKA class. 23// 24////////////////////////////////////////////////////////////////////// 25 26#include "ph.h" 27#include "ShellCommandDOKA.h" 28#include "RegistryExplorer.h" 29#include "SecurityDescriptor.h" 30 31#define DOKA_CMD _T("DOKA") 32#define DOKA_CMD_SHORT_DESC DOKA_CMD _T(" command is used to view/edit Desired Open Key Access.\n") 33 34////////////////////////////////////////////////////////////////////// 35// Construction/Destruction 36////////////////////////////////////////////////////////////////////// 37 38CShellCommandDOKA::CShellCommandDOKA(CRegistryTree& rTree):m_rTree(rTree) 39{ 40} 41 42CShellCommandDOKA::~CShellCommandDOKA() 43{ 44} 45 46BOOL CShellCommandDOKA::Match(const TCHAR *pchCommand) 47{ 48 return _tcsicmp(pchCommand,DOKA_CMD) == 0; 49} 50 51int CShellCommandDOKA::Execute(CConsole &rConsole, CArgumentParser& rArguments) 52{ 53 REGSAM Access = m_rTree.GetDesiredOpenKeyAccess(); 54 const TCHAR *pchParameter; 55 BOOL blnBadParameter = FALSE; 56 BOOL blnHelp = FALSE; 57 58 while((pchParameter = rArguments.GetNextArgument()) != NULL) 59 { 60 blnBadParameter = FALSE; 61// Console.Write(_T("Processing parameter: \")"); 62// Console.Write(pchParameter); 63// Console.Write(_T("\")\n"); 64 if ((_tcsicmp(pchParameter,_T("/?")) == 0) 65 ||(_tcsicmp(pchParameter,_T("-?")) == 0)) 66 { 67 blnHelp = TRUE; 68 } 69 else if (*pchParameter == _T('-')) 70 { 71 TCHAR a = *(pchParameter+1); 72 if (a == 0) 73 { 74 Access = 0; 75 } 76 else 77 { 78 if (*(pchParameter+2) != 0) 79 { 80 blnBadParameter = TRUE; 81 } 82 else 83 { 84 switch(a) 85 { 86 case _T('l'): // KEY_CREATE_LINK 87 case _T('L'): 88 Access &= ~KEY_CREATE_LINK; 89 break; 90 case _T('c'): // KEY_CREATE_SUB_KEY 91 case _T('C'): 92 Access &= ~KEY_CREATE_SUB_KEY; 93 break; 94 case _T('e'): // KEY_ENUMERATE_SUB_KEYS 95 case _T('E'): 96 Access &= ~KEY_ENUMERATE_SUB_KEYS; 97 break; 98 case _T('n'): // KEY_NOTIFY 99 case _T('N'): 100 Access &= ~KEY_NOTIFY; 101 break; 102 case _T('q'): // KEY_QUERY_VALUE 103 case _T('Q'): 104 Access &= ~KEY_QUERY_VALUE; 105 break; 106 case _T('s'): // KEY_SET_VALUE 107 case _T('S'): 108 Access &= ~KEY_SET_VALUE; 109 break; 110 default: 111 blnBadParameter = TRUE; 112 } // switch 113 } // else (*(pchParameter+2) != 0) 114 } // else (a == 0) 115 } // if (*pchParameter == _T('-')) 116 else if (*pchParameter == _T('+')) 117 { 118 TCHAR a = *(pchParameter+1); 119 if (a == 0) 120 { 121 blnBadParameter = TRUE; 122 } 123 else 124 { 125 if (*(pchParameter+2) != 0) 126 { 127 blnBadParameter = TRUE; 128 } 129 else 130 { 131 switch(a) 132 { 133 case _T('a'): // KEY_ALL_ACCESS 134 case _T('A'): 135 Access |= KEY_ALL_ACCESS; 136 break; 137 case _T('l'): // KEY_CREATE_LINK 138 case _T('L'): 139 Access |= KEY_CREATE_LINK; 140 break; 141 case _T('c'): // KEY_CREATE_SUB_KEY 142 case _T('C'): 143 Access |= KEY_CREATE_SUB_KEY; 144 break; 145 case _T('e'): // KEY_ENUMERATE_SUB_KEYS 146 case _T('E'): 147 Access |= KEY_ENUMERATE_SUB_KEYS; 148 break; 149 case _T('n'): // KEY_NOTIFY 150 case _T('N'): 151 Access |= KEY_NOTIFY; 152 break; 153 case _T('q'): // KEY_QUERY_VALUE 154 case _T('Q'): 155 Access |= KEY_QUERY_VALUE; 156 break; 157 case _T('s'): // KEY_SET_VALUE 158 case _T('S'): 159 Access |= KEY_SET_VALUE; 160 break; 161// case _T('X'): // KEY_EXECUTE 162// case _T('x'): 163// Access |= KEY_EXECUTE; 164// break; 165 case _T('R'): // KEY_READ 166 case _T('r'): 167 Access |= KEY_READ; 168 break; 169 default: 170 blnBadParameter = TRUE; 171 } // switch 172 } // else (*(pchParameter+2) != 0) 173 } // else (a == 0) 174 } // if (*pchParameter == _T('-')) 175 else 176 { 177 blnBadParameter = TRUE; 178 } 179 180 if (blnBadParameter) 181 { 182 rConsole.Write(_T("Bad parameter: ")); 183 rConsole.Write(pchParameter); 184 rConsole.Write(_T("\n")); 185 blnHelp = TRUE; 186 } 187 } // while((pchParameter = Parser.GetNextArgument()) != NULL) 188 189 if (blnHelp) 190 { 191 rConsole.Write(GetHelpString()); 192 } 193 else 194 { 195 m_rTree.SetDesiredOpenKeyAccess(Access); 196 rConsole.Write(_T("Desired open key access:\n")); 197 REGSAM Access = m_rTree.GetDesiredOpenKeyAccess(); 198 if (Access & KEY_CREATE_LINK) 199 { 200 rConsole.Write(_T("\tKEY_CREATE_LINK - Permission to create a symbolic link.\n")); 201 } 202 if (Access & KEY_CREATE_SUB_KEY) 203 { 204 rConsole.Write(_T("\tKEY_CREATE_SUB_KEY - Permission to create subkeys.\n")); 205 } 206 if (Access & KEY_ENUMERATE_SUB_KEYS) 207 { 208 rConsole.Write(_T("\tKEY_ENUMERATE_SUB_KEYS - Permission to enumerate subkeys.\n")); 209 } 210 if (Access & KEY_NOTIFY) 211 { 212 rConsole.Write(_T("\tKEY_NOTIFY - Permission for change notification.\n")); 213 } 214 if (Access & KEY_QUERY_VALUE) 215 { 216 rConsole.Write(_T("\tKEY_QUERY_VALUE - Permission to query subkey data.\n")); 217 } 218 if (Access & KEY_SET_VALUE) 219 { 220 rConsole.Write(_T("\tKEY_SET_VALUE - Permission to set subkey data.\n")); 221 } 222 } 223 return 0; 224} 225 226const TCHAR * CShellCommandDOKA::GetHelpString() 227{ 228 return DOKA_CMD_SHORT_DESC 229 _T("Syntax: ") DOKA_CMD _T(" [Switches] [/?]\n\n") 230 _T(" /? - This help.\n\n") 231 _T("Switches are:\n") 232 _T(" - - Reset all permisions.\n") 233 _T(" -l - Reset permission to create a symbolic link.\n") 234 _T(" -c - Reset permission to create subkeys.\n") 235 _T(" -e - Reset permission to enumerate subkeys.\n") 236 _T(" -n - Reset permission for change notification.\n") 237 _T(" -q - Reset permission to query subkey data.\n") 238 _T(" -s - Reset permission to set subkey data.\n") 239 _T(" +a - Set all permisions.\n") 240 _T(" +l - Set permission to create a symbolic link.\n") 241 _T(" +c - Set permission to create subkeys.\n") 242 _T(" +e - Set permission to enumerate subkeys.\n") 243 _T(" +n - Set permission for change notification.\n") 244 _T(" +q - Set permission to query subkey data.\n") 245 _T(" +s - Set permission to set subkey data.\n") 246 _T(" +r - Equivalent to combination of +q , +e and +n\n\n") 247 _T("Without parameters, command displays current Desired Open Key Access.\n"); 248} 249 250const TCHAR * CShellCommandDOKA::GetHelpShortDescriptionString() 251{ 252 return DOKA_CMD_SHORT_DESC; 253}