jrj@cave.UUCP (02/27/87)
H E L P !!!! We have purchased an HP 9000 series 300 system from HP that included their BASIC 4.0 . We have been using this computer for only 2 months and was trying to make use of the "secure" command, when we "lost" all the code. All we have now are line numbers and asterisks(?). Is anyone familiar with this BASIC? How do we recover the code? Thanks in advance!
rocky@hpfcms.UUCP (03/02/87)
> trying to make use of the "secure" command, when we "lost" all the code. > Is anyone familiar with this BASIC? How do we recover the code? Contact your local HP Sales Office. They can obtain a tool from the factory which will "unsecure" your code. You will be required to sign a legal document that you swear on your great uncle's grave that you really DO own source rights to the code, and that HP is not helping you pirate anything. "Honest" Rocky Craig Hewlett-Packard, Ft. Collins, Colorado (Home of Rocky Mountain BASIC) hplabs!hpfcla!rocky
paull@hpcvck.UUCP (03/02/87)
> We have been using BASIC 4.0 for only 2 months and were > trying to make use of the "secure" command, when we "lost" all the code. > All we have now are line numbers and asterisks(?). The code is not lost, just hidden. It is still fully executable. The SECURE feature is intended to prevent unauthorized alterations and to provide some degree of security. The secure facility is not that 'secure' because its effects can be reversed. > Is anyone familiar with this BASIC? How do we recover the code? I understand that sales engineers have an official utility for doing this and will unsecure programs for you if you would like. DISCLAIMER: The following information is from my personal experience and is not to be taken as a statement of the Hewlett-Packard Co. It has been a while since I've done this but the process is fairly simple. Become familiar with the PHYREAD / PHYWRITE utilities, you will need them. It will be convienent to think of a BASIC program as a sequence of 16 bit words. Each statement (a line of BASIC) is stored as a three word header followed by the tokenized representation of your statement. The three word header is a data structure that forms a doubly-linked list to the previous and following three word headers. Along with the linkage information, is the BASIC line number, the indentation (how far from the left margin does the line start), and a 'secured' bit. The SECURE command sets this bit, clearing it will restore your program. Now for the hard part, finding one of these three word headers. I'm sure that somewhere there is a pointer to the first statement but I have not bothered to search it out. As an alternative, I suggest that you create a program that will read a 'PROG' file (with PHYREAD) 256 bytes at a time, and print it out. My program printed out eight (16 bit) words in octal, followed by the sixteen corresponding characters (converting non-printables to spaces). Sixteen such lines are printed for each 256 byte record. BASIC programs store a symbol table (with variable names, labels, etc) at the beginning of each program. You may have to read several records (depending on how big the symbol table is) before reaching the tokenized lines. Any comments in your source program should stand out in the character field of the printout because the tokenized lines are pretty much gibberish. One of the three words is the BASIC line number. If your program was REN'd (renumbered) then the line numbers will increment by a fixed amount. Look for a word that matches one of your line numbers followed, several words later, by another with the increment added on. In time it will become easy to recognize these locations. If you're having trouble, generate a 'before' and 'after' securing printout of a trial program, the only differences should be the state of the 'secured' bit. The first word in a three word group contains the secured bit and the forward link. The second word contains the previous link and the indent level. The third word is the line number. The secured bit is the MSB of the first word. The forward link (the offset in bytes to the next three word group) is in the lower byte of the first word. I wrote a very simple minded program that would clear the secured bit and jump to the next link in a loop. It needed the first location to be input manually and it had to be restarted at subroutine boundaries, but it did do the job with minimal effort.
rocky@hpfcms.HP.COM ( Rocky Craig ) (03/05/87)
/ hpfcms:comp.sys.hp / paull@hpcvck.HP (Paul Liebert) / 12:32 pm Mar 2, 1987 / > We have been using BASIC 4.0 for only 2 months and were > trying to make use of the "secure" command, when we "lost" all the code. > All we have now are line numbers and asterisks(?). The code is not lost, just hidden. It is still fully executable. The SECURE feature is intended to prevent unauthorized alterations and to provide some degree of security. The secure facility is not that 'secure' because its effects can be reversed. > Is anyone familiar with this BASIC? How do we recover the code? I understand that sales engineers have an official utility for doing this and will unsecure programs for you if you would like. DISCLAIMER: The following information is from my personal experience and is not to be taken as a statement of the Hewlett-Packard Co. It has been a while since I've done this but the process is fairly simple. Become familiar with the PHYREAD / PHYWRITE utilities, you will need them. It will be convienent to think of a BASIC program as a sequence of 16 bit words. Each statement (a line of BASIC) is stored as a three word header followed by the tokenized representation of your statement. The three word header is a data structure that forms a doubly-linked list to the previous and following three word headers. Along with the linkage information, is the BASIC line number, the indentation (how far from the left margin does the line start), and a 'secured' bit. The SECURE command sets this bit, clearing it will restore your program. Now for the hard part, finding one of these three word headers. I'm sure that somewhere there is a pointer to the first statement but I have not bothered to search it out. As an alternative, I suggest that you create a program that will read a 'PROG' file (with PHYREAD) 256 bytes at a time, and print it out. My program printed out eight (16 bit) words in octal, followed by the sixteen corresponding characters (converting non-printables to spaces). Sixteen such lines are printed for each 256 byte record. BASIC programs store a symbol table (with variable names, labels, etc) at the beginning of each program. You may have to read several records (depending on how big the symbol table is) before reaching the tokenized lines. Any comments in your source program should stand out in the character field of the printout because the tokenized lines are pretty much gibberish. One of the three words is the BASIC line number. If your program was REN'd (renumbered) then the line numbers will increment by a fixed amount. Look for a word that matches one of your line numbers followed, several words later, by another with the increment added on. In time it will become easy to recognize these locations. If you're having trouble, generate a 'before' and 'after' securing printout of a trial program, the only differences should be the state of the 'secured' bit. The first word in a three word group contains the secured bit and the forward link. The second word contains the previous link and the indent level. The third word is the line number. The secured bit is the MSB of the first word. The forward link (the offset in bytes to the next three word group) is in the lower byte of the first word. I wrote a very simple minded program that would clear the secured bit and jump to the next link in a loop. It needed the first location to be input manually and it had to be restarted at subroutine boundaries, but it did do the job with minimal effort. ----------
rocky@hpfcms.HP.COM ( Rocky Craig ) (03/05/87)
> I understand that sales engineers have an official utility for doing this > and will unsecure programs for you if you would like. It is NOT official. See my earlier repsonse concerning HP's policy on unsecuring code. > Each statement (a line of BASIC) is stored as a three word header Unless the line is labelled; in that case a fourth word exists as an index into the symbol table (for the label). > It has been a while since I've done this but the process is fairly simple. > Now for the hard part, finding one of these three word headers. I'm sure Yes, conceptually simple, but VERY time consuming. A lot of work went into BASIC to make it fully relocatable, reentrant, traceable, fast, etc. etc. The information presented here is mostly correct, but the proper solution to the problem is to have HP unsecure your program. At this point in time it is not possible to distribute the unsecure program. Rocky Craig Hewlett-Packard, Ft. Collins, Colorado (Home of Rocky Mountain BASIC)
rocky@hpfcms.HP.COM ( Rocky Craig ) (03/05/87)
> I understand that sales engineers have an official utility for doing this > and will unsecure programs for you if you would like. It is NOT official. See my earlier repsonse concerning HP's policy on unsecuring code. > Each statement (a line of BASIC) is stored as a three word header Unless the line is labelled; in that case a fourth word exists as an index into the symbol table (for the label). > It has been a while since I've done this but the process is fairly simple. > Now for the hard part, finding one of these three word headers. I'm sure Yes, conceptually simple, but VERY time consuming. A lot of work went into BASIC to make it fully relocatable, reentrant, traceable, fast, etc. etc. Therefore the internal representation of a program is very complex. The information presented here is mostly correct, but the proper solution to the problem is to have HP unsecure your program. At this point in time it is not possible to distribute the unsecure program. Rocky Craig Hewlett-Packard, Ft. Collins, Colorado (Home of Rocky Mountain BASIC)