如何在用户模式下获得WLAN适配器支持的802.11操作模式?

时间:2016-10-08 04:39:30

标签: windows winapi driver wlan 802.11

我正在使用Windows上的数据包捕获软件,该软件支持在监控模式下捕获原始802.11数据包。我需要做的一件事是获得支持的WLAN适配器的802.11操作模式

我知道如何在内核模式下执行此操作:只查询内核驱动程序中的OID OID_DOT11_OPERATION_MODE_CAPABILITY

但是,我也想知道如何在用户模式(DLL)中执行此操作。我已经知道Microsoft提供了Native Wifi API。我可以使用 WlanQueryInterface WlanSetInterface 等函数来获取/设置当前的操作模式(下面的代码显示了它)。但它没有提供一个函数来获得适配器支持的操作模式。

有没有办法在不依赖内核代码的情况下解决这个问题?谢谢!

DWORD SetInterface(WLAN_INTF_OPCODE opcode, PVOID pData, GUID* InterfaceGuid)
{
    TRACE_ENTER();

    DWORD dwResult = 0;
    HANDLE hClient = NULL;
    DWORD dwCurVersion = 0;

    if (!initWlanFunctions())
    {
        TRACE_PRINT("SetInterface failed, initWlanFunctions error");
        TRACE_EXIT();
        return ERROR_INVALID_FUNCTION;
    }

    // Open Handle for the set operation
    dwResult = My_WlanOpenHandle(WLAN_CLIENT_VERSION_VISTA, NULL, &dwCurVersion, &hClient);
    if (dwResult != ERROR_SUCCESS)
    {
        TRACE_PRINT1("SetInterface failed, My_WlanOpenHandle error, errCode = %x", dwResult);
        TRACE_EXIT();
        return dwResult;
    }
    dwResult = My_WlanSetInterface(hClient, InterfaceGuid, opcode, sizeof(ULONG), pData, NULL);
    if (dwResult != ERROR_SUCCESS)
    {
        TRACE_PRINT1("SetInterface failed, My_WlanSetInterface error, errCode = %x", dwResult);
    }
    My_WlanCloseHandle(hClient, NULL);

    TRACE_EXIT();
    return dwResult;
}

DWORD GetInterface(WLAN_INTF_OPCODE opcode, PVOID* ppData, GUID* InterfaceGuid)
{
    TRACE_ENTER();

    DWORD dwResult = 0;
    HANDLE hClient = NULL;
    DWORD dwCurVersion = 0;
    DWORD outsize = 0;
    WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_invalid;

    if (!initWlanFunctions())
    {
        TRACE_PRINT("SetInterface failed, initWlanFunctions error");
        TRACE_EXIT();
        return ERROR_INVALID_FUNCTION;
    }

    // Open Handle for the set operation
    dwResult = My_WlanOpenHandle(WLAN_CLIENT_VERSION_VISTA, NULL, &dwCurVersion, &hClient);
    if (dwResult != ERROR_SUCCESS)
    {
        TRACE_PRINT1("GetInterface failed, My_WlanOpenHandle error, errCode = %x", dwResult);
        TRACE_EXIT();
        return dwResult;
    }
    dwResult = My_WlanQueryInterface(hClient, InterfaceGuid, opcode, NULL, &outsize, ppData, &opCode);
    if (dwResult != ERROR_SUCCESS)
    {
        TRACE_PRINT1("GetInterface failed, My_WlanQueryInterface error, errCode = %x", dwResult);
    }
    My_WlanCloseHandle(hClient, NULL);

    TRACE_EXIT();
    return dwResult;
}

0 个答案:

没有答案