I've been playing around with the Internet Connection Sharing interface, and have a couple of questions. I know very little about assembly, and almost nothing about COM. I've downloaded MASM32, and I have a PSDK. I'm running XP Pro.

I've been assembling code a line or two at a time, and then loading it into W32Dasm and single stepping through it, just to see what it does.

I can call CoCreateInstance and get an INetSharingManager interface, then an INetSharingEveryConnectionCollection interface, and then an interface to enumerate connections, IEnumNetSharingEveryConnection. I can call Reset okay, and then call Next, but that's as far as I can go. The PSDK says that this is supposed to return "a VARIANT variable for the connection. This variant contains a pointer to an INetConnection interface." I don't understand what this variant is. I gather from what I've seen in some of the headers that this is a structure of four words and a union of a bunch of other types, but I'm confused as to how to interpret this. I'm not sure that I understand exactly what a union is.

The first time I call Next, this is what I get back.

[00403058] - 0000000d
[0040305C] - 00000000
[00403060] - 0015f7c0
[00403064] - 00000000

[0015F7C0] - 771b4124

I thought that maybe this was a pointer to the INetConnection interface, so I put it in ecx and dereferenced it into edx. (Please don't dog me if I don't have the nomenclature right. I'm new at this.)


- 771e0b8b
- 771c10b2
- 771c160f
- 771e09d5
- 771e0971
- 771c10a1
- 771c15db
- 7725a0c3
- 00000018
- 00000000
- 000000c0

The INetConnection interface has 7 methods, plus IUnknown. So that's 10, right? So I guess this isn't a Vtable? All of these addresses are in ole32.dll.

When I call Next again I get this:

[00403058] - 0000000d
[0040305C] - 00000000
[00403060] - 0015f8a8
[00403064] - 00000000

Where does this go? Let's see...

[0015F8A8] - 771b4124

- 771e0b8b
- 771c10b2
- 771c160f
- 771e09d5
- 771e0971
- 771c10a1
- 771c15db
- 7725a0c3
- 00000018
- 00000000

I have three connections in my connections folder. I can call Next three times, and get three different pointers, and they all point to the same place. The fourth time I call Next eax returns 1.

I messed around for hours trying to call get_EnumEveryConnection from the INetSharingManager interface. I kept getting E_POINTER back in eax. The help page in the PSDK calls for a Flags parameter when you call this method, but according to netcon.h, it's not supposed to be there. So I don't know if I getting these results because I've hosed up something somewhere, or the because the documentation is wrong somewhere, or because I don't know what I'm doing, or what. If anyone could shed some light on this, I'd be grateful.
Posted on 2003-03-14 22:15:39 by T_Volk
Hi T_Volk,

from this IEnumXXX you get back a variant, which most likely is of type VT_DISPATCH or VT_UNKNOWN. But you can only be sure that its a IDispatch (for VT_DISPATCH) or IUnknown (for VT_UNKNOWN). So you will need to do a QueryInterface for INetConnection (or whatever you want) on the returned object first.

Be careful with the IEnumXXX:Reset with this INetSharing... stuff. Some collections work only once in my version of windows xp. You dont need to reset the enumeration if you read the objects just one time.

Japheth
Posted on 2003-03-15 03:34:38 by japheth
Japheth,

Thanks for the reply. I'll give that a try and see what happens.

T_Volk
Posted on 2003-03-15 23:24:20 by T_Volk