The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: brixton on June 04, 2005, 11:38:14 PM

Title: 2 quick questions
Post by: brixton on June 04, 2005, 11:38:14 PM
Hello all,

Just a couple of fast questions I would like answered! They are very simple so please don't laugh :lol

1)  If i was reading characters from a file on disk, how would I detect the end of a line?  Would I need to look for ASCII #10 (Ah), and if so, how would I go about looking for it?  Simple example maybe plz!  I am writing a program which filters out a variable string in a file based on the result of another string on a seperate line.

2)  Is it possible to launch an external program, but continue execution (ie. not wait until called program terminates)?

Many thanks!

ps. Other topic was locked, it's a shame, but I see your reasons.  It really was only innocent, it was for my parents to monitor my younger sister!  They didn't want to pay for any programs to restrict her, but wanted to keep an eye on her doings.  So I said i could help  :U
Title: Re: 2 quick questions
Post by: AeroASM on June 05, 2005, 07:48:50 PM
2)  use CreateProcess.
Title: Re: 2 quick questions
Post by: hutch-- on June 06, 2005, 05:55:54 AM
If you don't need the extra control, you can use the old WinExec() as it maps to CreateProcess anyway.


fn WinExec,"YourApp.exe",SW_SHOWNORMAL


It is worth the effort to learn how to use CreateProcess as it offers you more control when you need it.
Title: Re: 2 quick questions
Post by: brixton on June 06, 2005, 09:11:50 AM
I thought WinExec halted the calling process :eek

Btw I have now written a long and fairly complicated program which parses and sorts a big list (several hundred KB) and writes desired output to a file.  It is probably extremely messy, but it is fast, tiny in size (it is 42 times smaller than a similar program my friend created in C), so I am very happy  :bg

One thing though is sometimes there is a sharing violation or similar while using the 16-bit compatible functions _lwrite and _lread, I don't know why they occur.. can anyone help?
Title: Re: 2 quick questions
Post by: hutch-- on June 06, 2005, 09:33:18 AM
_lread and _lwrite should still work OK as they are 32 bit API functions, even though they are left there for 16 bit capacity when porting code. The share violatin probably depends on how your code is written, if the files you are trying to open are not locked by another application, then you mat be getting some lag with the opening and closing of files that is causing the problem.
Title: Re: 2 quick questions
Post by: brixton on June 06, 2005, 09:40:30 AM
Quote from: hutch-- on June 06, 2005, 09:33:18 AMyou mat be getting some lag with the opening and closing of files that is causing the problem.

I don't think this is the case, as it opens both files at the start of the program and points to them using their file handles throughout.

If I post my (extremely messy) code, perhaps ye olde experts could give me a hand?  Also give me pointers (Excuse the pun?  Did I just make a nerd joke?!) on how to improve the code  :red :U
Title: Re: 2 quick questions
Post by: QvasiModo on June 06, 2005, 09:05:01 PM
1) There are several "end of line" formats. Windows and DOS use the 0Dh,0Ah while Linux (and I think Mac too) use just the 0Ah. Conceivably one might expect a 0Ah,0Dh pair or just a 0Dh character (but I guess you're safe ignoring these cases anyway).

The safest approach IMHO would be to scan for either 0Ah of 0Dh, then check the next char. If it's 0Dh or 0Ah (but not the same as the previous one) then consider it part of the end of line too.
Title: Re: 2 quick questions
Post by: brixton on June 07, 2005, 12:35:34 AM
What I did was just compare the return value of _lread to 0 after each read, and if it was equal then it's the end of the file  :dance:

I have finished the whole program now, it works perfectly, and is only 4.5KB (compiled, uncompressed) compared to my friend's filter in C which is about 170KB  :bg

If you're interested in source or executable, and usage for the filter, please say!
Title: Re: 2 quick questions
Post by: pbrennick on June 07, 2005, 12:38:51 AM
Qvasimodo,
Just for clarity...

DOS/Windows = 0D0A
*nix               = 0A
Mac               = 0D

brixton,
I think I would be interested in seeing the source.

hth,
Paul
Title: Re: 2 quick questions
Post by: Bieb on June 07, 2005, 12:43:45 AM
What exactly does it do?
Title: Re: 2 quick questions
Post by: brixton on June 07, 2005, 01:02:16 AM
Well, it filters a bannerscan result log, and writes IPs which have a certain version in their response to a log file.
I wrote it for a friend.

The full source is here (http://www.dasm.co.uk/misc/banner_scan_sort.asm).

Bear in mind, this is one of my first programs in Assembly, and any tips are appreciated.  Just don't laugh at my messy code  :P
Title: Re: 2 quick questions
Post by: pbrennick on June 07, 2005, 01:13:39 AM
brixton,
You need not worry, nobody here is going to laugh and/or flame you.  The members of this forum are very well mannered and always want to help a newbe.

Paul
Title: Re: 2 quick questions
Post by: hutch-- on June 07, 2005, 01:24:47 AM
Yep,

Keep in mind that everyone here had to learn assembler the hard way. My early stuff back around 1990 was so dangerous that I used to park it in a directory called "trashcan" as stuff that should NEVER be run. You knew when you made a real mess of it when the monitor displayed multicolour random blinking characters in colour text mode.
Title: Re: 2 quick questions
Post by: Mark Jones on June 07, 2005, 01:28:23 AM
Another great way of doing that is to have a bunch of pocket change fall out and onto your video card. :toothy
Title: Re: 2 quick questions
Post by: brixton on June 07, 2005, 01:29:58 AM
pbrennick,

Thanks for the kind words, I have been looking at this forum for quite a while now (I first registered in mid-2004 sometime I think, on old forums, but I wasn't really much into assembly at that time), and I noted that most forumers were friendly and willing to help, which is great!  :cheekygreen:

hutch--,

That sounds pretty bad.. The only way I get my screen to do that is to overclock my old GeForce4 Ti4200 a little too much  :bg
Oh, and by the way, you look like my Uncle who lives in Perth, WA.  My father is from there (hence I am half Australian, and have a passport & citizenship :dance:)

Mark Jones,

Did you ever do that?  Poor card!  :'(
Title: Re: 2 quick questions
Post by: pbrennick on June 07, 2005, 01:31:24 AM
You guys are funny...

brixton,
What format is the input file supposed to have?  My email server is an ESMTP server and none of the following lines is liked by the program...

http://www.verizon.net
outgoing.verizon.net
incoming.verizon.net

It is looking for ESMTP servers?

Paul
Title: Re: 2 quick questions
Post by: brixton on June 07, 2005, 01:39:53 AM
pbrennick,

The log file contains a list of ESMTP servers, but I need IPs of servers with a particular version (specifically 5.0.2195, you can see me testing for these consecutive ascii codes in the source).

Basically, the program looks for a valid IP address (4 octets, with up to 3 numbers in each, and 3 periods between them), and then goes on to search for the 5.0.2195.  If however it reaches the hyphon seperators (more than one though, as some responses contain a time with a hyphon in eg. -5 GMT), it resets all buffers and looks for the next IP.

Small sample of log file it needs to be fed is as follows.  The 2nd IP is valid, as it has 5.0.2195 in a string after the IP but before the hyphon separators.

-------------------------------------------------------------------------------
163.5.69.2
Responded in 32 ms.
12 hops away
Responds with ICMP unreachable: No
TCP ports: 25


TCP 25:
[220 smtp.etna-etudiants.fr ESMTP]

-------------------------------------------------------------------------------
163.13.1.205
Responded in 328 ms.
15 hops away
Responds with ICMP unreachable: No
TCP ports: 25


TCP 25:
[220 homepageserver Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Mon, 6 Jun 2005 20:18:43 +0800]

-------------------------------------------------------------------------------
Title: Re: 2 quick questions
Post by: P1 on June 07, 2005, 01:25:57 PM
Seeing there is an Exploit against SMTP on Win2K OSes, of the version 5.0.2195.

I am locking this thread until we get a good explaination as to why this is important to you.  Please PM myself or any other Moderator with your reasons.

This is the VERY reason, I do not publish a standard connection string from our E-mail Server.

Regards,  P1  :8)
Title: Re: 2 quick questions
Post by: P1 on June 07, 2005, 08:33:37 PM
I got a PM and replied.  And the basic answer was "doing it for a friend".  Please read the rules.  And please do some Googling before you just jump into a project or ask a question, that could land you in prison.

Have your friend get his own account and we can roast them for dinner tomorrow.   :lol

So, it stays locked.

Regards,  P1  :8)