3

I have a service that needs to add URLs to the IE cache of the logged in user

In order to do that I first obtain the user's token with OpenProcessToken and call ImpersonateLoggedOnUser

I tried adding the URL with 2 methods

  1. Using the IUrlHistoryStg2 COM interface, and calling the AddUrlAndNotify method
  2. Using the CommitUrlCacheEntryW in the following way CommitUrlCacheEntryW(urlToEnterWithPrefix, 0, ExpireTime, LastModifiedTime, URLHISTORY_CACHE_ENTRY | NORMAL_CACHE_ENTRY, NULL, 0, NULL, NULL);

Both methods are working fine when the processes runs under the logged-in user, but fail when it runs under LocalSystem

CommitUrlCacheEntryW documentation stats that:

WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).

But I could not find any method in WinHTTP that corresponds to CommitUrlCacheEntryW

I would like help with the following issues:

  1. Can I use the IUrlHistoryStg2 from a service to access the logged-in user's url-history?
  2. How can I use CommitUrlCacheEntryW or a slimier function from a service to access the logged-in user's url-history?
  3. Is there a third option that I still did not use?
4x6hw
  • 149
  • 9
  • 3) A desktop application that runs at user logon that your service then communicates with. – Alex K. Apr 14 '16 at 10:44
  • Thanks @AlexK., I am trying to avoid from adding an additional application\process at this point. Do you know if this can be done with only the service? – 4x6hw Apr 14 '16 at 11:16
  • Well the Commit method is out as the docs tell you not to do it, what happens when you use the interface method from the service? – Alex K. Apr 14 '16 at 11:21
  • When running as a service, both: * AddUrlAndNotify * CommitUrlCacheEntryW produces the Error: `This function is not supported on this system` – 4x6hw Apr 14 '16 at 11:32

1 Answers1

0

After reversing the CommitUrlCacheEntryW API I found that it check

  • If the current thread was impersonating
  • If the processes a Service

In case either of the checks is true, it exists with error code 0x80070078

So, what I wanted to achieve is not possible from a service

4x6hw
  • 149
  • 9