@@ -66,22 +66,22 @@ void AnalyzeSecurity(ObjectEntry & oEntry)
66
66
bool bGroupIsDirty = false ;
67
67
68
68
// read security information from the file handle
69
- PACL tAclDacl = NULL ;
70
- PACL tAclSacl = NULL ;
71
- PSID tOwnerSid = NULL ;
72
- PSID tGroupSid = NULL ;
73
- PSECURITY_DESCRIPTOR tDesc = NULL ;
69
+ PACL tAclDacl = nullptr ;
70
+ PACL tAclSacl = nullptr ;
71
+ PSID tOwnerSid = nullptr ;
72
+ PSID tGroupSid = nullptr ;
73
+ PSECURITY_DESCRIPTOR tDesc = nullptr ;
74
74
DWORD iError = 0 ;
75
75
if (iInformationToLookup != 0 &&
76
76
(iError = GetNamedSecurityInfo (oEntry.Name .c_str (), SE_FILE_OBJECT,
77
- iInformationToLookup, (bFetchOwner) ? &tOwnerSid : NULL , (bFetchGroup) ? &tGroupSid : NULL ,
78
- (bFetchDacl) ? &tAclDacl : NULL , (bFetchSacl) ? &tAclSacl : NULL , &tDesc)) != ERROR_SUCCESS)
77
+ iInformationToLookup, (bFetchOwner) ? &tOwnerSid : nullptr , (bFetchGroup) ? &tGroupSid : nullptr ,
78
+ (bFetchDacl) ? &tAclDacl : nullptr , (bFetchSacl) ? &tAclSacl : nullptr , &tDesc)) != ERROR_SUCCESS)
79
79
{
80
80
// attempt to look up error message
81
- LPWSTR sError = NULL ;
82
- size_t iSize = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
81
+ LPWSTR sError = nullptr ;
82
+ const size_t iSize = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
83
83
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
84
- NULL , iError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&sError , 0 , NULL );
84
+ nullptr , iError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&sError , 0 , nullptr );
85
85
InputOutput::AddError (L" Unable to read file security" , (iSize == 0 ) ? L" " : sError );
86
86
if (iSize > 0 ) LocalFree (sError );
87
87
@@ -96,7 +96,7 @@ void AnalyzeSecurity(ObjectEntry & oEntry)
96
96
bool bSaclCleanupRequired = false ;
97
97
bool bOwnerCleanupRequired = false ;
98
98
bool bGroupCleanupRequired = false ;
99
- bool bDescCleanupRequired = (tDesc != NULL );
99
+ bool bDescCleanupRequired = (tDesc != nullptr );
100
100
101
101
// used for one-shot operations like reset children or inheritance
102
102
DWORD iSpecialCommitMergeFlags = 0 ;
@@ -188,14 +188,14 @@ void AnalyzeSecurity(ObjectEntry & oEntry)
188
188
if (!InputOutput::InWhatIfMode ())
189
189
{
190
190
if ((iError = SetNamedSecurityInfo ((LPWSTR) oEntry.Name .c_str (), SE_FILE_OBJECT, iInformationToCommit,
191
- (bOwnerIsDirty) ? tOwnerSid : NULL , (bGroupIsDirty) ? tGroupSid : NULL ,
192
- (bDaclIsDirty) ? tAclDacl : NULL , (bSaclIsDirty) ? tAclSacl : NULL )) != ERROR_SUCCESS)
191
+ (bOwnerIsDirty) ? tOwnerSid : nullptr , (bGroupIsDirty) ? tGroupSid : nullptr ,
192
+ (bDaclIsDirty) ? tAclDacl : nullptr , (bSaclIsDirty) ? tAclSacl : nullptr )) != ERROR_SUCCESS)
193
193
{
194
194
// attempt to look up error message
195
- LPWSTR sError = NULL ;
196
- size_t iSize = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
195
+ LPWSTR sError = nullptr ;
196
+ const size_t iSize = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
197
197
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
198
- NULL , iError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR) &sError , 0 , NULL );
198
+ nullptr , iError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR) &sError , 0 , NULL );
199
199
InputOutput::AddError (L" Unable to update file security" , (iSize == 0 ) ? L" " : sError );
200
200
if (iSize > 0 ) LocalFree (sError );
201
201
@@ -273,7 +273,7 @@ void AnalyzingQueue()
273
273
274
274
// update object attributes object
275
275
OBJECT_ATTRIBUTES oAttributes;
276
- InitializeObjectAttributes (&oAttributes, NULL , OBJ_CASE_INSENSITIVE, NULL , NULL );
276
+ InitializeObjectAttributes (&oAttributes, nullptr , OBJ_CASE_INSENSITIVE, nullptr , nullptr );
277
277
oAttributes.ObjectName = &tPathU;
278
278
279
279
// get an open file handle
@@ -310,9 +310,9 @@ void AnalyzingQueue()
310
310
// enumerate files in the directory
311
311
for (bool bFirstRun = true ; true ; bFirstRun = false )
312
312
{
313
- Status = NtQueryDirectoryFile (hFindFile, NULL , NULL , NULL , &IoStatusBlock,
313
+ Status = NtQueryDirectoryFile (hFindFile, nullptr , nullptr , nullptr , &IoStatusBlock,
314
314
DirectoryInfo, MAX_DIRECTORY_BUFFER, (FILE_INFORMATION_CLASS)FileDirectoryInformation,
315
- FALSE , NULL , (bFirstRun) ? TRUE : FALSE );
315
+ FALSE , nullptr , (bFirstRun) ? TRUE : FALSE );
316
316
317
317
// done processing
318
318
if (Status == STATUS_NO_MORE_FILES) break ;
@@ -324,7 +324,7 @@ void AnalyzingQueue()
324
324
}
325
325
326
326
for (auto * oInfo = (FILE_DIRECTORY_INFORMATION *)DirectoryInfo;
327
- oInfo != NULL ; oInfo = (FILE_DIRECTORY_INFORMATION *)((BYTE *)oInfo + oInfo->NextEntryOffset ))
327
+ oInfo != nullptr ; oInfo = (FILE_DIRECTORY_INFORMATION *)((BYTE *)oInfo + oInfo->NextEntryOffset ))
328
328
{
329
329
// continue immediately if we get the '.' or '..' entries
330
330
if (IsDirectory (oInfo->FileAttributes ))
@@ -384,7 +384,7 @@ VOID BeginFileScan()
384
384
// make a local copy of the path since we may have to alter it
385
385
// handle special case where a drive root is specified
386
386
// we must ensure it takes the form x:\. to resolve correctly
387
- size_t iSemiColon = sPath .rfind (L' :' );
387
+ const size_t iSemiColon = sPath .rfind (L' :' );
388
388
if (iSemiColon != std::wstring::npos)
389
389
{
390
390
std::wstring sEnd = sPath .substr (iSemiColon);
@@ -396,7 +396,7 @@ VOID BeginFileScan()
396
396
397
397
// convert the path to a long path that is compatible with the other call
398
398
UNICODE_STRING tPathU;
399
- RtlDosPathNameToNtPathName_U (sPath .c_str (), &tPathU, NULL , NULL );
399
+ RtlDosPathNameToNtPathName_U (sPath .c_str (), &tPathU, nullptr , nullptr );
400
400
401
401
// copy it to a null terminated string
402
402
oEntryFirst.Name = std::wstring (tPathU.Buffer , tPathU.Length / sizeof (WCHAR));
@@ -517,9 +517,9 @@ int wmain(int iArgs, WCHAR * aArgs[])
517
517
wprintf (L" ===============================================================================\n " );
518
518
519
519
// do the scan
520
- ULONGLONG iTimeStart = GetTickCount64 ();
520
+ const ULONGLONG iTimeStart = GetTickCount64 ();
521
521
BeginFileScan ();
522
- ULONGLONG iTimeStop = GetTickCount64 ();
522
+ const ULONGLONG iTimeStop = GetTickCount64 ();
523
523
524
524
// print out statistics
525
525
wprintf (L" ===============================================================================\n " );
0 commit comments