Index: src/ch/AsyncHttpFile.cpp =================================================================== diff -u -r44a2ec5f1eb0a435b56daef42ef5fe3b7a91da0d -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision 44a2ec5f1eb0a435b56daef42ef5fe3b7a91da0d) +++ src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -205,7 +205,10 @@ m_internetBuffers.lpvBuffer = pBuffer; m_dwExpectedState = INTERNET_STATUS_REQUEST_COMPLETE; - if(!::InternetReadFileEx(m_hOpenUrl, &m_internetBuffers, IRF_NO_WAIT, (DWORD_PTR)&m_tReadRequest)) + + // #WinXP #workaround - in bare WinXP SP3 (i.e. without additional updates), InternetReadFileExW returns + // error 120 (not implemented); it was implemented with some later update + if(!::InternetReadFileExA(m_hOpenUrl, &m_internetBuffers, IRF_NO_WAIT, (DWORD_PTR)&m_tReadRequest)) { SetErrorCode(::GetLastError()); if(GetErrorCode() == ERROR_IO_PENDING) Index: src/ch/AsyncHttpFile.h =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/AsyncHttpFile.h (.../AsyncHttpFile.h) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/AsyncHttpFile.h (.../AsyncHttpFile.h) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -90,7 +90,7 @@ DWORD m_dwExpectedState; ///< State we are expecting HANDLE m_hFinishedEvent; - INTERNET_BUFFERS m_internetBuffers; + INTERNET_BUFFERSA m_internetBuffers; details::CONTEXT_REQUEST m_tOpenRequest; details::CONTEXT_REQUEST m_tReadRequest; Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -r1f27a2022090cf7aaf827a3f1ad90d6fe0038518 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 1f27a2022090cf7aaf827a3f1ad90d6fe0038518) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -70,7 +70,7 @@ /// @param[in] bCheckBeta States if we are interested in beta products. /// @return True if operation started, false otherwise. // ============================================================================ -bool CUpdateChecker::AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType eUpdateChannel, bool bOnlyIfConnected) +bool CUpdateChecker::AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType eUpdateChannel, bool bOnlyIfConnected, bool bSendHeaders) { if(!pszSite) return false; @@ -86,6 +86,7 @@ m_eResult = eResult_Undefined; m_eUpdateChannel = eUpdateChannel; m_strLanguage = pszLanguage; + m_bSendHeaders = bSendHeaders; ::ResetEvent(m_hKillEvent); @@ -96,6 +97,7 @@ m_strSite.Empty(); m_eResult = eResult_Undefined; m_eUpdateChannel = UpdateVersionInfo::eStable; + m_bSendHeaders = true; return false; } @@ -190,6 +192,13 @@ ::LeaveCriticalSection(&m_cs); } +void CUpdateChecker::SetSendHeaders(bool bSendHeaders) +{ + ::EnterCriticalSection(&m_cs); + m_bSendHeaders = bSendHeaders; + ::LeaveCriticalSection(&m_cs); +} + // ============================================================================ /// CUpdateChecker::GetSiteAddress /// @date 2009/04/18 @@ -263,7 +272,10 @@ // open the connection and try to get to the file std::wstring wstrUserAgent = pUpdateChecker->m_tUpdateHeaders.GetUserAgent(); - std::wstring wstrHeaders = pUpdateChecker->m_tUpdateHeaders.GetHeaders((PCTSTR)pUpdateChecker->m_strLanguage, pUpdateChecker->m_eUpdateChannel); + std::wstring wstrHeaders; + if(pUpdateChecker->GetSendHeaders()) + wstrHeaders = pUpdateChecker->m_tUpdateHeaders.GetHeaders((PCTSTR)pUpdateChecker->m_strLanguage, pUpdateChecker->m_eUpdateChannel); + HRESULT hResult = pUpdateChecker->m_httpFile.Open(strSite, wstrUserAgent.c_str(), wstrHeaders.c_str()); if(SUCCEEDED(hResult)) { Index: src/ch/UpdateChecker.h =================================================================== diff -u -r1f27a2022090cf7aaf827a3f1ad90d6fe0038518 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/UpdateChecker.h (.../UpdateChecker.h) (revision 1f27a2022090cf7aaf827a3f1ad90d6fe0038518) +++ src/ch/UpdateChecker.h (.../UpdateChecker.h) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -48,7 +48,7 @@ ~CUpdateChecker(); /// Starts the 'check for updates' thread - bool AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType eUpdateChannel, bool bOnlyIfConnected); + bool AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType eUpdateChannel, bool bOnlyIfConnected, bool bSendHeaders); /// Stops checking and cleanups the object void Cleanup(); @@ -63,6 +63,7 @@ const wchar_t* GetDownloadAddress() const { return m_strDownloadAddress; } const wchar_t* GetReleaseDate() const { return m_strReleaseDate; } const wchar_t* GetReleaseNotes() const { return m_strReleaseNotes; } + bool GetSendHeaders() const { return m_bSendHeaders; } protected: /// Thread function (handles most of the internet connection operation) @@ -77,6 +78,8 @@ /// Retrieves the site address CString GetSiteAddress() const; + void SetSendHeaders(bool bSendHeaders); + /// Returns information if we're interested in beta versions UpdateVersionInfo::EVersionType GetUpdateChannel(); static std::wstring FormatDate(const boost::gregorian::date& date); @@ -91,7 +94,8 @@ CString m_strDownloadAddress; CString m_strReleaseDate; CString m_strReleaseNotes; - + bool m_bSendHeaders = true; + ECheckResult m_eResult; CAsyncHttpFile m_httpFile; Index: src/ch/UpdateHeaders.cpp =================================================================== diff -u -r1f27a2022090cf7aaf827a3f1ad90d6fe0038518 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/UpdateHeaders.cpp (.../UpdateHeaders.cpp) (revision 1f27a2022090cf7aaf827a3f1ad90d6fe0038518) +++ src/ch/UpdateHeaders.cpp (.../UpdateHeaders.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -36,7 +36,8 @@ boost::lexical_cast(PRODUCT_VERSION3) + L"." + boost::lexical_cast(PRODUCT_VERSION4) + L")"; - wstrUserAgent += L" (" + m_tWindowsVersion.GetWindowsVersion() + L")"; + wstrUserAgent += L"; " + m_tWindowsVersion.GetWindowsVersion(); + wstrUserAgent += L"; " + m_tWindowsVersion.GetCpuArch(); return wstrUserAgent; } Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -ra27d1acf1bda3c25b6dcce0d0eb0278009ce63ae -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision a27d1acf1bda3c25b6dcce0d0eb0278009ce63ae) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -9,6 +9,7 @@ #include "StaticEx.h" #include #include +#include "WindowsVersion.h" #define UPDATER_TIMER 639 @@ -339,7 +340,13 @@ EnableUpdateRelatedControls(false); m_eLastState = CUpdateChecker::eResult_Undefined; - m_ucChecker.AsyncCheckForUpdates(_T(UPDATE_CHECK_LINK), GetPropValue(GetConfig()), (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), m_bBackgroundMode); + bool bIsWinXP = WindowsVersion::IsWindowsXP(); + + CString strSite = _T(UPDATE_CHECK_LINK_SECURE); + if(bIsWinXP) + strSite = _T(UPDATE_CHECK_LINK_NONSECURE); + + m_ucChecker.AsyncCheckForUpdates(strSite, GetPropValue(GetConfig()), (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), m_bBackgroundMode, !bIsWinXP); } void CUpdaterDlg::EnableUpdateRelatedControls(bool bEnable) Index: src/ch/WindowsVersion.cpp =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/WindowsVersion.cpp (.../WindowsVersion.cpp) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/WindowsVersion.cpp (.../WindowsVersion.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -34,7 +34,7 @@ if (!m_wstrServicePack.empty()) wstrFullVer += L" " + m_wstrServicePack; - wstrFullVer += L" (" + m_wstrVersion + wstrShortInstallType + L";" + m_wstrCpuArch + L")"; + wstrFullVer += L" (" + m_wstrVersion + wstrShortInstallType + L")"; return wstrFullVer; } @@ -62,6 +62,28 @@ return m_wstrCpuArch; } +bool WindowsVersion::IsWindowsXP() +{ + OSVERSIONINFOEX ovi = { 0 }; + ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if(!GetVersionEx((OSVERSIONINFO*)&ovi)) + return false; + + if(ovi.dwMajorVersion != 5) + return false; + + // 32-bit WinXP + if(ovi.dwMinorVersion == 1) + return true; + + // 64bit WinXP + SYSTEM_INFO si = { 0 }; + GetNativeSystemInfo(&si); + + return ovi.dwMinorVersion == 2 && ovi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; +} + void WindowsVersion::UpdateCachedData() { if(m_bCacheFilled) @@ -96,19 +118,19 @@ case PROCESSOR_ARCHITECTURE_AMD64: { #ifndef _M_AMD64 - m_wstrCpuArch = L"x64-"; + m_wstrCpuArch = L"x86_64 WOW64"; #else - m_wstrCpuArch = L"x64"; + m_wstrCpuArch = L"x86_64"; #endif break; } case PROCESSOR_ARCHITECTURE_INTEL: { #ifndef _M_IX86 - m_wstrCpuArch = L"x86-"; + m_wstrCpuArch = L"x86_32-"; // should not happen #else - m_wstrCpuArch = L"x86"; + m_wstrCpuArch = L"x86_32"; #endif break; } Index: src/ch/WindowsVersion.h =================================================================== diff -u -r50ad2dc9f0b42ba432bb54e4a042582277410773 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/ch/WindowsVersion.h (.../WindowsVersion.h) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) +++ src/ch/WindowsVersion.h (.../WindowsVersion.h) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -30,6 +30,8 @@ std::wstring GetWindowsInstallType(); std::wstring GetCpuArch(); + static bool IsWindowsXP(); + private: void UpdateCachedData(); Index: src/common/version.h =================================================================== diff -u -r4ed6512d73cd1b444f83afdefe9a986b6ca9de90 -r50007f112b77cba170e6c427fee5428bda2d9dc5 --- src/common/version.h (.../version.h) (revision 4ed6512d73cd1b444f83afdefe9a986b6ca9de90) +++ src/common/version.h (.../version.h) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) @@ -36,7 +36,8 @@ // copyright information #define COPYRIGHT_INFO "Copyright (C) 2001-2016 J�zef Starosczyk" #define PRODUCT_SITE "http://www.copyhandler.com" -#define UPDATE_CHECK_LINK "https://www.copyhandler.com/update-check" +#define UPDATE_CHECK_LINK_SECURE "https://www.copyhandler.com/update-check" +#define UPDATE_CHECK_LINK_NONSECURE "http://www.copyhandler.com/update-check" #define CONTACT_INFO "http://www.copyhandler.com/contact" #endif