Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - invalid stream format errors on run

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

like image 413
durumdara Avatar asked Dec 07 '12 15:12

durumdara


1 Answers

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.

like image 143
David Heffernan Avatar answered Oct 14 '22 11:10

David Heffernan