bool CHttp::AllocHandles ( bool isbase64, int *status, bool checkauth) { DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION; unsigned long errnum; DWORD rec_timeout = RECIEVE_TIMEOUT; // override the 30 second timeout fixed in 12.11 wyString contenttype,contenttypestr; //wyInt32 ret; /* If a user has selected to use proxy server for Internet connection then we create a separate handle, send a dummy request and set the username, password The real data connection and transfer is done in another handle */ if (IsProxy () ) m_InternetSession = InternetOpen (TEXT(USER_AGENT), INTERNET_OPEN_TYPE_PROXY, GetProxy(), NULL, 0 ); else m_InternetSession = InternetOpen (TEXT(USER_AGENT), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 ); if (!m_InternetSession ) return false; InternetSetOption(m_InternetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &rec_timeout, sizeof(rec_timeout)); m_InternetConnect = InternetConnect (m_InternetSession, m_HostName, m_Port, m_UserName, m_Password, INTERNET_SERVICE_HTTP, 0L, 0L ); if (!m_InternetConnect ) return false; /* set the flags for internet connection and check if SSL required */ if (wcsicmp (m_Protocol, L"https" ) == 0 ) flags |= INTERNET_FLAG_SECURE; /* check for proxy or password protected authentication checkauth flag tells whether its required to be authenticated */ if (checkauth && !Authorize (&errnum) ) { *status = errnum; return false; } m_HttpOpenRequest = HttpOpenRequest(m_InternetConnect, L"POST", m_FileName, NULL, NULL, NULL, flags, 0L ); if (!m_HttpOpenRequest ) return false; //Content-Type contenttype.SetAs(m_contenttype); contenttypestr.Sprintf("Content-Type: %s\r\n", contenttype.GetString()); if (!HttpAddRequestHeaders(m_HttpOpenRequest, contenttypestr.GetAsWideChar () , (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false; /*if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false;*/ //changing user string for avoid update your browser bug if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"HTTP_USER_AGENT: Mozilla/5.0 (Windows; U;Windows NT 6.3; en-US; rv:36.0) Gecko/20100101 Firefox/36.0\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) return false; if (isbase64 ) { if (!HttpAddRequestHeaders(m_HttpOpenRequest, L"Base64: yes\r\n", (DWORD)-1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE ) ) { assert (0 ); return false; } } return true; }
bool IBattle::IsFounderMe() const { return ( ( m_opts.founder == GetMe().GetNick() ) || ( IsProxy() && !m_generating_script ) ); }
bool IsCPOW(JSObject* obj) { return IsProxy(obj) && GetProxyHandler(obj) == &CPOWProxyHandler::singleton; }
HRESULT MainThreadHandoff::OnWalkInterface(REFIID aIid, PVOID* aInterface, BOOL aIsInParam, BOOL aIsOutParam) { MOZ_ASSERT(aInterface && aIsOutParam); if (!aInterface || !aIsOutParam) { return E_UNEXPECTED; } // Adopt aInterface for the time being. We can't touch its refcount off // the main thread, so we'll use STAUniquePtr so that we can safely // Release() it if necessary. STAUniquePtr<IUnknown> origInterface(static_cast<IUnknown*>(*aInterface)); *aInterface = nullptr; if (!origInterface) { // Nothing to wrap. return S_OK; } // First make sure that aInterface isn't a proxy - we don't want to wrap // those. if (IsProxy(origInterface.get())) { *aInterface = origInterface.release(); return S_OK; } RefPtr<IInterceptor> interceptor; HRESULT hr = mInterceptor->Resolve(IID_IInterceptor, (void**) getter_AddRefs(interceptor)); MOZ_ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { return hr; } // Now make sure that origInterface isn't referring to the same IUnknown // as an interface that we are already managing. We can determine this by // querying (NOT casting!) both objects for IUnknown and then comparing the // resulting pointers. InterceptorTargetPtr existingTarget; hr = interceptor->GetTargetForIID(aIid, existingTarget); if (SUCCEEDED(hr)) { bool areIUnknownsEqual = false; // This check must be done on the main thread auto checkFn = [&existingTarget, &origInterface, &areIUnknownsEqual]() -> void { RefPtr<IUnknown> unkExisting; HRESULT hrExisting = existingTarget->QueryInterface(IID_IUnknown, (void**)getter_AddRefs(unkExisting)); RefPtr<IUnknown> unkNew; HRESULT hrNew = origInterface->QueryInterface(IID_IUnknown, (void**)getter_AddRefs(unkNew)); areIUnknownsEqual = SUCCEEDED(hrExisting) && SUCCEEDED(hrNew) && unkExisting == unkNew; }; MainThreadInvoker invoker; if (invoker.Invoke(NS_NewRunnableFunction(checkFn)) && areIUnknownsEqual) { // The existing interface and the new interface both belong to the same // target object. Let's just use the existing one. void* intercepted = nullptr; hr = interceptor->GetInterceptorForIID(aIid, &intercepted); MOZ_ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { return hr; } *aInterface = intercepted; return S_OK; } } // Now create a new MainThreadHandoff wrapper... RefPtr<IInterceptorSink> handoff; hr = MainThreadHandoff::Create(getter_AddRefs(handoff)); MOZ_ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { return hr; } RefPtr<IUnknown> wrapped; hr = Interceptor::Create(Move(origInterface), handoff, aIid, getter_AddRefs(wrapped)); MOZ_ASSERT(SUCCEEDED(hr)); if (FAILED(hr)) { return hr; } // And replace the original interface pointer with the wrapped one. wrapped.forget(reinterpret_cast<IUnknown**>(aInterface)); return S_OK; }