dynamically load CheckTokenMembership

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3012 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2008-06-13 07:24:11 +00:00
parent 51989fe5f6
commit e33bd0bff1

View file

@ -3132,11 +3132,11 @@ void COM_InitFilesystem (void)
#ifdef _WIN32
{ //win32 sucks.
HMODULE shfolder = LoadLibrary("shfolder.dll");
HMODULE advapi32;
DWORD winver = (DWORD)LOBYTE(LOWORD(GetVersion()));
if (shfolder)
{
//
HRESULT (WINAPI *dSHGetFolderPath) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);
dSHGetFolderPath = (void *)GetProcAddress(shfolder, "SHGetFolderPathA");
if (dSHGetFolderPath)
@ -3152,6 +3152,15 @@ void COM_InitFilesystem (void)
if (winver >= 0x6) // Windows Vista and above
usehome = true; // always use home directory by default, as Vista+ mimics this behavior anyway
else if (winver >= 0x5) // Windows 2000/XP/2003
{
advapi32 = LoadLibrary("advapi32.dll");
if (advapi32)
{
BOOL (WINAPI *dCheckTokenMembership) (HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember);
dCheckTokenMembership = (void *)GetProcAddress(advapi32, "CheckTokenMembership");
if (dCheckTokenMembership)
{
// on XP systems, only use a home directory by default if we're a limited user or if we're on a network
BOOL isadmin, isonnetwork;
@ -3172,10 +3181,10 @@ void COM_InitFilesystem (void)
0, 0, 0, 0, 0, 0, 0,
&networkSID);
if (isadmin && !CheckTokenMembership(0, adminSID, &isadmin))
if (isadmin && !dCheckTokenMembership(0, adminSID, &isadmin))
isadmin = 0;
if (isonnetwork && !CheckTokenMembership(0, networkSID, &isonnetwork))
if (isonnetwork && !dCheckTokenMembership(0, networkSID, &isonnetwork))
isonnetwork = 0;
usehome = isonnetwork || !isadmin;
@ -3184,6 +3193,9 @@ void COM_InitFilesystem (void)
FreeSid(adminSID);
}
FreeLibrary(advapi32);
}
}
if (!*com_homedir)
{