Can someone please tell me why this little proggie (written by me)
returns the following error on Win98 SE "Intermediate file error during pipe", but still does its job (between the error msgs).
On Win2k it doesn't work at all.


.386
.model flat, stdcall
option casemap :none
ArgCl PROTO :DWORD,:DWORD
pa PROTO

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
param1 db 50 dup (?)
dest db 50 dup (?)

.code

start:
invoke pa

pa proc
invoke ArgCl,1,ADDR param1
invoke MessageBox,NULL,ADDR param1,ADDR param1, MB_OK

;==============================================

cld
lea esi,param1
lea edi,dest

loopS:
lodsb
stosb
cmp al,'|'
jne loopS
rep stosb
jmp term1

term1:
invoke MessageBox,NULL,ADDR dest,ADDR dest, MB_OK

;==============================================

invoke ExitProcess,0
pa endp

end start

Thanks.
Posted on 2002-05-01 02:42:51 by ViperV`
1> rep stosb (what is in ecx)(buffer overrun)

2> what if there is no '|' (buffer overrun)

3> try just

end pa

instead of

start:
invoke pa

4>try just

term1:

instead of

jmp term1
term1:

5> does your buffer have a null character
before you call messagebox?
Posted on 2002-05-01 03:37:28 by bdjames
This is a wierd messsage, and it probably come from wierd practices :)

Your entry point is 'START:', but you exit the process from within a called function. Im about 99% sure the problem comes from the fact you call exit process here.

You should return from the function, and then call exit process, while within the scope of the created process. What i mean is, when you call functions, the EBP and ESP in particular get adjusted automatically (think the FS seg gets modified as well), and they *anticipate* that you will return from the function, where they will restore their initial values (before you first entering the funciton).

When you exit the process without letting these things happen, your bound to get very "interesting" messages. :)

:NaN:
Posted on 2002-05-01 05:44:41 by NaN
1) From my knowledge if ECX is initially 0 then the operation described by REP (STOSB in this case) is
not executed. So it can't be a buffer overrun. You were though somehow right because it had no meaning
to put the REP STOSB there as i said earlier.
2) COMEON. Do you think that i'm so stupid to test for a '|' and to forget to put one in the param ?!?!
3) The same thing applies to the NULL character.
4) I have to tell you NaN that i've done that type of exit many times in programs (almost all the time)
and i haven't recieved error msgs. It seems that this is one of the other 1% cases where whatever u do,
whereever u do it still doesn't work.

Still Thank You.
Posted on 2002-05-01 23:35:54 by ViperV`
| can't be used in the param, it is a special operator for dos/command prompt. It inserts the output of the first program into the second one. Example:
type blah.txt|more
Will cause the command type to echo the contents of blah.txt, but instead of to the screen it will send it into the command more, which will make the output stop every 25 lines.

Doing this is called piping.
Posted on 2002-05-01 23:51:40 by _js_
_js_, yup, that would make sence. Sneaky error.

ViperV, Perhaps you find this fustrating, but please dont antagonize those who are *trying* help you.

Personally, the reason i put 99% is because I've never found a valid reason why you would need to exit as you have, so I've never tested it. To me this is a poor coding style and leads to spegetti coding. Also, there is no telling how well your code will behave on a different Windows OS. However, this is my opinion, you do what you feel is correct.

As well, you shouldnt make assumptions (which you code is littered with). bdjames made his suggestions because these are common assumption based errors, and your code doesnt clearly address any of them. He is not assuming your stupid, you are. He just pointed out potential problems from what his experience has taught him, as did I.

:NAN:
Posted on 2002-05-02 00:32:53 by NaN
hum, is there an escape character?
This is for the PROMPT command:

$$ $ (dollar sign)
$T Current time
$D Current date
$P Current drive and path
$V Windows version number
$N Current drive
$G > (greater-than sign)
$L < (less-than sign)
$B | (pipe)
$H Backspace (erases previous character)
$E Escape code (ASCII code 27)
$_ Carriage return and linefeed
Posted on 2002-05-02 01:23:59 by bdjames
ExitProcess can be called whenever you feel like it. Why shouldn't
you be able to terminate your process from an arbitrary point in the
execution stream? If you couldn't, THEN you could get some pretty
phuked up spaghetti code ;).
Posted on 2002-05-02 09:29:17 by f0dder
I trully love assembler !!!
It's so delicate and accurate. One line misplaced and you've got yourself an avalanche of errors.
:o Anyway sorry if i offended you. I did not meant that but the cases you told me were nearly impossible
to realise. I mean how could you test for '|' and to forget to put it.
And _js_ you were right about that pipe problem. Thank you.
bdjames about that buffer overrun, you were right (rep stosb). However i don't know how is that possible.
It shouldn't of happened. I knew that if ECX is 0 then the REP is skipped.
NaN, i still maintain my opinion about that ExitProcess ;) .
Posted on 2002-05-02 16:28:20 by ViperV`
Well, i see my opinion is somewhat outdated on this issue ;) .

I see im wrong in this area, so im sorry i imposed it upon you.

:NaN:
Posted on 2002-05-02 16:32:51 by NaN
No harm done.:alright:
We're all human and we all make mistakes sometimes.
And that's just a remark. That does not mean that either me or you made a mistake.
Posted on 2002-05-02 16:45:20 by ViperV`

bdjames about that buffer overrun, you were right (rep stosb). However i don't know how is that possible. It shouldn't of happened. I knew that if ECX is 0 then the REP is skipped.
There is no way to define what ECX is at the point the
REP is reached - an assumption that it is zero is in error.
Posted on 2002-05-02 16:51:46 by bitRAKE
The presumption that ECX is 0 applies in the following case

cls
lea esi,source
lea edi,dest
mov ecx,10
rep movsb

That's what i meant.;)
Posted on 2002-05-02 17:08:40 by ViperV`