Beispiel #1
0
static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
{
    OmNavigator *This = impl_from_IOmNavigator(iface);

    char user_agent[512];
    DWORD size;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    size = sizeof(user_agent);
    hres = ObtainUserAgentString(0, user_agent, &size);
    if(FAILED(hres))
        return hres;

    if(strncmp(user_agent, "Mozilla/", 8)) {
        FIXME("Unsupported user agent\n");
        return E_FAIL;
    }

    size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
    *p = SysAllocStringLen(NULL, size-1);
    if(!*p)
        return E_OUTOFMEMORY;

    MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
    return S_OK;
}
void CFTLNetTester::test_UrlMonFunctions()
{
    HRESULT hr = E_FAIL;
    CHAR szUserAgent[4096] = {0};
    DWORD dwSize = _countof(szUserAgent) - 1;
    COM_VERIFY(ObtainUserAgentString(0, szUserAgent, &dwSize));
    //FTLTRACEA("userAgent=%s\n", szUserAgent);
}
Beispiel #3
0
void
CConnectionManager::SendHello()
{
	Json::Value msg;
	msg["command"] = "Hello";
	msg["type"] = "Internet Explorer";

	// obtain user agent
	char buf[1024];
	DWORD size = 1024;
	ObtainUserAgentString(0, buf, &size);
	msg["agent"] = buf;

	Send(msg);
}
Beispiel #4
0
/*
	Retrieve IE user agent
	return hardcoded UA if it fails
*/
char *get_default_ua(){
	char *ua;	
	DWORD ualength = 512;
	int res = 0;

	ua = malloc(512);
	RtlZeroMemory(ua, 512);
	if (ua == NULL){
		return NULL;
	}
	RtlZeroMemory(ua, 512);
	/*	If AV picks up, reading reg could be a possible alternative:
		https://diablohorn.wordpress.com/2010/08/14/internetqueryoption-internet_option_user_agent-replacement/
	*/
	res = ObtainUserAgentString(0, ua, &ualength);
	if (res != NOERROR){
		strcpy_s(ua, 512, SH_DEFAULT_UA);
	}

	return ua;
}
Beispiel #5
0
static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
{
    OmNavigator *This = impl_from_IOmNavigator(iface);
    char user_agent[512];
    DWORD size;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    size = sizeof(user_agent);
    hres = ObtainUserAgentString(0, user_agent, &size);
    if(FAILED(hres))
        return hres;

    size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
    *p = SysAllocStringLen(NULL, size-1);
    if(!*p)
        return E_OUTOFMEMORY;

    MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
    return S_OK;
}