Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM handling of C declarations
#1
Gintaras,
I really have hard time trying to port some C definitions in wanapi to QM....in fact, pointers and references do not seem handled the same in QM,
and that makes me lose a large amount of time

This is just an example, no real code needed for the moment....

somewhere in Winapi is this

dll iphlpapi #NotifyIpInterfaceChange @Family Callback !*CallerContext !InitialNotification *NotificationHandle
Callback: function !*CallerContext MIB_IPINTERFACE_ROW*Row NotificationType

NETIOAPI_API NotifyIpInterfaceChange(
_In_ ADDRESS_FAMILY Family,
_In_ PIPINTERFACE_CHANGE_CALLBACK Callback,
_In_ PVOID CallerContext,
_In_ BOOLEAN InitialNotification,
_Inout_ HANDLE *NotificationHandle
);

I try to understand how to handle this.

I did:


int y
_i=NotifyIpInterfaceChange(AF_UNSPEC &sub.g 0 1 &y)
if(_i=NO_ERROR) out "ok"
CancelMibChangeNotify2(y)

Frome there, i get "OK" result, so it works

#sub g v
function !*CallerContext MIB_IPINTERFACE_ROW*Row NotificationType (like definition above)


the problem here is that Row is defined as a pointer variable of MIB_IPINTERFACE_ROW type.

from MSDN
When the callback function is received when a change occurs and the Row parameter is not NULL, the pointer to the MIB_IPINTERFACE_ROW structure passed in the Row parameter contains incomplete data. The information returned in the MIB_IPINTERFACE_ROW structure is only enough information that an application can call the GetIpInterfaceEntry function to query complete information on the IP interface that changed. When the callback function is received, an application should allocate a MIB_IPINTERFACE_ROW structure and initialize it with the Family, InterfaceLuid and InterfaceIndex members in the MIB_IPINTERFACE_ROW structure pointed to by the Row parameter received. A pointer to this newly initialized MIB_IPINTERFACE_ROW structure should be passed to the GetIpInterfaceEntry function to retrieve complete information on the IP interface that was changed.

So i must declare a new MIB_IPINTERFACE_ROW, get Family, InterfaceLuid and InterfaceIndex from Row into it, then pass it to GetIpInterfaceEntry to get information.

an example program did that: http://www.antillia.com/sol9.2.0/classe ... ifier.html

As the code is not aimed to code something, i'd just like some explainations, and understant how QM handles pointers, references from Winapi C declarations (links are welcome)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)