Discussion:
IBindStatusCallback and CoGetClassObjectFromURL
(too old to reply)
Sujata
2009-01-06 19:33:01 UTC
Permalink
Hi,

I have an application where I am using CoGetClassObjectFromURL API to
download and install a package. I have implemented IBIndstatusCallBack
interface to monitor the data download. My application works fine if this
application is launched by the logged in user but, if I launch this
application from service (SYSTEM) account then IBindstatuscallback
QueryInterface fails for few interfaces and CoGetClassObjectFromURL API
(asynch) returns hresult 0x800c000d.
Any help is highly appreciated.

Thanks,
Sujata.
Igor Tandetnik
2009-01-06 19:43:59 UTC
Permalink
Post by Sujata
I have an application where I am using CoGetClassObjectFromURL API to
download and install a package. I have implemented IBIndstatusCallBack
interface to monitor the data download. My application works fine if
this application is launched by the logged in user but, if I launch
this application from service (SYSTEM) account
If I recall correctly, SYSTEM account is prevented from performing any
network operations at all, for security reasons.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Sujata
2009-01-06 19:58:01 UTC
Permalink
Will IE also not work if launched from service as a process?

Thanks,
Sujata.
Post by Igor Tandetnik
Post by Sujata
I have an application where I am using CoGetClassObjectFromURL API to
download and install a package. I have implemented IBIndstatusCallBack
interface to monitor the data download. My application works fine if
this application is launched by the logged in user but, if I launch
this application from service (SYSTEM) account
If I recall correctly, SYSTEM account is prevented from performing any
network operations at all, for security reasons.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Igor Tandetnik
2009-01-06 20:16:18 UTC
Permalink
Post by Sujata
Will IE also not work if launched from service as a process?
If launched under SYSTEM account - no, as far as I understand. Would be
hard to check whether it does or not, since you won't be able to
actually see it.

Note that services don't necessarily run under SYSTEM account - one can
configure a service to run under any account. You seem to treat
"service" and "SYSTEM account" as equivalent - that's not the case.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Sujata
2009-01-08 19:43:00 UTC
Permalink
Actually I tried to invoke iexplorer.exe from my service. It launched IE and
then when i entered the site where i download the patch to install, it did
actually download the package and installed.
Here is a link to msdn -
http://msdn.microsoft.com/en-us/library/ms684190(VS.85).aspx. It says - It
(LocalSystem) has extensive privileges on the local computer, and acts as the
computer on the network.
Doesnt it mean that application launched with LocalSystem should get all the
network access?
Post by Igor Tandetnik
Post by Sujata
Will IE also not work if launched from service as a process?
If launched under SYSTEM account - no, as far as I understand. Would be
hard to check whether it does or not, since you won't be able to
actually see it.
Note that services don't necessarily run under SYSTEM account - one can
configure a service to run under any account. You seem to treat
"service" and "SYSTEM account" as equivalent - that's not the case.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Igor Tandetnik
2009-01-08 21:22:10 UTC
Permalink
Post by Sujata
Actually I tried to invoke iexplorer.exe from my service. It launched
IE and then when i entered the site where i download the patch to
install, it did actually download the package and installed.
Here is a link to msdn -
http://msdn.microsoft.com/en-us/library/ms684190(VS.85).aspx. It says
- It (LocalSystem) has extensive privileges on the local computer,
and acts as the computer on the network.
Doesnt it mean that application launched with LocalSystem should get
all the network access?
Ah, it's possible I was thinking about LocalService account.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Igor Tandetnik
2009-01-08 21:24:28 UTC
Permalink
Post by Sujata
I have an application where I am using CoGetClassObjectFromURL API to
download and install a package. I have implemented IBIndstatusCallBack
interface to monitor the data download. My application works fine if
this application is launched by the logged in user but, if I launch
this application from service (SYSTEM) account then
IBindstatuscallback QueryInterface fails for few interfaces
What do you mean, IBindstatuscallback::QueryInterface fails? It's the
one you have implemented, isn't it? Can't you debug your own code and
figure out why it fails?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Sujata
2009-01-09 05:43:01 UTC
Permalink
Earlier I had implemented QI like this but added nothing much in QI;
STDMETHODIMP CDownload::XBindStatusCallback::QueryInterface(REFIID iid,
void** ppvObj)
{
METHOD_PROLOGUE(CDownload, BindStatusCallback)
HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj) ;
return hr ;
}
In this method I got ppvObj null for couple of interfaces. I had the
following code.
m_download->ExternalQueryInterface(&IID_IBindStatusCallback, (void
**)&m_pBindStatusCallback);
hr = CreateAsyncBindCtx(0, m_pBindStatusCallback, NULL, &m_pBindContext);
BIND_OPTS bindopts;
bindopts.cbStruct = sizeof(bindopts) ;
m_pBindContext->GetBindOptions(&bindopts);
bindopts.grfFlags |= BIND_MAYBOTHERUSER;
m_pBindContext->SetBindOptions(&bindopts);

CString szMime ;
IUnknown* pClassFactory = NULL;
szMime = "application/x-cabinet-%opersys%-%cpu%" ;
hr = CoGetClassObjectFromURL(CLSID_NULL, m_strCodebase,
m_major, m_minor,
szMime, m_pBindContext,
CLSCTX_INPROC,
0, IID_IUnknown, (void **)&pClassFactory);

The above CoGetClassObjectFromURL call returned me error code: 0x800C000D.
Which means INET_E_UNKNOWN_PROTOCOL.

In the another version I tried to make the things simple.
I implemented a class derived from IBindStatusCallback. I didnt
implement/overwrite QI. In that case also CoGetClassObjectFromURL returned
same error i.e. 0x800C000D.

Thanks,
Sujata.
Post by Igor Tandetnik
Post by Sujata
I have an application where I am using CoGetClassObjectFromURL API to
download and install a package. I have implemented IBIndstatusCallBack
interface to monitor the data download. My application works fine if
this application is launched by the logged in user but, if I launch
this application from service (SYSTEM) account then
IBindstatuscallback QueryInterface fails for few interfaces
What do you mean, IBindstatuscallback::QueryInterface fails? It's the
one you have implemented, isn't it? Can't you debug your own code and
figure out why it fails?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Igor Tandetnik
2009-01-09 19:43:43 UTC
Permalink
Post by Sujata
Earlier I had implemented QI like this but added nothing much in QI;
STDMETHODIMP CDownload::XBindStatusCallback::QueryInterface(REFIID
iid, void** ppvObj)
{
METHOD_PROLOGUE(CDownload, BindStatusCallback)
HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj) ;
return hr ;
}
In this method I got ppvObj null for couple of interfaces.
But again, it's your own code. pThis is a pointer to CDownload - the
class you wrote, presumably. It's not some opaque magic you get from the
OS.
Post by Sujata
szMime = "application/x-cabinet-%opersys%-%cpu%" ;
hr = CoGetClassObjectFromURL(CLSID_NULL, m_strCodebase,
m_major, m_minor,
szMime, m_pBindContext,
CLSCTX_INPROC,
0, IID_IUnknown, (void **)&pClassFactory);
You are supposed to specify the CLSID of the component you want to
download, or absent that, the MIME type of the content this component is
a player for - not the MIME type for the CAB file. In any case,
application/x-cabinet-%opersys%-%cpu% doesn't look like a valid MIME
type to me.
Post by Sujata
0x800C000D. Which means INET_E_UNKNOWN_PROTOCOL.
What's the value of m_strCodebase?
Post by Sujata
In the another version I tried to make the things simple.
I implemented a class derived from IBindStatusCallback. I didnt
implement/overwrite QI.
How is this possible? QueryInterface is a pure virtual function in
IBindStatusCallback. A class that derives from IBindStatusCallback but
doesn't implement QueryInterface is an abstact class and cannot be
instantiated.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Sujata
2009-01-12 05:04:00 UTC
Permalink
See comments below.
Post by Igor Tandetnik
Post by Sujata
szMime = "application/x-cabinet-%opersys%-%cpu%" ;
hr = CoGetClassObjectFromURL(CLSID_NULL, m_strCodebase,
m_major, m_minor,
szMime, m_pBindContext,
CLSCTX_INPROC,
0, IID_IUnknown, (void **)&pClassFactory);
You are supposed to specify the CLSID of the component you want to
download, or absent that, the MIME type of the content this component is
a player for - not the MIME type for the CAB file. In any case,
application/x-cabinet-%opersys%-%cpu% doesn't look like a valid MIME
type to me.
While implementing this, I refered a patent article. And that article had
mentioned that mime type. What do you mean by the content of the component?
Mine is a cab file which contains the installer for product update. What
could be the correct mime type for that?
Post by Igor Tandetnik
Post by Sujata
0x800C000D. Which means INET_E_UNKNOWN_PROTOCOL.
What's the value of m_strCodebase?
The m_strCodebase is the location to the cab file. For example:
https://abc.com/agent.cab.
Post by Igor Tandetnik
Post by Sujata
In the another version I tried to make the things simple.
I implemented a class derived from IBindStatusCallback. I didnt
implement/overwrite QI.
How is this possible? QueryInterface is a pure virtual function in
IBindStatusCallback. A class that derives from IBindStatusCallback but
doesn't implement QueryInterface is an abstact class and cannot be
instantiated.
Sorry I meant to say that in QI for my class (which is derived from
IBindStatusCallback), I have not added any code which could cause any error.
There is only one statement ie. return E_NOTIMPL.

I also tried another API i.e. URLDownloadToFile. This api also works if
invoked from SYSTEM account. It successfully downloaded file.

Thanks,
Sujata.
Igor Tandetnik
2009-01-12 05:24:50 UTC
Permalink
Post by Sujata
Post by Igor Tandetnik
You are supposed to specify the CLSID of the component you want to
download, or absent that, the MIME type of the content this
component is a player for - not the MIME type for the CAB file. In
any case, application/x-cabinet-%opersys%-%cpu% doesn't look like a
valid MIME type to me.
While implementing this, I refered a patent article. And that article
had mentioned that mime type. What do you mean by the content of the
component?
Like when implemeting a PDF reader, you would specify application/pdf or
something like that. Basically, it's designed for the browser to handle
<object type="MIME TYPE"> tag, where classid attribute is not specified.
Normally, you'd pass a CLSID for your component.
Post by Sujata
Mine is a cab file which contains the installer for
product update.
Try passing CLSID_NULL and NULL for content type. If that doesn't work,
invent a dummy CLSID.
Post by Sujata
Post by Igor Tandetnik
Post by Sujata
0x800C000D. Which means INET_E_UNKNOWN_PROTOCOL.
What's the value of m_strCodebase?
https://abc.com/agent.cab.
It's a long shot, but I wonder if the download would work from an HTTP
URL (as opposed to HTTPS). Perhaps the problem with the service is
actually about its security credentials.
Post by Sujata
Sorry I meant to say that in QI for my class (which is derived from
IBindStatusCallback), I have not added any code which could cause any
error. There is only one statement ie. return E_NOTIMPL.
That's not a valid implementation of QueryInterface. It should succeed
at least for IUnknown and IBindStatusCallback.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Loading...