gdgqler wrote: > If you add a Thing to the list of Things by using the software > described in the manual for the Trap #1 routine sms.lthg you will
Just to be sure, none of the trap #1 thing entry routines are supported in SMSQ/E. Just the traditional HOT_REXT way of calling them. > find that the linkage block you have provided is partially completed > (which is correct) but that, in addition, the long word 12 bytes > before the start of the linkage block is set with the linkage block's address. > > Does anyone know the reason for this bizarre and potentially dangerous > operation? Tobias almost nailed it, but not 100% (if I understand him correctly). This is a bit of a hack, but not unheard of: a few utilities use this mechanism. As you know, when a job is killed in QDOS, its memory allocations are freed. If the allocated memory belongs to a driver, the driver's close routine is called (this is the normal way open channels are ensured to be closed when a job is killed!). Now, the thing system employs the same mechanism to be invoked when a job is killed, just like a driver would have been called. To do so a fake driver control block address is entered into the heap data structure. The address is calculated thus that the only valid field of this "virtual" DCB is at the iod_clos offset, which aligns with and thus contains the address of th_frzap. So this routine will be called when the owning job is killed. IOW: the whole thing uses the assumption that no other field of the DCB is of interest to the OS, which is of course true. > The source code for this is: > > LEA TH_FRZAP+IOD_IOLK-IOD_CLOS(A1),A0 It's basically pure chance that this resolves to 0. So in principle this line is indeed not needed, but it's just good practice to use the symbols so a programmer can at least begin to understand what's going on (and obviously even then it's difficult to understand!). And if somebody were to modify the thing header structure, the line would be needed again. Of course nobody would be so daft to do so. ;-) Marcel _______________________________________________ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
