Re: [Ql-Users] QL Decompiler
> On 28 Jun 2015, at 14:22, Derek Stewart mailto:de...@q40.de>> > wrote: > > > One question with regards to the temporary file that is created by the > Parser_task: > > a) Is this the input file to the Codegen_task Yes > b) Do we know the format of the file It is known. In fact there is a program which decodes it in a readable form. When I alter TURBO I use it to check that the output is what I expect. However, this program is not generally available. I am not sure whether the format of the intermediate code is available either. Also, I think that the location of the intermediate file can vary. It is obviously available to CODEGEN_TASK but not otherwise easily accessible by the general public! George ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] QL Decompiler
Hi, I have been reading the Turbo manuals again, just refreshing my mind and the Turbo operation. I must say it was a quite a nice easy read. One question with regards to the temporary file that is created by the Parser_task: a) Is this the input file to the Codegen_task b) Do we know the format of the file Regards, Derek On 27/06/15 06:36, Wolf wrote: Hi, Probably George Gwilt is best suited to answer that. Hmm! I seem to have forgotten most of what I knew. But you probably still know more about it than anybody else... Parser_task analyses the SuperBASIC program and produces a list of calls to blocks of code, or templates, which do simple things like "print a comma" or "go to this procedure". Codegen_task reads this intermediate code and produces the final executable program. By analysing the threaded code inside this it might be possible to reconstruct something like the intermediate code which was the output from Parser_task. The next step would be to work back from that to a set of SuperBASIC instructions. Not a trivial task from the sound of it What about using external keywords bound into the program? Either the keyword has to be present at runtime or its code has to have been loaded into the compiled program. In either case there may be difficulty in pinpointing what the keyword is so that it can form part of the decompiled program. Yup! The version of the Turbo Library used should be recorded in the compiled program. But the templates could be different for each version? Wolfgang ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] QL Decompiler
Hi, Probably George Gwilt is best suited to answer that. Hmm! I seem to have forgotten most of what I knew. But you probably still know more about it than anybody else... Parser_task analyses the SuperBASIC program and produces a list of calls to blocks of code, or templates, which do simple things like "print a comma" or "go to this procedure". Codegen_task reads this intermediate code and produces the final executable program. By analysing the threaded code inside this it might be possible to reconstruct something like the intermediate code which was the output from Parser_task. The next step would be to work back from that to a set of SuperBASIC instructions. Not a trivial task from the sound of it What about using external keywords bound into the program? Either the keyword has to be present at runtime or its code has to have been loaded into the compiled program. In either case there may be difficulty in pinpointing what the keyword is so that it can form part of the decompiled program. Yup! The version of the Turbo Library used should be recorded in the compiled program. But the templates could be different for each version? Wolfgang ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] QL Decompiler
> On 25 Jun 2015, at 12:21, Wolfgang Lenerz wrote: > > Hi, >> >> I have in the past tried at disassemble Qlib and Turbo complied >> programmes, but quite hard when they are not written in an assembler. > > Yup! I very dimly remember that there even was (one or several?) > program(s) that used compiled basic progs as part of the copy protection. > >> Could Turbo compiled code be de-compiled and the resultant object code >> be then run through a Turbo re-translator to reconstruct the SuperBasic >> source code, as source code to Turbo is available and we know how the >> Turbo libraries work (maybe)? > > Probably George Gwilt is best suited to answer that. Hmm! I seem to have forgotten most of what I knew. > > I believe, though, that it won't be a trivial task. > > In many cases I assume that the compiler uses some kind of template > (i.e. for this instruction, use that code) and, when detecting these > templates, you could reconstruct the source code for them. > OTOH, think of all the possible ways of using PRINT….. Parser_task analyses the SuperBASIC program and produces a list of calls to blocks of code, or templates, which do simple things like "print a comma" or "go to this procedure". Codegen_task reads this intermediate code and produces the final executable program. By analysing the threaded code inside this it might be possible to reconstruct something like the intermediate code which was the output from Parser_task. The next step would be to work back from that to a set of SuperBASIC instructions. > > What about using external keywords bound into the program? Either the keyword has to be present at runtime or its code has to have been loaded into the compiled program. In either case there may be difficulty in pinpointing what the keyword is so that it can form part of the decompiled program. > >> This maybe good of great benefit to development programme to created >> which could yield the source code of older programmes that do not run on >> modern systems. >> > > This presumes that the code generating engines stayed the same during > the different versions of the compilers - is this a safe assumption to make? The version of the Turbo Library used should be recorded in the compiled program. > >> How would this affect copyrighted compiled programmes? > > Good question. Generally speaking that kind of reverse engineering could > get yuo into trouble. > > George ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] QL Decompiler
Hi, > > I have in the past tried at disassemble Qlib and Turbo complied > programmes, but quite hard when they are not written in an assembler. Yup! I very dimly remember that there even was (one or several?) program(s) that used compiled basic progs as part of the copy protection. > Could Turbo compiled code be de-compiled and the resultant object code > be then run through a Turbo re-translator to reconstruct the SuperBasic > source code, as source code to Turbo is available and we know how the > Turbo libraries work (maybe)? Probably George Gwilt is best suited to answer that. I believe, though, that it won't be a trivial task. In many cases I assume that the compiler uses some kind of template (i.e. for this instruction, use that code) and, when detecting these templates, you could reconstruct the source code for them. OTOH, think of all the possible ways of using PRINT. What about using external keywords bound into the program? > This maybe good of great benefit to development programme to created > which could yield the source code of older programmes that do not run on > modern systems. > This presumes that the code generating engines stayed the same during the different versions of the compilers - is this a safe assumption to make? > How would this affect copyrighted compiled programmes? Good question. Generally speaking that kind of reverse engineering could get yuo into trouble. > On the Amiga there is a programme called ReSource, which allows> reverse decompilation of compiled programmes. Easier on there as the > OS uses known libraries... Hmmm, I faintly remember that program, but wasn't that program just a disassembler? Wolfgang ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
[Ql-Users] QL Decompiler
Hi, I have in the past tried at disassemble Qlib and Turbo complied programmes, but quite hard when they are not written in an assembler. On the Amiga there is a programme called ReSource, which allows reverse decompilation of compiled programmes. Easier on there as the OS uses known libraries... Could Turbo compiled code be de-compiled and the resultant object code be then run through a Turbo re-translator to reconstruct the SuperBasic source code, as source code to Turbo is available and we know how the Turbo libraries work (maybe)? This maybe good of great benefit to development programme to created which could yield the source code of older programmes that do not run on modern systems. How would this affect copyrighted compiled programmes? --- Regards, Derek ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm