Author Topic: (Help) COM Objects  (Read 1807 times)

0 Members and 1 Guest are viewing this topic.

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
(Help) COM Objects
« on: September 27, 2012, 03:08:33 am »
i need to delete a file using the COM FileSystemObject

vbs example
Code: (vb) [Select]
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
« Last Edit: September 27, 2012, 03:08:50 am by bubzuru »
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: (Help) COM Objects
« Reply #1 on: September 27, 2012, 10:54:02 am »
CoCreateInstance() ?
-Xires

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: (Help) COM Objects
« Reply #2 on: 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

Code: (c) [Select]
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 
« Last Edit: September 27, 2012, 02:04:52 pm by bubzuru »
Damm it feels good to be gangsta
http://bubzuru.comule.com