[squeak-dev] Can a running Squeak program look at a Squeak image file and know if it is a good image?

David T. Lewis lewis at mail.msen.com
Tue Jul 25 15:18:05 UTC 2017


Hi Lou,

A simple check is to look at the first bytes of the image file, which
define the image format number. If the image format is something
reasonable (presumably the same as whatever image you are replacing in
most cases), then you know that it is a Squeak image file, although this
will not tell you if the actual image is valid.

To do this from a running Squeak image, try loading the ImageFormat
package from the VMMaker repository on squeaksource.com. Look at the class
comments, and you will find methods for reading the image format number
from a file stream.

There is also a C program called ckformat.c at
http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/. The C code is
automatically generated from the ImageFormat package, so they the do the
same thing. If you want to do the test from a shell script, as opposed to
doing it from the running image, then you can use this C program.

Of course in theory you can load an entire image file into a VM simulator
with the VMMaker package, but that would not be a practical test for what
you are trying to accomplish.

If you need a better test of "valid" then you might consider using
OSProcess/CommandShell to actually run the image file and see if it works.
Probably you would do something like run it with a PipeableOSProcess
connected to your main Squeak image, and just kill the image under test
once you have confirmed that it runs.

Dave

> Hi All,
>
> Can a running Squeak program look at a Squeak image file and know if it is
> a good image?  I'm
> working on a program that the user won't have easy access to.  I would
> like to allow its
> replacement with a new version.  I think I know how to do that but would
> like to see if I can
> program in some protection from the user replacing the image with a bad or
> completely wrong
> file.  Any ideas?
>
>
> Lou
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
>
>
>




More information about the Squeak-dev mailing list