Pointer Pointer as out argument of a method?

Mar 31, 2014 at 11:37 AM
Hi all,

I'm trying to hook this function :
HRESULT GetDefaultAudioEndpoint (
    EDataFlow dataFlow,
    ERole role,
    IMMDevice** ppEndpoint 
);
``

I've successfully hooked the correct adress method but it seems to have a problem in the hook with the last argument.
Here is my delegate & my hooked method:
public delegate int DGetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role, out IntPtr ppEndpoint);

public static int GetDefaultAudioEndpointH(EDataFlow dataFlow, ERole role, out IntPtr ppEndpoint)
But each time i want to access or define my last argument (aka ppEndpoint) i've got an error :

Object reference not set to an instance of an object.

I guess that is my definition of "IMMDevice** ppEndpoint" that is not correct but i don't know how to do..

Can u help?
Mar 31, 2014 at 6:28 PM
After looking more in details, i see that if u put a delegate with "out" or "ref" keyword, the object u try to pass is allways "nullreference".

Did i miss something?
Coordinator
Apr 5, 2014 at 7:16 AM
For IMMDeviceEnumerator::GetDefaultAudioEndpoint you probably need to add an additional first parameter for "this". e.g.:
public delegate int DGetDefaultAudioEndpoint(IMMDeviceEnumerator self, EDataFlow dataFlow, ERole role, out IntPtr ppEndpoint);
Cheers, J
Apr 19, 2014 at 1:56 PM
chemanel wrote:
After looking more in details, i see that if u put a delegate with "out" or "ref" keyword, the object u try to pass is allways "nullreference".

Did i miss something?
Hi,

How to hook com object function?

Could you give sample code?

Thank you