Skip to content

Commit

Permalink
Added GetLongPathName APIs, which basically return the short path pas…
Browse files Browse the repository at this point in the history
…sed as argument.
  • Loading branch information
cube0x8 committed Jan 6, 2021
1 parent de5bda0 commit 33dac1d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
mpclient
avscript
eicar.com
.gradle/
.idea/
26 changes: 26 additions & 0 deletions peloader/winapi/Paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ UINT WINAPI GetDriveTypeW(PWCHAR lpRootPathName)
return DRIVE_FIXED;
}

DWORD WINAPI GetLongPathNameA(LPCSTR lpszShortPath,
LPSTR lpszLongPath,
DWORD cchBuffer)
{
// For now we just return the 8.3 format path as the long path
if (cchBuffer > strlen(lpszShortPath)) {
memcpy(lpszLongPath, lpszShortPath, sizeof(lpszShortPath));
}

return strlen(lpszShortPath);
}

DWORD WINAPI GetLongPathNameW(LPCWSTR lpszShortPath,
LPWSTR lpszLongPath,
DWORD cchBuffer)
{
// For now we just return the 8.3 format path as the long path
if (cchBuffer > strlen(lpszShortPath)) {
memcpy(lpszLongPath, lpszShortPath, sizeof(lpszShortPath));
}

return strlen(lpszShortPath);
}

DECLARE_CRT_EXPORT("GetTempPathW", GetTempPathW);
DECLARE_CRT_EXPORT("GetLogicalDrives", GetLogicalDrives);
DECLARE_CRT_EXPORT("GetDriveTypeW", GetDriveTypeW);
DECLARE_CRT_EXPORT("GetLongPathNameA", GetLongPathNameA);
DECLARE_CRT_EXPORT("GetLongPathNameW", GetLongPathNameW);

0 comments on commit 33dac1d

Please sign in to comment.