Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle relative paths in the DeleteFileW() hook #16

Merged
Merged
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
8 changes: 5 additions & 3 deletions src/usvfs_dll/hooks/kernel32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,15 @@ BOOL WINAPI usvfs::hook_DeleteFileW(LPCWSTR lpFileName)
HOOK_START_GROUP(MutExHookGroup::DELETE_FILE)
// Why is the usual if (!callContext.active()... check missing?

RerouteW reroute = RerouteW::create(READ_CONTEXT(), callContext, lpFileName);
const std::wstring path = RerouteW::canonizePath(RerouteW::absolutePath(lpFileName)).wstring();

RerouteW reroute = RerouteW::create(READ_CONTEXT(), callContext, path.c_str());

PRE_REALCALL
if (reroute.wasRerouted()) {
res = ::DeleteFileW(reroute.fileName());
} else {
res = ::DeleteFileW(lpFileName);
res = ::DeleteFileW(path.c_str());
}
POST_REALCALL

Expand Down Expand Up @@ -868,7 +870,7 @@ BOOL WINAPI usvfs::hook_MoveFileWithProgressW(LPCWSTR lpExistingFileName, LPCWST

if (res) {
//TODO: this call causes the node to be removed twice in case of MOVEFILE_COPY_ALLOWED as the deleteFile hook lower level already takes care of it,
//but deleteFile can't be disabled since we are relying on it in case of MOVEFILE_REPLACE_EXISTING for the destination file.
//but deleteFile can't be disabled since we are relying on it in case of MOVEFILE_REPLACE_EXISTING for the destination file.
readReroute.removeMapping(READ_CONTEXT(), isDirectory); // Updating the rerouteCreate to check deleted file entries should make this okay (not related to comments above)

if (writeReroute.newReroute()) {
Expand Down