31#define OWNER_CMD _T("OWNER")
32#define OWNER_CMD_LENGTH COMMAND_LENGTH(OWNER_CMD)
33#define OWNER_CMD_SHORT_DESC OWNER_CMD _T(" command is used to view")
_T(" key's owner.\n")
66 const TCHAR *pchParameter;
80 goto CheckOwnerArgument;
86 blnBadParameter =
FALSE;
91 blnDo = pchKey !=
NULL;
95 pchKey = pchParameter;
100 blnBadParameter =
TRUE;
104 rConsole.
Write(
_T(
"Bad parameter: "));
105 rConsole.
Write(pchParameter);
123 if (blnDo&&blnHelp) rConsole.
Write(
_T(
"\n"));
138 DWORD dwSecurityDescriptorLength;
143 dwError =
Key.GetSecurityDescriptorLength(&dwSecurityDescriptorLength);
147 DWORD dwSecurityDescriptorLength1 = dwSecurityDescriptorLength;
151 BOOL blnOwnerDefaulted;
154 if (psidOwner ==
NULL)
156 rConsole.
Write(
_T(
"Key has no owner."));
162 rConsole.
Write(
_T(
"Key has invalid owner SID."));
166 rConsole.
Write(
_T(
"Key Owner: \n"));
167 DWORD dwSIDStringSize = 0;
179 rConsole.
Write(
_T(
"\nGetting string representation of SID\n"));
184 rConsole.
Write(pchSID);
188 DWORD dwNameBufferLength, dwDomainNameBufferLength;
189 dwNameBufferLength = 1024;
190 dwDomainNameBufferLength = 1024;
191 pchName =
new TCHAR [dwNameBufferLength];
192 pchDomainName =
new TCHAR [dwDomainNameBufferLength];
193 DWORD dwNameLength = dwNameBufferLength, dwDomainNameLength = dwDomainNameBufferLength;
195 if (!
LookupAccountSid(
NULL,psidOwner,pchName,&dwNameLength,pchDomainName,&dwDomainNameLength,&Use))
199 rConsole.
Write(
_T(
"\tOwner Domain: "));
200 rConsole.
Write(pchDomainName);
202 rConsole.
Write(
_T(
"\tOwner Name: "));
203 rConsole.
Write(pchName);
204 rConsole.
Write(
_T(
"\n\tSID type: "));
207 rConsole.
Write(
_T(
"\tOwner defaulted: "));
208 rConsole.
Write(blnOwnerDefaulted?
_T(
"Yes"):
_T(
"No"));
213 delete [] pchDomainName;
214 pchDomainName =
NULL;
218 delete [] pSecurityDescriptor;
220 catch (
DWORD dwError)
226 if (pchName)
delete [] pchName;
227 if (pchDomainName)
delete [] pchDomainName;
228 if (pSecurityDescriptor)
delete [] pSecurityDescriptor;
238 _T(
" <KEY> - Optional relative path of desired key.\n")
239 _T(
" /? - This help.\n\n")
240 _T(
"Without parameters, command displays information about owner of current key.\n");
#define COMMAND_NA_ON_ROOT
const TCHAR * GetSidTypeName(SID_NAME_USE Use)
BOOL GetTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen)
#define OWNER_CMD_SHORT_DESC
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetLastErrorDescription()
virtual ~CShellCommandOwner()
CShellCommandOwner(CRegistryTree &rTree)
virtual BOOL Match(const TCHAR *pchCommand)
virtual const TCHAR * GetHelpShortDescriptionString()
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)
virtual const TCHAR * GetHelpString()
#define ERROR_INSUFFICIENT_BUFFER
BOOL WINAPI IsValidSid(PSID pSid)
enum _SID_NAME_USE SID_NAME_USE
DWORD SECURITY_INFORMATION
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted)
DWORD WINAPI GetLastError(void)
#define OWNER_SECURITY_INFORMATION
struct _SECURITY_DESCRIPTOR * PISECURITY_DESCRIPTOR