Delphi - invalid stream format errors on run
Asked Answered
C

2

6

Delphi 6 Prof.

We have many applications. The programs have 8-12 MB size.

In this period we many times got reports about "Invalid stream format" errors.

We use shared Windows (or Linux) folders to store the applications, and users running them from these directories with links. This meaning that OS is paging the files, and loading the needed parts only.

Formerly we got C000006 exceptions. As I know this meaning that the file paging (loading) failed on any network problem (timeout, etc).

Now we face with "Invalid stream format" errors, and "invalid property xxxx" errors.

If I know well, both error caused by "paging problem", but C06 happens in code, and stream error in the data area of the Exe. But maybe I know wrong...

Anyway the problem is strange. Sometimes we got it, sometimes we not.

How to avoid it? These errors prevents the users to create new dialogs, to use the programs...

(In other place the user used wifi - then we got same side effects.)

Maybe you have any idea how to prevent, avoid this problem.

UPX (vs. Antiviruses)? Copy the exe-s to local place?

The system administrators of this customer are "our enemies", because they said: "everything is ok". The source of the problem isn't identifiable...

Thanks for every idea: dd

Curvature answered 7/12, 2012 at 15:44 Comment(3)
Step 1 is to add the IMAGE_FILE_NET_RUN_FROM_SWAP PE flag to the executable. Did you do that?Helban
Does Delphi 6 supports this? Or it doesn't?Curvature
The system admins can check the event log for application crash entries, and there will be some text in the error log pointing out possible crash reasons. IIRC unstable network is mentioned in this message. It does not 'identify' the source but gives some (hopefully correct) suggestions where to search.Chantry
H
6

Assuming your analysis is correct, and the problem is that the executable is located on a network drive with a flaky connection, then there is a solution. You need to add PE flags to your executable that forces Windows to copy the file from the network to the local machine before running it.

Make sure that your .dpr file's uses clause includes the Windows unit. And then add this line:

{$SetPEFlags IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP or IMAGE_FILE_NET_RUN_FROM_SWAP}

just before the begin in your .dpr file. We added the Windows unit so that the two constants would be recognised.

Helban answered 7/12, 2012 at 16:30 Comment(8)
Yes they are. If you want to double check (I know I would!!!), use dumpbin /headers on the executable that you produce.Helban
I can't find dumpbin. I have Win7 Prof. Where is it? Where from can I download it?Curvature
dumpbin is from the ms toolchainHelban
Do you know about any free dump tool to check the exe header?Curvature
Yes, dumpbin. It comes with express editions of VS, Windows SDKs and so on. Something easier to install might be this (heaventools.com/PE-file-header_viewer.htm). But you really ought to have the MS tools installed on a Windows dev machine.Helban
Sometimes I'm simply baffled about the knowledge around here. +1Alvinaalvine
Thanks, it is working ;-) ! I don't know, but may I use this prefix in any unit (that's what I believe), or only just in dpr?Curvature
From the documentation: "These directives only affect the output file if included in source code prior to linking. This means you should place these directives in a .dpr or .dpk file, not in a regular unit. Like the exe description directive, placing these directives in unit source code is not an error. However, these directives in unit source will not affect the output file (exe or dll) unless the unit source is recompiled at the time the output file is linked."Helban
L
0

Another possibility could be to pack the exe with upx tool for instance.

http://upx.sourceforge.net/

It will expand the whole file in memory before run.

And it will save bandwidth.

Laryngology answered 7/12, 2012 at 20:29 Comment(1)
I read in forumns that some of antiviruses are sensitive to UPX, because it manipulate the code onfly.Curvature

© 2022 - 2024 — McMap. All rights reserved.