We have an old application in Turbo Pascal which can save its internal state into a file, and we need to be able to read/write this file in a C# application.
The old application generates the file by dumping various in-memory data structures. In one place, the application just dumps a range of memory, and this memory range contains some arrays. I am trying to noodle out the purpose of the bytes immediately preceding the actual array elements. In particular, the first two items in the block can be represented as:
type
string2 = string[2];
stringarr2 = array[0..64] of string2;
string4 = string[4];
stringarr4 = array[0..64] of string4;
In the data file, I see the following byte sequence:
25 00 02 02 41 42 02 43 44 ...
The 25
is the number of elements in the array. The 02 41 42
is the first string element, "AB"; the 02 43 44
is the second string element, "CD", and so on. I don't know what the 00 02
between the array element count and the first array element refers to. It's possible the array element count is 25 00
and the element size is 02
, but each array element is actually 3 bytes in size.
In the place in the file where the array of 4-character strings starts, I see the following:
25 00 04 00 00 04 41 42 43 44 04 45 46 47 48
Again, there's the 25
which is the number of elements in the array; 04 41 42 43 44
is the first element in the array, "ABCD", and so on. In between there are the bytes 00 04 00 00
. Maybe they are flags. Maybe they are some kind of indication of the shape of the array (but I don't see how 02
and 04
both indicate a one-dimensional array).
I don't have access to Turbo Pascal to try writing different kinds of arrays to a file, and don't have authorization to install something like Free Pascal, so my opportunities for experimentation along those lines are very limited.
These arrays are not dynamic, since Turbo Pascal didn't have them.
Thanks in advance for any dusty memories.
BlockWrite
). That's why I am curious what the in-memory layout of an array is. – prprcupofcoffee