flat assembler
Message board for the users of flat assembler.
Index
> Windows > Some Winsock Functions Questions.. Goto page 1, 2, 3, 4 Next |
Author |
|
asmhack 09 Nov 2010, 00:14
|
|||
09 Nov 2010, 00:14 |
|
Overflowz 09 Nov 2010, 00:45
asmhack, maybe you have bad eyes ?
Code: #1 I found some examples in Google and here also but I don't understand much from there. #2 If anyone can write example with less API functions and less code for those structure... #3 P.S I'm saying it again. I already checked on this forum and Google but no one from them is good understandable for me. And 1 more thing. It should be in FASM with easiest source (if possible..) And I think it will be nice tutorial for other beginners too I'm not trying to "hack" things just interested how does it work, if so I could just copy source and replace things and done. PLEASE think before posting. Thanks. |
|||
09 Nov 2010, 00:45 |
|
revolution 09 Nov 2010, 01:04
Overflowz: Show what you have so far. At least give us some confidence that you are trying your best to get something working.
You can't really expect others to write stuff from scratch, it would be easier for others to modify something for you that you are having trouble with. Most people have limited time available to help out so it would be best for you if you try to make it easier for others to help you. And that means posting some code you are working on and ask specific questions. Usually one question at a time is the way to maximise the desire of others to help. |
|||
09 Nov 2010, 01:04 |
|
Overflowz 09 Nov 2010, 10:01
Allright. I'll show you codes and someone convert main functions from there please.
#1 Program called Headreq http://madwizard.org/download/winsock/headreq_asm.zip #2 Can't find any example.. just simple as it sounds.. #3 Like reverse of 2, for example server is running on 23 port. Connected to server and sent some data, clicked enter and connection closed and result saved in buffer. #4 Picnic's Simple Chat. http://board.flatassembler.net/download.php?id=5156 this is all what I mean. Thanks. Oh and P.S Interesting about difference between Blocking sockets and non-blocking and both examples. |
|||
09 Nov 2010, 10:01 |
|
b1528932 09 Nov 2010, 14:07
its much harder than u think.
you must first understand how windows managwe protocols, what are protocol properties, learn how functions inform you about certain network events (so you implicitly must know well tcp/ip). You need to know internals about your io method (assuming you are not a noob using blocking send/recv thread per client). And if you want to send http request, you need to learn http, because its insane complicated protocol. Ive spent much time learning this, and unless you dont plan using this knowleadge to hack something, there is no point wasing your time with it. Goto linux if you want to write 'friendly' programs. Windows is dead when it come to future programming, imho. The only thing keeping it on market is its popularity. Youll see, windows 10 will be opensource based on linux. All windows features will be emulated for backward compatibility. |
|||
09 Nov 2010, 14:07 |
|
Overflowz 09 Nov 2010, 14:48
b1528932, I know that things already. I'll explain what I don't know right now.
first, what to do first. I mean when WSAStartup initialized, then I'm creating socket and then I have no idea what should be next command for somethings.. I'm trying to learn on windows first, next time I'll use Linux. Just I'm trying to make programs on windows cause many people are using it in my country. I need just simple examples of them.. and BTW I don't understand why IP is converting to other thing, I have question, does that converting IP from big-endian to little-endian ? Hope someone will make examples of that structure what I wrote last post. Thanks. |
|||
09 Nov 2010, 14:48 |
|
revolution 09 Nov 2010, 14:56
If you want to connect to google.com then you have to knows its IP, so you need to do a DNS lookup first.
Then if you want to connect to a particular service at google.com then you need to know the port to connect to, HTTP=80, HTTPS=443 etc. Then if you want to send data to google.com on port 80 then you have to know the HTTP protocol details with properly formatted data to send to google.com. All that is just for #1 on your list. Once you get that all working then you can move to #2 and onwards. |
|||
09 Nov 2010, 14:56 |
|
Overflowz 09 Nov 2010, 15:03
revolution, I know already that what it should do. But I don't know how to code that. I'll write little example how I'm thinking it would be.
Code: format PE console 4.0 include 'WIN32AX.INC' entry main section '.data' data readable writeable hSock dd ? s_data db "HEAD / HTTP/1.1",0 wsaData WSADATA sin sockaddr_in sizeof.sin = $ - sockaddr_in section '.text' code readable executable proc main invoke WSAStartup,0202h,wsaData invoke socket,AF_INET,SOCK_STREAM,0 mov [hSock],eax ... section '.idata' import data readable blablabla.. I have no idea what should I write next to send "s_data" request to server and then receive output back.. I just need that nothing else. On listen I know first I should make socket then bind then listen then accept and done but on send I really don't know. I'm just asking about that examples |
|||
09 Nov 2010, 15:03 |
|
revolution 09 Nov 2010, 15:08
Do a DNS lookup, get the IP for google.com.
hint: invoke gethostbyname, ... |
|||
09 Nov 2010, 15:08 |
|
Overflowz 09 Nov 2010, 15:19
maybe full example please ? I know gethostbyname I mean I don't know what to do next. I'll write 1 more example after that code how I think it would be.
Code: invoke gethostbyname,ipBuffer ;I don't know where IP is located now. invoke connect,[hSock],sin,sizeof.sin invoke send,[hSock],s_data,sizeof.s_data invoke ExitProcess,0 Am I right ? |
|||
09 Nov 2010, 15:19 |
|
revolution 09 Nov 2010, 15:22
Overflowz wrote: maybe full example please ? https://encrypted.google.com/search?num=100&hl=en&q=gethostbyname&btnG=Search BTW: asmhack already gave a full working example but you rejected it. So we have to do this step by step. We can't rush the learning process. Last edited by revolution on 09 Nov 2010, 15:23; edited 1 time in total |
|||
09 Nov 2010, 15:22 |
|
Overflowz 09 Nov 2010, 15:23
I saw that but I'm not programmer to understand what that structure means and how to use that too.. I don't have problem about getting host IP. just how to send..
|
|||
09 Nov 2010, 15:23 |
|
revolution 09 Nov 2010, 15:24
Overflowz wrote: I saw that but I'm not programmer to understand what that structure means and how to use that too.. I don't have problem about getting host IP. just how to send.. |
|||
09 Nov 2010, 15:24 |
|
Overflowz 09 Nov 2010, 15:28
Urghh I hate English. For example I have IP not site. how to send packets there I don't know what command should be next and next after creating socket..
|
|||
09 Nov 2010, 15:28 |
|
revolution 09 Nov 2010, 15:28
Here is small snippet from some of my code:
Code: mov eax,dword[edx+HTTP_STATE.hostent_buff+hostent.h_addr_list] mov eax,[eax+0] ;get first entry in listhwnd test eax,eax jz .cant_find_IP mov eax,[eax+0] ;get IP test eax,eax jz .cant_find_IP stdcall HTTP_set_IP_address,edx,eax ;... proc HTTP_set_IP_address uses ebx,state,IP mov ebx,[state] mov eax,[IP] mov [ebx+HTTP_STATE.sock_addr.sin_addr],eax ;... |
|||
09 Nov 2010, 15:28 |
|
revolution 09 Nov 2010, 15:32
Once you have the IP stored in the sock_addr structure, next is to set the port.
hint: invoke htons, ... |
|||
09 Nov 2010, 15:32 |
|
Overflowz 09 Nov 2010, 15:32
(((((((( You don't understand me. FORGET everything and try to focus on this:
I have an ip address for example 127.0.0.1 I need to send some data to 127.0.0.1 and I don't know what commands should I use after creating socket. I need just example not explanation cause I don't understand so much about that things. I can only understand from sources.. Thank you. Brb after 3 hours and I'll post. |
|||
09 Nov 2010, 15:32 |
|
revolution 09 Nov 2010, 15:36
Overflowz wrote: I need just example ... http://flatassembler.net/examples/quetannon.zip You can safely ignore my attempts to explain this to you step by step and instead read the sources. When all else fails, read the source. |
|||
09 Nov 2010, 15:36 |
|
Overflowz 09 Nov 2010, 17:19
... just say u can't help.
asmhack wrote: http://flatassembler.net/examples/quetannon.zip |
|||
09 Nov 2010, 17:19 |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.