亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? firewall.cpp

?? 奇跡世界公用文件源代碼,研究網絡游戲的朋友可以研究下
?? CPP
字號:
#include "UtilityCommon.h"
#include "Firewall.h"
#ifdef _USE_FIREWALL_SKIP
#include <windows.h>
#include <strsafe.h>
#include <crtdbg.h>
#include <netfw.h>
#include <stdio.h>
#include <conio.h>


//--------------------------------------------------------------------------------------
// FirewallWrapper()
//      Initialize Com and fetch a firewall profile
//--------------------------------------------------------------------------------------
FirewallWrapper::FirewallWrapper()
    : m_pFwProfile(NULL)
{}




//--------------------------------------------------------------------------------------
// ~FirewallWrapper()
//      Release the firewall profile and uninitialize COM
//--------------------------------------------------------------------------------------
FirewallWrapper::~FirewallWrapper()
{
    // Release the firewall profile.
    if( m_pFwProfile != NULL )
    {
        m_pFwProfile->Release();
    }
}




//--------------------------------------------------------------------------------------
// FirewallWrapper::Create()
//--------------------------------------------------------------------------------------
FirewallWrapper* FirewallWrapper::Create()
{
    FirewallWrapper* pfw = new FirewallWrapper;
    if( pfw )
    {
        HRESULT hr = pfw->InitFirewallProfile();
        if( !pfw->FirewallPresent() )
        {
            hr;
            // printf( "Failed to initialize firewall profile: 0x%08lx\n", hr );
            delete pfw;
            pfw = NULL;
        }
    }
    return pfw;
}




//--------------------------------------------------------------------------------------
// InitFirewallProfile()
//      Access the firewall and policy to retrieve the firewall profile.  
//          Initialize COM  
//          Retrieve the firewall profile
//--------------------------------------------------------------------------------------
HRESULT FirewallWrapper::InitFirewallProfile()
{
    HRESULT         hr = S_OK;
    INetFwMgr*      pFwMgr = NULL;
    INetFwPolicy*   pFwPolicy = NULL;

    m_pFwProfile = NULL;

    // Create an instance of the firewall settings manager.
    hr = CoCreateInstance(
            __uuidof(NetFwMgr),
            NULL,
            CLSCTX_INPROC_SERVER,
            __uuidof(INetFwMgr),
            (void**)&pFwMgr
            );
    _ASSERT( hr != CO_E_NOTINITIALIZED && "COM has not been initialized" );
    if( FAILED(hr) )
    {
        // printf( "CoCreateInstance failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Retrieve the local firewall policy.
    hr = pFwMgr->get_LocalPolicy( &pFwPolicy );
    if( FAILED(hr) )
    {
        // printf( "get_LocalPolicy failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Retrieve the firewall profile currently in effect.
    hr = pFwPolicy->get_CurrentProfile( &m_pFwProfile );
    if( FAILED(hr) )
    {
        // printf( "get_CurrentProfile failed: 0x%08lx\n", hr );
        goto cleanup;
    }

cleanup:

    // Release the local firewall policy.
    if( pFwPolicy != NULL )
    {
        pFwPolicy->Release();
    }

    // Release the firewall settings manager.
    if( pFwMgr != NULL )
    {
        pFwMgr->Release();
    }

    return hr;
}




//--------------------------------------------------------------------------------------
// IsFirewallActive()
//      Test if the firewall is on, return as a boolean  
//--------------------------------------------------------------------------------------
BOOL FirewallWrapper::IsFirewallActive()
{
    HRESULT         hr = S_OK;
    VARIANT_BOOL    vbFwEnabled;

    // Get the current state of the firewall.
    // This requires the latest Microsoft Platform SDK to compile because 
    // it uses the Firewall API introduced with Windows XP SP2.
    hr = m_pFwProfile->get_FirewallEnabled( &vbFwEnabled );  // upgrade Platform SDK if this fails to compile
    if( FAILED(hr) || vbFwEnabled == VARIANT_FALSE )
    {
        return FALSE;
    }

    return TRUE;
}




//--------------------------------------------------------------------------------------
// FirewallWrapper::IsAppEnabled()
//      Determine if the specified application is enabled. Return the 
//      result in pbFWAppEnabled. 
//--------------------------------------------------------------------------------------
BOOL FirewallWrapper::IsAppEnabled(
            IN const wchar_t* szFwProcessImageFileName
            )
{
    HRESULT             hr = S_OK;
    BSTR                fwBstrProcessImageFileName = NULL;
    VARIANT_BOOL        vbFwEnabled;
    INetFwAuthorizedApplication*    pFwApp = NULL;
    INetFwAuthorizedApplications*   pFwApps = NULL;
    BOOL bFwAppEnabled = FALSE;
    
    _ASSERT( szFwProcessImageFileName != NULL );

    // Retrieve the collection of authorized applications.
    hr = m_pFwProfile->get_AuthorizedApplications( &pFwApps );
    if( FAILED(hr) )
    {
        // printf( "get_AuthorizedApplications failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Allocate a BSTR for the process image file name.
    fwBstrProcessImageFileName = SysAllocString( szFwProcessImageFileName );
    if( SysStringLen( fwBstrProcessImageFileName ) == 0 )
    {
        hr = E_OUTOFMEMORY;
        // printf( "SysAllocString failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Attempt to retrieve the authorized application.
    hr = pFwApps->Item( fwBstrProcessImageFileName, &pFwApp );
    if( SUCCEEDED(hr ) )
    {
        // Find out if the authorized application is enabled.
        hr = pFwApp->get_Enabled( &vbFwEnabled );
        if( FAILED(hr) )
        {
            // printf( "get_Enabled failed: 0x%08lx\n", hr );
            goto cleanup;
        }

        if( vbFwEnabled != VARIANT_FALSE )
        {
            // The authorized application is enabled.
            bFwAppEnabled = TRUE;

            // printf(
            //     "Authorized application %lS is enabled in the firewall.\n",
            //     szFwProcessImageFileName
            //     );
        }
        else
        {
            // printf(
            //     "Authorized application %lS is disabled in the firewall.\n",
            //     szFwProcessImageFileName
            //     );
        }
    }
    else
    {
        // The authorized application was not in the collection.
        hr = S_OK;

        // printf(
        //     "Authorized application %lS is disabled in the firewall.\n",
        //     szFwProcessImageFileName
        //     );
    }

cleanup:

    // Free the BSTR.
    SysFreeString( fwBstrProcessImageFileName );

    // Release the authorized application instance.
    if( pFwApp != NULL )
    {
        pFwApp->Release();
    }

    // Release the authorized application collection.
    if( pFwApps != NULL )
    {
        pFwApps->Release();
    }

    return bFwAppEnabled;
}


//--------------------------------------------------------------------------------------
// ExceptionsAllowed()
//      Find out if the system is in no-exceptions mode   
//--------------------------------------------------------------------------------------
BOOL FirewallWrapper::AreExceptionsAllowed()
{
    VARIANT_BOOL        vbNotAllowed = VARIANT_FALSE;
    HRESULT             hr = S_OK;

    hr = m_pFwProfile->get_ExceptionsNotAllowed( &vbNotAllowed );
    if( SUCCEEDED(hr) && vbNotAllowed != VARIANT_FALSE )
    {
        return FALSE;
    }
    
    return TRUE; 
}


//--------------------------------------------------------------------------------------
// AddAuthorizedApp()
//      Add an application to the exception list (aka AuthorizedApplication list)  
//--------------------------------------------------------------------------------------
HRESULT FirewallWrapper::AddAuthorizedApp(
            IN const wchar_t* szFwProcessImageFileName,
            IN const wchar_t* szFwFriendlyName
            )
{
    HRESULT             hr = S_OK;
    BSTR                fwBstrName = NULL;
    BSTR                fwBstrProcessImageFileName = NULL;
    INetFwAuthorizedApplication*    pFwApp = NULL;
    INetFwAuthorizedApplications*   pFwApps = NULL;

    _ASSERT( szFwProcessImageFileName != NULL );
    _ASSERT( szFwFriendlyName != NULL );

    // Retrieve the authorized application collection.
    hr = m_pFwProfile->get_AuthorizedApplications( &pFwApps );
    if( FAILED(hr) )
    {
        // printf( "get_AuthorizedApplications failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Create an instance of an authorized application.
    hr = CoCreateInstance(
            __uuidof(NetFwAuthorizedApplication),
            NULL,
            CLSCTX_INPROC_SERVER,
            __uuidof(INetFwAuthorizedApplication),
            (void**)&pFwApp
            );
    if( FAILED(hr) )
    {
        // printf( "CoCreateInstance failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Allocate a BSTR for the process image file name.
    fwBstrProcessImageFileName = SysAllocString( szFwProcessImageFileName );
    if( SysStringLen( fwBstrProcessImageFileName ) == 0 )
    {
        hr = E_OUTOFMEMORY;
        // printf( "SysAllocString failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Set the process image file name.
    hr = pFwApp->put_ProcessImageFileName( fwBstrProcessImageFileName );
    if( FAILED(hr) )
    {
        // printf( "put_ProcessImageFileName failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Allocate a BSTR for the application friendly name.
    fwBstrName = SysAllocString( szFwFriendlyName );
    if( SysStringLen( fwBstrName ) == 0 )
    {
        hr = E_OUTOFMEMORY;
        // printf( "SysAllocString failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Set the application friendly name.
    hr = pFwApp->put_Name( fwBstrName );
    if( FAILED(hr) )
    {
        // printf( "put_Name failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Add the application to the collection.
    hr = pFwApps->Add( pFwApp );
    if( FAILED(hr) )
    {
        // printf( "Add failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // printf(
    //     "Authorized application %lS is now enabled in the firewall.\n",
    //     szFwProcessImageFileName
    //     );

cleanup:

    // Free the BSTRs.
    SysFreeString( fwBstrName );
    SysFreeString( fwBstrProcessImageFileName );

    // Release the authorized application instance.
    if( pFwApp != NULL )
    {
        pFwApp->Release();
    }

    // Release the authorized application collection.
    if( pFwApps != NULL )
    {
        pFwApps->Release();
    }

    return hr;
}


//--------------------------------------------------------------------------------------
// RemoveAuthorizedApp()
//      Remove an application from the exception list (aka AuthorizedApplication list)  
//--------------------------------------------------------------------------------------
HRESULT FirewallWrapper::RemoveAuthorizedApp(
            IN const wchar_t* szFwProcessImageFileName
            )
{
    HRESULT             hr = S_OK;
    BSTR                fwBstrProcessImageFileName = NULL;
    INetFwAuthorizedApplications*   pFwApps = NULL;

    _ASSERT( szFwProcessImageFileName != NULL );

    // Retrieve the authorized application collection.
    hr = m_pFwProfile->get_AuthorizedApplications( &pFwApps );
    if( FAILED(hr) )
    {
        // printf( "get_AuthorizedApplications failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // Allocate a BSTR for the process image file name.
    fwBstrProcessImageFileName = SysAllocString( szFwProcessImageFileName );
    if( SysStringLen( fwBstrProcessImageFileName ) == 0 )
    {
        hr = E_OUTOFMEMORY;
        // printf( "SysAllocString failed: 0x%08lx\n", hr );
        goto cleanup;
    }


    // Remove the application from the collection.
    hr = pFwApps->Remove( fwBstrProcessImageFileName );
    if( FAILED(hr) )
    {
        // printf( "Remove failed: 0x%08lx\n", hr );
        goto cleanup;
    }

    // printf(
    //     "Authorized application %lS is now removed from the firewall.\n",
    //     szFwProcessImageFileName
    //     );

cleanup:

    // Free the BSTRs.
    SysFreeString( fwBstrProcessImageFileName );

    // Release the authorized application collection.
    if( pFwApps != NULL )
    {
        pFwApps->Release();
    }

    return hr;
}


//--------------------------------------------------------------------------------------
// OnInstallApplication() 
// Add the application to the exception (aka authorized) list.
// Returns true if we've been added.
//--------------------------------------------------------------------------------------
BOOL OnInstallApplication(
            IN const wchar_t* szFwProcessImageFileName,
            IN const wchar_t* szFwFriendlyName
            )
{
    FirewallWrapper* pfw = FirewallWrapper::Create();
    if( !pfw )
        return FALSE; 

    HRESULT hr = pfw->AddAuthorizedApp(            
        szFwProcessImageFileName,
        szFwFriendlyName
        );
    return SUCCEEDED(hr);
}


//--------------------------------------------------------------------------------------
// OnUninstallApplication()
//      Remove the application from the exception list.
//--------------------------------------------------------------------------------------
BOOL OnUninstallApplication(
            IN const wchar_t* szFwProcessImageFileName
            )
{
    FirewallWrapper* pfw = FirewallWrapper::Create();
    if( !pfw )
        return FALSE; 
    
    HRESULT hr = pfw->RemoveAuthorizedApp( 
        szFwProcessImageFileName
        );
    return SUCCEEDED(hr);
}


//--------------------------------------------------------------------------------------
// CanHostMultiplayer() 
//      Check that the firewall is properly configured for the game. 
//      Returns FALSE if the firewall is configured to block us from hosting. 
//--------------------------------------------------------------------------------------
BOOL CanHostMultiplayer(
            IN const wchar_t* szFwProcessImageFileName
            )
{
    FirewallWrapper* pfw = FirewallWrapper::Create();
    if( !pfw )
        return TRUE; 
    
    if( !pfw->IsAppEnabled(szFwProcessImageFileName) )
    {
        OutputDebugString( "Application is not enabled in the firewall. You will not be able host games or join a peer-to-peer game. Depending on the game, you may be able to join.\n" );
        return FALSE;
    }

    if( !pfw->AreExceptionsAllowed() )
    {
        OutputDebugString( "Firewall is on with no exceptions. You will not be able host games or join a peer-to-peer game. Depending on the game, you may be able to join.\n" );
        return FALSE;
    }

    return TRUE; 
}

#endif
// _USE_FIREWALL_SKIP

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色猫猫国产区一区二在线视频| 亚洲主播在线播放| 国产欧美日韩在线| 国产精品三级在线观看| 国产精品久久久爽爽爽麻豆色哟哟 | 美腿丝袜亚洲三区| 国产真实乱子伦精品视频| 国产乱码精品一区二区三区av| 国产91在线观看丝袜| 色综合天天综合色综合av | 精品国产乱子伦一区| 欧美高清在线精品一区| 亚洲精品成人在线| 首页综合国产亚洲丝袜| 精品无人码麻豆乱码1区2区 | 欧美一级日韩一级| 久久精品日产第一区二区三区高清版 | 欧美三级中文字| 欧美理论在线播放| 久久在线免费观看| 亚洲婷婷国产精品电影人久久| 亚洲一区在线看| 久久成人免费网| www.日韩大片| 欧美一区二区在线观看| 久久久久国产精品人| 中文字幕一区二区三区在线不卡 | 日韩精品每日更新| 欧美96一区二区免费视频| 国产成人精品网址| 欧美视频精品在线观看| 久久精品视频免费| 午夜精品一区二区三区三上悠亚| 国产精品亚洲视频| 欧美做爰猛烈大尺度电影无法无天| 日韩三级免费观看| 亚洲四区在线观看| 亚洲va欧美va天堂v国产综合| 韩国欧美一区二区| 欧美日韩国产不卡| 欧美国产一区二区在线观看| 亚洲成人精品影院| 国产a视频精品免费观看| 欧美色男人天堂| 2023国产精华国产精品| 一区二区三区免费在线观看| 国产一区二区影院| 欧美日本视频在线| 亚洲美女精品一区| 国产精品影视天天线| 欧美高清一级片在线| 日韩理论片网站| 国产成人免费视频网站| 亚洲国产精品99久久久久久久久| 亚洲在线观看免费视频| 国产91丝袜在线播放| 日韩欧美一级二级三级久久久| 玉米视频成人免费看| 国产99久久久精品| 在线不卡免费av| 欧美国产日本韩| 国产在线播精品第三| 欧美剧情片在线观看| 1000精品久久久久久久久| 国内精品免费在线观看| 欧美一区二区观看视频| 亚洲综合一二区| 99久久777色| 欧美成人a视频| 视频在线观看一区二区三区| 99精品视频一区二区三区| 久久女同精品一区二区| 麻豆高清免费国产一区| 欧美精品日韩一本| 亚洲国产综合色| 成人av网在线| 国产欧美视频在线观看| 国产一区二区日韩精品| 日韩欧美在线影院| 久久精品免费观看| 日韩一区二区电影网| 天堂影院一区二区| 欧美日韩在线亚洲一区蜜芽| 国产日产欧美一区二区视频| 精品一区二区精品| 日韩欧美国产系列| 麻豆国产精品官网| 欧美大片国产精品| 精品制服美女丁香| 久久影院午夜片一区| 国产原创一区二区三区| 欧美mv日韩mv国产网站app| 蜜桃av噜噜一区| 精品精品国产高清a毛片牛牛 | 国产午夜亚洲精品午夜鲁丝片| 国产一区二区在线观看视频| 欧美一区二区免费视频| 久久精品国产澳门| 欧美xxxx在线观看| 国产成人精品亚洲777人妖| 中文在线一区二区| 99国内精品久久| 中文字幕一区二区三| 91成人免费电影| 亚洲成人三级小说| 日韩欧美一级二级三级| 极品少妇一区二区| 国产日本欧美一区二区| 波多野结衣一区二区三区| 91一区一区三区| 一区二区激情小说| 欧美放荡的少妇| 国产做a爰片久久毛片| 欧美激情综合五月色丁香小说| 国产精品亚洲成人| 亚洲免费观看高清完整版在线观看 | 日韩午夜中文字幕| 国产一区二区在线电影| 国产精品家庭影院| 在线视频一区二区三区| 亚洲一区二区四区蜜桃| 欧美日韩久久一区| 毛片基地黄久久久久久天堂| 国产视频亚洲色图| 91免费观看在线| 青青青爽久久午夜综合久久午夜| 久久久久久久综合日本| 色94色欧美sute亚洲线路一久 | 六月婷婷色综合| 国产精品国模大尺度视频| 在线播放日韩导航| 成人黄色免费短视频| 日本v片在线高清不卡在线观看| 国产精品日韩成人| 欧美一卡二卡三卡四卡| 91美女片黄在线观看91美女| 久久99精品久久久久久国产越南| 亚洲码国产岛国毛片在线| 久久综合色8888| 欧美高清视频www夜色资源网| 国产69精品久久777的优势| 日韩精品电影在线| 亚洲日本中文字幕区| 26uuu欧美| 日韩亚洲欧美综合| 欧美日韩日日摸| 色综合色综合色综合| 高清国产一区二区| 久久99久久久久| 婷婷久久综合九色国产成人| 综合色中文字幕| 日本一区二区三区电影| 精品国产一区二区三区久久久蜜月| 欧美中文字幕一区| 99精品国产热久久91蜜凸| 国产呦萝稀缺另类资源| 三级久久三级久久| 亚洲第一福利一区| 亚洲在线免费播放| 一区二区三区**美女毛片| 国产精品天干天干在线综合| 精品第一国产综合精品aⅴ| 欧美一级二级三级蜜桃| 欧美精品视频www在线观看| 色综合久久天天| 99re这里只有精品首页| 成人国产精品视频| 成人免费精品视频| 成人自拍视频在线| 国产jizzjizz一区二区| 国产a久久麻豆| 成人午夜又粗又硬又大| 国产成a人亚洲| 高清av一区二区| 国产高清精品久久久久| 国产精品一区二区无线| 激情文学综合网| 激情综合网激情| 国产激情精品久久久第一区二区 | 国产精品青草综合久久久久99| 久久嫩草精品久久久久| 精品久久人人做人人爽| 精品国产亚洲在线| 精品动漫一区二区三区在线观看| 精品国一区二区三区| 久久免费的精品国产v∧| 2021久久国产精品不只是精品| 精品国产1区2区3区| 国产亚洲短视频| 亚洲欧洲日韩在线| 亚洲美女屁股眼交| 亚洲一区日韩精品中文字幕| 亚洲成人动漫在线观看| 视频一区欧美精品| 久久精品国产秦先生| 国产精品一区二区黑丝| 成人黄色777网| 欧美影院一区二区| 91精品在线免费| 精品人在线二区三区|