flat assembler
Message board for the users of flat assembler.
Index
> Windows > Picnic Playground Goto page 1, 2 Next |
Author |
|
Overflowz 21 Sep 2010, 11:20
Oh, so nice ! BTW can you write more simple code without command line args and without proc-s ? just like when conencted to wait for recive or send and client/server same like that. thank you!
|
|||
21 Sep 2010, 11:20 |
|
edfed 21 Sep 2010, 11:35
and for IRC?
|
|||
21 Sep 2010, 11:35 |
|
Picnic 22 Sep 2010, 11:26
Hi,
Overflowz, __getmainargs function provides a simple way to get the command line parameters. As better alternatives see Windows API functions GetCommandLine or CommandLineToArgvW Search fasm board for examples or even more simple winsock samples. edfed i don't know much about IRC, never used it. |
|||
22 Sep 2010, 11:26 |
|
Overflowz 22 Sep 2010, 12:55
Okay thanks. I'm just stuck how to receive buffer and I know only send >.<
|
|||
22 Sep 2010, 12:55 |
|
Picnic 22 Jul 2012, 21:51
A simple Winsock Multi-User Console Chat Server.
Made for Windows XP, tested with telnet.exe, putty client will also work. It can handle backspace, users can change their names, it prints a user-list. Program is inspired from a C++ sample. The listening port can be passed as a command line argument, the default port is 23. Esc stops the server. Despite my lame code which is written in three days, it works well. [code removed] Last edited by Picnic on 21 Mar 2020, 11:26; edited 5 times in total |
|||
22 Jul 2012, 21:51 |
|
sleepsleep 23 Jul 2012, 00:40
looks great!!
|
|||
23 Jul 2012, 00:40 |
|
bzdashek 23 Jul 2012, 05:48
Yeah, wonderful!
|
|||
23 Jul 2012, 05:48 |
|
Picnic 24 Jul 2012, 05:06
thank you both, appreciate the comments.
|
|||
24 Jul 2012, 05:06 |
|
bzdashek 26 Aug 2012, 07:32
Where did the last version go?
|
|||
26 Aug 2012, 07:32 |
|
Picnic 26 Aug 2012, 10:44
A login system with a username and password as well as a server log were added to server.
[code removed] Last edited by Picnic on 21 Mar 2020, 14:20; edited 7 times in total |
|||
26 Aug 2012, 10:44 |
|
bzdashek 26 Aug 2012, 10:47
Thank you, Picnic!
|
|||
26 Aug 2012, 10:47 |
|
Picnic 12 Jan 2013, 16:24
You're welcome bzdashek!
Last edited by Picnic on 03 Mar 2013, 19:55; edited 1 time in total |
|||
12 Jan 2013, 16:24 |
|
typedef 13 Jan 2013, 00:35
When working on such projects consider using multi-threaded libraries with callback support (Windows has one for GUI but kind of sucks).
Example. Make a library that can be re-used (duh) Pseudo code Code: ; import winsock ; Define our interface here. Just a struct struct ISocketEvent onDataArrival dd ? ; implement as proc onDataArrival, handle, lpData, dwSize onClientReady dd ? ; implement as proc onClientReady, handle, lpData, lpdwSize ; return data to send and size in the last two parameters. (See below) onError dd ? ; implement as proc onError, dwCode, pszDecription onConnect dd ? ; implement as proc onConnect, handle, pszRemoteHost, dwPort onDisconnect dd ? ; implement as proc onDisconnect, handle ends ; Object identifiers struct SocketObject .socket dd 0 ; socket handle .sai sockaddr_in .stop dd 1 ; connection state (closed, this stops the loop) .ISocketEventPtr ; the callback table pointer to user functions endp ; impl proc Startup ... winsock initialization here endp /// Returns a handle (Basically a pointer to SocketObject struct) proc Connect pszIP_or_DNS, port, iCallbackPtr handle = memalloc SocketObject.Size handle.sai.port = port; handle.ISocketEventPtr = iCallbackPtr ... start connection thread CreateThread.. ConnectionThread, handle return handle endp proc ConnectionThread, handle ..winsock connection functions here handle.socket = socket(...); .. if error call handle.ISocketEventPtr.onError, socket_error_code, "Custom or system description" .. if connection made call handle.ISocketEventPtr.onConnect, handle, pszHostName, port CreateThread( MonitorThread, handle ) .. if not call handle.ISocketEventPtr.onError, socket_error_code, "Custom or system description" .. this thread exits endp /// Returns a handle (Basically a pointer to SocketObject struct) proc Listen, port, iCallbackPtr handle = memalloc , SocketObject.Size handle.sai.port = port handle.ISocketEventPtr = iCallbackPtr // start listening thread endp proc ListenThread, handle while handle.stop = false // you know the drill here boys end while endp proc MonitorThread, handle while handle.stop = false fd_set read_set. fd_set write_set. fd_set error_set. // check states here ..if(read_set) dwBytes = 0 ioctlsocket(handle.socket, FIONREAD, dwBytes); .. available bytes to read buffer = memalloc dwBytes .. if not call handle.ISocketEventPtr.onError, custom_error_code, "Custom or system description" ..else recv(handle.socket, buffer, dwBytes) .. if not call handle.ISocketEventPtr.onError, socket_error_code, "Custom or system description" .. else call handle.ISocketEventPtr.onDataAvailable, handle, buffer, dwBytes if(buffer != null) ; in case user did something stupid with the buffer memfree(buffer) .. if(write_set) dwSize = 0 lpBuffer= 0 buffer = call handle.ISocketEventPtr.onClientReady, handle, buffer, dwSize if(buffer != null and dwSize > 0 ) send(handle.socket, buffer, dwSize); .. if not call handle.ISocketEventPtr.onError, socket_error_code, "Custom or system description" if(error_set) get error code call handle.ISocketEventPtr.onError, socket_error_code, "Custom or system description" // check MSDN for more on how to check for a closed/disconnected socket if(read_set && <some other byte checks>) call handle.ISocketEventPtr.onDisconnected, handle exit here break; // pause or sleep here end while closesocket handle.socket endp proc FreeHandle, handle memfree, handle endp proc Close, handle handle.stop = true // this will stop the thread endp ; exports Startup Connect Listen Send Close FreeHandle Using it Code: ; setup GUI myGui.setup; libSocket.Statup proc onDataArrival, handle, bytes, size if(handle = my_handle) ; of course you'd know how to do this myGui.RichEdit.Text.Append(bytes) endp proc onDisconnect myGui.Button.Connect.Enabled = true; endp my_handle dd 0 proc myGui.button.Connent.Click host = myGui.Edit.Host.Text port = int( myGui.Edit.Port.Text ) my_handle = libSOcket.Connect, host, port endp Well that's about it. Sorry if it seems like nonsense but someone one day will find it useful. I'm currently developing on android and I'm using threads quite extensively so I often use interfaces to make things flow better other than having to wait for a function/method to return. |
|||
13 Jan 2013, 00:35 |
|
Picnic 15 Jan 2013, 12:40
@typedef no, it doesn't seem nonsense, suggestions and pseudocode are welcome.
I do have a multi-user chat program on which i used threads but is left unfinished. I have little reusable code in asm, programs above are more like simple learning excercises, practicing C/C++ and asm simultaneously. |
|||
15 Jan 2013, 12:40 |
|
typedef 05 Mar 2015, 02:07
Lol. No source code?
And what's up with the CryptXXX functions? |
|||
05 Mar 2015, 02:07 |
|
catafest 07 May 2017, 23:11
Windows defender see this like malware
Picnic wrote: I thought to make it better, a login system with username and password for each account would be nice but to be honest i'm bored now. Feel free to modify source as you wish. |
|||
07 May 2017, 23:11 |
|
Picnic 09 May 2017, 06:46
Unfortunately many of my fasm console programs that using sockets are recognized as viruses. I can not resolve this.
|
|||
09 May 2017, 06:46 |
|
catafest 09 May 2017, 10:59
Picnic wrote: Unfortunately many of my fasm console programs that using sockets are recognized as viruses. I can not resolve this. I think the problem is the format of : Code: pe console , I don't have your source code for CHAT.rar If you make a search on this forum will see how to fix that. Nice ideea if you will update this with useful tools under Windows OS ... Make a brainstroming about how can be usefull your application |
|||
09 May 2017, 10:59 |
|
Picnic 27 Apr 2020, 10:36
--
Last edited by Picnic on 14 Jul 2024, 09:25; edited 2 times in total |
|||
27 Apr 2020, 10:36 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.