hello all !
some logical question from me while coding on the irc client :-)

if the irc server send me some msg, i want to check for the commands (like 442)
what i actual do is to sort the command out and compare it with a string.

like:
invoke lstrcmp,addr INCOMMSG, addr sz443
.if eax=0
;command found
.endif

then i check next command on the same way...

invoke lstrcmp,addr INCOMMSG, addr sz442
.if eax=0
;command found
.endif

if i check for alot commands the source grow up and looks bad :(

so i think about it and now i want to make a stringlist and compare the entrys.

like:
szLIST db "442,443,and so on...",0

@@loopagain:
get one string from szLIST (if list empty = jmp to end...)
inc LISTFLAG                  (this flag is to know what function in the list is found)
compare the actualmessagestring with the one from the list
if found jmp to DOFUNCTION
if not found jmp to @@loopagain
@@endloop:


@@DOFUNCTION:
.IF        LISTFLAG=1
whe found 442...
.ELSEIF  LISTFLAG=2
whe found 443...
.endif


as beginner i better ask here what you say to this idea,
so any better idea on how to handle a lot incoming commands and how to make a clear coded function ?

Posted on 2005-08-09 04:45:13 by masm_coder
I would use an array with pairs of {commandstring,handlerfunction} pairs.

The IRC codes are always three bytes long, right? You can put the four-byte strings (3 bytes chars, 1 byte '\0') directly in the structure then, rather than a pointer to the data.

Some commands have common processing (similar format), so you can probably share some code.

Handlerfunction is a DWORD, holding pointers to functions to handle the message.

You have to be VERY careful about buffer overflows. IMO, assembly isn't the right language for this project.
Posted on 2005-08-09 05:34:49 by f0dder
thanks you f00der for your comments !

now i have some question to you:
You have to be VERY careful about buffer overflows.

where can i find more info on this topic ?
(a look in google bring me tutorials on how to produze one, not what i like to know.)
i dont understand what happend at this moment and so i cant understand why a buffer overflow should in my progie and what to do from me to stop this.


IMO, assembly isn't the right language for this project.

Why ?
is it not possible to code "anything" in asm ?
ok is more work then in delphi or so, but i like asm and want not learn it for nothing.
please tell me why do you think so.

btw. possible i found now a answer why my last big programm crash from time to time, by reading a big txt database.
i work with a virtual buffer and some time it work perfect, then it crashed and i dont know why.
(most after restart the progie it works again fine...the sometime i open it again and it crashed)
as i say, im a beginner and the way is long :)

thank you.


Posted on 2005-08-09 07:32:46 by masm_coder

where can i find more info on this topic ?
(a look in google bring me tutorials on how to produze one, not what i like to know.)
i dont understand what happend at this moment and so i cant understand why a buffer overflow should in my progie and what to do from me to stop this.


I'm afraid the best source is looking at how the bad guys do it. Detailed information probably can't be given here because of the board rules, but the basics are: *always* make sure your buffers are large enough for the data you put in it. Avoid wsprintf with string arguments. Always check strings for validity, whether they're entered by users or received over the network. Be VERY careful when manipulating strings (you'll often see "off-by-one" errors that can lead to at least a program crash), et cetera.

Yes, it's possible to create anything in assembly - it just isn't suited very well for everything. Every language has it's pros and cons. For instance, safe string and buffer management. You can get a long way with code and macros, but you'll have to write those first, and the syntax will most likely still be less elegant than some other languages can offer.

Not trying to discourage you from assembly btw, just saying you should keep an open mind and use the best tool for the job (or assembly if you do it just for fun :)).
Posted on 2005-08-09 08:04:10 by f0dder