mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 22:18:13 +00:00
improved error handling
svn path=/trunk/; revision=20854
This commit is contained in:
parent
9a1758ce5a
commit
2edcb03c9d
1 changed files with 29 additions and 13 deletions
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
|
|
||||||
|
|
||||||
static GENERIC_MAPPING FileGenericMapping =
|
static GENERIC_MAPPING FileGenericMapping =
|
||||||
{
|
{
|
||||||
FILE_GENERIC_READ,
|
FILE_GENERIC_READ,
|
||||||
|
@ -28,6 +27,7 @@ static GENERIC_MAPPING FileGenericMapping =
|
||||||
FILE_ALL_ACCESS
|
FILE_ALL_ACCESS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static INT
|
static INT
|
||||||
LengthOfStrResource(IN HINSTANCE hInst,
|
LengthOfStrResource(IN HINSTANCE hInst,
|
||||||
IN UINT uID)
|
IN UINT uID)
|
||||||
|
@ -173,7 +173,7 @@ PrintFileDacl(IN LPTSTR FilePath,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
||||||
DWORD SDSize = 0;
|
DWORD SDSize = 0;
|
||||||
TCHAR FullFileName[MAX_PATH + 1];
|
TCHAR FullFileName[MAX_PATH + 1];
|
||||||
BOOL Ret = FALSE;
|
BOOL Error = FALSE, Ret = FALSE;
|
||||||
|
|
||||||
Indent = _tcslen(FilePath) + _tcslen(FileName);
|
Indent = _tcslen(FilePath) + _tcslen(FileName);
|
||||||
if (Indent++ > MAX_PATH - 1)
|
if (Indent++ > MAX_PATH - 1)
|
||||||
|
@ -250,16 +250,13 @@ PrintFileDacl(IN LPTSTR FilePath,
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_NONE_MAPPED)
|
if (GetLastError() == ERROR_NONE_MAPPED)
|
||||||
{
|
{
|
||||||
if (!ConvertSidToStringSid(Sid,
|
goto BuildSidString;
|
||||||
&SidString))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
|
Error = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +266,7 @@ PrintFileDacl(IN LPTSTR FilePath,
|
||||||
if (Name == NULL)
|
if (Name == NULL)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
Error = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,10 +283,21 @@ PrintFileDacl(IN LPTSTR FilePath,
|
||||||
HeapFree(GetProcessHeap(),
|
HeapFree(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
Name);
|
Name);
|
||||||
break;
|
Name = NULL;
|
||||||
|
goto BuildSidString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BuildSidString:
|
||||||
|
if (!ConvertSidToStringSid(Sid,
|
||||||
|
&SidString))
|
||||||
|
{
|
||||||
|
Error = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* print the file name or space */
|
/* print the file name or space */
|
||||||
_tprintf(_T("%s "),
|
_tprintf(_T("%s "),
|
||||||
|
@ -389,7 +398,8 @@ PrintFileDacl(IN LPTSTR FilePath,
|
||||||
DWORD Access;
|
DWORD Access;
|
||||||
UINT uID;
|
UINT uID;
|
||||||
}
|
}
|
||||||
AccessRights[] = {
|
AccessRights[] =
|
||||||
|
{
|
||||||
{FILE_WRITE_ATTRIBUTES, IDS_FILE_WRITE_ATTRIBUTES},
|
{FILE_WRITE_ATTRIBUTES, IDS_FILE_WRITE_ATTRIBUTES},
|
||||||
{FILE_READ_ATTRIBUTES, IDS_FILE_READ_ATTRIBUTES},
|
{FILE_READ_ATTRIBUTES, IDS_FILE_READ_ATTRIBUTES},
|
||||||
{FILE_DELETE_CHILD, IDS_FILE_DELETE_CHILD},
|
{FILE_DELETE_CHILD, IDS_FILE_DELETE_CHILD},
|
||||||
|
@ -467,7 +477,8 @@ PrintSpecialAccess:
|
||||||
AceIndex++;
|
AceIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ret = TRUE;
|
if (!Error)
|
||||||
|
Ret = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -512,6 +523,7 @@ int _main (int argc, char *argv[])
|
||||||
TCHAR *FilePart = NULL;
|
TCHAR *FilePart = NULL;
|
||||||
WIN32_FIND_DATA FindData;
|
WIN32_FIND_DATA FindData;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
DWORD LastError;
|
||||||
BOOL ContinueAccessDenied = FALSE;
|
BOOL ContinueAccessDenied = FALSE;
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
|
@ -553,11 +565,15 @@ int _main (int argc, char *argv[])
|
||||||
if (!PrintFileDacl(FullPath,
|
if (!PrintFileDacl(FullPath,
|
||||||
FindData.cFileName))
|
FindData.cFileName))
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_ACCESS_DENIED &&
|
LastError = GetLastError();
|
||||||
!ContinueAccessDenied)
|
|
||||||
|
if (LastError == ERROR_ACCESS_DENIED &&
|
||||||
|
ContinueAccessDenied)
|
||||||
{
|
{
|
||||||
break;
|
PrintErrorMessage(LastError);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_tprintf(_T("\n"));
|
_tprintf(_T("\n"));
|
||||||
|
|
Loading…
Reference in a new issue