Malcolm,
there was a lengthy reply to the mailing list 10 days ago sent by me,
explaining what's going on.
Your assumption is wrong. VirtualBox on all Windows versions worth
talking about will NOT fall through, it'll use the profile directory
returned by SHGetFolderPath.
Klaus
On 20.11.2016 19:55, Malcolm Clarke wrote:
Dear Max
Still no response.
Looking at path-win.cpp, the following code is unclear
RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
{
/*
* Validate input
*/
AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
AssertReturn(cchPath, VERR_INVALID_PARAMETER);
RTUTF16 wszPath[RTPATH_MAX];
bool fValidFolderPath = false;
/*
* Try with Windows XP+ functionality first.
*/
RTLDRMOD hShell32;
int rc = RTLdrLoadSystem("Shell32.dll", true /*fNoUnload*/,
&hShell32);
if (RT_SUCCESS(rc))
{
PFNSHGETFOLDERPATHW pfnSHGetFolderPathW;
rc = RTLdrGetSymbol(hShell32, "SHGetFolderPathW",
(void**)&pfnSHGetFolderPathW);
if (RT_SUCCESS(rc))
{
HRESULT hrc = pfnSHGetFolderPathW(0, CSIDL_PROFILE, NULL,
SHGFP_TYPE_CURRENT, wszPath);
fValidFolderPath = (hrc == S_OK);
}
RTLdrClose(hShell32);
}
DWORD dwAttr;
if ( !fValidFolderPath
|| (dwAttr = GetFileAttributesW(&wszPath[0])) ==
INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
/*
* Fall back to Windows specific environment variables. HOME
is not used.
*/
if ( !GetEnvironmentVariableW(L"USERPROFILE", &wszPath[0],
RTPATH_MAX)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) ==
INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
/* %HOMEDRIVE%%HOMEPATH% */
if (!GetEnvironmentVariableW(L"HOMEDRIVE", &wszPath[0],
RTPATH_MAX))
return VERR_PATH_NOT_FOUND;
size_t const cwc = RTUtf16Len(&wszPath[0]);
if ( !GetEnvironmentVariableW(L"HOMEPATH",
&wszPath[cwc], RTPATH_MAX - (DWORD)cwc)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) ==
INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
return VERR_PATH_NOT_FOUND;
}
}
Assuming this falls through to get the environment variable, then
USERPROFILE is used over %HOMEDRIVE%%HOMEPATH%, however in most other
places %HOMEDRIVE%%HOMEPATH% alone is used. This appears to result in
inconsistent behaviour if USERPROFILE is not equal to
%HOMEDRIVE%%HOMEPATH%.
This needs to be remedied for people using roaming profiles when these
environmental variables can be set differently.
1. %HOMEDRIVE%%HOMEPATH% is used for location of configuration files
(create and check location for existence)
2. USERPROFILE may be used for temporary files
Regards
Malcolm
On 09/11/2016 14:36, Maxime Dor wrote:
Hi Malcolm,
While I have extensive knowledge of VBox, I'm not a dev so I can't
really answer that question, only the devs can.
They should answer anytime soon now! If they don't be tomorrow, just
let me know and I'll drop them a note.
Max
--
*Malcolm Clarke *BSc (Hons), PhD
Reader in Telemedicine and Data Communication Systems
T+44 (0) 1895 265053
*Brunel University London*
College of Engineering, Design and Physical Sciences
Department of Computer Science
HNZW010, Heinz Wolff Building, Kingston Lane, Uxbridge, Middlesex, UB8 3PH
*www.brunel.ac.uk <http://www.brunel.ac.uk/>*
Connect with the university on*Linkedin, Twitter, Facebook*
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev