If you want to get the IP Address,Subnet Mask,Default Gateway,DHCP Server,Primary WINS Server,Secondary WINS Server then use this snippet:
Demo:
Code:
const // put this const at the header of the code
ADAPTERCAPACITY = 4096 // ADAPTERCAPACITY >= 640 * ADAPTERSCOUNT // make sure to count the number of adapters you have at your computer.
IPOFFSETIPADDRESS = 0x1B0 // Current IP Address
IPOFFSETSUBNETMASK = 0x1C0 // Subnet Mask
IPOFFSETGATEWAY = 0x1D8 // Default Gateway
IPOFFSETDHCPSERVER = 0x1E8 // DHCP Server
IPOFFSETPWINSS = 0x200 // Primary WINS Server
IPOFFSETSWINSS = 0x210 // Secondary WINS Server
end
const // used by GetMyLocalIP
ADAPTERLIBRARY = 31@
ADAPTERPROC = 30@
ALLADAPTERSINFO = 29@
NEXTIPADAPTERINFO = 28@
ADAPTERBLOCKSIZEPERINDEX = 27@
end
// 0AB1: @GetMyLocalIP 3 _adapterindex 0@ _ipoffset 1@ _storetobuffer 2@
// index must be within "0 upto ADAPTERMAXINDEX-1" where ADAPTERMAXINDEX is the number of adapters on your computer
// buffer size must be >= 16
:GetMyLocalIP
if 0AA2: ADAPTERLIBRARY = load_library "Iphlpapi.dll" // IF and SET
then
if 0AA4: ADAPTERPROC = get_proc_address "GetAdaptersInfo" library ADAPTERLIBRARY // IF and SET
then
28@ = 4096
alloc ALLADAPTERSINFO 28@
0AA5: call ADAPTERPROC num_params 2 pop 0 28@v ALLADAPTERSINFO // inparams 28@v=buffer size pointer << ALLADAPTERSINFO=buffer pointer
0085: 11@ = ALLADAPTERSINFO
0A8D: NEXTIPADAPTERINFO = read_memory 11@ size 4 virtual_protect 0 // get the pointer of the next ip adapter
0085: ADAPTERBLOCKSIZEPERINDEX = NEXTIPADAPTERINFO
0062: ADAPTERBLOCKSIZEPERINDEX -= 11@
006A: 0@ *= ADAPTERBLOCKSIZEPERINDEX
005A: 11@ += 0@ // jump to the specified index then afterwards read that adapter block
005A: 11@ += 1@ // IP Offset
// memcpy _source 11@ _destination 0@ _size 16
2@+=15
0A8C: write_memory 2@ size 1 value 0 virtual_protect 0 // null terminator
2@-=15
for 9@ = 1 to 15
0A8D: 10@ = read_memory 11@ size 1 virtual_protect 0
0A8C: write_memory 2@ size 1 value 10@ virtual_protect 0
if 10@ == 0x0 // null terminator
then break
else
2@++
11@++
end
end
//
free ALLADAPTERSINFO
end
0AA3: free_library ADAPTERLIBRARY
end
ret 0
Demo:
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETIPADDRESS _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d IP: %s" -1 1@ 0@
end
free 0@
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETSUBNETMASK _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d Subnet Mask: %s" -1 1@ 0@
end
free 0@
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETGATEWAY _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d Default Gateway: %s" -1 1@ 0@
end
free 0@
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETDHCPSERVER _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d DHCP Server: %s" -1 1@ 0@
end
free 0@
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETPWINSS _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d Primary WINS Server: %s" -1 1@ 0@
end
free 0@
Code:
alloc 0@ 16
for 1@ = 0 to 5 // in my pc I got 6 adapters with me
0AB1: @GetMyLocalIP 3 _adapterindex 1@ _ipoffset IPOFFSETSWINSS _storetobuffer 0@ // 4th index is my wlan, try getting your own index
chatmsg "Adapter %d Secondary WINS Server: %s" -1 1@ 0@
end
free 0@