Kenna Posted July 22, 2011 Share Posted July 22, 2011 (edited) So, I'm fairly decent as far as my knowledge of autoit goes. I have limited experience in C/C++ enough to figure out most of what I want done. However I have a slight issue, I'm using someone elses DLL that has a custom recv I'm trying to call. Their DLL works fine. I can use the send no problem. But when I call recv, my code is wrong and it causes it to hang. So the question I have is, can somebody show me a DLL call for the OFFICIAL ws2_32.dll recv in autoit? I'll just modify it accordingly. Edited July 22, 2011 by Kenna Link to comment Share on other sites More sharing options...
Exit Posted July 22, 2011 Share Posted July 22, 2011 First, welcome to the forum. Second, would you show the code? We could help you better. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
ProgAndy Posted July 22, 2011 Share Posted July 22, 2011 (edited) You could always use TCPSend / TCPRecv. Here is the doc for recv: http://msdn.microsoft.com/en-us/library/ms740121%28VS.85%29.aspx Result: $tBuff = DllStructCreate("byte[1024]") DllCall($dll, "int", "recv", "uint", $socket, "ptr", DllStructGetPtr($tBuff), "int", DllStructGetSize($tBuff), "int" $flags Edited July 22, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Kenna Posted July 22, 2011 Author Share Posted July 22, 2011 (edited) You could always use TCPSend / TCPRecv. Here is the doc for recv: http://msdn.microsoft.com/en-us/library/ms740121%28VS.85%29.aspx Result: $tBuff = DllStructCreate("byte[1024]") DllCall($dll, "int", "recv", "uint", $socket, "ptr", DllStructGetPtr($tBuff), "int", DllStructGetSize($tBuff), "int" $flags Thanks alot! I would if the DLL didn't do some minor encoding/encrypting to protect the data, and I don't know the algorithm so I can't replicate it. This helps more than you know. I'll tell you if it works out for me. @forumer100: Thanks I'm sure it has to do with the buffer I'm storing it in not being properly formed e.g.: $tBuff = DllStructCreate("byte[1024]") Kkk brb. Edit: Also @Andy I was looking at the recv msdn but I wasn't able to get my code to work properly even though send works. Do you believe this code is sufficient for my send? Func _send($sck, $snd) DllCall("custom_ws2_32.dll", "int", "send", "int", $sck, "str", $snd, "int", StringLen($snd), "int", 0) EndFunc It seems to work but I'm not sure if that would be "proper." Edited July 22, 2011 by Kenna Link to comment Share on other sites More sharing options...
ProgAndy Posted July 22, 2011 Share Posted July 22, 2011 (edited) This should be ok. You should use DllOpen, though. Edit: Depending on the data, recv should also work with ..., "str", "", "int", 56000, ... Edited July 22, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
twitchyliquid64 Posted July 23, 2011 Share Posted July 23, 2011 Zatorg's Async sockets UDF has some examples of interfacing with winsock with dynamic linking. They use TCPSend and Recv to get the data, though, but the DLL for setting up the connection and callbacks. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
Kenna Posted July 23, 2011 Author Share Posted July 23, 2011 (edited) K! So I got the DLLCall working properly using both andys code and my own code. However both return int 0, no matter what. At the moment I'm using a slightly modified (example send/recv scripts). Simply to weed out any variables. The idea being that I have it set up like this client +> _send +> server server <- TCPrecv <- client server +> TCPSend +> client client <- _recv <- server But when I get to the point where I _recv, the return is integer, 0. When I TCPRecv, the return is a proper string, "test". Is there a function I need to use to read the recv buffer? Edit: Func _recv($socket) Dim $rTest, $tBuff $tBuff = DllStructCreate("byte[1024]") $rTest = DllCall("ws2_32.dll", "int", "recv", "uint", $socket, "ptr", DllStructGetPtr($tBuff), "int", DllStructGetSize($tBuff), "int", 0) ConsoleWrite($rTest & @CRLF) EndFunc #cs Func _recv($sck) Dim $buff = 1024 Dim $rcv = "" $Output = DllCall($dll, "int", "recv", "int", $sck, "str*", $rcv, "int", $buff, "int", 0) ConsoleWrite($Output & @CRLF) EndFunc #ce Now I even tried using ws2_32.dll, as you can see, and it gives the same return value. Edited July 23, 2011 by Kenna Link to comment Share on other sites More sharing options...
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