d77fn Posted April 10, 2024 Posted April 10, 2024 (edited) Should I use ulong for NET_LUID? (Well I find it should be uint64) Things like "NET_LUID InterfaceLuid;" is not like "type name" style. They are two name. The type name "NET_LUID" is defined in other file. So I should be lookup every type if they are not explicit written? If I just write DllStructCreate(NET_IFINDEX InterfaceIndex; ) will it work!? Should I include some .h file?! Will it automatically find the correct type? And the I don't know how to do with enum type. What about that sub-struct started with BOOLEAN which 1st one is HardwareInterface : 1; And it's ended with InterfaceAndOperStatusFlags; Should this "InterfaceAndOperStatusFlags" write inside DllStructCreate? expandcollapse popuptypedef struct _MIB_IF_ROW2 { NET_LUID InterfaceLuid; NET_IFINDEX InterfaceIndex; GUID InterfaceGuid; WCHAR Alias[IF_MAX_STRING_SIZE + 1]; WCHAR Description[IF_MAX_STRING_SIZE + 1]; ULONG PhysicalAddressLength; UCHAR PhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH]; UCHAR PermanentPhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH]; ULONG Mtu; IFTYPE Type; TUNNEL_TYPE TunnelType; NDIS_MEDIUM MediaType; NDIS_PHYSICAL_MEDIUM PhysicalMediumType; NET_IF_ACCESS_TYPE AccessType; NET_IF_DIRECTION_TYPE DirectionType; 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; IF_OPER_STATUS OperStatus; NET_IF_ADMIN_STATUS AdminStatus; NET_IF_MEDIA_CONNECT_STATE MediaConnectState; NET_IF_NETWORK_GUID NetworkGuid; NET_IF_CONNECTION_TYPE ConnectionType; ULONG64 TransmitLinkSpeed; ULONG64 ReceiveLinkSpeed; ULONG64 InOctets; ULONG64 InUcastPkts; ULONG64 InNUcastPkts; ULONG64 InDiscards; ULONG64 InErrors; ULONG64 InUnknownProtos; ULONG64 InUcastOctets; ULONG64 InMulticastOctets; ULONG64 InBroadcastOctets; ULONG64 OutOctets; ULONG64 OutUcastPkts; ULONG64 OutNUcastPkts; ULONG64 OutDiscards; ULONG64 OutErrors; ULONG64 OutUcastOctets; ULONG64 OutMulticastOctets; ULONG64 OutBroadcastOctets; ULONG64 OutQLen; } MIB_IF_ROW2, *PMIB_IF_ROW2; What about NDIS_MEDIUM MediaType;? It's a NDIS_MEDIUM type and is a enum!!! typedef enum _NDIS_MEDIUM { NdisMedium802_3, NdisMedium802_5, NdisMediumFddi, NdisMediumWan, NdisMediumLocalTalk, NdisMediumDix, // defined for convenience, not a real medium NdisMediumArcnetRaw, NdisMediumArcnet878_2, NdisMediumAtm, NdisMediumWirelessWan, NdisMediumIrda, NdisMediumBpc, NdisMediumCoWan, NdisMedium1394, NdisMediumInfiniBand, #if ((NTDDI_VERSION >= NTDDI_VISTA) || NDIS_SUPPORT_NDIS6) NdisMediumTunnel, NdisMediumNative802_11, NdisMediumLoopback, #endif // (NTDDI_VERSION >= NTDDI_VISTA) #if (NTDDI_VERSION >= NTDDI_WIN7) NdisMediumWiMAX, NdisMediumIP, #endif NdisMediumMax // Not a real medium, defined as an upper-bound } NDIS_MEDIUM, *PNDIS_MEDIUM; Edited April 10, 2024 by d77fn
Andreik Posted April 10, 2024 Posted April 10, 2024 3 hours ago, d77fn said: If I just write DllStructCreate(NET_IFINDEX InterfaceIndex; ) will it work!? Should I include some .h file?! Will it automatically find the correct type? No, it won't work. You should spend some time to understand the basics of AutoIt and then how conversions from Windows API types to AutoIt types are done. Also you can check this repository with some AHK code that use similar data types like AutoIt. However don't take them blindly, for example NET_LUID it clearly unsigned not signed.
Danyfirex Posted April 11, 2024 Posted April 11, 2024 Hello just converted it for fun. Local $sTag_NDIS_MEDIUM = "uint64 InterfaceLuid;int InterfaceIndex;dword Data1InterfaceGuid; word Data2InterfaceGuid; word Data3InterfaceGuid; byte Data4InterfaceGuid[8];wchar Alias[257];wchar Description[257];ulong PhysicalAddressLength;" & _ "byte PhysicalAddress[32];byte PermanentPhysicalAddress[32];ulong Mtu;ulong Type;int TunnelType;int MediaType;int PhysicalMediumType;int AccessType;int DirectionType;" & _ "boolean HardwareInterface;boolean FilterInterface;boolean ConnectorPresent;boolean NotAuthenticated;boolean NotMediaConnected;boolean Paused;boolean LowPower;boolean EndPointInterface;" & _ "int OperStatus;int AdminStatus;int MediaConnectState;dword Data1NetworkGuid; word Data2NetworkGuid; word Data3NetworkGuid; byte Data4NetworkGuid[8];int ConnectionType;" & _ "uint64 TransmitLinkSpeed;uint64 ReceiveLinkSpeed;uint64 InOctets;uint64 InUcastPkts;uint64 InNUcastPkts;uint64 InDiscards;uint64 InErrors;uint64 InUnknownProtos;" & _ "uint64 InUcastOctets;uint64 nMulticastOctets;uint64 InBroadcastOctets;uint64 OutOctets;uint64 OutUcastPkts;uint64 OutNUcastPkts;uint64 OutDiscards;uint64 OutErrors;" & _ "uint64 OutUcastOctets;uint64 OutMulticastOctets;uint64 OutBroadcastOctets;uint64 OutQLen;" Local $tNDIS_MEDIUM = DllStructCreate($sTag_NDIS_MEDIUM) ConsoleWrite(DllStructGetSize($tNDIS_MEDIUM) & @CRLF) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
d77fn Posted April 12, 2024 Author Posted April 12, 2024 On 4/11/2024 at 8:02 AM, Danyfirex said: Hello just converted it for fun. Local $sTag_NDIS_MEDIUM = "uint64 InterfaceLuid;int InterfaceIndex;dword Data1InterfaceGuid; word Data2InterfaceGuid; word Data3InterfaceGuid; byte Data4InterfaceGuid[8];wchar Alias[257];wchar Description[257];ulong PhysicalAddressLength;" & _ "byte PhysicalAddress[32];byte PermanentPhysicalAddress[32];ulong Mtu;ulong Type;int TunnelType;int MediaType;int PhysicalMediumType;int AccessType;int DirectionType;" & _ "boolean HardwareInterface;boolean FilterInterface;boolean ConnectorPresent;boolean NotAuthenticated;boolean NotMediaConnected;boolean Paused;boolean LowPower;boolean EndPointInterface;" & _ "int OperStatus;int AdminStatus;int MediaConnectState;dword Data1NetworkGuid; word Data2NetworkGuid; word Data3NetworkGuid; byte Data4NetworkGuid[8];int ConnectionType;" & _ "uint64 TransmitLinkSpeed;uint64 ReceiveLinkSpeed;uint64 InOctets;uint64 InUcastPkts;uint64 InNUcastPkts;uint64 InDiscards;uint64 InErrors;uint64 InUnknownProtos;" & _ "uint64 InUcastOctets;uint64 nMulticastOctets;uint64 InBroadcastOctets;uint64 OutOctets;uint64 OutUcastPkts;uint64 OutNUcastPkts;uint64 OutDiscards;uint64 OutErrors;" & _ "uint64 OutUcastOctets;uint64 OutMulticastOctets;uint64 OutBroadcastOctets;uint64 OutQLen;" Local $tNDIS_MEDIUM = DllStructCreate($sTag_NDIS_MEDIUM) ConsoleWrite(DllStructGetSize($tNDIS_MEDIUM) & @CRLF) Saludos So If I don't use emulated type, I can just write a wrong type like "int" and leave if alone? I see you don't use STRUCT ... ENDSTRUCT for booleans. Is it still work?
Solution MattyD Posted April 12, 2024 Solution Posted April 12, 2024 7 hours ago, d77fn said: So If I don't use emulated type, I can just write a wrong type like "int" and leave if alone? Do you mean an enumeration? - These are all usually 32bit values, as long as the lengths match you should be OK. 7 hours ago, d77fn said: I see you don't use STRUCT ... ENDSTRUCT for booleans. Is it still work? I could be doing something bad, but I've never really used the struct - end struct tags... The only thing to watch when dealing with odd lengths in the middle of a struct is alignment. You may end up with 00s appearing in the middle to move a value up to the next dword or something. I've been caught before, the struct was fine in 32bit, but it broke when compiling as 64bit. (but you can use the align tag to get out of that one!)
Andreik Posted April 12, 2024 Posted April 12, 2024 On 4/11/2024 at 3:02 AM, Danyfirex said: Hello just converted it for fun. Local $sTag_NDIS_MEDIUM = "uint64 InterfaceLuid;int InterfaceIndex;dword Data1InterfaceGuid; word Data2InterfaceGuid; word Data3InterfaceGuid; byte Data4InterfaceGuid[8];wchar Alias[257];wchar Description[257];ulong PhysicalAddressLength;" & _ "byte PhysicalAddress[32];byte PermanentPhysicalAddress[32];ulong Mtu;ulong Type;int TunnelType;int MediaType;int PhysicalMediumType;int AccessType;int DirectionType;" & _ "boolean HardwareInterface;boolean FilterInterface;boolean ConnectorPresent;boolean NotAuthenticated;boolean NotMediaConnected;boolean Paused;boolean LowPower;boolean EndPointInterface;" & _ "int OperStatus;int AdminStatus;int MediaConnectState;dword Data1NetworkGuid; word Data2NetworkGuid; word Data3NetworkGuid; byte Data4NetworkGuid[8];int ConnectionType;" & _ "uint64 TransmitLinkSpeed;uint64 ReceiveLinkSpeed;uint64 InOctets;uint64 InUcastPkts;uint64 InNUcastPkts;uint64 InDiscards;uint64 InErrors;uint64 InUnknownProtos;" & _ "uint64 InUcastOctets;uint64 nMulticastOctets;uint64 InBroadcastOctets;uint64 OutOctets;uint64 OutUcastPkts;uint64 OutNUcastPkts;uint64 OutDiscards;uint64 OutErrors;" & _ "uint64 OutUcastOctets;uint64 OutMulticastOctets;uint64 OutBroadcastOctets;uint64 OutQLen;" Local $tNDIS_MEDIUM = DllStructCreate($sTag_NDIS_MEDIUM) ConsoleWrite(DllStructGetSize($tNDIS_MEDIUM) & @CRLF) Saludos You must be aware of bit fields declarations. For InterfaceAndOperStatusFlags it will be used one byte, not 8 bytes: 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; Local $sTAG_InterfaceAndOperStatusFlags = "boolean HardwareInterface;boolean FilterInterface;boolean ConnectorPresent;boolean NotAuthenticated;boolean NotMediaConnected;boolean Paused;boolean LowPower;boolean EndPointInterface;" Local $tInterfaceAndOperStatusFlags = DllStructCreate($sTAG_InterfaceAndOperStatusFlags) ConsoleWrite(DllStructGetSize($tInterfaceAndOperStatusFlags) & @CRLF) Danyfirex, MattyD and d77fn 3
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now