Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Winfile.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@
<ClCompile Include="wfsearch.c" />
<ClCompile Include="wftree.c" />
<ClCompile Include="wfutil.c" />
<ClCompile Include="wfwow.c" />
<ClCompile Include="winfile.c" />
<ClCompile Include="wnetcaps.c" />
</ItemGroup>
Expand Down
25 changes: 7 additions & 18 deletions src/lfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ WFFindFirst(
// and ORDINARY files too.
//

PVOID oldValue;
Wow64DisableWow64FsRedirection(&oldValue);

if ((dwAttrFilter & ~(ATTR_DIR | ATTR_HS)) == 0)
{
// directories only (hidden or not)
lpFind->hFindFile = FindFirstFileEx(lpName, FindExInfoStandard, &lpFind->fd, FindExSearchLimitToDirectories, NULL, 0);
lpFind->hFindFile = WFWowFindFirstFileEx(lpName, FindExInfoStandard, &lpFind->fd, FindExSearchLimitToDirectories, NULL, 0);
}
else
{
// normal case: directories and files
lpFind->hFindFile = FindFirstFile(lpName, &lpFind->fd);
lpFind->hFindFile = WFWowFindFirstFile(lpName, &lpFind->fd);
}

if (lpFind->hFindFile == INVALID_HANDLE_VALUE) {
Expand All @@ -68,8 +65,6 @@ WFFindFirst(

lpFind->fd.dwFileAttributes &= ATTR_USED;

Wow64RevertWow64FsRedirection(oldValue);

//
// Keep track of length
//
Expand Down Expand Up @@ -116,10 +111,7 @@ WFFindFirst(
BOOL
WFFindNext(LPLFNDTA lpFind)
{
PVOID oldValue;
Wow64DisableWow64FsRedirection(&oldValue);

while (FindNextFile(lpFind->hFindFile, &lpFind->fd)) {
while (WFWowFindNextFile(lpFind->hFindFile, &lpFind->fd)) {

lpFind->fd.dwFileAttributes &= ATTR_USED;

Expand Down Expand Up @@ -154,15 +146,12 @@ WFFindNext(LPLFNDTA lpFind)
}
}

Wow64RevertWow64FsRedirection(oldValue);

lpFind->err = 0;
return TRUE;
}

lpFind->err = GetLastError();

Wow64RevertWow64FsRedirection(oldValue);
return(FALSE);
}

Expand Down Expand Up @@ -210,7 +199,7 @@ WFFindClose(LPLFNDTA lpFind)
BOOL
WFIsDir(LPTSTR lpDir)
{
DWORD attr = GetFileAttributes(lpDir);
DWORD attr = WFWowGetFileAttributes(lpDir);

if (attr == INVALID_FILE_ATTRIBUTES)
return FALSE;
Expand Down Expand Up @@ -493,7 +482,7 @@ WFCopyIfSymlink(LPTSTR pszFrom, LPTSTR pszTo, DWORD dwFlags, DWORD dwNotificatio
WCHAR szReparseDest[2 * MAXPATHLEN];
DWORD dwReparseTag = DecodeReparsePoint(pszFrom, szReparseDest, 2 * MAXPATHLEN);
if (IO_REPARSE_TAG_SYMLINK == dwReparseTag) {
CreateSymbolicLink(pszTo, szReparseDest, dwFlags);
WFWowCreateSymbolicLink(pszTo, szReparseDest, dwFlags);
dwRet = GetLastError();
if (ERROR_SUCCESS == dwRet)
ChangeFileSystem(dwNotification, pszTo, NULL);
Expand All @@ -517,7 +506,7 @@ WFCopy(LPTSTR pszFrom, LPTSTR pszTo)
Notify(hdlgProgress, IDS_COPYINGMSG, pszFrom, pszTo);

BOOL bCancel = FALSE;
if (CopyFileEx(pszFrom, pszTo, NULL, NULL, &bCancel, COPY_FILE_COPY_SYMLINK)) {
if (WFWowCopyFileEx(pszFrom, pszTo, NULL, NULL, &bCancel, COPY_FILE_COPY_SYMLINK)) {
ChangeFileSystem(FSC_CREATE, pszTo, NULL);
dwRet = 0;
}
Expand All @@ -535,7 +524,7 @@ WFCopy(LPTSTR pszFrom, LPTSTR pszTo)
//
lstrcpy(szTemp, pszTo);
RemoveLast(szTemp);
if (CopyFile(pszFrom, szTemp, FALSE)) {
if (WFWowCopyFile(pszFrom, szTemp, FALSE)) {
ChangeFileSystem(FSC_CREATE, szTemp, NULL);
dwRet = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/treectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ GetTreePath(PDNODE pNode, register LPTSTR szDest)
VOID
SetNodeAttribs(PDNODE pNode, LPTSTR szPath)
{
pNode->dwAttribs = GetFileAttributes(szPath);
pNode->dwAttribs = WFWowGetFileAttributes(szPath);
if (INVALID_FILE_ATTRIBUTES == pNode->dwAttribs) {
pNode->dwAttribs = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/wfcomman.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ ChangeFileSystem(
// Are we renaming a directory?
lstrcpy(szTemp, szTo);

if (GetFileAttributes(szTemp) & ATTR_DIR)
if (WFWowGetFileAttributes(szTemp) & ATTR_DIR)
{
for (hwnd = GetWindow(hwndMDIClient, GW_CHILD);
hwnd;
Expand Down Expand Up @@ -1375,7 +1375,7 @@ AppCommandProc(register DWORD id)
sei.lpDirectory = szPath;
}

ShellExecuteEx(&sei);
WFWowShellExecuteEx(&sei);
}
else if (count > 1)
DialogBox(hAppInstance, (LPTSTR) MAKEINTRESOURCE(MULTIPLEATTRIBSDLG), hwndFrame, AttribsDlgProc);
Expand Down
24 changes: 12 additions & 12 deletions src/wfcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
lstrcat(szDestAlt, szExtension);

// We only do a one level '- Copy' postfixing, and do intentionally not go for a '- Copy (n)' postfix
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(szDestAlt)) {
if (INVALID_FILE_ATTRIBUTES == WFWowGetFileAttributes(szDestAlt)) {
lstrcpy(szDest, szDestAlt);
bSameFile = FALSE;
} else {
Expand Down Expand Up @@ -2512,7 +2512,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
// Save the attributes, since ConfirmDialog may change them.
//
dwAttr = GetFileAttributes(szDest);
dwAttr = WFWowGetFileAttributes(szDest);

// we need to check if we are trying to copy a file
// over a directory and give a reasonable error message
Expand Down Expand Up @@ -2600,7 +2600,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
if (ret)
{
SetFileAttributes(szDest, dwAttr);
WFWowSetFileAttributes(szDest, dwAttr);
}
}

Expand Down Expand Up @@ -2809,7 +2809,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
// Tuck away the attribs in case we fail.
//
dwAttr = GetFileAttributes(szSource);
dwAttr = WFWowGetFileAttributes(szSource);

WFSetAttr(szSource, FILE_ATTRIBUTE_NORMAL);

Expand Down Expand Up @@ -2880,8 +2880,8 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
// NOTE: Must first make sure the attributes are clear so that
// the delete will always succeed.
//
SetFileAttributes(szDest, FILE_ATTRIBUTE_NORMAL);
DeleteFile(szDest);
WFWowSetFileAttributes(szDest, FILE_ATTRIBUTE_NORMAL);
WFWowDeleteFile(szDest);

//
// Show retry popup.
Expand Down Expand Up @@ -2955,7 +2955,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
// Save the attributes, since ConfirmDialog may change them.
//
dwAttr = GetFileAttributes(szSource);
dwAttr = WFWowGetFileAttributes(szSource);

// Confirm the rename

Expand Down Expand Up @@ -3066,7 +3066,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
// Reset the attributes on the source file, since they
// may have been changed by ConfirmDialog.
//
SetFileAttributes(szSource, dwAttr);
WFWowSetFileAttributes(szSource, dwAttr);
}

if (pCopyInfo->bUserAbort)
Expand All @@ -3088,7 +3088,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
// Save the attributes, since ConfirmDialog may change them.
//
dwAttr = GetFileAttributes(szSource);
dwAttr = WFWowGetFileAttributes(szSource);

// Confirm the delete first

Expand Down Expand Up @@ -3131,7 +3131,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter)
//
if (ret)
{
SetFileAttributes(szSource, dwAttr);
WFWowSetFileAttributes(szSource, dwAttr);
}

break;
Expand Down Expand Up @@ -3387,7 +3387,7 @@ DMMoveCopyHelper(
DWORD
FileRemove(LPTSTR pSpec)
{
if (DeleteFile(pSpec))
if (WFWowDeleteFile(pSpec))
return (DWORD)0;
else
return GetLastError();
Expand All @@ -3404,7 +3404,7 @@ FileMove(LPTSTR pFrom, LPTSTR pTo, PBOOL pbErrorOnDest, BOOL bSilent)
*pbErrorOnDest = FALSE;

TryAgain:
if (MoveFile((LPTSTR)pFrom, (LPTSTR)pTo))
if (WFWowMoveFile((LPTSTR)pFrom, (LPTSTR)pTo))
result = 0;
else
result = GetLastError();
Expand Down
4 changes: 2 additions & 2 deletions src/wfdirrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ CreateDTABlockWorker(

// Check if it is a Reparse Point
lpTemp[0] = '\0';
DWORD attr = GetFileAttributes(szPath);
DWORD attr = WFWowGetFileAttributes(szPath);
lpTemp[0] = CHAR_BACKSLASH;
if (attr & ATTR_REPARSE_POINT) {
// For dead Reparse Points just tell that the directory could not be read
Expand Down Expand Up @@ -1168,7 +1168,7 @@ DWORD DecodeReparsePoint(LPCWSTR szFullPath, LPWSTR szDest, DWORD cwcDest)
DWORD reparseTag;
BOOL bRP;

hFile = CreateFile(szFullPath, FILE_READ_EA, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
hFile = WFWowCreateFile(szFullPath, FILE_READ_EA, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return IO_REPARSE_TAG_RESERVED_ZERO;

Expand Down
6 changes: 3 additions & 3 deletions src/wfdlgs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ JAPANEND
QualifyPath(szTemp);

// Is this a file or directory
if (GetFileAttributes(szTemp) & FILE_ATTRIBUTE_DIRECTORY) {
if (WFWowGetFileAttributes(szTemp) & FILE_ATTRIBUTE_DIRECTORY) {
if (szTo[ich2 - 1] == '\"')
ich2--;
}
Expand Down Expand Up @@ -1402,7 +1402,7 @@ InitPropertiesDialog(
{
if ((bFileCompression) && (dwAttribsOn & ATTR_COMPRESSED))
{
qCSize.LowPart = GetCompressedFileSize(szName, &(qCSize.HighPart));
qCSize.LowPart = WFWowGetCompressedFileSize(szName, &(qCSize.HighPart));
PutSize(&qCSize, szNum);
wsprintf(szTemp, szSBytes, szNum);
SetDlgItemText(hDlg, IDD_CSIZE, szTemp);
Expand Down Expand Up @@ -1778,7 +1778,7 @@ AttribsDlgProc(register HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)

QualifyPath(szName);

dwAttribs = GetFileAttributes(szName);
dwAttribs = WFWowGetFileAttributes(szName);

if (dwAttribs == INVALID_FILE_ATTRIBUTES)
goto AttributeError;
Expand Down
4 changes: 2 additions & 2 deletions src/wfdrop.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static HRESULT StreamToFile(IStream *stream, TCHAR *szFile)
HRESULT hr;
HANDLE hFile;

hFile = CreateFile( szFile,
hFile = WFWowCreateFile( szFile,
FILE_READ_DATA | FILE_WRITE_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
Expand All @@ -210,7 +210,7 @@ static HRESULT StreamToFile(IStream *stream, TCHAR *szFile)
} while (S_OK == hr && bytes_written != 0);
CloseHandle(hFile);
if (FAILED(hr))
DeleteFile(szFile);
WFWowDeleteFile(szFile);
else
hr = S_OK;
}
Expand Down
Loading