Page 1 of 1
GET ADSL IP
Posted: Fri Dec 02, 2016 8:13 am
by callroot
Code: Select all
Structure RASCONN
dwSize.l
hRasConn.l
szEntryName.b[256+1]
szDeviceType.b[16+1]
szDeviceName.b[128+1]
EndStructure
Structure RASCONNSTATUS
dwSize.l
RasConnState.l
dwError.l
szDeviceType.b[16+1]
szDeviceName.b[128+1]
EndStructure
Structure RASDIALPARAMS
dwSize.l
szEntryName.b[256 + 1]
szPhoneNumber.b[128 + 1]
szCallbackNumber.b[128 + 1]
szUserName.b[256 + 1]
szPassword.b[256 + 1]
szDomain.b[15 + 1]
EndStructure
Structure RASPPPIP
dwSize.l
dwError.l
szIpAddress.b[15+1]
szServerIpAddress.b[15+1]
dwOptions.l
dwServerOptions.l
EndStructure
Procedure.S GETADSLIP();GET ADSL IP
Protected dwSize.l,RASpppIPs.RASPPPIP,Dim lprasconn.RASCONN(255),lpcConnections.l,lpcb.l,lngRetCode.l
lprasconn(0)\dwSize = 412
lpcb = 256 * lprasconn(0)\dwSize
lngRetCode = RasEnumConnections_(@lprasconn(0), @lpcb, @lpcConnections)
Debug lngRetCode
Debug lprasconn(0)\hRasConn
Debug SizeOf(RASpppIP)
dwSize=SizeOf(RASpppIP)
pp=$08021
Debug RasGetProjectionInfo_(lprasconn(0)\hRasConn,pp,@RASpppIPs,@dwSize)
EndProcedure
GETADSLIP(); ret 632
Error return 632
What reason
Re: GET ADSL IP
Posted: Fri Dec 02, 2016 9:08 am
by DarkDragon
https://msdn.microsoft.com/de-de/librar ... s.85).aspx
ERROR_INVALID_SIZE: The dwSize member of the structure pointed to by lpprojection specifies an invalid size.
Re: GET ADSL IP
Posted: Fri Dec 02, 2016 10:47 pm
by netmaestro
Try it like this for fun:
Code: Select all
Import "Rasapi32.lib"
RasEnumConnectionsA(*buffer, *pointer1, *pointer2)
EndImport
#RAS_MaxEntryName = 256
#RAS_MaxDeviceName = 128
#Ras_MaxDeviceType = 16
Structure RASCONN
dwSize.l
hRasConn.l
szEntryName.b[#RAS_MaxEntryName+1]
szDeviceType.b[#Ras_MaxDeviceType+1]
szDeviceName.b[#RAS_MaxDeviceName+1]
szPhonebook.b[#MAX_PATH]
dwSubEntry.l
guidEntry.GUID
dwFlags.l
luid.LUID
guidCorrelationId.GUID
EndStructure
Remember to change RasEnumConnections_() later in your code to RasEnumConnectionsA()
The reason I suggest the import is I'm not sure if the sz_ members in the structure need to be .u or not as PB 5.5 is linking RasEnumConnectionsW for the native import, but with RasEnumConnectionsA what I have here should be right. Just remember to PeekS() them as #PB_Ascii if you ever get some useful information returned.
Re: GET ADSL IP
Posted: Sat Dec 03, 2016 5:30 am
by callroot
netmaestro wrote:Try it like this for fun:
Code: Select all
Import "Rasapi32.lib"
RasEnumConnectionsA(*buffer, *pointer1, *pointer2)
EndImport
#RAS_MaxEntryName = 256
#RAS_MaxDeviceName = 128
#Ras_MaxDeviceType = 16
Structure RASCONN
dwSize.l
hRasConn.l
szEntryName.b[#RAS_MaxEntryName+1]
szDeviceType.b[#Ras_MaxDeviceType+1]
szDeviceName.b[#RAS_MaxDeviceName+1]
szPhonebook.b[#MAX_PATH]
dwSubEntry.l
guidEntry.GUID
dwFlags.l
luid.LUID
guidCorrelationId.GUID
EndStructure
Remember to change RasEnumConnections_() later in your code to RasEnumConnectionsA()
The reason I suggest the import is I'm not sure if the sz_ members in the structure need to be .u or not as PB 5.5 is linking RasEnumConnectionsW for the native import, but with RasEnumConnectionsA what I have here should be right. Just remember to PeekS() them as #PB_Ascii if you ever get some useful information returned.
Code: Select all
Procedure.S GETADSLIP();GET ADSL IP
Protected dwSize.l,RASpppIPs.RASPPPIP,Dim lprasconn.RASCONN(255),lpcConnections.l,lpcb.l,lngRetCode.l,rval.l,erro.l
lprasconn(0)\dwSize = 412
lpcb = 256 * lprasconn(0)\dwSize
lngRetCode = RasEnumConnections_(@lprasconn(0), @lpcb, @lpcConnections)
dwSize=SizeOf(RASpppIPs)
RASpppIPs\dwSize =dwSize
base1:
rval = RasGetProjectionInfo_(lprasconn(0)\hRasConn,$08021,@RASpppIPs,@dwSize)
If rval <> 0
erro=erro+1
If erro=3:ProcedureReturn "" : EndIf
Delay(100)
Goto base1:
EndIf
ProcedureReturn PeekS(@RASpppIPs\szIpAddress)
EndProcedure
RASpppIPs\dwSize =dwSize
Specified size is now normal, thank you
__________________________________________________
Code tags added
04.12.2016
RSBasic
Re: GET ADSL IP
Posted: Sat Dec 03, 2016 5:31 am
by callroot
Re: GET ADSL IP
Posted: Sat Dec 03, 2016 6:39 am
by nco2k
you dont need to import RasEnumConnectionsA, your structures are wrong!
Code: Select all
#RAS_MaxEntryName = 256
#RAS_MaxDeviceType = 16
#RAS_MaxDeviceName = 128
#RAS_MaxPhoneNumber = 128
#RAS_MaxCallbackNumber = 128
#RAS_MaxIpAddress = 15
#PWLEN = 256
#DNLEN = 15
Structure RASCONN Align #PB_Structure_AlignC
dwSize.l
hrasconn.l
szEntryName.c[#RAS_MaxEntryName + 1]
szDeviceType.c[#RAS_MaxDeviceType + 1]
szDeviceName.c[#RAS_MaxDeviceName + 1]
szPhonebook.c[#MAX_PATH]
dwSubEntry.l
guidEntry.GUID
dwFlags.l
luid.LUID
guidCorrelationId.GUID
EndStructure
Structure RASTUNNELENDPOINT Align #PB_Structure_AlignC
dwType.l
StructureUnion
ipv4.b[4]
ipv6.b[16]
EndStructureUnion
EndStructure
Structure RASCONNSTATUS Align #PB_Structure_AlignC
dwSize.l
rasconnstate.l
dwError.l
szDeviceType.c[#RAS_MaxDeviceType + 1]
szDeviceName.c[#RAS_MaxDeviceName + 1]
szPhoneNumber.c[#RAS_MaxPhoneNumber + 1]
localEndPoint.RASTUNNELENDPOINT
remoteEndPoint.RASTUNNELENDPOINT
rasconnsubstate.l
EndStructure
Structure RASDIALPARAMS Align #PB_Structure_AlignC
dwSize.l
szEntryName.c[#RAS_MaxEntryName + 1]
szPhoneNumber.c[#RAS_MaxPhoneNumber + 1]
szCallbackNumber.c[#RAS_MaxCallbackNumber + 1]
szUserName.c[#UNLEN + 1]
szPassword.c[#PWLEN + 1]
szDomain.c[#DNLEN + 1]
dwSubEntry.l
*dwCallbackId.Long
dwIfIndex.l
*szEncPassword.String
EndStructure
Structure RASPPPIP Align #PB_Structure_AlignC
dwSize.l
dwError.l
szIpAddress.c[#RAS_MaxIpAddress + 1]
szServerIpAddress.c[#RAS_MaxIpAddress + 1]
dwOptions.l
dwServerOptions.l
EndStructure
c ya,
nco2k