OleClipboard and IDataObject under local SYSTEM account

180 Views Asked by At

There is an implementation of remote file transfer via dragging virtual files using IStream/IDataObject (based on Raymond Chen's blog topic: What a drag: Dragging a virtual file (IStream edition)).

Basically, it works good. But if the application is run under the SYSTEM account, the IDataObject::GetData() is called only once - requests a FILEDESCRIPTOR, but doesn't return with a requests for FILECONTENTS.

How I use IDataObject:

if (SUCCEEDED(OleInitialize(NULL))) {
    IDataObject* dtob = new MyDataObject(/*some files info here*/);
    if (dtob) {
        OleSetClipboard(dtob);
        dtob->Release();
    }
    
    //simulate Ctrl-V
    ...
    
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    OleUninitialize();
}
1

There are 1 best solutions below

0
On BEST ANSWER

The solution is to set security for the process using CoInitializeSecurity:

HRESULT res = CoInitialize(NULL);
if (SUCCEEDED(res))
    CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE,
        RPC_C_IMP_LEVEL_IDENTIFY, NULL, NULL, NULL);

// your code here....

if (SUCCEEDED(res))
    CoUninitialize();