Ejemplo n.º 1
0
static void UpdateDataGeneral(__in HWND hDlg, PSHWZCNET pwzcnet, INT *pnMeta, BOOL fSetControl)
{
   BOOL    bCheck = FALSE;

   DDX_Comb(hDlg, IDC_WZC_COMBO_CONNECT_TO, pnMeta, fSetControl);

   if (fSetControl)
   {
      // Set SSID
      DDX_Text(hDlg, IDC_WZC_EDIT_SSID, pwzcnet->szName, 0, TRUE);

      // Check ADHOC network
      bCheck = BOOLIFY(pwzcnet->dwFlags & SHWZCF_NET_ADHOC);
      DDX_Check(hDlg, IDC_WZC_CHECK_ADHOC, &bCheck, TRUE);

      // Hidden network checkbox
      bCheck = BOOLIFY(pwzcnet->dwFlags & SHWZCF_NET_REQUIRE_WZC_PROBE);
      DDX_Check(hDlg, IDC_WZC_CHECK_HIDDEN, &bCheck, TRUE);
      
   }
   else 
   {
      DDX_Text (hDlg, IDC_WZC_EDIT_SSID, pwzcnet->szName, ARRAYSIZE(pwzcnet->szName), FALSE);

      DDX_Check(hDlg, IDC_WZC_CHECK_ADHOC, &bCheck, FALSE);
      pwzcnet->dwFlags = (pwzcnet->dwFlags & ~SHWZCF_NET_ADHOC) | (bCheck ? SHWZCF_NET_ADHOC : 0);

      DDX_Check(hDlg, IDC_WZC_CHECK_HIDDEN, &bCheck, FALSE);
      pwzcnet->dwFlags = (pwzcnet->dwFlags & ~SHWZCF_NET_REQUIRE_WZC_PROBE) | (bCheck ? SHWZCF_NET_REQUIRE_WZC_PROBE : 0);
   }
}
Ejemplo n.º 2
0
static HRESULT OnConnect(PWLAN_INFO psInfo, INT iItem)
{
    HRESULT    hr = S_OK;
    PCSHWZCNET pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem);
    SHWZCNET   wzcnet;
    BOOL       fSecure;

    // The first item is "Add net settings...". It cannot be deleted.
    CBR(iItem > 0 && pwzcnet != NULL);
    memcpy(&wzcnet, pwzcnet, sizeof(SHWZCNET));

    // If the item isn't preferred
    if (!(SHWZCF_NET_PREFERRED & wzcnet.dwFlags))
    {
        DWORD dwNoFastConnect = 0;

        fSecure = BOOLIFY(wzcnet.dwFlags & SHWZCF_NET_8021X) ||
                !( ( (Ndis802_11Encryption1Enabled != wzcnet.dwEncryptionType) &&
                (Ndis802_11Encryption2Enabled != wzcnet.dwEncryptionType) &&
                (Ndis802_11Encryption3Enabled != wzcnet.dwEncryptionType) ) &&
                (Ndis802_11AuthModeOpen == wzcnet.dwAuthentication) );

        // If secure or fastconnect is disabled, show the settings wizard, else connect
        RegistryGetDWORD(HKEY_LOCAL_MACHINE, WZC_REGKEY_BASE, WZC_REGKEY_DISABLEFASTCONNECT, &dwNoFastConnect);
        if (fSecure || dwNoFastConnect != 0)
        {
            CBR(OnNetworkProperties(psInfo, iItem));
        }
        else
        {
            SHWZCSetNetwork(psInfo->hshwzc, &wzcnet, NULL, NULL, 0, SHWZCF_SETMASK_ALL);
        }
    }

    // disable SK1 Connect while we're attempting to connect for this network
    SHEnableSoftkey(psInfo->hwndNetListMB, 0, TRUE, FALSE);

    // Ensure that power is on. Ignore errors, this is a "Best-effort" attempt
    SHWZCSetPowerState(TRUE);
        
    // Now connect directly (we'll automatically get a refresh event)
    hr = SHWZCConnectNetwork(psInfo->hshwzc, wzcnet.szName,
        BOOLIFY(SHWZCF_NET_ADHOC & wzcnet.dwFlags));
    CHR(hr);

Error:
    if(FAILED(hr))
    {
        // re-enable SK since something went wrong
        SHEnableSoftkey(psInfo->hwndNetListMB, 0, TRUE, TRUE);
    }
    
    return hr;
}
Ejemplo n.º 3
0
void EnableGeneralControls(HWND hDlg, PWLAN_CFG_PROPS psProp)
{
    EnableWindow(GetDlgItem(hDlg, IDC_WZC_EDIT_SSID),        BOOLIFY(psProp->dwFlags & WZCDLG_PROPS_RWSSID));
    EnableWindow(GetDlgItem(hDlg, IDC_WZC_COMBO_CONNECT_TO), TRUE);
    
    // Disable the ad-hoc checkbox if this network was already marked as hidden
    EnableWindow(GetDlgItem(hDlg, IDC_WZC_CHECK_ADHOC),      BOOLIFY((psProp->dwFlags & WZCDLG_PROPS_RWINFR) &&
                                                                     !(psProp->wzcnet.dwFlags & SHWZCF_NET_REQUIRE_WZC_PROBE)));
    // Disable the hidden checkbox if this network was already marked ad-hoc
    EnableWindow(GetDlgItem(hDlg, IDC_WZC_CHECK_HIDDEN),     BOOLIFY(!(psProp->wzcnet.dwFlags & SHWZCF_NET_ADHOC)));
}
Ejemplo n.º 4
0
const bool Symbols::SymbolFromName(const char * const pName, const SymbolInfo **pFullSymbolInfo)
{
    char pBuffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)
        + sizeof(ULONG64) - 1 / sizeof(ULONG64)] = { 0 };
    PSYMBOL_INFO pSymInfo = (PSYMBOL_INFO)pBuffer;
    
    pSymInfo->SizeOfStruct = sizeof(SYMBOL_INFO);
    pSymInfo->MaxNameLen = MAX_SYM_NAME;

    const bool bSuccess = BOOLIFY(SymFromName(m_hProcess, pName, pSymInfo));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not retrieve symbol for name %s. Error = %X.\n",
            pName, GetLastError());
        return false;
    }

    fprintf(stderr, "Symbol found for %s. Name: %.*s. Address: %p. Base address of module: %p\n",
        pName, pSymInfo->NameLen, pSymInfo->Name, (DWORD_PTR)pSymInfo->Address,
        (DWORD_PTR)pSymInfo->ModBase);

    *pFullSymbolInfo = FindSymbolByAddress((DWORD_PTR)pSymInfo->Address);

    return bSuccess;
}
Ejemplo n.º 5
0
BOOL OnOKGeneral(HWND hDlg, PWLAN_CFG_PROPS psProp)
{
    HRESULT  hr = S_OK;
    SHWZCNET wzcnet;
    INT      nMeta;
    DWORD    dwMask;

    // Get the UI settings
    memcpy(&wzcnet, &psProp->wzcnet, sizeof(SHWZCNET));
    UpdateDataGeneral(hDlg, &wzcnet, &nMeta, FALSE);

    if (psProp->dwFlags & WZCDLG_PROPS_RWSSID) // SSID is changable
    {
        // Is the SSID empty?
        if (TEXT('\0') == wzcnet.szName[0])
        {
            MessageBoxWithResID(hDlg, IDS_WZC_NULL_SSID, IDS_WZC_MSG_TITLE, MB_ICONSTOP | MB_OK);
            CBR(FALSE);
        }

        // Is the name valid?
        hr = SHWZCValidateNetworkName(wzcnet.szName, NULL, 0);
        if (FAILED(hr))
        {
            MessageBoxWithResID(hDlg, IDS_WZC_INVALID_NAME, IDS_WZC_MSG_TITLE, MB_ICONSTOP | MB_OK);
            CHR(hr);
        }

        // Make sure that we do have a valid handle to shwzc
        // If the handle is null, most likely the parent window received an OnActivateHome.
        // We don't ever destroy the callback because the parent window will destroy it.
        hr = SetCallbackRegistration(TRUE, psProp->psWLanInfo);
        CHR(hr);
        // Is this a duplicate name?
        if (S_FALSE != SHWZCIsDuplicateName(psProp->psWLanInfo->hshwzc,
            wzcnet.szName, BOOLIFY(wzcnet.dwFlags & SHWZCF_NET_ADHOC)))
        {
            MessageBoxWithResID(hDlg, IDS_WZC_DUP_SSID, IDS_WZC_MSG_TITLE, MB_ICONSTOP | MB_OK);
            CBR(FALSE);
        }

        // Copy the name
        CHRA(StringCchCopy(psProp->wzcnet.szName, ARRAYSIZE(psProp->wzcnet.szName), wzcnet.szName));
    }

    // Apply the changes
    dwMask = SHWZCF_SETMASK_ADHOC | SHWZCF_SETMASK_REQUIRE_WZC_PROBE;
    hr = SHWZCCopySettings(&psProp->wzcnet, &wzcnet, dwMask);
    CHR(hr);

    psProp->uMeta = nMeta;
    psProp->dwMask |= dwMask;

Error:
    if (FAILED(hr))
    {
        PostMessage(hDlg, WM_DELAY_SETFOCUS, IDC_WZC_EDIT_SSID, 0L);
    }
    return SUCCEEDED(hr);
}
Ejemplo n.º 6
0
Symbols::~Symbols()
{
    const bool bSuccess = BOOLIFY(SymCleanup(m_hProcess));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not terminate symbol handler. Error = %X.\n",
            GetLastError());
    }
}
Ejemplo n.º 7
0
const bool Symbols::ListSourceFiles()
{
    const bool bSuccess = BOOLIFY(SymEnumSourceFiles(m_hProcess, 0, nullptr,
        SymEnumSourceFilesCallback, nullptr));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not enumerate source files for process. Error = %X\n", GetLastError());
    }

    return bSuccess;
}
Ejemplo n.º 8
0
const bool Symbols::EnumerateAllModulesWithSymbols()
{
    const bool bSuccess = BOOLIFY(SymEnumerateModules64(m_hProcess, SymEnumCallback, this));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not enumerate symbols. Error = %X.\n",
            GetLastError());
    }

    return bSuccess;
}
Ejemplo n.º 9
0
const bool Symbols::DumpSourceFileInfo(const DWORD64 dwBaseAddress, const char * const pFilePath)
{
    const bool bSuccess = BOOLIFY(SymEnumLines(m_hProcess, dwBaseAddress, nullptr, pFilePath,
        SymEnumLinesCallback, nullptr));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not dump source file %s with base address %p.\n",
            pFilePath, dwBaseAddress);
    }

    return bSuccess;
}
Ejemplo n.º 10
0
Symbols::Symbols(const HANDLE hProcess, const HANDLE hFile, const bool bLoadAll /*= false*/)
    : m_hProcess{ hProcess }, m_hFile{ hFile }
{
    (void)SymSetOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_DEFERRED_LOADS |
        SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);

    const bool bSuccess = BOOLIFY(SymInitialize(hProcess, nullptr, bLoadAll));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not initialize symbol handler. Error = %X.\n",
            GetLastError());
    }
}
bool AvisynthCheckThread::detect(SysinfoModel *sysinfo)
{
	sysinfo->clearAvisynth();
	double version = 0.0;
	QMutexLocker lock(&m_avsLock);

	QEventLoop loop;
	AvisynthCheckThread thread(sysinfo);

	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

	connect(&thread, SIGNAL(finished()), &loop, SLOT(quit()));
	connect(&thread, SIGNAL(terminated()), &loop, SLOT(quit()));
	
	thread.start();
	QTimer::singleShot(30000, &loop, SLOT(quit()));
	
	qDebug("Avisynth thread has been created, please wait...");
	loop.exec(QEventLoop::ExcludeUserInputEvents);
	qDebug("Avisynth thread finished.");

	QApplication::restoreOverrideCursor();

	if(!thread.wait(1000))
	{
		qWarning("Avisynth thread encountered timeout -> probably deadlock!");
		thread.terminate();
		thread.wait();
		return false;
	}

	if(thread.getException())
	{
		qWarning("Avisynth thread encountered an exception !!!");
		return false;
	}
	
	if(thread.getSuccess())
	{
		sysinfo->setAvisynth(SysinfoModel::Avisynth_X86, thread.getSuccess() & AVISYNTH_X86);
		sysinfo->setAvisynth(SysinfoModel::Avisynth_X64, thread.getSuccess() & AVISYNTH_X64);
		sysinfo->setAVSPath(thread.getPath());
		qDebug("Avisynth support is officially enabled now! [x86=%c, x64=%c]", BOOLIFY(sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)), BOOLIFY(sysinfo->getAvisynth(SysinfoModel::Avisynth_X64)));
	}
	else
	{
		qWarning("Avisynth could not be found -> Avisynth support disabled!");
	}

	return true;
}
Ejemplo n.º 12
0
//==========================================================================*
// Function: OnNetworkProperties
//
// Purpose:  (1) Display the network properties dialog
//           (2) Move(insert) the network to the head of the prefered list
//           
// Arguments: 
//     [IN] psInfo - pointer to the WLAN_INFO structure
//     [IN] item   - item need to show context menu
//
// Return Values:
//     BOOL - TRUE for handle it successfully
//==========================================================================*
static BOOL OnNetworkProperties(PWLAN_INFO psInfo, INT iItem)
{
    HRESULT        hr = S_OK;
    WLAN_CFG_PROPS sProps = {0};
    PCSHWZCNET     pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem);
    BOOL           fAdhoc;
    TCHAR          szGUID[MAX_PATH];
    FINDGUID       fg;

    CBR(iItem > 0 && pwzcnet != NULL);

    // If the selected network is a "Permanent" non-editable network, exit without 
    // showing the NetworkProperties pages
    fAdhoc = BOOLIFY(SHWZCF_NET_ADHOC & pwzcnet->dwFlags);
    CBREx (!SHWZCIsPermanentNetwork(pwzcnet->szName, fAdhoc), S_FALSE);

    // Get the current EAP data
    hr = SHWZCGetNetwork(psInfo->hshwzc, pwzcnet->szName, fAdhoc,
        &sProps.wzcnet, &sProps.pvEapData, &sProps.cbEapData);
    CHR(hr);

    // We don't care about the result, since if this fails we just won't match
    // with any networks and we'll use the default
    szGUID[0] = 0;
    SHWZCGetDestinationGUID(psInfo->hshwzc, pwzcnet->szName, fAdhoc,
        szGUID, ARRAYSIZE(szGUID));

    fg.pszGUID = szGUID;
    fg.uIndex = 0;
    if (S_FALSE == SHWZCEnumDestinations(EnumFindGUID, &fg))
    {
        sProps.uMeta = fg.uIndex;
    }

    sProps.psWLanInfo = psInfo;
    
    hr = WZCCreateNetworkWLanPropsDlgs(psInfo->hDlg, &sProps);
    CHR(hr);

    if (IDOK == sProps.nReturn)
    {
        hr = ApplyProperties(psInfo, &sProps);
        CHR(hr); 
    }

Error:
    LocalFree(sProps.pvEapData);
    return SUCCEEDED(hr);
}
Ejemplo n.º 13
0
static HRESULT ApplyProperties(PWLAN_INFO psInfo, const WLAN_CFG_PROPS *psProps)
{
    HRESULT  hr = S_OK;
    FINDGUID fg;
    TCHAR    szGUID[MAX_PATH];
    DWORD dwHardwareState;

    fg.pszGUID = szGUID;
    fg.cchGUID = ARRAYSIZE(szGUID);
    fg.uIndex = 0;
    fg.uDesired = psProps->uMeta;

    // Set the network data
    hr = SHWZCSetNetwork(psInfo->hshwzc, &psProps->wzcnet, psProps->pszKey,
        psProps->pvEapData, psProps->cbEapData, psProps->dwMask);
    CHR(hr);

    // Copy the GUID string
    CBR(S_FALSE == SHWZCEnumDestinations(EnumSetGUID, &fg));
    hr = SHWZCSetDestinationGUID(psInfo->hshwzc, psProps->wzcnet.szName,
        BOOLIFY(SHWZCF_NET_ADHOC & psProps->wzcnet.dwFlags), szGUID);
    CHR(hr);

    // Refresh the view
    RefreshNetListView(psInfo);

    dwHardwareState = SHWZCGetHardwareFlags();
    if (!(dwHardwareState & SHWZCF_HW_CONNECTED) && !(dwHardwareState & SHWZCF_HW_CONNECTING))
    {
        hr = SHWZCConnectNetwork(psInfo->hshwzc, psProps->wzcnet.szName,
            BOOLIFY(SHWZCF_NET_ADHOC & psProps->wzcnet.dwFlags));
        CHR(hr);
    }        
Error:
    return hr;
}
Ejemplo n.º 14
0
const IMAGEHLP_LINE64 Symbols::GetSymbolLineInfo(const DWORD64 dwAddress, DWORD &dwDisplacement, bool &bSuccess)
{
    dwDisplacement = 0;
    IMAGEHLP_LINE64 lineInfo = { 0 };
    lineInfo.SizeOfStruct = sizeof(IMAGEHLP_LINE64);

    bSuccess = BOOLIFY(SymGetLineFromAddr64(m_hProcess, dwAddress, &dwDisplacement, &lineInfo));
    if (!bSuccess)
    {
        //fprintf(stderr, "Could not get line from address %p. Error = %X.\n",
        //    (DWORD_PTR)dwAddress, GetLastError());
    }

    return lineInfo;
}
Ejemplo n.º 15
0
const bool Disassembler::TransferBytes(const DWORD_PTR dwAddress)
{
    SIZE_T ulBytesRead = 0;
    bool bSuccess = BOOLIFY(ReadProcessMemory(m_hProcess, (LPCVOID)dwAddress, m_bytes.data(), m_bytes.size(), &ulBytesRead));
    if (bSuccess && ulBytesRead == m_bytes.size())
    {
        return true;
    }
    else
    {
        fprintf(stderr, "Could not read from %p. Error = %X\n", dwAddress, GetLastError());
    }

    return false;
}
Ejemplo n.º 16
0
const IMAGEHLP_LINE64 Symbols::GetSymbolLineInfo(const char * const pName, const char * const pFileName,
    const DWORD dwLineNumber, LONG &lDisplacement, bool &bSuccess)
{
    IMAGEHLP_LINE64 lineInfo = { 0 };
    lineInfo.SizeOfStruct = sizeof(IMAGEHLP_LINE64);

    bSuccess = BOOLIFY(SymGetLineFromName64(m_hProcess, pName, pFileName, dwLineNumber,
        &lDisplacement, &lineInfo));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not get virtual address for symbol %s:%s on line %i.\n"
            "Error = %X.\n", pFileName, pName, dwLineNumber, GetLastError());
    }

    return lineInfo;
}
Ejemplo n.º 17
0
HRESULT EnableControlsAuthentication(HWND hDlg, PWLAN_CFG_PROPS psProp)
{
    HRESULT hr = S_OK;
    HWND    hcbAuth = GetDlgItem(hDlg, IDC_WZC_COMBO_AUTHENTICATION);

    // Clear the authentication combo box
    SendMessage(hcbAuth, CB_RESETCONTENT, 0, 0);

    // Populate the authentication combo box
    hr = SHWZCEnumAuthenticationTypes(BOOLIFY(SHWZCF_NET_ADHOC & psProp->wzcnet.dwFlags),
        EnumAuthentication, hcbAuth);
    CHR(hr);
    CBR(S_OK == hr);  // S_FALSE is failure

Error:
    return hr;
}
Ejemplo n.º 18
0
HRESULT UpdateDataAuthentication(HWND hDlg, PSHWZCNET pwzcnet, BOOL fSetControl)
{
    HRESULT hr = S_OK;
    BOOL    bCheck = FALSE;
    INT     nIndex = 0;

    CBRA(hDlg && pwzcnet);

    if (fSetControl)
    {
        DWORD dwDisplayFlags = 0;
        
        HWND hcbAuth = GetDlgItem(hDlg, IDC_WZC_COMBO_AUTHENTICATION);
        CWRA(hcbAuth);
        nIndex = FindIndexFromComboData(hcbAuth, pwzcnet->dwAuthentication);
        CBRA(0 <= nIndex);  // huh??

        SendMessage(hcbAuth, CB_SETCURSEL, nIndex, 0);

        // Get the display flags
        SHWZCGetDisplayFlags(pwzcnet, &dwDisplayFlags);
        bCheck = BOOLIFY(SHWZCF_UI_AUTOKEY_SET & dwDisplayFlags);      
        DDX_Check(hDlg, IDC_WZC_CHECK_KEY_PROVIDED_AUTOMATICALLY, &bCheck, TRUE);

        nIndex = pwzcnet->dwKeyIndex - 1;
        if (nIndex < 0) nIndex = 0;
        DDX_Comb(hDlg, IDC_WZC_COMBO_WEP_INDEX, &nIndex, TRUE);

        // If the auth mode changed then we should re-set the encryption mode
        PopulateEncryptionBox(hDlg, pwzcnet);
    }
    else 
    {
        UpdateAuthenticationMode(hDlg, pwzcnet);
        UpdateEncryptionMode(hDlg, pwzcnet);
        UpdateAutoKeyMode(hDlg, pwzcnet);

        DDX_Comb(hDlg, IDC_WZC_COMBO_WEP_INDEX, &nIndex, FALSE);
        pwzcnet->dwKeyIndex = nIndex + 1;
        ASSERT(0 <= nIndex && nIndex <= 3);
    }

Error:
    return hr;
}
Ejemplo n.º 19
0
static HRESULT OnRemoveSetting(PWLAN_INFO psInfo, INT iItem)
{
    HRESULT    hr = S_OK;
    PCSHWZCNET pwzcnet =(PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem);

    // The first item is "Add net settings...". It cannot be deleted.
    CBR(iItem > 0 && pwzcnet != NULL);

    // Delete the network
    hr = SHWZCDeleteNetwork(psInfo->hshwzc, pwzcnet->szName,
        BOOLIFY(SHWZCF_NET_ADHOC & pwzcnet->dwFlags));
    CHR(hr);

    // Refresh list view
    RefreshNetListView(psInfo);

Error:
    return hr;
}
Ejemplo n.º 20
0
const bool Symbols::EnumerateModuleSymbols(const char * const pModulePath, const DWORD64 dwBaseAddress)
{
    DWORD64 dwBaseOfDll = SymLoadModuleEx(m_hProcess, m_hFile, pModulePath, nullptr,
        dwBaseAddress, 0, nullptr, 0);
    if (dwBaseOfDll == 0)
    {
        fprintf(stderr, "Could not load modules for %s. Error = %X.\n",
            pModulePath, GetLastError());
        return false;
    }

    UserContext userContext = { this, pModulePath };
    const bool bSuccess = 
       BOOLIFY(SymEnumSymbols(m_hProcess, dwBaseOfDll, "*!*", SymEnumCallback, &userContext));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not enumerate symbols for %s. Error = %X.\n",
            pModulePath, GetLastError());
    }

    return bSuccess;
}
Ejemplo n.º 21
0
const bool Symbols::SymbolFromAddress(const DWORD64 dwAddress, const SymbolInfo **pFullSymbolInfo)
{
    char pBuffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(char)] = { 0 };
    PSYMBOL_INFO pSymInfo = (PSYMBOL_INFO)pBuffer;

    pSymInfo->SizeOfStruct = sizeof(SYMBOL_INFO);
    pSymInfo->MaxNameLen = MAX_SYM_NAME;

    DWORD64 dwDisplacement = 0;
    const bool bSuccess = BOOLIFY(SymFromAddr(m_hProcess, dwAddress, &dwDisplacement, pSymInfo));
    if (!bSuccess)
    {
        fprintf(stderr, "Could not retrieve symbol from address %p. Error = %X.\n",
            (DWORD_PTR)dwAddress, GetLastError());
        return false;
    }

    fprintf(stderr, "Symbol found at %p. Name: %.*s. Base address of module: %p\n",
        (DWORD_PTR)dwAddress, pSymInfo->NameLen, pSymInfo->Name, (DWORD_PTR)pSymInfo->ModBase);

    *pFullSymbolInfo = FindSymbolByName(pSymInfo->Name);

    return bSuccess;
}
Ejemplo n.º 22
0
BOOL OnOKAuthentication(HWND hDlg, PWLAN_CFG_PROPS psProp, BOOL fValidate)
{
    HRESULT  hr = S_OK;
    SHWZCNET wzcnet;
    DWORD    dwDisplayFlags = 0;
    BOOL     fApplyKey;
    BOOL     fVerified = FALSE;
    DWORD    dwMask = SHWZCF_SETMASK_AUTHENTICATION | SHWZCF_SETMASK_ENCRYPTION | SHWZCF_SETMASK_KEYINDEX;

    // Get the UI settings
    memcpy(&wzcnet, &psProp->wzcnet, sizeof(SHWZCNET));
    hr = UpdateDataAuthentication(hDlg, &wzcnet, FALSE);
    CHR(hr);

    // Check for valid authentication and encryption configuration
    if (fValidate && 
        !SHWZCValidateSecurityConfig(wzcnet.dwAuthentication, 
                                     wzcnet.dwEncryptionType,
                                     BOOLIFY(SHWZCF_NET_ADHOC & wzcnet.dwFlags)))
    {
        DisplayError(hDlg, IDS_WZC_INVALID_CONFIG, IDC_WZC_COMBO_AUTHENTICATION);
        CBR(FALSE);
    }

    // Get the display flags
    hr = SHWZCGetDisplayFlags(&wzcnet, &dwDisplayFlags);
    CHR(hr);

    // Only verify the key if the key material is touched
    if (!(SHWZCF_UI_KEYDATA_DISABLED & dwDisplayFlags) &&
        (SHWZCF_NET_KEYDATA & wzcnet.dwFlags) &&
        (WZCDLG_PROPS_KEYTOUCHED & psProp->dwFlags))
    {
        TCHAR szKeyBuf[WZCCTL_MAX_WEPK_MATERIAL * 2 + 1];
        DDX_Text(hDlg, IDC_WZC_EDIT_WEP, szKeyBuf, ARRAYSIZE(szKeyBuf), FALSE);

        if(fValidate)
        {        
            BOOL fDisplayError = FALSE;
            
            if(TEXT('\0') == szKeyBuf[0])
            {
                // only adhoc networks can have an empty string as a key
                if(BOOLIFY(SHWZCF_NET_ADHOC & psProp->wzcnet.dwFlags))
                {
                    // make sure apply key doesn't get set.  This way if the user validates this state, the wifi netkey will not display *'s when 
                    // when editing the network.  
                    wzcnet.dwFlags &= ~SHWZCF_NET_KEYDATA;
                }
                else
                {
                    fDisplayError = TRUE;
                }
            }
            else 
            {
                if (SHWZCValidateKey(szKeyBuf, wzcnet.dwEncryptionType, wzcnet.dwAuthentication))
                {
                    fVerified = TRUE;
                }
                else
                {
                    fDisplayError = TRUE;
                }
            }

            if(fDisplayError)
            {
                DisplayError(hDlg, IDS_WZC_INCORRECT_WEP_KEY, IDC_WZC_EDIT_WEP);
                CBR(FALSE);
            }
        }

        // Copy the key data into the buffer
        hr = StringCchCopy(psProp->pszKey, ARRAYSIZE(psProp->pszKey), szKeyBuf);
        CHRA(hr);  // this should always work
    }

    // Apply the changes to the network
    fApplyKey = (!(SHWZCF_NET_KEYDATA & wzcnet.dwFlags) || (WZCDLG_PROPS_KEYTOUCHED & psProp->dwFlags));
    dwMask |= (fApplyKey ? SHWZCF_SETMASK_KEYDATA : 0);
    hr = SHWZCCopySettings(&psProp->wzcnet, &wzcnet, dwMask);
    CHR(hr);

    // Success
    psProp->dwMask |= dwMask;

    if(fVerified)
    {   
        // at this point we can say the WEP key is untouched since it's been verified
        psProp->dwFlags &= ~WZCDLG_PROPS_KEYTOUCHED;
    }

Error:
    return SUCCEEDED(hr);
}
Ejemplo n.º 23
0
void Enable8021xControls(HWND hDlg, WLAN_CFG_PROPS *pWCP)
{
    DWORD dwDisplayFlags = 0;
    BOOL  f8021x = BOOLIFY(SHWZCF_NET_8021X & pWCP->wzcnet.dwFlags);
    BOOL  fEnabled;
    HWND  hwndCbEAPType = GetDlgItem(hDlg, IDC_WZC_COMBO_EAP_TYPE);

    // Get the UI flags for this network
    SHWZCGetDisplayFlags(&pWCP->wzcnet, &dwDisplayFlags);

    if (SHWZCF_UI_8021X_DISABLED & dwDisplayFlags)
    {
        // Disable 802.1x checkbox
        DDX_Check(hDlg, IDC_WZC_CHECK_ENABLE8021X, &f8021x, TRUE);
        EnableWindow(GetDlgItem(hDlg, IDC_WZC_CHECK_ENABLE8021X), FALSE);
    }
    else
    {
        // Enable 802.1x
        EnableWindow(GetDlgItem(hDlg, IDC_WZC_CHECK_ENABLE8021X), TRUE);
    }

    // Is the EAP combo enabled?
    fEnabled = !BOOLIFY(SHWZCF_UI_EAPTYPE_DISABLED & dwDisplayFlags);
    if (fEnabled)
    {
        // We also disable if 802.1x isn't checked
        DDX_Check(hDlg, IDC_WZC_CHECK_ENABLE8021X, &fEnabled, FALSE);
        EnableWindow(GetDlgItem(hDlg, IDC_WZC_STATIC_ENABLE8021X), TRUE);
    }
    else
    {
        PWZC_EAP_CB_ITEMDATA pEapCbItemData;
        UINT cItems = ComboBox_GetCount(hwndCbEAPType);
        UINT i;

        // The configuration doesn't allow custom EAP types, so set it to the
        // default
        for (i = 0; i != cItems; ++i)
        {
            pEapCbItemData = (PWZC_EAP_CB_ITEMDATA)ComboBox_GetItemData(hwndCbEAPType, i);
            if (DEFAULT_EAP_TYPE == pEapCbItemData->pEapExtInfo->dwExtensionType)
            {
                ComboBox_SetCurSel(hwndCbEAPType, i);
                break;
            }
        }

        // Also disable the EAP type label so the user knows it doesn't apply
        EnableWindow(GetDlgItem(hDlg, IDC_WZC_STATIC_ENABLE8021X), FALSE);
    }

    // Set the control state
    EnableWindow(hwndCbEAPType, fEnabled);

    // Determine whether to enable the properties button
    if (fEnabled)
    {
        PWZC_EAP_CB_ITEMDATA pEapCbItemData=NULL;
        int                  iListIndex = ComboBox_GetCurSel(hwndCbEAPType);
        
        if (iListIndex != CB_ERR) 
        {
            pEapCbItemData = (WZC_EAP_CB_ITEMDATA *)ComboBox_GetItemData(hwndCbEAPType, iListIndex);
        }
        
        fEnabled = (pEapCbItemData && ((int)pEapCbItemData != CB_ERR) && 
                   pEapCbItemData->pEapExtInfo->wszConfigUIPath && 
                   pEapCbItemData->pEapExtInfo->wszConfigUIPath[0]);
    }

    // Set the control state
    EnableWindow(GetDlgItem(hDlg, IDC_WZC_BUTTON_EAP_PROPERTIES), fEnabled);
}
Ejemplo n.º 24
0
DWORD Init8021xControls(HWND hDlg, WLAN_CFG_PROPS *pWCP)
{
    DWORD dwError;
    BOOL  fEnabled;
    BOOL  bCurSelSet    = FALSE;
    HWND  hwndCbEAPType = GetDlgItem(hDlg, IDC_WZC_COMBO_EAP_TYPE);
    int   i;

    fEnabled = BOOLIFY(SHWZCF_NET_8021X & pWCP->wzcnet.dwFlags);
    SendMessage(GetDlgItem(hDlg, IDC_WZC_CHECK_ENABLE8021X), BM_SETCHECK, 
                fEnabled ? BST_CHECKED : BST_UNCHECKED, 0);

    if (pWCP->pEapExtInfo == NULL) 
    {
        // Load EAP extension info
        dwError = WZCEnumEapExtensions(&pWCP->dwNumEapExt,&pWCP->pEapExtInfo);
        if (dwError != ERROR_SUCCESS) 
        {
            DEBUGMSG(ZONE_ERROR,(TEXT("!WZCUI:Error 0x%X loading EAP extensions\r\n"),dwError));
            return dwError;
        }                  

        if (pWCP->dwNumEapExt > 0 && pWCP->pEapExtInfo)
        {
            PEAP_EXTENSION_INFO pCurExt;           
            PWCHAR              wszDefaultFriendlyName=NULL;
            
            for ( i = 0, pCurExt = pWCP->pEapExtInfo; i < (int)pWCP->dwNumEapExt; i++, pCurExt++) 
            {
                // Add EAP types to combo box
                WZC_EAP_CB_ITEMDATA *pEapCbItemData = (WZC_EAP_CB_ITEMDATA *)LocalAlloc(LPTR,sizeof(WZC_EAP_CB_ITEMDATA));
                int                  iListIndex;
                
                if (pEapCbItemData) 
                {
                    iListIndex = ComboBox_AddString(hwndCbEAPType, pCurExt->wszFriendlyName);
                    pEapCbItemData->pEapExtInfo = pCurExt;
                    ComboBox_SetItemData(hwndCbEAPType, iListIndex,pEapCbItemData);
                    
                    // For currently selected EAP type, store provider specific data
                    if (fEnabled && pWCP->wzcnet.dwEAPType == pCurExt->dwExtensionType)
                    {
                        // Get the current EAP data
                        pEapCbItemData->pbAuthData = (LPBYTE)pWCP->pvEapData;
                        pEapCbItemData->dwAuthDataLen = pWCP->cbEapData;
                        pWCP->pvEapData = NULL;  // so we don't free it twice

                        // Select this entry in the list
                        ComboBox_SetCurSel(hwndCbEAPType, iListIndex);
                        bCurSelSet = TRUE;
                    } 
                    else if (pCurExt->dwExtensionType == DEFAULT_EAP_TYPE) 
                    {
                        wszDefaultFriendlyName = pCurExt->wszFriendlyName;
                    }
                }
            }
            // No matching providers, set to default
            if (pWCP->dwNumEapExt && !bCurSelSet) 
            {
                UINT uResult=0;
                DEBUGMSG(ZONE_NETWORK,(TEXT("WZCUI: No matching providers for EAP type %d\r\n"),
                                       pWCP->wzcnet.dwEAPType));
                if (wszDefaultFriendlyName) 
                {
                    uResult = ComboBox_FindString(hwndCbEAPType, -1, wszDefaultFriendlyName);
                    if (uResult == CB_ERR)
                        uResult = 0;
                }
                ComboBox_SetCurSel(hwndCbEAPType, uResult);
            }
        }
    }
    
    return ERROR_SUCCESS;
}
Ejemplo n.º 25
0
BOOL NetworkWLanGeneralPropsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    PWLAN_CFG_PROPS psProps = (PWLAN_CFG_PROPS)GetWindowLong(hDlg, GWL_USERDATA);
    BOOL            fRet = 0;

    fRet = SHRCMLDialogProc( HINST_RESDLL, MAKEINTRESOURCE(IDD_WZC_WLAN_GENERAL_PROP_PAGE), hDlg, message, wParam, lParam );

    switch(message)
    {
    case WM_INITDIALOG:
        psProps = (PWLAN_CFG_PROPS)lParam;
        SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psProps);
        
        fRet = OnInitDialogGeneral(hDlg, psProps);
        break;

    case WM_SETTINGCHANGE:
        SHHandleSipChange(hDlg, wParam, lParam, NULL);
        break;

    case WM_WINDOWPOSCHANGED:
    case WM_SIZE:
        SetDialogAutoScrollBarEx(hDlg);
        break;

    case WM_DESTROY:
        break;

    case WM_COMMAND:
        {
            switch(LOWORD(wParam))
            {
            case ID_CANCEL:
                EndDialog(hDlg, 0);
                break;
                
            case ID_NEXT:
                if (OnOKGeneral(hDlg, psProps))
                {
                    EndDialog(hDlg, IDD_WZC_WLAN_AUTHENTICATION_PAGE);
                }
                break;
                
            case IDC_WZC_CHECK_ADHOC:
            case IDC_WZC_CHECK_HIDDEN:
                {
                    // These are mutually exclusive checkboxes - a network cannot be both hidden and ad-hoc.
                    UINT uID = LOWORD(wParam);
                    UINT uID2 = (uID == IDC_WZC_CHECK_ADHOC) ? IDC_WZC_CHECK_HIDDEN : IDC_WZC_CHECK_ADHOC;

                    // See if we're allowed to change checkbox state
                    BOOL bRWAllowed = (uID2 == IDC_WZC_CHECK_ADHOC) ? BOOLIFY(psProps->dwFlags & WZCDLG_PROPS_RWINFR) : TRUE;

                    if (bRWAllowed)
                    {
                        if (SendDlgItemMessage(hDlg, uID, BM_GETCHECK, 0, 0))
                        {
                            // User checked one of the checkboxes (hidden or ad-hoc) - uncheck and disable 
                            // the other checkbox
                            SendDlgItemMessage(hDlg, uID2, BM_SETCHECK, BST_UNCHECKED, 0);
                            EnableWindow(GetDlgItem(hDlg, uID2), FALSE);
                        }
                        else
                        {
                            // User unchecked a checkbox - reenable the other checkbox
                            EnableWindow(GetDlgItem(hDlg, uID2), TRUE);
                        }
                    }
                    
                    break;
                }
            }            
        }
        break;
            

    case WM_DELAY_SETFOCUS:
        SetFocus(GetDlgItem(hDlg, wParam));
        break;

    case WM_NETUI_INVALIDKEY:
        OnInvalidKey(hDlg);
        break;

    case WM_ACTIVATE:
        // Pass message back to WiFi CPL main window unless the new/previous window is 
        // the parent window itself, in which case the CPL will handle it's own 
        // activation or deactivation. The CPL (psProps->psWLanInfo->hDlg) is a child
        // of the same parent as us.
        if (psProps && psProps->psWLanInfo)
        {
            HWND hwndPrevious = (HWND)lParam;
            if (hwndPrevious != GetParent(hDlg))
            {
                PostMessage (psProps->psWLanInfo->hDlg, message, wParam, lParam);
            }
        }
        break;
    }

    return fRet;
}
Ejemplo n.º 26
0
static BOOL OnNotify(PWLAN_INFO psInfo, WPARAM wParam, LPARAM lParam)
{
    NM_LISTVIEW *pnmlv;
    LPNMHDR pnmh = (LPNMHDR) lParam; 
    BOOL    bRet = FALSE; 
    INT     nItemSelected ;

    if (NULL == pnmh)
    {
        goto Error;
    }

    switch(LOWORD(wParam))
    {
    case IDC_WZC_LIST_NETWORKS:
        pnmlv = (NM_LISTVIEW*)lParam;

        if (-1 != pnmlv->iItem)
        {
            nItemSelected = pnmlv->iItem;
        }
        else
        {
            // Always use a valid default item even if notification doesn't provide one
            nItemSelected = ListView_GetNextItem(psInfo->hwndNetList, -1, LVNI_SELECTED);
        }

        switch(pnmlv->hdr.code)
        {
        case GN_CONTEXTMENU:
            bRet = OnNetworkContextMenu(psInfo, ((NMRGINFO *)lParam)->ptAction, nItemSelected);
            break;
            
        case LVN_ITEMACTIVATE:
            if (nItemSelected == 0)
            {
                // User hit the first item which is "Add new setting..." or "Search for Networks"
                OnFirstSettingActivate(psInfo);
            }
            else if (nItemSelected > 0)
            {
                // User hit a wireless network, bring up the config properties dialog
                SendMessage(psInfo->hDlg, WM_COMMAND, MAKEWPARAM(IDM_WZC_NETWORK_PROPERTIES, 0), 0L);
            }                       
            bRet = TRUE;
            break;

        case NM_RECOGNIZEGESTURE:
        {
            DWORD dwItem = ((NMRGINFO*)lParam)->dwItemSpec;
            
            if (0 == dwItem || (DWORD)-1 == dwItem || psInfo->bConnecting)
            {
                // No context menu for "Add new URL" or 
                // if user hasn't clicked on an item or
                // We are connecting to a wireless network
                SetWindowLong(psInfo->hDlg, DWL_MSGRESULT, TRUE);
                return TRUE;
            }
        }
        case LVN_ITEMCHANGED:
        {
            if (pnmlv->uChanged & LVIF_STATE && pnmlv->uNewState & LVIS_SELECTED)
            {
                BOOL fEnable = BOOLIFY(nItemSelected);
                
                if(fEnable)
                {
                    PCSHWZCNET pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, nItemSelected);
                    ASSERT(pwzcnet);

                    fEnable = !BOOLIFY(SHWZCF_NET_CONNECT_MASK & pwzcnet->dwFlags);
                }

                // Enable SK1 if selected item is a network and user isn't already connecting to it.
                SHEnableSoftkey(psInfo->hwndNetListMB, 0, TRUE, fEnable);
            }
            break;
        }
        }
        break;

    default:        
        switch(pnmh->code)
        {
            case PSN_APPLY:
                bRet = SendMessage(psInfo->hDlg, WM_COMMAND, IDOK, 0L);
                break;
            case PSN_KILLACTIVE:
            case PSN_SETACTIVE:
                ShowWindow(psInfo->hwndNetListMB, (pnmh->code == PSN_SETACTIVE ? SW_SHOW : SW_HIDE));
                break;
        }
        break;
    }

Error:
    return bRet;
}
Ejemplo n.º 27
0
static HRESULT PopulateNetworkList(PWLAN_INFO psInfo)
{
    HRESULT hr = S_OK;
    LPCTSTR pszConnected, pszConnecting, pszAvailable, pszUnavailable;
    LV_ITEM lv = { 0 };
    UINT    i, cConfigs;
    BOOL    fNetAvailable = FALSE;

    CBREx(psInfo, E_INVALIDARG);

    // Load strings
    pszConnected = (LPCTSTR)LoadString(HINST_RESDLL, IDS_WZC_ACTIVE, NULL, 0);
    CBRA(NULL != pszConnected);

    pszConnecting = (LPCTSTR)LoadString(HINST_RESDLL, IDS_WZC_CONNECTING, NULL, 0);
    CBRA(NULL != pszConnecting);

    pszAvailable = (LPCTSTR)LoadString(HINST_RESDLL, IDS_WZC_AIRING, NULL, 0); 
    CBRA(NULL != pszAvailable);

    pszUnavailable = (LPCTSTR)LoadString(HINST_RESDLL, IDS_WZC_SILENT, NULL, 0); 
    CBRA(NULL != pszUnavailable);

    // Add the first setting item
    hr = InsertFirstSettingsItem(psInfo);
    CHR(hr);

    // Get the network list
    hr = SHWZCGetAllNetworks(psInfo->hshwzc, &psInfo->hdsaNetworks);
    CHR(hr);

    // Are there any items?
    cConfigs = DSA_GetItemCount(psInfo->hdsaNetworks);
    CBREx(0 != cConfigs, S_FALSE);
    ListView_SetItemCount(psInfo->hwndNetList, cConfigs + 1);

    // Add the networks to the list
    for (i = 0; i != cConfigs; ++i)
    {
        PCSHWZCNET pwzcnet = (PSHWZCNET)DSA_GetItemPtr(psInfo->hdsaNetworks, i);
        BOOL       fAdhoc = (SHWZCF_NET_ADHOC & pwzcnet->dwFlags);
        BOOL       fSecure;
        LPCTSTR    pszDesc;
        int        nIndex;
        BOOL       fUseSignalStrength = FALSE;

        // If this network is AP, mark it
        if (FALSE == fAdhoc)
        {
            psInfo->fAPAir = TRUE;
            fUseSignalStrength = TRUE;
        }

        // network is considered secure if it's 802.1x, or not OPEN and without
        // encryption enabled
        fSecure = BOOLIFY(pwzcnet->dwFlags & SHWZCF_NET_8021X) ||
            !( ( (Ndis802_11Encryption1Enabled != pwzcnet->dwEncryptionType) &&
            (Ndis802_11Encryption2Enabled != pwzcnet->dwEncryptionType) &&
            (Ndis802_11Encryption3Enabled != pwzcnet->dwEncryptionType) ) &&
            (Ndis802_11AuthModeOpen == pwzcnet->dwAuthentication) );

        // Get the icon and the description for the network
        if (SHWZCF_NET_CONNECTED & pwzcnet->dwFlags)
        {
            lv.iImage = fAdhoc ? WZCIMG_ADHOC_ACTIVE : 0;
            pszDesc = pszConnected;
        }
        else if (SHWZCF_NET_CONNECTING & pwzcnet->dwFlags)
        {
            lv.iImage = fAdhoc ? WZCIMG_ADHOC_AIRING : 0;
            pszDesc = pszConnecting;
        }
        else if (SHWZCF_NET_BROADCAST & pwzcnet->dwFlags)
        {
            lv.iImage = fAdhoc ? WZCIMG_ADHOC_AIRING : 0;
            pszDesc = pszAvailable;
        }
        else
        {
            ASSERT(SHWZCF_NET_PREFERRED & pwzcnet->dwFlags);
            lv.iImage = fAdhoc ? WZCIMG_ADHOC_SILENT : WZCIMG_INFRA_SILENT;

            pszDesc = pszUnavailable;
            // no need to get signal strength
            fUseSignalStrength = FALSE;
        }

        if (SHWZCF_NET_BROADCAST & pwzcnet->dwFlags)
        {
            fNetAvailable = TRUE;
        }

        // Update the icon to have signal strength if we're in Infrastructure mode
        if (fUseSignalStrength)
        {
            UINT uiStrength = pwzcnet->nRssi;

            if (uiStrength)
            {
                lv.iImage = WZCIMG_SIGNAL_1 + uiStrength - 1;
                if (fSecure)
                {
                    lv.iImage += WZCIMG_SIGNAL_SECURE_1 - WZCIMG_SIGNAL_1;
                }
            }
            else
            {
                lv.iImage = WZCIMG_INFRA_SILENT;
            }
        }

        ASSERT(lv.iImage);

        // Insert the item into the listview
        lv.mask     = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
        lv.iItem    = i;
        lv.iSubItem = 0;
        lv.pszText  = (LPTSTR)pwzcnet->szName;
        lv.lParam   = (LPARAM)pwzcnet;

        nIndex = ListView_InsertItem(psInfo->hwndNetList, &lv);
        CBR(0 <= nIndex);

        // Set the state text
        lv.mask     = LVIF_TEXT;
        lv.iItem    = nIndex;
        lv.iSubItem = 1;
        lv.pszText  = (LPTSTR)pszDesc;

        CBR(ListView_SetItem(psInfo->hwndNetList, &lv));
    }

    // Sort the networks
    CBREx(ListView_SortItems(psInfo->hwndNetList, CompareNetworks, NULL), E_OUTOFMEMORY);

Error:

    if(psInfo)
    {
        SetCursor(psInfo->hOldCursor);
        psInfo->hOldCursor = NULL;

        // We just turned power on, but didn't find any broadcasting networks
        if((psInfo->bUserInitiatedSearch) && (!fNetAvailable) && (psInfo->dwHWFlags & SHWZCF_HW_ON))
        {
            psInfo->bUserInitiatedSearch = FALSE;
            SH_BOXEX sbex = {0};
            sbex.cbSize = sizeof(sbex);
            sbex.dwStyle = SHBEXF_CLOSE_ON_ACTIVATION_LOSS|SHBEXF_SUPRESS_DEFAULT_SOUND;
            sbex.nTimeOut = 0;
            sbex.hwndOwner = psInfo->hDlg;
            sbex.sbextype = sbextTextBox;
            sbex.info.ti.pszText = LoadStringEtc(HINST_RESDLL, IDS_WZC_WIFI_SEARCH_ERROR, NULL);
            sbex.info.ti.bi.cButtons = 1;
            
            SHBoxEx(&sbex);
        }

        psInfo->bUserInitiatedSearch = FALSE;
    }
    
    return hr;
}
Ejemplo n.º 28
0
//==========================================================================*
// Function: OnMenuPopup
//
// Purpose:  Enable and disable wireless network context menu items.
//           We need to show/hide connect or disconnect items according to
//           the connection state of the network.
//           The first listview item "add new setting..." doesn't have a context menu
//           
// Arguments: 
//     [IN] psInfo - pointer to the WLAN_INFO structure
//     [IN] hMenu  - HANDLE to the menu
//     [IN] iItem   - item need to show menu
//
// Return Values:
//     BOOL - TRUE for handle it successfully
//==========================================================================*
static void OnMenuPopup(PWLAN_INFO psInfo, HMENU hMenu, INT iItem)
{
    HRESULT    hr = S_OK;
    PCSHWZCNET pwzcnet;
    DWORD      dwState = 0, dwSize;
    BOOL       fEnableConnect = BOOLIFY(iItem);
    BOOL       fEnableRemove = BOOLIFY(iItem);
    BOOL       fEnableEdit = BOOLIFY(iItem);
    LPTSTR     pNetwork;

    // "Turn Wi-Fi Off/On"
    RemoveMenu(hMenu, IDM_WZC_WIFI_POWERCMD, MF_BYCOMMAND);
    InsertMenu(hMenu, (UINT)-1, MF_BYPOSITION|MF_STRING, IDM_WZC_WIFI_POWERCMD,
               LoadStringEtc(HINST_RESDLL, IDS_WZC_WIFI_POWERON + ((psInfo->dwHWFlags & SHWZCF_HW_ON) ? 1:0), NULL));

    pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem);
    CBR(pwzcnet != NULL);

    dwSize = ARRAYSIZE(pwzcnet->szName);
    pNetwork = (LPTSTR)LocalAlloc(NONZEROLPTR, dwSize * sizeof(TCHAR));
    CPR(pNetwork);
    StringCchCopy(pNetwork, dwSize, pwzcnet->szName);
    
    ((CNetworkObject*)(psInfo->pNetworkObject))->SetData(pNetwork, CF_UNICODETEXT);
    SHQueryMenuExtensions(psInfo->hContextExt ? psInfo->hContextExt : psInfo->hSoftKeyExt,
                          hMenu, 0xFFFFFFFF, IDM_WZC_MENU_EXT_FIRST, IDM_WZC_MENU_EXT_LAST,
                          CMF_NORMAL);

    // Get the current state
    SHWZCGetState(psInfo->hshwzc, &dwState);

    // If the selected network is ad-hoc, but there are infrastructure networks
    // airing, we can't connect, since ad-hoc networks are always considered
    // connected, unless the hardware is limited to use ONLY ad-hoc networks.
    if ((SHWZCF_NET_ADHOC & pwzcnet->dwFlags) &&
        SHWZCF_ALLOW_ADHOC != (SHWZCF_ALLOW_MASK & dwState) &&
        psInfo->fAPAir)
    {
        fEnableConnect = FALSE;
    }

    // If we're already connected to the selected network, we can't
    // "re-connect"
    else if (SHWZCF_NET_CONNECT_MASK & pwzcnet->dwFlags)
    {
        fEnableConnect = FALSE;
    }

    // If the selected network isn't preferred, disable the "Remove Settings"
    if (0 == (SHWZCF_NET_PREFERRED & pwzcnet->dwFlags))
    {
        fEnableRemove = FALSE;
    }

    // If the selected network is a "permanent" non-editable network, disable both
    // "Remove Settings" and "Edit"
    if (SHWZCIsPermanentNetwork(pwzcnet->szName, BOOLIFY(SHWZCF_NET_ADHOC & pwzcnet->dwFlags)))
    {
        fEnableRemove = FALSE;
        fEnableEdit = FALSE;
    }

Error:
    EnableMenuItem(hMenu, IDM_WZC_NETWORK_CONNECT, fEnableConnect ? MF_ENABLED : MF_GRAYED);
    EnableMenuItem(hMenu, IDM_WZC_NETWORK_REMOVE, fEnableRemove ? MF_ENABLED : MF_GRAYED);
    EnableMenuItem(hMenu, IDM_WZC_NETWORK_PROPERTIES, fEnableEdit ? MF_ENABLED : MF_GRAYED);
    return;
}
Ejemplo n.º 29
0
void DebugEventHandler::Initialize()
{
    Register(DebugEvents::eCreateThread, [&](const DEBUG_EVENT &dbgEvent)
    {
        auto &info = dbgEvent.u.CreateThread;
        fprintf(stderr, "CREATE_THREAD_DEBUG_EVENT received.\n"
            "Handle: %X\n"
            "TLS base: %X\n"
            "Start address: %X\n",
            info.hThread, info.lpThreadLocalBase, info.lpStartAddress);
        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eCreateProcess, [&](const DEBUG_EVENT &dbgEvent)
    {
        auto &info = dbgEvent.u.CreateProcessInfo;
        fprintf(stderr, "CREATE_PROCESS_DEBUG_EVENT received.\n"
            "Handle (image file): %X\n"
            "Handle (process): %X\n"
            "Handle (main thread): %X\n"
            "Image base address: %X\n"
            "Debug info file offset: %X\n"
            "Debug info size: %X\n"
            "TLS base: %X\n"
            "Start address: %X\n",
            info.hFile, info.hProcess, info.hThread, info.lpBaseOfImage,
            info.dwDebugInfoFileOffset, info.nDebugInfoSize, info.lpThreadLocalBase,
            info.lpStartAddress);

        m_hProcess = info.hProcess;

        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eExitThread, [&](const DEBUG_EVENT &dbgEvent)
    {
        fprintf(stderr, "EXIT_THREAD_DEBUG_EVENT received.\n"
            "Thread %X exited with code %X.\n",
            dbgEvent.dwThreadId, dbgEvent.u.ExitThread.dwExitCode);
        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eExitProcess, [&](const DEBUG_EVENT &dbgEvent)
    {
        fprintf(stderr, "EXIT_PROCESS_DEBUG_EVENT received.\n"
            "Process %X exited with code %X.\n",
            dbgEvent.dwProcessId, dbgEvent.u.ExitProcess.dwExitCode);
        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eLoadDll, [&](const DEBUG_EVENT &dbgEvent)
    {
        auto &info = dbgEvent.u.LoadDll;
        fprintf(stderr, "LOAD_DLL_DEBUG_EVENT received.\n"
            "Handle: %X\n"
            "Base address: %X\n"
            "Debug info file offset: %X\n"
            "Debug info size: %X\n",
            info.hFile, info.lpBaseOfDll, info.dwDebugInfoFileOffset,
            info.nDebugInfoSize);
        char strName[MAX_PATH] = { 0 };
        (void)GetFinalPathNameByHandleA(info.hFile, strName, sizeof(strName), FILE_NAME_NORMALIZED);
        fprintf(stderr, "Name: %s\n", strName);

        m_dwContinueStatus = DBG_CONTINUE;
    });

    Register(DebugEvents::eUnloadDll, [&](const DEBUG_EVENT &dbgEvent)
    {
        fprintf(stderr, "UNLOAD_DLL_DEBUG_EVENT received.\n"
            "Dll at %X has unloaded.\n", dbgEvent.u.UnloadDll.lpBaseOfDll);
        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eDebugString, [&](const DEBUG_EVENT &dbgEvent)
    {
        auto &info = dbgEvent.u.DebugString;
        fprintf(stderr, "OUTPUT_DEBUG_STRING_EVENT received.\n");
        std::unique_ptr<char[]> pBuffer = std::unique_ptr<char[]>(new char[info.nDebugStringLength]);
        DWORD dwBytesRead = 0;

        const bool bSuccess = BOOLIFY(ReadProcessMemory(m_hProcess, info.lpDebugStringData, pBuffer.get(), info.nDebugStringLength, &dwBytesRead));
        if (bSuccess)
        {
            if (info.fUnicode)
            {
                fwprintf(stderr, L"Debug string: %s\n", (wchar_t *)pBuffer.get());
            }
            else
            {
                fprintf(stderr, "Debug string: %s\n", pBuffer.get());
            }
        }
        else
        {
            fprintf(stderr, "Could not read debug string. Error = %X\n", GetLastError());
        }

        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eRipEvent, [&](const DEBUG_EVENT &dbgEvent)
    {
        fprintf(stderr, "Received RIP event.\n");
        SetContinueStatus(DBG_CONTINUE);
    });

    Register(DebugEvents::eException, [&](const DEBUG_EVENT &dbgEvent)
    {
        auto &exception = dbgEvent.u.Exception;
        fprintf(stderr, "Received exception event.\n"
            "First chance exception: %X\n"
            "Exception code: %X\n"
            "Exception flags: %X\n"
            "Exception address: %X\n"
            "Number parameters (associated with exception): %X\n",
            exception.dwFirstChance, exception.ExceptionRecord.ExceptionCode,
            exception.ExceptionRecord.ExceptionFlags, exception.ExceptionRecord.ExceptionAddress,
            exception.ExceptionRecord.NumberParameters);

        m_pExceptionHandler->Notify((DebugExceptions)dbgEvent.u.Exception.ExceptionRecord.ExceptionCode, dbgEvent);
        SetContinueStatus(m_pExceptionHandler->ContinueStatus());
    });
}