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

durumdara
  • 3,411
  • 4
  • 43
  • 71
  • Step 1 is to add the `IMAGE_FILE_NET_RUN_FROM_SWAP` PE flag to the executable. Did you do that? – David Heffernan Dec 07 '12 at 15:50
  • Does Delphi 6 supports this? Or it doesn't? – durumdara Dec 07 '12 at 16:09
  • 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. – mjn Dec 07 '12 at 19:36

2 Answers2

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Yes they are. If you want to double check (I know I would!!!), use `dumpbin /headers` on the executable that you produce. – David Heffernan Dec 07 '12 at 16:39
  • I can't find dumpbin. I have Win7 Prof. Where is it? Where from can I download it? – durumdara Dec 07 '12 at 16:59
  • dumpbin is from the ms toolchain – David Heffernan Dec 07 '12 at 17:13
  • Do you know about any free dump tool to check the exe header? – durumdara Dec 07 '12 at 19:37
  • Yes, `dumpbin`. It comes with express editions of VS, Windows SDKs and so on. Something easier to install might be this (http://www.heaventools.com/PE-file-header_viewer.htm). But you really ought to have the MS tools installed on a Windows dev machine. – David Heffernan Dec 07 '12 at 19:40
  • Sometimes I'm simply baffled about the knowledge around here. +1 – NGLN Dec 07 '12 at 20:34
  • 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? – durumdara Dec 10 '12 at 08:46
  • From the [documentation](http://docwiki.embarcadero.com/RADStudio/XE3/en/PE_(portable_executable)_header_flags_(Delphi)): "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." – David Heffernan Dec 10 '12 at 08:59
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.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159