home *** CD-ROM | disk | FTP | other *** search
- ╔══════════════════════════════════════════════════════════════════════════╗
- ║STOP! ARRET! ALTO! HALT! STOP! ARRET! ALTO! HALT! STOP! ARRET! ALTO! HALT!║
- ║ ║
- ║ This program can harm your HARDWARE...! ║
- ║ YOU USE IT AT YOUR OWN RISK !!! ║
- ║ ABSOLUTELY NO LIABILITY ACCEPTED !!! ║
- ║ ║
- ║The program will not run without the appropriate parameters, so there is ║
- ║LITTLE risk that you will run it accidentally. But be very careful if you ║
- ║call it from a batch file...! ║
- ║ ║
- ║STOP! ARRET! ALTO! HALT! STOP! ARRET! ALTO! HALT! STOP! ARRET! ALTO! HALT!║
- ╚══════════════════════════════════════════════════════════════════════════╝
-
-
- PORTS.EXE
- ─────────
-
- (Ver 1.3 - 19 Sep 91)
-
-
-
- Copyright (c) and developed by
-
- José Campione
- 2415 SouthVale Cr. U-25, Ottawa, Ont. K1B 4T9 (613) 523-4345.
-
- and
-
- C. Robert Parkinson
- 5 Ramsgate, Ottawa, Ont. K1V 8M4, (613) 523-7299.
-
-
- Program suggested by Micheline Johnson
- (who also worked out the details for example #4).
-
- * * *
-
- NOTICE
- ══════
-
- This program and every file distributed with it are copyright (c)
- by the authors, who retain authorship both of the pre-compiled and
- compiled codes. Their use and distribution are unrestricted, as long
- as nobody gets any richer in the process. Although these programs
- were developed to the best of the authors abilities, no guarantees
- can be given as to their performance. By using them, the user
- accepts all risks and the authors decline all liability.
-
-
-
- INTRODUCTION
- ════════════
-
- PORTS.EXE is a small utility to read and/or write a byte or
- word value of an input/output (I/O) port. This ability will enable
- you to alter some of the defaults for your system operation. In
- particular, this program was designed to allow you to view and/or
- alter the CMOS configuration values in 80286 and higher systems,
- although it can be used for other purposes (see the WARNING below).
-
- For those users who are not familiar with the Intel/Microsoft
- I/O port address structure, please read the BACKGROUND section below
- BEFORE you use this program.
-
-
-
- WARNING
- ═══════
-
- This utility can alter the basic operation of your system.
- DO NOT use it to write to the ports unless you thoroughly understand
- what you are doing. In particular, DO NOT write to any port which
- is concerned with disk operations. An incorrect value in another
- location may crash your system, but an improper value in these
- locations may corrupt your disk. Be very careful to not get
- confused between decimal and hexadecimal values.
-
- Merely reading a port may also disrupt your system operation,
- although it will not harm any hardware.
-
- You have been warned!
-
-
-
- SYNTAX
- ══════
-
- PORTS.EXE uses five possible first parameters. The "u", "a"
- and "w" parameters, while they may be useful in other circumstances,
- were specifically created to deal with the CMOS RAM settings in 286
- and higher systems. The parameters are:
-
- i = In (from port).
- Input/display a single byte from a port.
-
- o = Out (to port).
- Output/send a single byte to a port.
-
- u = Out/In (to port 1/from port 2).
- Output/send a single byte to a port, followed
- by an input/display from a second port.
- The optional parameter "#xxxx" (see below)
- permits a delay of xxxx milliseconds to be
- inserted between the two port accesses.
-
- a = Out/Out (to port 1/to port 2).
- Output/send a single byte to a port, followed
- by an output/send of another byte to a second port.
- The optional parameter "#xxxx" (see below)
- permits a delay of xxxx milliseconds to be
- inserted between the two port accesses.
-
- w = Word out (to port).
- Output/send a 2-byte word to a port.
-
-
- Usage:
- ─────
-
- C:\> PORTS i $INWORD <!>
-
- C:\> PORTS o $OUTWORD <byte value> <!>
-
- C:\> PORTS u $OUTWORD <byte value> $INWORD <!>
-
- C:\> PORTS a $OUTWORD <byte value> $OUTWORD <byte value> <!>
-
- C:\> PORTS w $OUTWORD <word value> <!>
-
-
- Where:
-
- - INWORD and OUTWORD are port addresses. These are not in the
- normal "segment:offset" form, but rather they are in terms of
- an "absolute" port address (e.g., "$061" for the speaker).
- The addresses can be entered as hex or decimal numbers,
- but hex addresses must be preceded by the "$" sign. (This is
- Pascal's way of indicating a hex number).
-
- - <byte value> or <word value> is the decimal or hex value
- that you wish written to the port. Hex values must be
- preceded by the "$" sign.
-
- - The optional "#xxxx" parameter will only function with the
- first parameters "u" and "a", when making two successive
- calls to ports. In the syntax for this parameter, "xxxx"
- represents any decimal number between (and including) 0 to
- 9999. A string representing a number within this range
- will cause a delay of "xxxx" milliseconds between the first
- and the second port call. Any string not representing a
- number within that range will cause this parameter to be
- ignored (i.e., no delay between the port calls).
-
- - The optional "!" parameter causes the display on the screen
- of the value of the last input/output byte in decimal, hex
- and binary formats. It will also display the delay value
- if "#xxxx" was used.
-
- - Any positive integer below 65536 (0 to 65535 decimal, or
- $0 to $FFFF hex) is a valid word. Similarly, any positive
- integer below 256 (0 to 255 decimal, or $00 to $FF hex) is a
- valid byte. When entering bytes or words, $DF is equivalent
- to $00DF and both are valid either as bytes or as words.
-
- - Note that parameter "u" causes two successive calls. The
- first one is similar to a call using parameter "o" and the
- second one is similar to a call using parameter "i".
- Similarly, parameter "a" makes two successive calls
- equivalent to two separate calls using parameter "o".
- Our testing on several systems has determined that these two
- successive calls (as, for example, those required to access
- the CMOS) could not be carried out by two successive
- individual commands from the DOS prompt. They require a
- special "single step" operation with a single call to PORTS.
-
-
-
- CMOS CONFIGURATION
- ══════════════════
-
- For 80286 and higher systems, configuration information is held
- in battery-powered CMOS memory that retains the information even
- when the computer is switched off. That information, originally
- entered through the software setup program, can be altered with
- PORTS.EXE. However, to do so you must know the CMOS address and the
- desired value. To display bytes in CMOS, use "PORTS u" (as in the
- example below). To change a CMOS value, using the example below,
- simply use "PORTS a" to output the CMOS address (byte) into port 70h
- and output the desired byte value into port 71h.
-
-
- Example:
- ───────
- C:\>PORTS u $70 $14 $71 !
-
- This line causes the following display:
-
- Port byte = 35d, 0023h, 00100011b.
-
- Similarly, the same command line can be entered using decimal
- notation as:
-
- C:\>PORTS u 112 20 113 !
-
- which would have caused exactly the same display.
-
- This command outputs byte $14 (a CMOS address) to port $70
- and requests the input of the value currently held at that
- CMOS address from port $71, which in this case happens to
- contain byte $23. In this example, the displayed byte
- is the equipment byte held in the CMOS. You can interpret
- it as follows, remembering that bit 0 is the rightmost bit:
-
- Bits 6,7: 00 - 1 floppy drive
- 01 - 2 floppy drives
-
- Bits 4,5: 00 - No monitor, or EGA or better.
- 01 - 40 column, color.
- 10 - 80 column, color.
- 11 - monochrome.
-
- Bits 2,3: (not used)
-
- Bit 1 : 0 - math coprocessor not installed.
- 1 - math coprocessor installed.
-
- Bit 0 : 0 - No floppies installed.
- 1 - 1 or more floppies installed.
-
-
-
- ERRORLEVELS
- ═══════════
-
- In all cases but one, the byte being addressed is returned as an
- ASCII value in the exit errorlevel. The exception is when using the
- "w" parameter (out a 2-byte word to a port), when the returned
- errorlevel will be 0. This exit errorlevel capability makes PORTS
- well suited for use in a batch file. Use "PORTS i" with an
- errorlevel test to confirm that this is the proper value to alter,
- then use "PORTS u" with another errorlevel test to confirm that it
- has indeed been changed to the value that you desire, branching to
- an error routine in either case if the correct errorlevel is not
- returned.
-
-
-
- BACKGROUND
- ══════════
-
- The term "port" has two meanings, so this needs to be cleared
- up first. From a user perspective, "port" is normally thought of
- as being a hardware connector. The user is likely to consider that
- he has, for example, two serial ports, one parallel port and,
- perhaps, a mouse port and a game port. However, to a programmer
- the term "port" implies an access point to facilitate data
- transfer, in other words, an input/output (I/O) address. To
- contrast the two meanings, consider that one serial "port" has, in
- fact, eight separate but integral I/O "ports". This document is
- concerned solely with the I/O address meaning of the word "port".
-
- Any Intel 80x8x processor has two separate address modes, using
- the same addressing pins. The first mode addresses memory (i.e.,
- normal RAM/ROM addressing). The second mode, I/O port addressing,
- while it uses some of the same numerical addresses as for RAM,
- actually sends/receives the information to or from support chips
- (e.g., the timer, the keyboard controller, etc.) or peripheral
- devices (e.g., the disk controller, the graphics adapter, etc.).
- All programming languages have built-in methods of differentiating
- between the two modes of addressing.
-
- As we said before, I/O address ports are used by DOS for data
- transfer. The values in these locations govern that part of the
- system which is external to the processor itself. Therefore, the
- ports allow direct access to the hardware. Through ports you can
- access components on the mother board, on expansion cards or even
- devices external to the system proper, such as modems, printers,
- etc. Each port will have a different meaning for each particular
- device and the use of any given port varies from chip to chip or
- device to device. Before using PORTS, check your technical
- documentation for the motherboard, the expansion card or the device.
-
- Although we normally speak of the ports as one generic class,
- they are actually divided into two types, CPU ports and DOS ports.
- CPU ports (also known as "logical" ports) are directly accessible to
- the CPU and govern such things as the speaker, keyboard, timer, disk
- access, etc. DOS ports are normally accessible to the processor
- only through the use of DOS "interrupts". They control high-level
- data transfer via "serial" ports (e.g., COM1) and "parallel" ports
- (e.g., LPT1). Understanding this difference is essential for those
- programmers who write at the hardware level.
-
- There are many differences in the port addressing schemes used
- by various Intel processors, although newer processors are always a
- superset of older ones. These differences are necessarily also
- supported by the specific ROM BIOS for that system type. Because of
- these differences, compatibility is normally attained by interacting
- with the ports only through the processor itself or through DOS/BIOS
- interrupts. But sometimes, in order to achieve a specific purpose,
- direct access to the hardware cannot be avoided; PORTS.EXE can do
- this for you.
-
- Each port has a specific port number, or address. In a 16-bit
- bus system (8086, 80286 and above) this allows 65,535 ports (0 to
- FFFFh). As of 1990, only port addresses 000h to 3FFh had been
- assigned. In an XT system, because of the 8-bit external bus, the
- ports are limited to a maximum of 1,024.
-
- Five kinds of operations are usually performed on ports:
-
- 1) input (receive from port) a byte;
-
- 2) output (send to port) a byte;
-
- 3) output (send to a port) a byte and input (receive) a byte
- from a second port in one single operation;
-
- 4) output (send to a port) a byte and output (send to the same
- or another port) another byte in one single operation; and
-
- 5) output (send to a port) a word (two consecutive bytes in one
- single step).
-
- This last "word" operation is necessary because many hardware
- functions are triggered immediately by any operation on the
- applicable port. Any attempt to send two consecutive single-byte
- values to this port would necessarily fail.
-
- Some port operations require two successive bytes sent to the
- same port, but the hardware may require a small delay between these
- bytes. PORTS can interpose this delay if required.
-
- Many ports are "bit-mapped", in that each bit has a specific
- function. For example, port 14h is the so-called "equipment byte",
- since it specifies, in bit values, the elementary hardware
- configuration of your system. Similarily, port 61h uses only the
- first two bits to control the speaker, the remaining six being used
- for unrelated purposes. Changing bit-mapped ports with PORTS is a
- complex operation, requiring the conversion to and from binary
- values. See Example #3 below. To assist in this conversion, you
- may wish to use the PC Magazine utility CONVERT.COM.
-
- There are also many anomalies in the way in which ports respond.
- These are dependent upon the hardware being addressed, the system
- being used, the manufacturer's design whims, etc. As these
- anomalies are very much system-specific, trial and error (hopefully
- not too much error!) is the only sure test.
-
- This small technical background is NOT designed to make you
- familiar with I/O ports and their usage. Please consult any
- reliable programmer's handbook.
-
-
-
- EXAMPLES
- ════════
-
- Example #1 - Controlling the Speaker
- ────────────────────────────────────
-
- Your computer's speaker is controlled by bits 0 and 1 of the
- bit-mapped byte found at port 61h. If both bits are set to 1 you
- will hear a continuous tone in the same frequency as the infamous
- DOS beep. To vary the tone, programs must use ports 42h and 43h to
- tell the system programmable timer chip how to vary the output
- frequency. That's beyond what we want to demonstrate here; we're
- just going to show you how to output sound.
-
- The remaining bits 2 to 7 of the byte at port 61h are uses for
- other purposes, so don't disturb these. This means that we have to
- first find the existing byte at that port. Do that with this
- command:
-
- "PORTS o $061 !"
-
- Now take the binary byte on the screen (e.g., 01001000 or 48h)
- and change it so that bits 0 and 1 are set to 1 (e.g., 01001011 or
- 4Bh). Make certain that you do not alter the other 6 bits. The
- easiest way to do this conversion is to use the CONVERT.COM utility
- from PC Magazine, but you can do it manually using the technique
- illustrated in Example #3.
-
- If we just output the changed byte to port 61h, we will get a
- continuous tone and we will then have to output the original byte
- to turn it off. But we can use the PORTS "a" parameter to do both,
- inserting a variable delay so that we can tell that our ports call
- does work. Using the example byte, this is the command:
-
- "PORTS a $061 $04B $061 $048 #500"
-
- Change the "#500" to vary the duration of the sound.
-
-
-
- Example #2 - Initializing the Printer
- ─────────────────────────────────────
-
- Here is a simple example to reset a printer connected to your
- system to the printer's built-in default settings, assuming that it
- is a parallel port Centronics-compatible printer. It also assumes
- that your printer is addressed through LPT1. While this type of
- reinitialization can more easily be done using your printer's
- built-in "escape" sequences, this example merely illustrates one of
- the capabilities of PORTS. The third of the LPT1 I/O port addresses
- is the one that controls the initialization (INIT) line to the
- printer. To initialize the printer we have to drop the normal +5V
- signal on that INIT line to 0V, then restore it to +5V again. To
- do this with a software routine, we have to determine that specific
- I/O address for our system, then send two sequential values to that
- port; one to set bit 2 to zero, then one to set bit 2 to 1.
-
- However, since the INIT line has to be held low (0V) for long
- enough for the printer to notice, we must either use two separate
- PORTS "o" calls or, preferably, use a PORTS "a" call to the same
- I/O address but with a delay ("#xxxx") between the two calls. Here
- is the routine:
-
- - To find the specific I/O address for your system, we will use
- DEBUG. However, you could use any other memory editor. At the
- DEBUG "-" prompt, enter "d 0040:0008". The values in the first
- two bytes are the first LPT1 I/O address. On our test system,
- DEBUG gave "BC 03". Remembering to reverse the order, we get
- an I/O address of "03BCh". But we want the THIRD I/O address,
- so we add 2 (in hex) to that, giving us "03BEh" as the INIT
- port address.
-
- - Now, we have to drop bit 2 to 0, then raise it to 1 again. So
- we output binary 11101000 (232) to the port. Counting from 0
- on the right, you can see that bit 2 is indeed a 0. To raise
- bit 2 to 1, we then output binary 11101100 (236) to the same
- port.
-
- - We're ready to try our test. Execute the following PORTS
- command, remembering to substitute your own I/O port address if
- it differs from 03BEh:
-
- "PORTS a $03BE 232 $03BE 236 #50!"
-
-
- Experiment with different values for "#xxxx" to find the minimum
- delay that your printer requires. On the test system, for example,
- a delay as small as 1 millisecond was acceptable.
-
-
-
- Example #3 - Setting Bright Text Background Colours
- ───────────────────────────────────────────────────
-
- Try this test if your system has a CGA card. Only use it if you
- have a CGA card, as it may not work with other adapters. If your
- VGA or SuperVGA adapter is 100% EGA compatible (e.g., the ATI VGA
- Wonder) this test will work. PORTS does not check for the adapter
- type.
-
- You can modify the blinking bit that causes blinking characters
- on the screen, so that, instead of blinking, it will enable the use
- of bright background colors.
-
- Most CGA cards can be accessed through port 03D8h ($03D8). The
- configuration word of the CGA card can be obtained from the BIOS (it
- is the word at address $0040:$0065). Usually, this word contains the
- value $3029 (if you look into this address using DEBUG, remember that
- DOS inverts the bytes in a word), which in binary is:
-
-
- 3 0 2 9 h
- 0011 0000 0010 1001 b
- ^
-
- To toggle blinking, bit 5 has to be reset (indicated with the
- caret). This can be done by "ANDing" 3029h with $DF:
-
-
- 3 0 2 9 h
- 0011 0000 0010 1001 b
-
- AND D F h
- 0000 0000 1101 1111 b
- ^
- ─────────────────────
-
- 3 0 0 9 h
- 0011 0000 0000 1001 b
-
-
-
- So enter the following:
-
- C:\>PORTS !
-
- And you'll get the ports message with the blinking string
- "WARNING!".
-
- Then enter:
-
- C:\>PORTS w $0D38 $3009 !
-
- If everything went smoothly, you'll see that the blinking of
- "WARNING!" has ceased and that, instead, it is being displayed on
- a bright background color.
-
- To change your display back to normal, enter:
-
- C:\>PORTS w $0D38 $3029 !
-
- Or replace $3029 with whatever word was originally found at
- address $0040:$0065 in your system.
-
-
-
- Example #4 - Denying Access to Drives
- ─────────────────────────────────────
-
- For 286/386/486 systems only.
-
-
- ╔════════════════════════════════════════════════════╗
- ║ CAUTION ║
- ║ ─────── ║
- ║ This procedure, if improperly done, can result ║
- ║ in your having great difficulty accessing ║
- ║ your computer system. ║
- ║ ║
- ║ Improper inactivation of a hard drive can be ║
- ║ rectified by booting from a floppy diskette ║
- ║ and restoring the CMOS from the setup diskette. ║
- ║ ║
- ║ Improper inactivation of floppy drives is of ║
- ║ more concern. If you have provided for no way ║
- ║ of restoring the CMOS from the hard drive, then ║
- ║ you'll probably need to return to your dealer. ║
- ║ ║
- ║ UNDER NO CIRCUMSTANCES inactivate all floppy ║
- ║ and hard drives. Should you do so, even your ║
- ║ dealer will be very unhappy. ║
- ║ ║
- ╚════════════════════════════════════════════════════╝
-
-
- There are several password protection programs that permit the
- hiding or disabling of one or more storage devices. One limitation
- of these programs is that they can usually be bypassed by booting
- with a system (bootable) diskette from the A: drive.
-
- To overcome this security limitation, it is possible to switch
- off the A: and B: drives by appropriate editing of the CMOS RAM.
-
- The retrieval and input of the CMOS configuration setup
- information from and to the CMOS EEPROM chip can be done by using
- the PC Magazine utilities CMOSGET and CMOSPUT. In a manual
- operation, the byte file generated by CMOSGET can be edited using
- any good binary editor and then uploaded to the system using
- CMOSPUT.
-
- However, PORTS permits a more elegant and practical approach:
-
-
- 1) Back up the complete hard drive that you wish to hide.
-
-
- 2) Make a copy of the CMOS RAM, using "CMOSGET > CMOS.DAT".
-
-
- 3) Make a bootable system diskette with the following programs (in
- addition to the two hidden system files) on it, which will
- permit everything to be put back to normal if there are any
- problems:
-
- COMMAND.COM
- CMOSPUT.COM
- CMOS.DAT
- PORTS.EXE
-
-
- 4) Note the contents of your CMOS RAM at address 10h (floppy
- drives), address 12h (hard drives) and at addresses 2E,2Fh
- (checksum). An example of the contents might be:
-
- - at address 10h, the value 24h (1.2M and 1.4M floppy drives).
-
- - at address 12h, the value F0h (single hard drive type Fh).
-
- - at address 2E,2Fh, the checksum value 04D4h.
-
-
- 5) To switch off the floppy drives, address 10h has to be cleared
- (subtract 24h) and to switch off the hard drive, address 12h has
- to be cleared (subtract F0h). Therefore, switching off the
- floppy drives requires a checksum of 04B0h. If you are switching
- off the hard drive, a checksum of 03E4h is required.
-
-
- 6) Put the following batch files on the hard drive:
-
- FLOFF.BAT
- ─────────
-
- ports a $70 $10 $71 $00 !
- ports a $70 $2E $71 $04 !
- ports a $70 $2F $71 $B0 !
-
- and
-
- FLON.BAT
- ────────
-
- ports a $70 $10 $71 $24 !
- ports a $70 $2E $71 $04 !
- ports a $70 $2F $71 $D4 !
-
-
- 7) Put the following batch files on the bootable floppy diskette:
-
- HDOFF.BAT
- ─────────
-
- ports a $70 $12 $71 $00 !
- ports a $70 $2E $71 $03 !
- ports a $70 $2F $71 $E4 !
-
- and
-
- HDON.BAT
- ────────
-
- ports a $70 $12 $71 $F0 !
- ports a $70 $2E $71 $04 !
- ports a $70 $2F $71 $D4 !
-
-
- 8) In the above examples, the CMOS RAM port addresses are $70 and
- $71. The parameters following $70 and $71 are the CMOS RAM
- internal address and the data to be written there, respectively.
- The "$" is the Pascal representation for hex numbers, used by
- PORTS.
-
-
- To Turn Off the Hard Drive
- ──────────────────────────
-
- 8) Run HDOFF from the bootable diskette in floppy drive A:. To
- test whether you have been successful in hiding the hard drive,
- do a boot, without the floppy diskette in drive A:. If your
- efforts have been a success, the computer will now find no hard
- drive, and will give the prompt:
-
- "Insert BOOT diskette in drive A:"
-
- After booting from the floppy drive, any request to log on to
- the hard drive causes the display of the DOS error message:
-
- "Invalid drive specification".
-
-
- 9) To return everything back to normal, run HDON from the floppy
- drive and reboot.
-
-
- To Turn Off the Floppy Drives
- ─────────────────────────────
-
- 10) Run FLOFF from the hard drive, and reboot. The computer will
- not even check the floppy drives to see if they contain
- diskettes. Instead, it will boot straight from the hard drive.
- A request to log on to one of the floppy drives, regardless of
- the presence of a diskette in that drive, causes the display of
- the DOS error message:
-
- "Not ready reading drive A
- Abort, Retry, Fail ?"
-
-
- 11) To return everything back to normal, run FLON from the hard
- drive and reboot.
-
- * * *
-