EvilZone

Programming and Scripting => C - C++ => : bubzuru September 27, 2012, 03:08:33 AM

: (Help) COM Objects
: bubzuru September 27, 2012, 03:08:33 AM
i need to delete a file using the COM FileSystemObject

vbs example
: (vb)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\users\bubzuru\desktop\test.txt")

any ideas about creating COM objects in C\C++
C examples would be better for me
: Re: (Help) COM Objects
: Xires September 27, 2012, 10:54:02 AM
CoCreateInstance() ?
: Re: (Help) COM Objects
: bubzuru September 27, 2012, 02:04:27 PM
CoCreateInstance() ?

yup that did it, now i need help with, with elevating the com object
take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687%28v=vs.85%29.aspx)

: (c)
HRESULT CoCreateInstanceAsAdmin(HWND hwnd, REFCLSID rclsid, REFIID riid, __out void ** ppv)
{
    BIND_OPTS3 bo;
    WCHAR  wszCLSID[50];
    WCHAR  wszMonikerName[300];

    StringFromGUID2(rclsid, wszCLSID, sizeof(wszCLSID)/sizeof(wszCLSID[0]));
    HRESULT hr = StringCchPrintf(wszMonikerName, sizeof(wszMonikerName)/sizeof(wszMonikerName[0]), L"Elevation:Administrator!new:%s", wszCLSID);
    if (FAILED(hr))
        return hr;
    memset(&bo, 0, sizeof(bo));
    bo.cbStruct = sizeof(bo);
    bo.hwnd = hwnd;
    bo.dwClassContext  = CLSCTX_LOCAL_SERVER;
    return CoGetObject(wszMonikerName, &bo, riid, ppv);
}

i just cant get the code to work, it will be running from an injected dll if that makes a difference