Delphi - invalid stream format errors on run

2019-04-08 03:51发布

问题:

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

回答1:

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.



回答2:

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.