Correctly initializing the COM library from V8Handler

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Correctly initializing the COM library from V8Handler

Postby mrp » Tue Nov 18, 2014 7:43 pm

Not sure if this is even a question to this forum (apologies if so) but I am trying to call an executable that requires elevated permissions from the V8Handler in the render process. But calling the CoInitializeEx() results in an exception in the KernelBase.dll. Doing the same from the browser process handler (Handler::OnQuery()) succeeds.

This is the code snippet:

Code: Select all
      class V8Handler : public CefV8Handler
      {
      public:
         V8Handler()
         {
            ...
         }


         virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
            CefRefPtr<CefV8Value>& retval, CefString& exception)
         {      
                 ....
                 ....
   
                 SHELLEXECUTEINFO sei;

                 ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));

                 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

                 sei.cbSize = sizeof(SHELLEXECUTEINFO);
                 sei.lpVerb = L"runas";
                 sei.lpParameters = cmd;
                 sei.lpFile = file;
                 if (!ShellExecuteEx(&sei))
                 {
                    DWORD le = GetLastError();
                    error = GetErrorString(le);
                    result = false;
                 }

                 CoUninitialize();


Any ideas what I am doing wrong.

Thanks,
mrp
mrp
Newbie
 
Posts: 5
Joined: Mon Nov 03, 2014 1:43 pm

Re: Correctly initializing the COM library from V8Handler

Postby Czarek » Thu Nov 20, 2014 10:27 am

Renderer process runs in a sandbox. Try disabling sandbox or move code to a different process and use inter-process communication.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 73 guests

cron