**Context:**
Vanguard Saga of Heroes is an MMORPG that was closed years ago by SOE. However the game is still alive in the emulator scene at https://vgoemulator.net/
The game seems to have relied on an old behaviour of the function SetCurrentDirectoryW( LPCWSTR dir ) which currently crashes the game.
This patch was a solution discovered by the community at https://vgoemulator.net/phpBB3/viewtopic.php?t=5563
It was previously reported to wine bugzilla in this bug report. https://bugs.winehq.org/show_bug.cgi?id=34285
**Summary of changes:**
Updates the function SetCurrentDirectoryW( LPCWSTR dir ) to remove any trailing "." Previously the game will set the current directory as "bin\." and subsequently crash when accessing "bin\.Caches". It will now access "bin\Caches" and run successfully
**Notes:**
This is my first contribution to the project so I might be making a lot of incorrect assumptions on how this might affect other binaries. Please do let me know if there is a better way to implement a change like this in the codebase.
Thanks for your help
-- v4: kernelbase: Workaound for SetCurrentDirectoryW misuse
From: Lois Gomez csberto@gmail.com
--- dlls/ntdll/path.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index 8956ff07f6c..86b35495885 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -966,6 +966,13 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir) ptr = newdir.Buffer; ptr += 4; /* skip ??\ prefix */ size -= 4; + + /* remove trailing '.' if present */ + if (size && ptr[size - 1] == '.' && (size == 1 || ptr[size - 2] == '\')) + { + size--; + } + if (size && ptr[size - 1] != '\') ptr[size++] = '\';
/* convert ??\UNC\ path to \ prefix */