[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 17:47:12 UTC 2017

Hi Lou,

Ugh, I think that was due to a bug that I fixed not too long ago (some
missing methods for the latest Spur formats IIRC). I thought I had
uploaded the fix but I do not see it in the repository. My apologies, I
will address it as quickly as I can, but it might not be until tomorrow.


> Hi Dave,
> Thanks you very much for the prompt reply.  I loaded the ImageFormat
> package as you suggested
> into a fairly new 32 bit image.  But when I try ImageFormat fromFile: to
> that image of the
> image with my program, I get an "unrecognized image format" error.  I will
> keep trying more
> after lunch but for now I don't get it?
> Lou
> On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis"
> <lewis at mail.msen.com> wrote:
>>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.
>>> 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
> --
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon

More information about the Squeak-dev mailing list