Moore's Mind

Saturday, October 01, 2005

PeerCollabEnumCapabilities

Why does PeerCollabEnumCapabilities return "The parameter is incorrect" when I pass the PEER_ENDPOINT part of a PEER_ENDPOINT_NEAR_ME data structure. Does this function allow enumerating the capabilities of a endpoint near me that isn't in my list of contacts?

Below is the managed definition for this function:

[DllImport("p2p.dll", PreserveSig=true)]
internal static extern uint PeerCollabEnumCapabilities(IntPtr pcContact, IntPtr pcEndpoint, IntPtr pCapabilityId, ref IntPtr phPeerEnum);

Since some parameters can be NULL, I'm using IntPtr and having to Marshal each data structure. The structure definition for a PEER_ENDPOINT is:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct PEER_ENDPOINT
{
public PEER_ADDRESS address;
[MarshalAs(UnmanagedType.LPWStr)] public String pwzEndpointName;
};

[StructLayout(LayoutKind.Sequential)]
internal struct PEER_ADDRESS
{
public uint dwSize;
public SOCKADDR_IN6 sin6;
};

[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct SOCKADDR_IN6
{
public short sin6_family;
public ushort sin6_port;
public uint sin6_flowinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=0x10)]
public byte[] sin6_addr;
public uint sin6_scope_id;
};

I'm calling this function in the following way...

IntPtr conptr = IntPtr.Zero;
if (contact != null)
{
PEER_CONTACT ncon = contact.Convert();
conptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PEER_CONTACT)));
Marshal.StructureToPtr(ncon, conptr, true);
}
IntPtr epptr = IntPtr.Zero;
if (endpoint != null)
{
PEER_ENDPOINT nep = endpoint.Convert();
epptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PEER_ENDPOINT)));
Marshal.StructureToPtr(nep, epptr, true);
}
IntPtr capptr = IntPtr.Zero;
result = PeerCollabNative.PeerCollabEnumCapabilities(conptr, epptr, capptr, ref hPeerEnum);

Any help is appreciated.

7 Comments:

  • At 10:28 AM, Blogger Ad. said…

    I created a Managed C++ test application and posted a question in the Windows Vista formum...

    http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=100343#100343

     
  • At 2:15 PM, Blogger Tripp Parks said…

    is this beta 1 or 5219?

     
  • At 4:03 PM, Blogger Ad. said…

    This is beta 1. I tried 5219 at work but the PNRP service wouldn't start (missing references to MSJAVA.DLL and RPCSHIM.DLL) which prevents the Collab API's from working.

     
  • At 8:17 PM, Blogger Tripp Parks said…

    I do not believe it is possible in beta 1, I will check on Monday.

    In any newer builds (5219+) you will be able to, although in 5219 the collab api's are broken due to a dependency issue.

    you will probably want to change Marshal.StructureToPtr(ncon, conptr, true);
    to
    Marshal.StructureToPtr(ncon, conptr, false);
    the true should only be used if you want to reuse the same memory. (and it causes AV's that the CLR catches)

    you can also change

    [DllImport("p2p.dll", PreserveSig=true)]
    internal static extern uint PeerCollabEnumCapabilities(IntPtr pcContact, IntPtr pcEndpoint, IntPtr pCapabilityId,ref IntPtr phPeerEnum);

    [DllImport("p2p.dll", PreserveSig=true)]
    internal static extern uint PeerCollabEnumCapabilities(IntPtr pcContact, IntPtr pcEndpoint, IntPtr pCapabilityId, out IntPtr phPeerEnum);

    so you dont have to initialize phPeerEnum

     
  • At 6:48 AM, Blogger Ad. said…

    Thanks for the info Trip. I'll work on something else until there is a new drop of Windows Vista.

     
  • At 5:46 AM, Blogger Abundant Universe said…

    Hi,

    You have a nice blog and I believe that you DESERVE more in life; that is why you are receiving this today.

    Click NOW to know more on The Secrets of Bill Gates and Donald Trump today.

    Consider yourself MADE! Imagine the FREEDOM!!!

     
  • At 5:47 AM, Blogger Andrea Peterson said…

    Journalism faculty part of blogging trend
    Web logging is becoming an increasingly popular trend and University of Wisconsin-Milwaukee faculty members are a part of it, typing their ideas and commentary online.
    Find out how you can buy & sell anything, like things related to music on interest free credit and pay back whenever you want! Exchange FREE ads on any topic, like music!

     

Post a Comment

<< Home