[squeak-dev] Can a running Squeak program look at a Squeak image file and know if it is a good image?
Lou at Keystone-Software.com
Tue Jul 25 16:32:56 UTC 2017
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?
On Tue, 25 Jul 2017 11:18:05 -0400 (EDT), "David T. Lewis" <lewis at mail.msen.com> wrote:
>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?
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
Keystone Software Corp.
More information about the Squeak-dev