Author | Message | Time |
---|---|---|
JoeTheOdd | [code] strIP = Asc(Mid(strTempData, 1, 1)) & "." & _ Asc(Mid(strTempData, 2, 1)) & "." & _ Asc(Mid(strTempData, 3, 1)) & "." & _ Asc(Mid(strTempData, 4, 1))[/code] I suggest using a function, as this is done in many packets, if I'm correct. Its also used in proxy handling, which many bots have. [code]Public Function DWORDtoIP(DWORD as Long) as String Dim IP as String * 11 For i = 1 to 4 IP = IP and Asc(Mid(DWORD, i, 1) Next i DWORDtoIP = IP End Function Public Function IPtoDWORD(IP as Long) as Long Dim DWORD as String * 4, Splt(0 to 4) as String Splt = Split(IP, ".") For i = 1 to 4 DWORD = DWORD and Chr(CLng(Splt(i))) Next i IPtoDWORD = CLng(DWORD) End Function[/code] | April 15, 2005, 3:07 AM |
UserLoser. | Just use inet_addr and inet_ntoa instead of using much less efficient vb code Example: inet_addr(255.255.255.255) = 0xffffffff unsigned long addr = 0x12345678; inet_ntoa(*(struct in_addr*)&addr)) = 120.86.52.18 | April 15, 2005, 3:09 AM |
JoeTheOdd | Huh? Mind posting a VB code snippet to call the C++ function or whatever it is? | April 15, 2005, 4:00 AM |
LoRd | April 15, 2005, 4:17 AM | |
Kp | As a side note, inet_addr is obsolete and should not be used in new code. You should instead use inet_aton. | April 15, 2005, 4:37 AM |
dRAgoN | Not to be rude lol but can somone split this into the general forum, and re-lock it for now. edit: This way if I ever fix anything the post is not like 3 pages away from the original info. If I could edit my posts while the thread was locked I wouldent have asked for it to be unlocked though I think theres a limit on how much text I can add to it anyways. The reasons I did that for the IP instead of going with eg. inet_ntoa, was to keep it as simple as possible and to show how to do this manualy (doubt there's many here familiar with the function anyways), which I was going to do with GetLong in the begining but I'm sure noone wanted to see (((b*(2^8))*(2^8))*(2^8)) etc etc etc.. Eventualy you'll probably find more things that could be done better, which should be done at your own discretion. | April 15, 2005, 8:03 AM |
Myndfyr | [quote author=l)ragon link=topic=11287.msg108652#msg108652 date=1113552201] Not to be rude lol but can somone split this into the general forum, and re-lock it for now. [/quote] I would have, but I thought you didn't want it locked at the moment. Topic split. | April 15, 2005, 8:51 AM |
dRAgoN | [quote author=MyndFyre link=topic=11287.msg108656#msg108656 date=1113555077] [quote author=l)ragon link=topic=11287.msg108652#msg108652 date=1113552201] Not to be rude lol but can somone split this into the general forum, and re-lock it for now. [/quote] I would have, but I thought you didn't want it locked at the moment. Topic split. [/quote] I was going to complete it the night of my last post to the thread, but I kept getting side tracked with other crap, and at the moment I dont have vb6 installed on this pc, and its about a 36 hour walk from here to get my cd's, so it may be awhile. | April 15, 2005, 9:47 AM |
JoeTheOdd | Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion. Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did. [code]Public Declare Function inet_addr Lib Ws2_32.dll (in as String) '// inet_addr is used as an IPtoDWORD function. Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String) '// inet_ntoa is used as a DWORDtoIP function. Public Function IPtoDWORD(IP as String) as Long '// This is used as a wrapper for the inet_addr function, providing an easier to remember name. IPtoDWORD = inet_addr(IP) End Function Public Function DWORDtoIP(DWORD as Long) as String '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name. DWORDtoIP = inet_ntoa(DWORD) End Function[/code] | April 15, 2005, 9:19 PM |
dRAgoN | [quote author=Joe[x86] link=topic=11287.msg108685#msg108685 date=1113599999] Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion. Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did. [code]Public Declare Function inet_addr Lib Ws2_32.dll (in as String) '// inet_addr is used as an IPtoDWORD function. Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String) '// inet_ntoa is used as a DWORDtoIP function. Public Function IPtoDWORD(IP as String) as Long '// This is used as a wrapper for the inet_addr function, providing an easier to remember name. IPtoDWORD = inet_addr(IP) End Function Public Function DWORDtoIP(DWORD as Long) as String '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name. DWORDtoIP = inet_ntoa(DWORD) End Function[/code] [/quote] [code]Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long Private Declare Function inet_ntoa Lib "wsock32.dll" (ByVal addr As Long) As Long[/code] | April 15, 2005, 10:50 PM |
UserLoser. | [code] Public Function DWORDtoIP(DWORD as Long) as String '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name. DWORDtoIP = inet_ntoa(DWORD) End Function [/code] That doesn't work. inet_ntoa is returning as a Long, or pointer to the string. See: lstrcpy(A/W) | April 16, 2005, 12:21 AM |
JoeTheOdd | Ooh, thanks. The rest works, provided I make them return longs? EDIT: Anybody wanna explain the whole Alias thing? I think that way we would only need the wrapper for the second, when we un-pointer-ify the string. | April 16, 2005, 2:17 AM |
R.a.B.B.i.T | [quote author=l)ragon link=topic=11287.msg108697#msg108697 date=1113605438] [quote author=Joe[x86] link=topic=11287.msg108685#msg108685 date=1113599999] Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion. Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did. [code]Public Declare Function inet_addr Lib Ws2_32.dll (in as String) '// inet_addr is used as an IPtoDWORD function. Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String) '// inet_ntoa is used as a DWORDtoIP function. Public Function IPtoDWORD(IP as String) as Long '// This is used as a wrapper for the inet_addr function, providing an easier to remember name. IPtoDWORD = inet_addr(IP) End Function Public Function DWORDtoIP(DWORD as Long) as String '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name. DWORDtoIP = inet_ntoa(DWORD) End Function[/code] [/quote] [code]Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long Private Declare Function inet_ntoa Lib "wsock32.dll" (ByVal addr As Long) As Long[/code] [/quote]such a waste of cycles... | April 16, 2005, 4:12 PM |
Myndfyr | [quote author=Joe[x86] link=topic=11287.msg108722#msg108722 date=1113617829] Ooh, thanks. The rest works, provided I make them return longs? EDIT: Anybody wanna explain the whole Alias thing? I think that way we would only need the wrapper for the second, when we un-pointer-ify the string. [/quote] Alias allows you to define a name for your function that is something other than the export from the DLL. For example, CopyMemory is actually a declared alias of the DLL function RtlMoveMemory. | April 16, 2005, 6:52 PM |