I am reverse engineering a file format where they have encrypted section. I have determine the algorithm and written a script tp decrypt. My problem is that the template variable arrays are only available at the base scope of the script. As soon as I put them in a block they disappear. This is preventing me from incrementing over the arrays. For a given file I can create calls in the base scope for as many sections that file has, but that is not very convenient. I have tried to convince the script that the variable is local amongst other tricks.
Below pathFill is a template results variable that was automatically made into an array. It is a union of an array of uchars (pathData) and the structure that defines it. Decrypt is my function.
I believe the loop is failing because ‘i’ is going off the end of the array. ‘sizeof(pathFill)’ reports the size in number of bytes, not the number of elements. You can either divide by the size of each element, or you can use ‘exists’ like this:
I believe the error message you received above does not properly include the index that was being accessed and we will try to improve the error message in a future version. Let us know if you can’t get this to work. Cheers!
I had tried putting accessing the array in a function and got the same result. I now see it was for the same reason. I became convinced that because templates create arrays in loops that something similar was happening in the script and that the variable got changed somehow after the first pass in a loop. I should have known about the sizeof. That’s the problem with working with a lot of languages. You forget the nuance of the ones from long ago.
I am glad you see that the “undefined” error message is misleading.
BTW, the while loop is a very clever use of the exists test. I am adding it to my repertoire.