mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[SHELL32] Don't crash on Control Panel item D&D (#6289)
Based on @douglyons 's control-panel-copy-to-desktop-fix.patch. JIRA issue: CORE-19210 - Delete needless #ifdef __REACTOS__ guards because shlfileop.cpp is a forked file. - Do NULL check against feFrom->szFilename.
This commit is contained in:
parent
8d7a8f0ec1
commit
d689cfe158
1 changed files with 4 additions and 60 deletions
|
@ -658,7 +658,6 @@ EXTERN_C DWORD WINAPI Win32DeleteFileW(LPCWSTR path)
|
||||||
return (SHNotifyDeleteFileW(NULL, path) == ERROR_SUCCESS);
|
return (SHNotifyDeleteFileW(NULL, path) == ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* CheckForError [internal]
|
* CheckForError [internal]
|
||||||
*
|
*
|
||||||
|
@ -698,7 +697,6 @@ static DWORD CheckForError(FILE_OPERATION *op, DWORD error, LPCWSTR src)
|
||||||
exit:
|
exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* SHNotifyMoveFile [internal]
|
* SHNotifyMoveFile [internal]
|
||||||
|
@ -748,11 +746,7 @@ static DWORD SHNotifyMoveFileW(FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BO
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
return CheckForError(op, GetLastError(), src);
|
return CheckForError(op, GetLastError(), src);
|
||||||
#else
|
|
||||||
return GetLastError();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL SHIsCdRom(LPCWSTR path)
|
static BOOL SHIsCdRom(LPCWSTR path)
|
||||||
|
@ -822,11 +816,7 @@ static DWORD SHNotifyCopyFileW(FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BO
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
return CheckForError(op, GetLastError(), src);
|
return CheckForError(op, GetLastError(), src);
|
||||||
#else
|
|
||||||
return GetLastError();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -1336,7 +1326,7 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
|
WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
|
||||||
FILE_LIST flFromNew, flToNew;
|
FILE_LIST flFromNew, flToNew;
|
||||||
|
|
||||||
if (IsDotDir(feFrom->szFilename))
|
if (feFrom->szFilename && IsDotDir(feFrom->szFilename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (PathFileExistsW(szDestPath))
|
if (PathFileExistsW(szDestPath))
|
||||||
|
@ -1344,7 +1334,6 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
else
|
else
|
||||||
lstrcpyW(szTo, szDestPath);
|
lstrcpyW(szTo, szDestPath);
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
if (PathFileExistsW(szTo))
|
if (PathFileExistsW(szTo))
|
||||||
{
|
{
|
||||||
if (op->req->fFlags & FOF_RENAMEONCOLLISION)
|
if (op->req->fFlags & FOF_RENAMEONCOLLISION)
|
||||||
|
@ -1356,16 +1345,6 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(op->req->fFlags & FOF_NOCONFIRMATION))
|
else if (!(op->req->fFlags & FOF_NOCONFIRMATION))
|
||||||
#else
|
|
||||||
if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo))
|
|
||||||
{
|
|
||||||
CStringW newPath;
|
|
||||||
if (lstrcmp(feFrom->szDirectory, szDestPath) == 0 && !(newPath = try_find_new_name(szTo)).IsEmpty())
|
|
||||||
{
|
|
||||||
StringCchCopyW(szTo, _countof(szTo), newPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FOLDER, feFrom->szFilename, op))
|
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FOLDER, feFrom->szFilename, op))
|
||||||
{
|
{
|
||||||
|
@ -1396,7 +1375,6 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
|
|
||||||
static BOOL copy_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
|
static BOOL copy_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
|
||||||
{
|
{
|
||||||
#ifdef __REACTOS__
|
|
||||||
if (PathFileExistsW(szTo))
|
if (PathFileExistsW(szTo))
|
||||||
{
|
{
|
||||||
if (op->req->fFlags & FOF_RENAMEONCOLLISION)
|
if (op->req->fFlags & FOF_RENAMEONCOLLISION)
|
||||||
|
@ -1412,18 +1390,6 @@ static BOOL copy_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCH
|
||||||
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FILE, PathFindFileNameW(szTo), op))
|
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FILE, PathFindFileNameW(szTo), op))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo))
|
|
||||||
{
|
|
||||||
CStringW newPath;
|
|
||||||
if (lstrcmp(szFrom, szTo) == 0 && !(newPath = try_find_new_name(szTo)).IsEmpty())
|
|
||||||
{
|
|
||||||
return SHNotifyCopyFileW(op, szFrom, newPath, FALSE) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FILE, PathFindFileNameW(szTo), op))
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SHNotifyCopyFileW(op, szFrom, szTo, FALSE) == 0;
|
return SHNotifyCopyFileW(op, szFrom, szTo, FALSE) == 0;
|
||||||
|
@ -1719,7 +1685,7 @@ static void move_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
|
WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
|
||||||
FILE_LIST flFromNew, flToNew;
|
FILE_LIST flFromNew, flToNew;
|
||||||
|
|
||||||
if (IsDotDir(feFrom->szFilename))
|
if (feFrom->szFilename && IsDotDir(feFrom->szFilename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SHNotifyCreateDirectoryW(szDestPath, NULL);
|
SHNotifyCreateDirectoryW(szDestPath, NULL);
|
||||||
|
@ -1744,7 +1710,6 @@ static void move_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
|
||||||
Win32RemoveDirectoryW(feFrom->szFullPath);
|
Win32RemoveDirectoryW(feFrom->szFullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
static BOOL move_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
|
static BOOL move_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
|
||||||
{
|
{
|
||||||
if (PathFileExistsW(szTo))
|
if (PathFileExistsW(szTo))
|
||||||
|
@ -1766,26 +1731,19 @@ static BOOL move_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCH
|
||||||
|
|
||||||
return SHNotifyMoveFileW(op, szFrom, szTo, FALSE) == 0;
|
return SHNotifyMoveFileW(op, szFrom, szTo, FALSE) == 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* moves a file or directory to another directory */
|
/* moves a file or directory to another directory */
|
||||||
static void move_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
|
static void move_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
|
||||||
{
|
{
|
||||||
WCHAR szDestPath[MAX_PATH];
|
WCHAR szDestPath[MAX_PATH];
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
if (!PathFileExistsW(feTo->szFullPath))
|
if (!PathFileExistsW(feTo->szFullPath))
|
||||||
SHNotifyCreateDirectoryW(feTo->szFullPath, NULL);
|
SHNotifyCreateDirectoryW(feTo->szFullPath, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename);
|
PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename);
|
||||||
|
|
||||||
if (IsAttribFile(feFrom->attributes))
|
if (IsAttribFile(feFrom->attributes))
|
||||||
#ifdef __REACTOS__
|
|
||||||
move_file_to_file(op, feFrom->szFullPath, szDestPath);
|
move_file_to_file(op, feFrom->szFullPath, szDestPath);
|
||||||
#else
|
|
||||||
SHNotifyMoveFileW(op, feFrom->szFullPath, szDestPath, FALSE);
|
|
||||||
#endif
|
|
||||||
else if (!(op->req->fFlags & FOF_FILESONLY && feFrom->bFromWildcard))
|
else if (!(op->req->fFlags & FOF_FILESONLY && feFrom->bFromWildcard))
|
||||||
move_dir_to_dir(op, feFrom, szDestPath);
|
move_dir_to_dir(op, feFrom, szDestPath);
|
||||||
}
|
}
|
||||||
|
@ -1846,7 +1804,6 @@ static DWORD move_files(FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
if ((flFrom->dwNumFiles > 1 && flTo->dwNumFiles == 1) ||
|
if ((flFrom->dwNumFiles > 1 && flTo->dwNumFiles == 1) ||
|
||||||
IsAttribDir(fileDest->attributes))
|
IsAttribDir(fileDest->attributes))
|
||||||
{
|
{
|
||||||
|
@ -1864,12 +1821,6 @@ static DWORD move_files(FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flF
|
||||||
return ERROR_CANCELLED;
|
return ERROR_CANCELLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (fileDest->bExists && IsAttribDir(fileDest->attributes))
|
|
||||||
move_to_dir(op, entryToMove, fileDest);
|
|
||||||
else
|
|
||||||
SHNotifyMoveFileW(op, entryToMove->szFullPath, fileDest->szFullPath, IsAttribDir(entryToMove->attributes));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (op->progress != NULL)
|
if (op->progress != NULL)
|
||||||
op->bCancelled |= op->progress->HasUserCancelled();
|
op->bCancelled |= op->progress->HasUserCancelled();
|
||||||
|
@ -1921,18 +1872,12 @@ static void check_flags(FILEOP_FLAGS fFlags)
|
||||||
{
|
{
|
||||||
WORD wUnsupportedFlags = FOF_NO_CONNECTED_ELEMENTS |
|
WORD wUnsupportedFlags = FOF_NO_CONNECTED_ELEMENTS |
|
||||||
FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE |
|
FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE |
|
||||||
#ifdef __REACTOS__
|
|
||||||
FOF_WANTMAPPINGHANDLE;
|
FOF_WANTMAPPINGHANDLE;
|
||||||
#else
|
|
||||||
FOF_RENAMEONCOLLISION | FOF_WANTMAPPINGHANDLE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fFlags & wUnsupportedFlags)
|
if (fFlags & wUnsupportedFlags)
|
||||||
FIXME("Unsupported flags: %04x\n", fFlags);
|
FIXME("Unsupported flags: %04x\n", fFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
|
|
||||||
static DWORD
|
static DWORD
|
||||||
validate_operation(LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom, FILE_LIST *flTo)
|
validate_operation(LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom, FILE_LIST *flTo)
|
||||||
{
|
{
|
||||||
|
@ -2026,7 +1971,7 @@ validate_operation(LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom, FILE_LIST *flT
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SHFileOperationW [SHELL32.@]
|
* SHFileOperationW [SHELL32.@]
|
||||||
*
|
*
|
||||||
|
@ -2063,11 +2008,10 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
|
||||||
op.completedSize.QuadPart = 0ull;
|
op.completedSize.QuadPart = 0ull;
|
||||||
op.bManyItems = (flFrom.dwNumFiles > 1);
|
op.bManyItems = (flFrom.dwNumFiles > 1);
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
ret = validate_operation(lpFileOp, &flFrom, &flTo);
|
ret = validate_operation(lpFileOp, &flFrom, &flTo);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
#endif
|
|
||||||
if (lpFileOp->wFunc != FO_RENAME && !(lpFileOp->fFlags & FOF_SILENT)) {
|
if (lpFileOp->wFunc != FO_RENAME && !(lpFileOp->fFlags & FOF_SILENT)) {
|
||||||
ret = CoCreateInstance(CLSID_ProgressDialog,
|
ret = CoCreateInstance(CLSID_ProgressDialog,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
Loading…
Reference in a new issue