TBBS 2.1S - Finding Driver Tables

Contact:   eSoft, Inc. (Makers of TBBS)
           15200 E. Girard Ave., Suite 3000
           Aurora, CO  80014
           (303) 699-6565      Voice
           (303) 699-6872      Fax
           (303) 699-8222      BBS
           support@esoft.com   E-Mail

FINDING DRIVER TABLES
---------------------

THIS INFORMATION APPLIES ONLY TO TBBS VERSION 2.1 SINGLE LINE (2.1S)

There have been many here who want to know how to find the driver tables in 
BASIC.  I will give an example along with the theory, so others can use it in 
other languages as well.  The problem is determining the driver's segment, 
since it is wherever PC-DOS puts it whne it loads, and not predictable on a 
general basis.  Since the driver patches into the video BIOS interrupt, this 
is the method we will use to find it.  The video interrupt is INT 10h.  Since 
there are 4 bytes in a full SEG:OFFSET address, the interrupt address is 
0000:0040h. 

The address in an 8088 is stored in reverse order so the bytes are in memory
as:

40h = OFFSET Lo order
41h = OFFSET Hi order
42h = SEGMENT Lo order
43h = SEGMENT Hi order

Since we are interested in the segment, we need bytes 42h and 43h.  In order
to get them in BASIC we do the following:

10 DEF SEG
20 DEF SEG=0: DEF SEG=PEEK(&H43)*256+PEEK(&H42)

After this, peeks and poke will go to the TBBSDVR segment.  So to get address 0 
of the parameter table PEEK(&H130), loc 1 PEEK(&H131) etc.  This works because 
line 10 sets the segment to the  segment and resets certain PEEK/POKE logic in 
BASICA.  Line 20 sets the segment to the interrupt page and then sets the 
segment to the segment value of the video interrupt. 


             FINDING USER NAME IN TYPE 44 COMMAND


To try to answer the MANY who want to know how to access the USER NAME from a 
type 44 command.  Here is a BASICA program to do it using Version 2.1 TBBS. 
Note: This is a tested program (not like some of the "oughta work" code 
fragments I sometimes post).  It will only work for Version 2.1 

10 DEF SEG
20 DEF SEG=0: DEF SEG=PEEK(&H43)*256+PEEK(&H42)
30 UL=PEEK(&H130+16)*256+PEEK(&H130+15)
40 OPEN "R",#1,"USERLOG.BBS",512
50 FIELD 1, 128 AS U1$, 128 AS U2$, 128 AS U3$, 128 AS U4$
60 GET #1,UL+1
70 N$=""
80 FOR I=1 TO 50: IF MID$(U1$,I,1)<>CHR$(0) THEN N$=N$+MID$(U1$,I,1): NEXT I
90 CLOSE #1
100 PRINT "User Name = ";N$

How Does it work?

Line 10 resets the PEEK segment.  This is to assure reliability in line 20.
Line 20 sets the PEEK segment to the TBBSDVR segment by getting the segment
        portion of the video (INT 10h) int vector.
Line 30 peeks from the driver table and calculates the user log number of the
        current caller (see chapter 10 for driver table description).
Line 40 Opens USERLOG.BBS for random access as file #1 with a logical record
        size of 512 bytes/record.
Line 50 Fields the record as four 128 byte strings U1$ through U4$.
Line 60 The BASIC GET command is used to read the record for the calculated
        user.  Since GET calls the first record in the file record 1, while
        ULEDIT calls it record 0, the GET command is asked to get record UL+1
        to correct for this offset.
Line 70 initializes the N$ string to a null string to begin forming the name.
Line 80 takes the name from the userlog and builds it into N$.  The string is
        terminated by a 00 byte (CHR$(0)).  SInce the name is restricted to a
        length of 30 characters, the 50 gives a sizeable margin of error.
Line 90 Closes USERLOG.BBS
Line 100 prints the user's name.

                        ****CAUTION****

Never attempt to write to the USERLOG.BBS file from a type 44 command.  To do
so could cause severe damage to the data in the userlog!!


I hope this gets some of you who were stuck on this point "off dead center"
and your projects underway.

                       Phil

Note:  Because the file record size is greater than the default of 128 bytes,
you will need to use the /S:512 option on the BASICA calling line. If this
program were caller ULFIND.BAS, the calling line for it in a type 44 command
would be:

BASICA ULFIND /S:512

And the line:

110 SYSTEM

should be added at the end to get it to exit when finished.

- END -
TBBS0033
Rev. ??/??

Copyright (C) 1994 eSoft, Inc., All Rights Reserved.  Permission granted
to distribute this file in its entirety, without modification, to any
interested party.  Any other use requires the written permission of
eSoft, Inc.

IMPORTANT:  The information herein is subject to change without notice.
Please call or write to confirm factual information of importance to you
or your organization.

