mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
dll: np: NPGetConnection fix and FspNpGetRemoteInfo
This commit is contained in:
parent
f9b6fb8817
commit
5005dd6f5b
43
src/dll/np.c
43
src/dll/np.c
@ -247,14 +247,13 @@ static WCHAR FspNpGetDriveLetter(PDWORD PLogicalDrives, PWSTR VolumeName)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD FspNpGetCredentialsKind(PWSTR RemoteName, PDWORD PCredentialsKind)
|
static DWORD FspNpGetRemoteInfo(PWSTR RemoteName, PDWORD PCredentialsKind)
|
||||||
{
|
{
|
||||||
HKEY RegKey = 0;
|
|
||||||
DWORD NpResult, RegSize;
|
|
||||||
DWORD Credentials;
|
|
||||||
PWSTR ClassName, InstanceName;
|
PWSTR ClassName, InstanceName;
|
||||||
ULONG ClassNameLen, InstanceNameLen;
|
ULONG ClassNameLen, InstanceNameLen;
|
||||||
WCHAR ClassNameBuf[sizeof(((FSP_FSCTL_VOLUME_PARAMS *)0)->Prefix) / sizeof(WCHAR)];
|
WCHAR ClassNameBuf[sizeof(((FSP_FSCTL_VOLUME_PARAMS *)0)->Prefix) / sizeof(WCHAR)];
|
||||||
|
FSP_LAUNCH_REG_RECORD *Record;
|
||||||
|
NTSTATUS Result;
|
||||||
|
|
||||||
*PCredentialsKind = FSP_NP_CREDENTIALS_NONE;
|
*PCredentialsKind = FSP_NP_CREDENTIALS_NONE;
|
||||||
|
|
||||||
@ -267,34 +266,22 @@ static DWORD FspNpGetCredentialsKind(PWSTR RemoteName, PDWORD PCredentialsKind)
|
|||||||
memcpy(ClassNameBuf, ClassName, ClassNameLen * sizeof(WCHAR));
|
memcpy(ClassNameBuf, ClassName, ClassNameLen * sizeof(WCHAR));
|
||||||
ClassNameBuf[ClassNameLen] = '\0';
|
ClassNameBuf[ClassNameLen] = '\0';
|
||||||
|
|
||||||
NpResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"" FSP_LAUNCH_REGKEY,
|
Result = FspLaunchRegGetRecord(ClassNameBuf, L"" FSP_NP_NAME, &Record);
|
||||||
0, FSP_LAUNCH_REGKEY_WOW64 | KEY_READ, &RegKey);
|
if (!NT_SUCCESS(Result))
|
||||||
if (ERROR_SUCCESS != NpResult)
|
return WN_NO_NETWORK;
|
||||||
goto exit;
|
|
||||||
|
|
||||||
RegSize = sizeof Credentials;
|
switch (Record->Credentials)
|
||||||
Credentials = 0; /* default is NO credentials */
|
|
||||||
NpResult = RegGetValueW(RegKey, ClassNameBuf, L"Credentials", RRF_RT_REG_DWORD, 0,
|
|
||||||
&Credentials, &RegSize);
|
|
||||||
if (ERROR_SUCCESS != NpResult && ERROR_FILE_NOT_FOUND != NpResult)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
switch (Credentials)
|
|
||||||
{
|
{
|
||||||
case FSP_NP_CREDENTIALS_NONE:
|
case FSP_NP_CREDENTIALS_NONE:
|
||||||
case FSP_NP_CREDENTIALS_PASSWORD:
|
case FSP_NP_CREDENTIALS_PASSWORD:
|
||||||
case FSP_NP_CREDENTIALS_USERPASS:
|
case FSP_NP_CREDENTIALS_USERPASS:
|
||||||
*PCredentialsKind = Credentials;
|
*PCredentialsKind = Record->Credentials;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NpResult = ERROR_SUCCESS;
|
FspLaunchRegFreeRecord(Record);
|
||||||
|
|
||||||
exit:
|
return WN_SUCCESS;
|
||||||
if (0 != RegKey)
|
|
||||||
RegCloseKey(RegKey);
|
|
||||||
|
|
||||||
return NpResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD FspNpGetCredentials(
|
static DWORD FspNpGetCredentials(
|
||||||
@ -409,7 +396,7 @@ DWORD APIENTRY NPGetConnection(
|
|||||||
|
|
||||||
Result = FspNpGetVolumeList(&VolumeListBuf, &VolumeListSize);
|
Result = FspNpGetVolumeList(&VolumeListBuf, &VolumeListSize);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
return WN_OUT_OF_MEMORY;
|
return WN_NOT_CONNECTED;
|
||||||
|
|
||||||
NpResult = WN_NOT_CONNECTED;
|
NpResult = WN_NOT_CONNECTED;
|
||||||
for (P = VolumeListBuf, VolumeListBufEnd = (PVOID)((PUINT8)P + VolumeListSize), VolumeName = P;
|
for (P = VolumeListBuf, VolumeListBufEnd = (PVOID)((PUINT8)P + VolumeListSize), VolumeName = P;
|
||||||
@ -502,7 +489,9 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
|
|||||||
return WN_ALREADY_CONNECTED;
|
return WN_ALREADY_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FspNpGetCredentialsKind(lpRemoteName, &CredentialsKind);
|
NpResult = FspNpGetRemoteInfo(lpRemoteName, &CredentialsKind);
|
||||||
|
if (WN_SUCCESS != NpResult)
|
||||||
|
return NpResult;
|
||||||
|
|
||||||
#if defined(FSP_NP_CREDENTIAL_MANAGER)
|
#if defined(FSP_NP_CREDENTIAL_MANAGER)
|
||||||
/* if we need credentials and none were passed check with the credential manager */
|
/* if we need credentials and none were passed check with the credential manager */
|
||||||
@ -686,7 +675,9 @@ DWORD APIENTRY NPAddConnection3(HWND hwndOwner,
|
|||||||
return NpResult;
|
return NpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
FspNpGetCredentialsKind(RemoteName, &CredentialsKind);
|
NpResult = FspNpGetRemoteInfo(RemoteName, &CredentialsKind);
|
||||||
|
if (WN_SUCCESS != NpResult)
|
||||||
|
return NpResult;
|
||||||
if (FSP_NP_CREDENTIALS_NONE == CredentialsKind)
|
if (FSP_NP_CREDENTIALS_NONE == CredentialsKind)
|
||||||
return WN_CANCEL;
|
return WN_CANCEL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user