[WLANAPI]

partially implement RpcOpenHandle and RpcCloseHandle

svn path=/trunk/; revision=66557
This commit is contained in:
Christoph von Wittich 2015-03-03 20:57:33 +00:00
parent edb65177d2
commit 0117e3b8cb
7 changed files with 208 additions and 86 deletions

View file

@ -12,4 +12,13 @@
#include <winsvc.h>
#include <wlansvc_s.h>
#include <ndk/rtlfuncs.h>
#include <ndk/obfuncs.h>
typedef struct _WLANSVCHANDLE
{
LIST_ENTRY WlanSvcHandleListEntry;
DWORD dwClientVersion;
} WLANSVCHANDLE, *PWLANSVCHANDLE;
#endif /* _WLANSVC_PCH_ */

View file

@ -12,21 +12,103 @@
#include <debug.h>
//#define GET_IF_ENTRY2_IMPLEMENTED 1
LIST_ENTRY WlanSvcHandleListHead;
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
{
RPC_STATUS Status;
InitializeListHead(&WlanSvcHandleListHead);
Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"wlansvc", NULL);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec, NULL, NULL);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerListen() failed (Status %lx)\n", Status);
}
DPRINT("RpcServerListen finished\n");
return 0;
}
PWLANSVCHANDLE WlanSvcGetHandleEntry(LPWLANSVC_RPC_HANDLE ClientHandle)
{
PLIST_ENTRY CurrentEntry;
PWLANSVCHANDLE lpWlanSvcHandle;
CurrentEntry = WlanSvcHandleListHead.Flink;
while (CurrentEntry != &WlanSvcHandleListHead)
{
lpWlanSvcHandle = CONTAINING_RECORD(CurrentEntry,
WLANSVCHANDLE,
WlanSvcHandleListEntry);
CurrentEntry = CurrentEntry->Flink;
if (lpWlanSvcHandle == (PWLANSVCHANDLE) ClientHandle)
return lpWlanSvcHandle;
}
return NULL;
}
DWORD _RpcOpenHandle(
wchar_t *arg_1,
DWORD dwClientVersion,
DWORD *pdwNegotiatedVersion,
LPWLANSVC_RPC_HANDLE phClientHandle)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
PWLANSVCHANDLE lpWlanSvcHandle;
lpWlanSvcHandle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WLANSVCHANDLE));
if (lpWlanSvcHandle == NULL)
{
DPRINT1("Failed to allocate Heap!\n");
return ERROR_NOT_ENOUGH_MEMORY;
}
if (dwClientVersion > 2)
dwClientVersion = 2;
if (dwClientVersion < 1)
dwClientVersion = 1;
lpWlanSvcHandle->dwClientVersion = dwClientVersion;
*pdwNegotiatedVersion = dwClientVersion;
InsertTailList(&WlanSvcHandleListHead, &lpWlanSvcHandle->WlanSvcHandleListEntry);
*phClientHandle = lpWlanSvcHandle;
return ERROR_SUCCESS;
}
DWORD _RpcCloseHandle(
LPWLANSVC_RPC_HANDLE phClientHandle)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
PWLANSVCHANDLE lpWlanSvcHandle;
lpWlanSvcHandle = WlanSvcGetHandleEntry(phClientHandle);
if (!lpWlanSvcHandle)
{
return ERROR_INVALID_HANDLE;
}
RemoveEntryList(&lpWlanSvcHandle->WlanSvcHandleListEntry);
HeapFree(GetProcessHeap(), 0, lpWlanSvcHandle);
return ERROR_SUCCESS;
}
DWORD _RpcEnumInterfaces(
@ -120,6 +202,14 @@ DWORD _RpcGetInterfaceCapability(
const GUID *pInterfaceGuid,
PWLAN_INTERFACE_CAPABILITY *ppCapability)
{
PWLANSVCHANDLE lpWlanSvcHandle;
lpWlanSvcHandle = WlanSvcGetHandleEntry(hClientHandle);
if (!lpWlanSvcHandle)
{
return ERROR_INVALID_HANDLE;
}
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
}
@ -167,6 +257,14 @@ DWORD _RpcScan(
PDOT11_SSID pDot11Ssid,
PWLAN_RAW_DATA pIeData)
{
PWLANSVCHANDLE lpWlanSvcHandle;
lpWlanSvcHandle = WlanSvcGetHandleEntry(hClientHandle);
if (!lpWlanSvcHandle)
{
return ERROR_INVALID_HANDLE;
}
/*
DWORD dwBytesReturned;
HANDLE hDevice;
@ -284,7 +382,7 @@ DWORD _RpcGetProfile(
DWORD _RpcDeleteProfile(
WLANSVC_RPC_HANDLE hClientHandle,
const GUID *pInterfaceGuid,
wchar_t *strProfileName)
const wchar_t *strProfileName)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
@ -293,8 +391,8 @@ DWORD _RpcDeleteProfile(
DWORD _RpcRenameProfile(
WLANSVC_RPC_HANDLE hClientHandle,
const GUID *pInterfaceGuid,
wchar_t *strOldProfileName,
wchar_t *strNewProfileName)
const wchar_t *strOldProfileName,
const wchar_t *strNewProfileName)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
@ -501,7 +599,7 @@ DWORD _RpcCancelPlap(
DWORD _RpcSetSecuritySettings(
WLANSVC_RPC_HANDLE hClientHandle,
WLAN_SECURABLE_OBJECT SecurableObject,
wchar_t *strModifiedSDDL)
const wchar_t *strModifiedSDDL)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;

View file

@ -21,34 +21,9 @@ SERVICE_STATUS_HANDLE ServiceStatusHandle;
SERVICE_STATUS SvcStatus;
static WCHAR ServiceName[] = L"WlanSvc";
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter);
/* FUNCTIONS *****************************************************************/
static DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
{
RPC_STATUS Status;
Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"wlansvc", NULL);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec, NULL, NULL);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status);
return 0;
}
Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0);
if (Status != RPC_S_OK)
{
DPRINT("RpcServerListen() failed (Status %lx)\n", Status);
}
DPRINT("RpcServerListen finished\n");
return 0;
}
static void UpdateServiceStatus(HANDLE hServiceStatus, DWORD NewStatus, DWORD Increment)
{

View file

@ -106,22 +106,22 @@ WlanConnect(IN HANDLE hClientHandle,
IN const PWLAN_CONNECTION_PARAMETERS pConnectionParameters,
PVOID pReserved)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL) || (pConnectionParameters == NULL))
return ERROR_INVALID_PARAMETER;
RpcTryExcept
{
_RpcConnect(hClientHandle, pInterfaceGuid, &pConnectionParameters);
dwResult = _RpcConnect(hClientHandle, pInterfaceGuid, &pConnectionParameters);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -130,22 +130,22 @@ WlanDisconnect(IN HANDLE hClientHandle,
IN const GUID *pInterfaceGuid,
PVOID pReserved)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL))
return ERROR_INVALID_PARAMETER;
RpcTryExcept
{
_RpcDisconnect(hClientHandle, pInterfaceGuid);
dwResult = _RpcDisconnect(hClientHandle, pInterfaceGuid);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -155,7 +155,7 @@ WlanOpenHandle(IN DWORD dwClientVersion,
OUT DWORD *pdwNegotiatedVersion,
OUT HANDLE *phClientHandle)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
WCHAR szDummy[] = L"localhost";
if ((pReserved != NULL) || (pdwNegotiatedVersion == NULL) || (phClientHandle == NULL))
@ -163,18 +163,18 @@ WlanOpenHandle(IN DWORD dwClientVersion,
RpcTryExcept
{
dwError = _RpcOpenHandle(szDummy,
dwResult = _RpcOpenHandle(szDummy,
dwClientVersion,
pdwNegotiatedVersion,
(WLANSVC_RPC_HANDLE) phClientHandle);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -182,22 +182,22 @@ WINAPI
WlanCloseHandle(IN HANDLE hClientHandle,
PVOID pReserved)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (hClientHandle == NULL))
return ERROR_INVALID_PARAMETER;
RpcTryExcept
{
_RpcCloseHandle(hClientHandle);
dwResult = _RpcCloseHandle(&hClientHandle);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -206,22 +206,22 @@ WlanEnumInterfaces(IN HANDLE hClientHandle,
PVOID pReserved,
OUT PWLAN_INTERFACE_INFO_LIST *ppInterfaceList)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (ppInterfaceList == NULL) || (hClientHandle == NULL))
return ERROR_INVALID_PARAMETER;
RpcTryExcept
{
_RpcEnumInterfaces(hClientHandle, ppInterfaceList);
dwResult = _RpcEnumInterfaces(hClientHandle, ppInterfaceList);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -232,22 +232,22 @@ WlanScan(IN HANDLE hClientHandle,
IN PWLAN_RAW_DATA pIeData,
PVOID pReserved)
{
DWORD dwError = ERROR_SUCCESS;
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL))
return ERROR_INVALID_PARAMETER;
RpcTryExcept
{
_RpcScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData);
dwResult = _RpcScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwError;
return dwResult;
}
DWORD
@ -319,11 +319,22 @@ WlanSetSecuritySettings(IN HANDLE hClientHandle,
IN WLAN_SECURABLE_OBJECT SecurableObject,
IN LPCWSTR strModifiedSDDL)
{
DWORD dwResult = ERROR_SUCCESS;
if ((hClientHandle == NULL) || (strModifiedSDDL == NULL) || (SecurableObject >= WLAN_SECURABLE_OBJECT_COUNT))
return ERROR_INVALID_PARAMETER;
UNIMPLEMENTED;
return ERROR_SUCCESS;
RpcTryExcept
{
dwResult = _RpcSetSecuritySettings(hClientHandle, SecurableObject, strModifiedSDDL);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwResult;
}
DWORD

View file

@ -39,11 +39,22 @@ WlanDeleteProfile(IN HANDLE hClientHandle,
IN LPCWSTR strProfileName,
PVOID pReserved)
{
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL) || (strProfileName == NULL))
return ERROR_INVALID_PARAMETER;
UNIMPLEMENTED;
return ERROR_SUCCESS;
RpcTryExcept
{
dwResult = _RpcDeleteProfile(hClientHandle, pInterfaceGuid, strProfileName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwResult;
}
DWORD
@ -54,11 +65,22 @@ WlanRenameProfile(IN HANDLE hClientHandle,
IN LPCWSTR strNewProfileName,
PVOID pReserved)
{
DWORD dwResult = ERROR_SUCCESS;
if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL) || (strOldProfileName == NULL) || (strNewProfileName == NULL))
return ERROR_INVALID_PARAMETER;
UNIMPLEMENTED;
return ERROR_SUCCESS;
RpcTryExcept
{
dwResult = _RpcRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwResult = RpcExceptionCode();
}
RpcEndExcept;
return dwResult;
}
DWORD

View file

@ -10,6 +10,9 @@ extern "C" {
#endif
/* Defines */
#define WLAN_API_VERSION_1_0 0x00000001
#define WLAN_API_VERSION_2_0 0x00000002
#define WLAN_MAX_PHY_INDEX 64
#define WLAN_MAX_NAME_LENGTH 256

View file

@ -6,7 +6,7 @@
#include <wlanapi.h>
typedef [context_handle] PVOID WLANSVC_RPC_HANDLE;
typedef WLANSVC_RPC_HANDLE* LPWLANSVC_RPC_HANDLE;
typedef WLANSVC_RPC_HANDLE *LPWLANSVC_RPC_HANDLE;
typedef [handle, string] LPWSTR WLANSVC_HANDLE;
/* FIXME */
@ -39,8 +39,12 @@ typedef struct struct_E {
} struct_E ;
[
uuid(266f33b4-c7c1-4bd1-8f52-ddb8f2214ea9),
version(1.0)
uuid(266f33b4-c7c1-4bd1-8f52-ddb8f2214ea9),
version(1.0),
pointer_default(unique)
#ifndef __midl
,explicit_handle
#endif
]
interface wlansvc_interface
@ -50,11 +54,11 @@ interface wlansvc_interface
[in] WLANSVC_HANDLE szMachineName,
[in] DWORD dwClientVersion,
[out] DWORD* pdwNegotiatedVersion,
[out] LPWLANSVC_RPC_HANDLE phClientHandle);
[out] WLANSVC_RPC_HANDLE *phClientHandle);
/* Function: 0x01 */
DWORD _RpcCloseHandle(
[in, out] LPWLANSVC_RPC_HANDLE phClientHandle);
[in, out] WLANSVC_RPC_HANDLE *phClientHandle);
/* Function: 0x02 */
DWORD _RpcEnumInterfaces(
@ -189,14 +193,14 @@ interface wlansvc_interface
DWORD _RpcDeleteProfile(
[in] WLANSVC_RPC_HANDLE hClientHandle,
[in] const GUID* pInterfaceGuid,
[in][string] wchar_t * strProfileName);
[in][string] const wchar_t * strProfileName);
/* Function: 0x14 */
DWORD _RpcRenameProfile(
[in] WLANSVC_RPC_HANDLE hClientHandle,
[in] const GUID* pInterfaceGuid,
[in][string] wchar_t * strOldProfileName,
[in][string] wchar_t * strNewProfileName);
[in][string] const wchar_t * strOldProfileName,
[in][string] const wchar_t * strNewProfileName);
/* Function: 0x15 */
DWORD _RpcSetProfileList(
@ -262,35 +266,35 @@ interface wlansvc_interface
[in] DWORD dwFlags,
[in] BOOL bOverWrite);
/* Function: 0x1E, address: 0x2C992E36 */
/* Function: 0x1E */
DWORD _RpcIsUIRequestPending(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] const GUID* pInterfaceGuid,
[in] struct_C * arg_3,
[out] LPDWORD arg_4);
/* Function: 0x1F, address: 0x2C992EB3 */
/* Function: 0x1F */
DWORD _RpcSetUIForwardingNetworkList(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in][size_is(dwSize)] GUID* arg_2,
[in] DWORD dwSize,
[out] GUID* arg_4);
/* Function: 0x20 */
DWORD _RpcIsNetworkSuppressed(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] DWORD arg_2,
[in] const GUID* pInterfaceGuid,
[out] LPDWORD arg_4);
/* Function: 0x21 */
DWORD _RpcRemoveUIForwardingNetworkList(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] const GUID* pInterfaceGuid);
/* Function: 0x22 */
DWORD _RpcQueryExtUIRequest(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] GUID* arg_2,
[in] GUID* arg_3,
[in] /* enum16 */ short arg_4,
@ -299,13 +303,13 @@ interface wlansvc_interface
/* Function: 0x23 */
DWORD _RpcUIResponse(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] struct_C * arg_2,
[in] struct_D * arg_3);
/* Function: 0x24 */
DWORD _RpcGetProfileKeyInfo(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] DWORD arg_2,
[in] const GUID* pInterfaceGuid,
[in][string] wchar_t * arg_4,
@ -316,7 +320,7 @@ interface wlansvc_interface
/* Function: 0x25 */
DWORD _RpcAsyncDoPlap(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] const GUID* pInterfaceGuid,
[in][string] wchar_t * arg_3,
[in] DWORD dwSize,
@ -324,7 +328,7 @@ interface wlansvc_interface
/* Function: 0x26 */
DWORD _RpcQueryPlapCredentials(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in, out] LPDWORD dwSize,
[out][ref][size_is(*dwSize)] struct_E ** arg_3,
[out][ref][string] wchar_t ** arg_4,
@ -336,14 +340,14 @@ interface wlansvc_interface
/* Function: 0x27 */
DWORD _RpcCancelPlap(
[in] wchar_t * arg_1,
[in] WLANSVC_HANDLE arg_1,
[in] const GUID* pInterfaceGuid);
/* Function: 0x28 */
DWORD _RpcSetSecuritySettings(
[in] WLANSVC_RPC_HANDLE hClientHandle,
[in] WLAN_SECURABLE_OBJECT SecurableObject,
[in][string] wchar_t * strModifiedSDDL);
[in][string] const wchar_t * strModifiedSDDL);
/* Function: 0x29 */
DWORD _RpcGetSecuritySettings(