GetIfTable2 - wie funktionierts richtig?
Verfasst: 11.09.2010 14:42
Ich versuche Gerade GetIfTable2 zum laufen zu bringen.
hier die infos von MS:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
hier die Strucktur:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Ich hab folgendes bisher gemacht:
Ja ist schlampig gemacht ;9
Meine Fragen:
Die Strucktur - irgendwo ist noch ein großer Fehler drin. die ist 4 Bytes zu klein.
Das zweite Problem: Das Datenfeld beginnt bei mir irgendwie 4 Bytes zu weit unten - ansonsten gibt Index bspw. völlig unsinige Werte. Aber InterfaceLuid ist definitv 8 Bytes groß - also kann ich nicht beide Probleme koppeln, wenn ich InterfaceLuid 4 Bytes größer mach.
Hat jemand eine Ahnung, wo mein Denkfehler ist?
hier die infos von MS:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
hier die Strucktur:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Ich hab folgendes bisher gemacht:
Code: Alles auswählen
Global library
library=OpenLibrary(1,"Iphlpapi.dll")
Procedure GetIfTable2(a)
ProcedureReturn CallFunction(1,"GetIfTable2",a)
EndProcedure
Procedure FreeMibTable(a)
ProcedureReturn CallFunction(1,"FreeMibTable",a)
EndProcedure
#IF_MAX_STRING_SIZE = 256
#IF_MAX_PHYS_ADDRESS_LENGTH =32
Structure MIB_IF_ROW2
InterfaceLuid.b[8] ; Ein Quad
InterfaceIndex.l
InterfaceGuid.b[4+2+2+8]
Alias.u[#IF_MAX_STRING_SIZE +1];
Description.u[#IF_MAX_STRING_SIZE +1];
PhysicalAddressLength.l;
PhysicalAddress.b[#IF_MAX_PHYS_ADDRESS_LENGTH];
PermanentPhysicalAddress.b[#IF_MAX_PHYS_ADDRESS_LENGTH];
Mtu.l;
Type.l;
TunnelType.l;?
MediaType.l;?
PhysicalMediumType.l;?
AccessType.l;?
DirectionType.l;?
InterfaceAndOperStatusFlags.l
; #struct {
; BOOLEAN HardwareInterface :1;
; BOOLEAN FilterInterface :1;
; BOOLEAN ConnectorPresent :1;
; BOOLEAN NotAuthenticated :1;
; BOOLEAN NotMediaConnected :1;
; BOOLEAN Paused :1;
; BOOLEAN LowPower :1;
; BOOLEAN EndPointInterface :1;
; } InterfaceAndOperStatusFlags;
OperStatus.l;
AdminStatus.l;
MediaConnectState.l;
NetworkGuid.b[4+2+2+8];
ConnectionType.l;
TransmitLinkSpeed.q;
ReceiveLinkSpeed.q;
InOctets.q;
InUcastPkts.q;
InNUcastPkts.q;
InDiscards.q;
InErrors.q;
InUnknownProtos.q;
InUcastOctets.q;
InMulticastOctets.q;
InBroadcastOctets.q;
OutOctets.q;
OutUcastPkts.q;
OutNUcastPkts.q;
OutDiscards.q;
OutErrors.q;
OutUcastOctets.q;
OutMulticastOctets.q;
OutBroadcastOctets.q;
OutQLen.q;
fill.l; <--- Strucktur ist um 4 zu klein, aber wo?
EndStructure
buf.l
If GetIfTable2(@buf)=#ERROR_SUCCESS
count=PeekL(buf)
Debug PeekL(buf)
Debug PeekL(buf+4)
Debug PeekQ(buf)
Debug "Anzahl:"+Str(count)
*line.mib_if_row2=buf+8;<- eigentlich müßte es+4 heißen, aber dann stimmt was nicht!
For i=1 To count
Debug "index:"+Str(*line\InterfaceIndex)
;Debug @*line\InterfaceIndex-*line
Debug PeekS(@*line\Description,#IF_MAX_STRING_SIZE,#PB_Unicode)
Debug PeekS(@*line\Alias,#IF_MAX_STRING_SIZE,#PB_Unicode)
a$=""
For b=0 To *line\PhysicalAddressLength-1
a$+Hex(*line\PhysicalAddress[b] &$FF)
Next
;Debug a$
b=4
a=PeekQ(@*line\inOctets+b)
Debug Str(b)+"x:"+Hex(a)+" "+Str(a)
*line+SizeOf(mib_if_row2)
Next
EndIf
FreeMibTable(buf)
Meine Fragen:
Die Strucktur - irgendwo ist noch ein großer Fehler drin. die ist 4 Bytes zu klein.
Das zweite Problem: Das Datenfeld beginnt bei mir irgendwie 4 Bytes zu weit unten - ansonsten gibt Index bspw. völlig unsinige Werte. Aber InterfaceLuid ist definitv 8 Bytes groß - also kann ich nicht beide Probleme koppeln, wenn ich InterfaceLuid 4 Bytes größer mach.
Hat jemand eine Ahnung, wo mein Denkfehler ist?