Noitidart / Profilist

ff-addon: Profile manager for Australis
https://addons.mozilla.org/en-US/firefox/addon/profilist/?src=github
34 stars 1 forks source link

memmove #23

Closed nmaier closed 9 years ago

nmaier commented 10 years ago

Since gist apparently don't notify anymore:

@Noitidart https://gist.github.com/nmaier/ab4bfe59e8c8fcdc5b90

Noitidart commented 10 years ago

<3 <3 <3

Noitidart commented 10 years ago

You know it's such a habit for me. After I read through your thing I was looking for the "green tick" and "up vote" buttons just for like half a sec tho. :LOL:

Noitidart commented 10 years ago

Hey man

I'm working on this line of code here for Win7.

  var pps = new IID;
  var ppv = ctypes.voidptr_t(0);
  var hr = SHGetPropertyStoreForWindow(hwnd, pps.address(), ppv.address());

The place I'm converting from actually does this:

 IPropertyStore *pps;
 HRESULT hr = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pps));

So I'm just passing ppv as 0. But I'm not sure why hr is coming back error.

Can we skip IID_PPV_ARGS in ctypes, because i think its just doing something like memset, where it sets it to 0. This is the macro code:

/*http://msdn.microsoft.com/en-us/library/windows/desktop/ee330727%28v=vs.85%29.aspx
* void IID_PPV_ARGS(
*   T **pType
* );
*/

http://blogs.msdn.com/b/yvesdolc/archive/2006/12/27/iid-ppv-args-macro.aspx

My full code is here, it can be copy pasted and it errors on the line hr line above. https://gist.github.com/yajd/862832b07a1d46caef8b#comment-1255934

I was getting an error on HR so do you think it's due to me skipping IID_PPV_ARGS?

yajd commented 10 years ago

The more I think about it, the more I think i should skip IID_PPV_ARGS:


//  IID_PPV_ARGS(ppType)

//      ppType is the variable of type IType that will be filled

//

//      RESULTS in:  IID_IType, ppvType

//      will create a compiler error if wrong level of indirection is used.

//

extern "C++"

{

    template<typename T> void** IID_PPV_ARGS_Helper(T** pp)

    {

        // make sure everyone derives from IUnknown

        static_cast<IUnknown*>(*pp);

        return reinterpret_cast<void**>(pp);

    }

}

#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)

It looks like its just converting whatever i pass to it to a voidptr_t