home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fwktl101.zip / FWKTL101.DOC < prev    next >
Text File  |  1996-05-28  |  37KB  |  938 lines

  1. (C)Copyright Frederick W. Kantor 1996. All rights reserved.
  2.  
  3.  
  4.  
  5.                FWKTL(TM) Text_program Launcher, Version 1.01
  6.  
  7.                                     for
  8.  
  9.                             OS/2 Protected Mode
  10.  
  11.                                 1996 May 28
  12.  
  13.  
  14. Summary:
  15.  
  16. FWKTL lets you use tight, .COM_like code in protected mode in OS/2:
  17. flat, 32_bit code, able to address megabytes of memory, call OS/2 APIs,
  18. and use dynamic link libraries (.DLLs).  The special_format programs
  19. loaded with FWKTL can modify themselves and their program files.  A
  20. "Hello, world!" program is less than 70 bytes long.  FWKTL is shareware; it
  21. must be registered for commercial, school, or government use.  Assemblers
  22. A386 and IBM Assembly Language Processor (ALP) are recommended.
  23.  
  24. This kit contains version 1.01 of program launcher FWKTL.EXE and program
  25. trimmer FWKTRIM.EXE;  two "Hello, world!" assembly_language source files
  26. for use, respectively, with assemblers A386 and ALP;  two source files
  27. for a self_overwriting program; .BAT and .CMD programs to make programs
  28. for loading with FWKTL;  six examples of short "Hello, world!" programs;
  29. and two examples of self_overwriting programs.
  30.  
  31. See registration information in the FWKTL101.REG file.
  32.  
  33.  
  34. Distribution
  35. ~~~~~~~~~~~~
  36. Except as otherwise authorized by the author, this software may be
  37. distributed only in its original Authenticity Verified Zipfile
  38. FWKTL101.ZIP:  using PKUNZIP 2.04g, this test,  PKUNZIP -t FWKTL101.ZIP,
  39. must show  OK -AV  for every file, and must end with this statement:
  40.  
  41.      Authentic files Verified!   # OFT466
  42.      Frederick W. Kantor (founder/information mechanics)
  43.  
  44. displayed flush left.
  45.  
  46. WARNING:  If you receive FWKTL101.ZIP without the AV stamp described
  47. above, or if it contains any file which does not show  OK -AV , do not
  48. run any of the programs.
  49.  
  50. Validation:  FWKCS(TM) contents_signatures for all the files but this one
  51. (FWKTL101.DOC) that belong in FWKTL101.ZIP are listed near the end of
  52. this file (see "Validation signatures"); the contents_signature for this
  53. file itself is being distributed separately.
  54.  
  55.  
  56. Programs
  57. ~~~~~~~~
  58.    FWKTL.EXE     Text_program Launcher, Version 1.01, 1996 May 28.
  59.                      (32_bit flat protected_mode assembly_language code)
  60.                    For help screen, do  FWKTL <enter>
  61.  
  62.    FWKTRIM.EXE   program trimmer, used in preparing programs made using
  63.                      IBM Assembly Language Processor (ALP) and a 32_bit
  64.                      linker (e.g., LINK386).
  65.                    For help screen, do  FWKTRIM /* <enter>
  66.  
  67.    MK_A386.CMD   general purpose utility for making .COM programs, and
  68.                      optional code listing, using A386; can be used to
  69.                      make special programs for loading with FWKTL in one
  70.                      step.
  71.                    For help screen, do  MK_A386 <enter>
  72.  
  73.    MK_ALP.CMD    general purpose utility for making special .COM
  74.                      programs for loading with FWKTL, in one pass;
  75.                      can keep or delete intermediate files and code
  76.                      listing; uses ALP, LINK386, and FWKTRIM.
  77.                    For help screen, do  MK_ALP <enter>
  78.  
  79.    Special versions of MK_A386 and MK_ALP are provided for use just with
  80.    the "Hello, world!" templates:
  81.  
  82.    MKHWA386.BAT  make "Hello, world!" program, using assembler A386.
  83.                    For help screen, do  MKHWA386 <enter>
  84.  
  85.    MK_HWALP.CMD  make "Hello, world!" program, using ALP, LINK386, FWKTRIM.
  86.                    For help screen, do  MK_HWALP <enter>
  87.  
  88.    examples of "Hello, world!" and self_overwriting programs are
  89.    discussed in Examples, below.
  90.  
  91.  
  92. Background
  93. ~~~~~~~~~~
  94. When people study a new computer language, one of the first programs is
  95. often a skeleton program that writes "Hello, world!" to the screen.
  96.  
  97. In 16_bit assembly language code under DOS 3.30 or later, that only
  98. takes 24 bytes, total, including carriage_return line_feed.
  99.  
  100. In protected mode, in assembly language, the overhead of using an .EXE
  101. structure typically increases that by a factor of around 20 or more.
  102.  
  103. In C, a program to write "Hello, world!" to the screen may be around
  104. 15,000 bytes long -- more than 500 times as big.
  105.  
  106. Even larger "Hello, world!" programs are generated by compilers for other
  107. high_level languages.
  108.  
  109. During this remarkable bloating of code, sight has often been lost of one
  110. of the most subtle and powerful programming tools: the ability of a
  111. program to redesign and rewrite itself.
  112.  
  113. Meanwhile, IBM's OS/2 operating system has grown so sophisticated that
  114. many services offered by an older high level language, such as C, can now
  115. be requested from the operating system directly from assembly language,
  116. using only a few bytes of code.  The supported services range from basic
  117. file handling and input/output procedures, through coprocessor emulation,
  118. geometric transforms and Bezier splines, and more.  Semaphores for
  119. multithread execution are directly supported by OS/2.
  120.  
  121. Assembly_language programming lets you use operating_system services,
  122. without having to wait for someone else to incorporate them into a
  123. high_level language, and without having to be burdened with large lumps
  124. of unused code inflicted by coarsely grained compilers.  A small program
  125. can look, speaking metaphorically, like thin layers of glue holding
  126. together the system calls, with an occasional little block of code that
  127. carries out the special function of the program -- backed by the direct
  128. power and speed of the CPU.
  129.  
  130. And, writing in assembly language helps protect against conceptual "blind
  131. spots" which may be hidden in the assumptions underlying the design of a
  132. high_level language.
  133.  
  134. However, the way in which "protected mode" has been implemented, has made
  135. it difficult to use self_modifying code.  And, popular tools for making
  136. programs have not only added cumbersome overhead, they have seriously
  137. obstructed people from seeing that programming can be thought about from
  138. this point of view.
  139.  
  140.  
  141. Protected_mode programs with self modification allowed
  142. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  143. FWKTL launches special "text" programs (as distinct from "Presentation
  144. Manager" programs) in protected mode, in such way that each program is
  145. free to modify itself and free to modify the file from which it came.
  146. This code supports the use of small, tightly written assembly_language
  147. programs, and can launch large programs. (FWKTL itself is written in
  148. flat 32_bit assembly_language)
  149.  
  150. These programs have a special header and structure, discussed in more
  151. detail below (see "Program structure").  Instead of the overhead of an
  152. .EXE file, the header for each program is only 12 bytes long.
  153.  
  154. An instance of FWKTL provides initialization, making available to the
  155. newly launched program information as to where the program came from;
  156. where it is loaded in memory; where to find its command tail; and where
  157. the free memory it requested, if any, begins.
  158.  
  159. FWKTL provides streamlined procedures for the newly launched program to
  160. obtain addresses for operating_system services, including a handle to use
  161. for obtaining DOSCALL API addresses.  This, in turn, lets the program use
  162. system calls, load and call dynamically linked libraries, load and
  163. execute programs, etc.
  164.  
  165. Because of the streamlined procedures, the incremental cost in program
  166. size to selectively fetch more than one DOSCALL API address is only two
  167. bytes per DOSCALL API.
  168.  
  169. A "Hello, world!" program loaded by FWKTL can be 41 bytes long, using a
  170. simple SHOW procedure in FWKTL to send an ASCIIZ string up to, but not
  171. including, its terminal 00 to 'standard output' (defaults to screen), and
  172. append a terminal carriage_return line_feed.  (to save space in this
  173. short program, the exit errorlevel is not set to zero: the errorlevel
  174. returned is the low 16 bits of the DWORD for the program's entry point.)
  175. (EXAMPLE EQU 2; included as EX2_A386.COM and EX2_ALP.COM)
  176.  
  177. A "Hello, world!" program which includes the example of fetching the
  178. address for the DOS32WRITE API, using it, cleaning up, and setting the
  179. exit errorlevel to zero, is 69 bytes long.
  180. (EXAMPLE EQU 1; included as EX1_A386.COM and EX1_ALP.COM)
  181.  
  182. A more complex "Hello, world!" program, which fetches a list of 25 API
  183. addresses, uses two of them (DOS32BEEP and DOS32WRITE), etc, is 142 bytes
  184. long. (EXAMPLE EQU 3; included as EX3_A386.COM and EX3_ALP.COM)
  185.  
  186. A self_overwiting program, which fetches and uses 3 API addresses (for
  187. DOS32OPEN, DOS32WRITE, and DOS32CLOSE), is 232 bytes long, including the
  188. internal 32_byte array in which it can save an entry from the command
  189. tail. (source files SELFWRIT.1 and SELFWRIT.ASM for use respectively with
  190. A386 and ALP; resulting programs included as EXS_A386.COM and EXS_ALP.COM)
  191.  
  192. Each program is written in assembly language, in flat 32_bit protected_mode
  193. code; conditional jumps can use 32_bit relative addresses.
  194.  
  195.  
  196.  
  197. Using FWKTL to load and run a program
  198. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  199.  
  200. Format:  FWKTL (/option) PROGRAM.EXT command tail
  201.  
  202. where the only /option which can be added and still load and run a
  203. program is /c (upper or lower case), described below.
  204.  
  205. For example, to load and run EX1_ALP.COM using FWKTL, do
  206.  
  207.            FWKTL EX1_ALP.COM <enter>
  208.  
  209. To also display where the loaded program came from, and any command tail
  210. furnished to it, use /c ; for example,
  211.  
  212.            FWKTL /c EX1_ALP.COM this is a command tail <enter>
  213.  
  214. The program origin and command tail are written on separate lines to
  215. 'standard error' (handle 2); each line ends with 0d,0a (carriage_return
  216. line_feed); this output defaults to the screen, and can be redirected
  217. using  2> .
  218.  
  219. For example, to load and run EXS_ALP.COM, saving internally up to 32
  220. bytes from the command tail, do
  221.  
  222.            FWKTL EXS_ALP.COM load this command tail/w <enter>
  223.  
  224. To display any current non_zero contents of EXS_ALP.COM's internal
  225. storage, do
  226.  
  227.            FWKTL EXS_ALP.COM <enter>
  228.  
  229. EXS_ALP.COM outputs via the SHOW utility provided by FWKTL, which uses
  230. the 'standard error' handle (handle 2); SHOW removes the terminal 00 from
  231. the ASCIIZ string and adds a carriage_return line_feed (0d,0a).  To
  232. redirect the output from EXS_ALP to a file FOO, do
  233.  
  234.            FWKTL EXS_ALP.COM 2>FOO <enter>
  235.  
  236.  
  237.  
  238. Starting FWKTL in a DOS session under OS/2:
  239.  
  240. If you start FWKTL in a DOS session under OS/2, an OS/2 session is
  241. automatically opened and execution proceeds in protected mode.
  242.  
  243. However, when that OS/2 session is opened, it does not automatically
  244. default to the current DOS directory:  any program you have specified for
  245. loading must either have appropriate d:\path\filename.ext, or be findable
  246. on the default OS/2 PATH (specified in CONFIG.SYS) rather than on the DOS
  247. PATH.  For example, if the file is in a directory (Q) not on the OS/2
  248. PATH, located below another directory (P) which is on the OS/2 PATH, then
  249. you only need to provide enough  path\  to reach down from P to Q.  For
  250. example,  P\asneeded\Q\filename.ext   (in this case, no ' \ ' at the
  251. beginning of  path\filename.ext  ).
  252.  
  253. Don't assume that redirection ( <  or  > ) specified on the DOS command
  254. line will work under these circumstances.
  255.  
  256.  
  257.  
  258. Filenames:
  259.  
  260. If you wish to, you can rename the .COM programs .EXE : in that case,
  261. these special programs, when called directly in a DOS session, will
  262. return to the command line; and when called directly in an OS/2 (Warp)
  263. session, will result in a message saying that the program cannot be run
  264. in an OS/2 session.
  265.  
  266. Any allowed filename and extension can be used for a program launched with
  267. FWKTL, including HPFS long names and files without any extension.  If a
  268. filename has a gap in it, or a leading blank space, use quotation marks
  269. around the entire name, including any blank spaces that serve as part of
  270. the filename.
  271.  
  272. FWKTL can search for a program to launch which is specified using
  273.  
  274.       d:\path\filename.ext   (environment PATH not searched)
  275.  
  276.       filename.ext           (current directory is searched before PATH)
  277.  
  278.       d:filename.ext                (environment PATH not searched)
  279.       d:.\filename.ext               "
  280.       d:..\filename.ext              "
  281.       d:subpath\filename.ext         "
  282.       d:.\subpath\filename.ext       "
  283.       d:..\subpath\filename.ext      "
  284.       \\machine\path\filename.ext    "
  285.  
  286.       \path\filename.ext        (FWKTL inserts current drive's  D:  before
  287.                                  initial single '\';  environment PATH not
  288.                                  searched)
  289.  
  290.       .\filename.ext            (the first base directory used is the current
  291.       ..\filename.ext            directory, then directories on PATH are used
  292.       subpath\filename.ext       sequentially as the base directory until the
  293.       .\subpath\filename.ext     first copy of the file reached in that order
  294.       ..\subpath\filename.ext    is found)
  295.  
  296.       For "file not found", FWKTL returns exit errorlevel = 65533
  297.       (your display may show this as -3 ).
  298.  
  299.                  Note: PROMPT $r can be used to display the exit errorlevel;
  300.                        for example, for [d:\path errorlevel], use
  301.  
  302.                        PROMPT [$p $r] <enter>
  303.  
  304.  
  305. Notes re specifying program to launch:
  306.  
  307.       Wildcards are not permitted.
  308.  
  309.       Backslash ('\') and forwardslash ('/') can be used in specifying a
  310.       program.
  311.  
  312.       If a drive letter, initial backslash ('\'), or initial forwardslash
  313.       ('/') is used in specifying the program to launch, then FWKTL does
  314.       not search the environment PATH.
  315.  
  316.       If a single initial backslash ('\') or forwardslash ('/') is used in
  317.       specifying the program to launch, FWKTL inserts the default drive
  318.       letter and a colon  D:  before that '\' or '/'.
  319.  
  320.       Any entries of the form
  321.           .\  or ./   current directory
  322.           ..\ or ../  shift to the directory immediately above
  323.       appearing in the program specification are processed before the
  324.       program is launched, and do not appear in the origin information
  325.       provided to the program.  More than one '..\' or '../' can be used.
  326.  
  327.  
  328.  
  329. Version identification
  330. ~~~~~~~~~~~~~~~~~~~~~~
  331.  
  332. To identify the version of FWKTL.EXE or FWKTRIM.EXE in a .CMD program,
  333. you can use  FWKTL /ver  or  FWKTRIM /ver  to return the version number
  334. without the decimal point as the exit errorlevel, and then branch on that
  335. errorlevel.  E.g., this is version 1.01, so  FWKTL /ver  returns an
  336. errorlevel of 101.  (in an OS/2 session, an errorlevel can be 0...65535;
  337. when FWKTL is started from a DOS session under OS/2, its exit errorlevel is
  338. not returned in that DOS session)
  339.  
  340. Also, FWKTL.EXE and FWKTRIM.EXE carry internal signatures which can be
  341. read using BLDLEVEL.  E.g., do  BLDLEVEL FWKTL.EXE <enter>.
  342.  
  343.  
  344.  
  345. Program structure
  346. ~~~~~~~~~~~~~~~~~
  347. FWKTL launches special protected_mode programs, each of which starts with
  348. a 12_byte header, can end with a RET command, and has available to it
  349. specific services and initial data described below.
  350.  
  351. Program header:
  352.  
  353. CODESTART:   ; optional reference point for describing offsets within the
  354.              ;   code
  355.  
  356. RET          ; 32_bit header identification string C3h,46h,57h,4Bh
  357. DB 'FWK'     ;
  358.  
  359. DD PSETUP    ; bit00 = 0 for PSETUP=0 (see P_ STRUC)
  360.              ; bit00 = 1 for PSETUP=1 (see P_ STRUC)
  361.              ; bits 31...01 are reserved, and must be zero for use with
  362.              ;   FWKTL version 1.00.
  363.  
  364. DD TYPE P_   ; amount of free memory requested after code;
  365.              ;   in these examples, just enough to hold a P_ STRUC;
  366.              ;   PSETUP affects the size of P_ STRUC used
  367.              ;   to hold standard FWKTL initialization data;
  368.              ;   storage of any other data there also affects the
  369.              ;   size of P_ STRUC; e.g., P_ can contain buffers.
  370.              ; the free memory starts DWORD aligned, zeroed.
  371.  
  372.              ; more memory than used in P_ STRUC can be requested;
  373.              ; note that memory requested in this way is committed
  374.              ; when allocated.
  375.  
  376.              ; for efficiency and flexibility, programs which need a
  377.              ; lot of memory can use API procedures to allocate and
  378.              ; free memory, rather than asking for it as part of
  379.              ; installation. EXAMPLE EQ 3 loads the addresses for
  380.              ; calling some memory management procedures.
  381.  
  382.              ; Note that this kind of program can write new code into
  383.              ; the memory and then run it, or can relocate or modify
  384.              ; itself and continue to run.
  385.  
  386. ; this is the execution entry point
  387. ;.
  388. ;.  (program follows here)
  389. ;.
  390.  
  391. The first byte is a "return" command: if one of these programs is
  392. accidentally started, it simply returns to the command line. That byte,
  393. together with the next three bytes, makes a 32_bit signature for
  394. identifying the program type.
  395.  
  396. The second 4_byte double_word is bit flags, of which bit00 is used in
  397. this first release; bits 31...01 are reserved and must be 0.  The bit00
  398. flag tells FWKTL whether to provide addresses for two extra functions
  399. (see P_ STRUC, below).
  400.  
  401. The third 4_byte double_word specifies how much extra free space is to
  402. be initially committed when the program is loaded, starting double_word
  403. aligned after the end of the program.
  404.  
  405. The entry point is offset 12 bytes into the program (counting the first
  406. position as offset 0).
  407.  
  408. Program EOF:
  409.  
  410. When this type of program is assembled using IBM's ALP, a linker may be
  411. needed to insert relative offsets for calls to routines within the
  412. program.  The resulting .EXE or .DLL file is then stripped down to make
  413. the finished program, using FWKTRIM.  For this purpose, an end_of_file
  414. designator  DB 'FWKEOF',0,1  is placed at the end of the source code to
  415. mark where to strip the tail. (see HELOWRLD.ASM and SELFWRIT.ASM)
  416.  
  417. When Eric Isaacson's A386 is used to assemble the program, the output is
  418. the finished code; a linker is not needed, a program end_of_file
  419. designator is not used, and FWKTRIM is not needed. (see HELOWRLD.1 and
  420. SELFWRIT.1)
  421.  
  422.  
  423.  
  424. Initialization
  425. ~~~~~~~~~~~~~~
  426.  
  427. FWKTL loads a program and sets
  428.  
  429.    EAX = entry point for execution
  430.  
  431.    EBX = 0 if no free memory requested
  432.      ELSE EBX points to start of free memory, DWORD aligned, after code
  433.  
  434.    ECX = number of DWORDs in initial data requested (see P_ STRUC)
  435.  
  436.    ESI points to start of initial_data source (matching start of P_)
  437.  
  438.    EDI = 0 if no free memory requested
  439.      ELSE EDI = EBX = start of free memory, in case you wish to put
  440.          initial data there
  441.  
  442.    the "direction flag" (decrement flag) is cleared (CLD)
  443.  
  444. FWKTL provides initial values, and several procedures;
  445.  
  446.    (see P_ STRUC, below, for initial values and procedure addresses)
  447.  
  448.    These values are easily copied, with ESI, EDI, ECX, and CLD from
  449.    FWKTL. If free memory was requested (see HELOWRLD.1 and HELOWRLD.ASM),
  450.    use
  451.  
  452.      REP MOVSD
  453.  
  454.    If no free memory was requested, save initial values in the STACK:
  455.    e.g.,
  456.  
  457.      SUB ESP,TYPE J_
  458.      MOV EBP,ESP
  459.      MOV EDI,EBP
  460.      REP MOVSD          ; using ESI, ECX, and CLD from FWKTL
  461.  
  462.  
  463.  
  464. Transfer of control
  465. ~~~~~~~~~~~~~~~~~~~
  466.  
  467. FWKTL calls the program as a routine in Thread 1:
  468.  
  469.    on entry, the STACK from FWKTL provides working space for 0400h
  470.          (1024 decimal) dwords, not counting space allowed for system
  471.          use;
  472.        the STACK will not return an exception until more than 0ABAh
  473.          dwords are pushed (2746 decimal)
  474.  
  475.    on return to FWKTL, CS, SS, and ESP must be correct when RET is
  476.       executed
  477.  
  478.    EAX, EBX, ECX, EDX, ESI, EDI, EBP, DS, ES, FS, GS, and flags can be
  479.       changed
  480.  
  481.    EAX is used to return an exit errorlevel, of which the low 16 bits
  482.        (AX) is returned by OS/2 Warp at the command line.
  483.  
  484. to display exit errorlevels, you can use  PROMPT=[$p $r]
  485.  
  486.  
  487.  
  488. STRUCture for initial data, and FWKTL services
  489. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  490.  
  491. PSETUP is used to control P_ STRUC and to set
  492.          bit00 in the second DWORD in the program header
  493.          = 0 to get the shorter initial setup data;
  494.          = 1 to get the longer initial setup data which has the addresses
  495.            for the SHOW and USWORDCAPS utilities
  496.  
  497. ;-------------------------------------------------------
  498.  
  499. ; structure for initial data:
  500.  
  501. P_ STRUC          ; these are provided by FWKTL during initialization,
  502.                   ;  according to file header settings:
  503.  
  504. P_LOADEDAT DD ?   ; start of this memory block
  505. P_PWHENCE DD ?    ; points to ASCIIZ string re where program was found
  506. P_PCOMTAIL DD ?   ; points to ASCIIZ command tail
  507.  
  508. P_GETFN DD ?      ; address for indirect call to FWKTL GETFN function:
  509.                   ;
  510.                   ; Input:
  511.                   ;     EAX = ProcedureOrdinal
  512.                   ;         (maximum permitted OS/2 ordinal <= 65533)
  513.                   ;         if EAX > 0, ESI is ignored
  514.                   ;   OR
  515.                   ;     EAX = 0
  516.                   ;     ESI points to ASCIIZ procedure_name
  517.                   ;
  518.                   ;   EDX = module handle
  519.                   ;   EDI points to target DWORD to receive
  520.                   ;         procedure address
  521.                   ;
  522.                   ; Output:
  523.                   ;  if no error:
  524.                   ;     zero_flag is set
  525.                   ;     procedure address is in target DWORD
  526.                   ;     EAX = 0
  527.                   ;
  528.                   ;  if error:
  529.                   ;     zero_flag is cleared
  530.                   ;     EAX contains error number:
  531.                   ;              6  ERROR_INVALID_HANDLE
  532.                   ;            123  ERROR_INVALID_NAME
  533.                   ;          65079  ERROR_ENTRY_IS_CALLGATE
  534.                   ;
  535.                   ; all other CPU registers and flags are preserved
  536.  
  537. P_GETFNLIST DD ?  ; address for indirect call to FWKTL GETFNLIST
  538.                   ;   function, to get the addresses for a list of
  539.                   ;   procedures in the same module:
  540.                   ;
  541.                   ; EBX, EDX, EBP are preserved across this function
  542.                   ;
  543.                   ; Input:
  544.                   ;   EAX = 0 if list is ASCIIZ procedure_names
  545.                   ;         2 if list is WORD ordinals
  546.                   ;         4 if list is DWORD ordinals
  547.                   ;         (maximum permitted OS/2 ordinal = 65533)
  548.                   ;   ECX = number of items in procedure list
  549.                   ;   EDX = module handle
  550.                   ;   ESI points to start of list of WORDs, DWORDs,
  551.                   ;         or series of ASCIIZ procedure_names
  552.                   ;   EDI points to start of target DWORDs to receive
  553.                   ;         the corresponding procedure addresses
  554.                   ;
  555.                   ; Output:
  556.                   ; if no error:
  557.                   ;   zero_flag is set
  558.                   ;   each target DWORD contains its procedure address
  559.                   ;   ESI:
  560.                   ;      if EAX = 0
  561.                   ;           ESI points to terminal 00h of last ASCIIZ
  562.                   ;              string;
  563.                   ;      ELSE if EAX > 0
  564.                   ;           ESI points to first byte after source;
  565.                   ;   EDI points to first byte after last target DWORD
  566.                   ;
  567.                   ; if error:
  568.                   ;   zero_flag is cleared
  569.                   ;   EAX contains error number:
  570.                   ;            6  ERROR_INVALID_HANDLE
  571.                   ;          123  ERROR_INVALID_NAME
  572.                   ;        65079  ERROR_ENTRY_IS_CALLGATE
  573.                   ;   ECX is not decremented on failed step
  574.                   ;   ESI points to list item identifying the procedure
  575.                   ;         for which the failure occurred
  576.  
  577. P_HDOSCALLS DD ?  ; handle for DOSCALLS module as loaded by FWKTL,
  578.                   ;   can be used in EDX for P_GETFN or P_GETFNLIST.
  579.  
  580.     ;------------------------- end of setup for PSETUP EQ 0
  581.  
  582. IF PSETUP EQ 1
  583.  
  584.     ; two additional procedures are optionally available from FWKTL:
  585.  
  586. P_SHOW DD ?        ; address for FWKTL SHOW function;
  587.                    ;
  588.                    ; usage:
  589.                    ;
  590.                    ; ESI points to ASCIIZ string to show on screen
  591.                    ;       using 'standard error' handle=2;
  592.                    ;   this procedure drops terminal 00 and adds 0D,0A;
  593.                    ; all CPU registers and flags are preserved.
  594.  
  595. P_USWORDCAPS DD ?  ; address for FWKTL capitalization function;
  596.                    ;
  597.                    ; usage:
  598.                    ;
  599.                    ; ESI points to contiguous string > ' ' to
  600.                    ;   capitalize, US English;
  601.                    ; all CPU registers and flags are preserved.
  602.                    ;
  603.                    ; (e.g., this procedure can be used when '/' or '-'
  604.                    ; is found in command tail, for case_insensitive
  605.                    ; options when you don't capitalize whole tail)
  606.  
  607. ENDIF  ;------------------------- end of setup for PSETUP EQ 1
  608.  
  609. P_ ENDS    ; end of P_ STRUC
  610.  
  611.            ; (for examples, see HELOWRLD.1 and HELOWRLD.ASM)
  612.  
  613.  
  614.  
  615. Termination
  616. ~~~~~~~~~~~
  617.  
  618. The program terminates by returning to FWKTL.  For example,
  619.  
  620.  EXIT:
  621.    XOR EAX,EAX      ; set exit errorlevel to 0
  622.  
  623.  BADEXIT:           ; jump to here if trouble, and pass errorlevel along
  624.    MOV ESP,EBP
  625.  
  626.    IF KEEP_EBX      ; optionally remove one dword from stack
  627.    POP EBX          ; (see HELOWRLD.1, HELOWRLD.ASM, SELFWRIT.1, SELFWRIT.ASM)
  628.    ENDIF            ; (IF and ENDIF shown here are in ALP format)
  629.  
  630.    RET              ; return to FWKTL
  631.  
  632. FWKTL then releases memory it allocated for the program, and exits
  633. with the errorlevel passed to it in EAX.
  634.  
  635.  
  636.  
  637. Examples
  638. ~~~~~~~~
  639. "Hello, world!" programs (for self_overwrite, see below):
  640.  
  641. Two "Hello, world!" program templates are included:  HELOWRLD.1, and
  642. HELOWRLD.ASM.  In each of these templates, three different settings of
  643. EXAMPLE can be used to control what is made.
  644.  
  645.  
  646. For use with Eric Isaacson's A386 assembler version 0.66 or later:
  647.  
  648.     HELOWRLD.1      for assembly using A386 to make HELOWRLD.COM.
  649.                     Running in a DOS session, this command produces the
  650.                     finished output:
  651.  
  652.                           A386 HELOWRLD.1 <enter>
  653.  
  654.     MKHWA386.BAT    uses A386 to make a detailed .LST along with
  655.                     HELOWRLD.COM, by running this command line:
  656.  
  657.                           A386 +P3 +G16 +S +L39 +H127 helowrld.1
  658.  
  659.  
  660.  
  661. For use with IBM Assembly Language Processor Version 3.00.004 or later
  662. (ALP):
  663.  
  664.     MK_HWALP.CMD    running in an OS/2 session, this does the
  665.                       following in one pass:
  666.  
  667.       HELOWRLD.ASM  is assembled using ALP to make HELOWRLD.OBJ
  668.  
  669.       HELOWRLD.OBJ  is linked using LINK386 and HELOWRLD.DEF (included)
  670.                       to make HELOWRLD.DLL
  671.  
  672.       HELOWRLD.DLL  is trimmed using FWKTRIM.EXE (included) to make
  673.                       output file HELOWLD2.COM
  674.  
  675.  
  676. Whether using A386 or ALP, first use a text editor to set the desired
  677. value for EXAMPLE in the appropriate source file, and then build the
  678. output program.
  679.  
  680. Setting EXAMPLE to its three possible values in HELOWRLD.1 and
  681. HELOWRLD.ASM results in three output programs from each.  For each value
  682. of EXAMPLE, the two output files have the same length whether made using
  683. HELOWRLD.1 or HELOWRLD.ASM.  However, the programs made with A386 differ
  684. from the programs made using ALP in how  MOV EBP,ESP  and  MOV ESP,EBP
  685. are coded (this is part of the assembler "footprint" system used in A386).
  686.  
  687. Copies of these six output programs are included as
  688.    EX1_A386.COM  EX2_A386.COM  EX3_A386.COM  (from HELOWRLD.1), and
  689.    EX1_ALP.COM   EX2_ALP.COM   EX3_ALP.COM   (from HELOWRLD.ASM).
  690.  
  691.  
  692.  
  693. Self_overwrite programs:
  694.  
  695. For use with Eric Isaacson's A386 assembler version 0.66 or later:
  696.  
  697.     SELFWRIT.1      for assembly using A386 to make SELFWRIT.COM.
  698.                     Running in a DOS session, this command produces the
  699.                     finished output:
  700.  
  701.                           A386 SELFWRIT.1 <enter>
  702.  
  703.     MK_A386.BAT     uses A386 to make a detailed %1.LST along with
  704.                     %1.COM, by running this command line:
  705.  
  706.                           A386 +P6 +G16 +S +L39 +H127 %1
  707.  
  708.                     Usage:  MK_A386 filename.ext k <enter>
  709.  
  710.                       where option  k  is to make a code .LST
  711.  
  712.                       (the +P6 setting is to support code up to and
  713.                       including Intel's Pentium Pro)
  714.  
  715. For use with IBM Assembly Language Processor Version 3.00.004 or later
  716. (ALP):
  717.  
  718.     SELFWRIT.ASM and SELFWRIT.DEF are provided.  Use MK_ALP to make
  719.     SELFWRIT.COM:
  720.  
  721.     MK_ALP.CMD      running in an OS/2 session, this does the
  722.                       following in one pass:
  723.  
  724.             %1.ASM  is assembled using ALP to make %1.OBJ
  725.  
  726.             %1.OBJ  is linked using LINK386 and %1.DEF to make %1.DLL
  727.  
  728.             %1.DLL  is trimmed using FWKTRIM.EXE (included) to make
  729.                       output file %1.COM
  730.  
  731.  
  732.                     Usage:  MK_ALP filename (k) <enter>
  733.  
  734.                     where option  k  is to keep intermediate files, code
  735.                                      listing, .MAP, REPORT from ALP, etc
  736.  
  737.                     Important: use only the filename, without any
  738.                                extension.
  739.  
  740. Note that programs assembled with A386 and those assembled using ALP will
  741. normally show differences in how various instances of the MOV command are
  742. coded.  This is used in A386 as a "footprint" for the assembler; it does
  743. not change the length of the program.
  744.  
  745.  
  746.  
  747. FWKTL help screen
  748. ~~~~~~~~~~~~~~~~~
  749.  
  750. For online description from FWKTL, type FWKTL /* <enter>
  751.  
  752. The resulting help screen is written to 'standard output' (handle 1),
  753. which defaults to the screen and can be redirected using > .
  754.  
  755. Here is what the FWKTL help screen looks like:
  756. ------------------------------------------------------------------------------
  757. FWKTL(TM) Text_program Launcher, Ver. 1.01. 1996 May 28. OS/2 protected mode.
  758. (C)Copyright Frederick W. Kantor 1996. All rights reserved.
  759.  
  760. Format:  FWKTL (/option) (D:\PATH\)PROGRAM.COM (command tail)
  761.  
  762. Use full filename.ext, no wildcards; if gap in filename, use quotes; can use
  763. HPFS long names.  Program search defaults to current directory, then PATH.
  764. PROGRAM.COM can contain self_modifying code, and can modify its own file.
  765.  
  766. option:
  767.    * - show this help screen; set errorlevel = 65535 decimal ("-1").
  768.    c - show where program was found; if launched, show command tail; 2 lines.
  769.  ver - set exit errorlevel per version number sans ".".
  770.  
  771. exit errorlevel:
  772.   FWKTL:
  773.     65533 ("-3") - file not found.
  774.     65534 ("-2") - wrong program header.
  775.     65535 ("-1") - see help screen.
  776.      /ver (see above).
  777.   ELSE operating_system errorlevel.
  778. ELSE returns exit errorlevel per EAX from PROGRAM.COM.
  779. ------------------------------------------------------------------------------
  780.  
  781.  
  782.  
  783. FWKTRIM help screen
  784. ~~~~~~~~~~~~~~~~~~~
  785.  
  786. For online description from FWKTRIM, type FWKTRIM /* <enter>
  787.  
  788. The resulting help screen is written to 'standard output' (handle 1),
  789. which defaults to the screen and can be redirected using > .
  790.  
  791. Here is what the FWKTRIM help screen looks like:
  792. ------------------------------------------------------------------------------
  793. FWKTRIM(TM) Text_program Trimmer. 1.01. 1996 May 28. OS/2 protected mode.
  794. (C)Copyright Frederick W. Kantor 1996. All rights reserved.
  795.  
  796. Format:  FWKTRIM (/option) < (D:\PATH\)PROGRAM.ext > PROGRAM.COM
  797.  
  798. The output file, PROGRAM.COM, is for use with FWKTL(TM):
  799. PROGRAM.COM can contain self_modifying code, and can modify its own file.
  800.  
  801. option:
  802.    * - show this help screen; set errorlevel = 65535 decimal ("-1").
  803.  ver - set exit errorlevel per version number sans ".".
  804.  
  805. exit errorlevel:
  806.              0 - no error.
  807.   65533 ("-3") - did not find tail 'FWKEOF',0,1 .
  808.   65534 ("-2") - did not find header C3h,'FWK'.
  809.   65535 ("-1") - see help screen.
  810.    /ver (see above).
  811.   ELSE operating_system errorlevel.
  812. ------------------------------------------------------------------------------
  813.  
  814.  
  815.  
  816. MK_A386 help screen
  817. ~~~~~~~~~~~~~~~~~~~
  818.  
  819. For online description from MK_A386, type MK_A386 <enter>
  820.  
  821. Here is what the MK_A386 help screen looks like:
  822. ------------------------------------------------------------------------------
  823. Part of the FWKTL(TM) Text_program Launcher kit, version 1.01.
  824. (C)Copyright Frederick W. Kantor 1996. All rights reserved.
  825.  
  826.  MK_A386.BAT for use with A386 version 0.66 or later.
  827.  
  828.  Usage:  MK_A386 FILENAME.EXT (k) "<enter>"
  829.  
  830.     where option  k  makes a .LST file (see below)
  831.  
  832.  "Wildcards" can be used in FILENAME.EXT.
  833.  
  834.  Output files:
  835.                 FILENAME.COM  for loading with FWKTL
  836.   IF k option:
  837.                 FILENAME.LST  code list, from A386
  838. ------------------------------------------------------------------------------
  839.  
  840.  
  841.  
  842.  
  843. MK_ALP help screen
  844. ~~~~~~~~~~~~~~~~~~
  845.  
  846. For online description from MK_ALP, type MK_ALP <enter>
  847.  
  848. Here is what the MK_ALP help screen looks like:
  849. ------------------------------------------------------------------------------
  850. Part of the FWKTL(TM) Text_program Launcher kit, version 1.01.
  851. (C)Copyright Frederick W. Kantor 1996. All rights reserved.
  852.  
  853.  MK_ALP.CMD for use with
  854.             IBM Assembly Language Processor (ALP), Ver. 3.00.004 or later,
  855.             LINK386, and
  856.             FWKTRIM.EXE, version 1.01.
  857.  
  858.  Usage:   MK_ALP FILENAME (k) "<enter>"
  859.  
  860.     where option  k  keeps the intermediate files (see below)
  861.  
  862.  Important: for input, use only the filename, without any file extension
  863.  
  864.   Input files: FILENAME.ASM, FILENAME.DEF
  865.  
  866.  Output files: FILENAME.COM    for loading with FWKTL
  867.  
  868.   IF k option: FILENAME.OBJ    intermediate step, made by ALP
  869.                FILENAME.LST    code list, from ALP
  870.                REPORT          describing work done by ALP
  871.                FILENAME.MAP    byproduct of LINK386
  872.                FILENAME.DLL    intermediate step, before stripping
  873. ------------------------------------------------------------------------------
  874.  
  875.  
  876.  
  877. Validation signatures
  878. ~~~~~~~~~~~~~~~~~~~~~
  879.  
  880. Here is a sorted list of the FWKCS contents_signatures for all the other
  881. files that belong in FWKTL101.ZIP, except for this file itself (FWKTL101.DOC):
  882.  
  883. 005DCA3C     6A25DAB87540C3AECB0910D7671050E37EC FWKTL101.REGaFWKTL101.ZIPv
  884. 0BC2F46A      2943A66DF04CA4FFC0DDB6A26F13095F4D EX2_A386.COMaFWKTL101.ZIPv
  885. 188A6443      8EF79095357D15E6289196871479AB4D27 EX3_ALP.COM aFWKTL101.ZIPv
  886. 1EA5151B     611654C3B0EDBCA6AFD25ACC2FB2546DF21 MK_HWALP.CMDaFWKTL101.ZIPv
  887. 3FE300CD     78EF4912965D938725169E009D9F87652DF MK_ALP.CMD  aFWKTL101.ZIPv
  888. 416256DF      456E92D09485626ED4FFB921A6FFAC2839 EX1_A386.COMaFWKTL101.ZIPv
  889. 4191819F    56E31BA196ADD84D2551F017CA57DE9D188A HELOWRLD.ASMaFWKTL101.ZIPv
  890. 4F6A5A79     2414F84FF54ED966AC138CF491BAD1479D8 HELOWRLD.DEFaFWKTL101.ZIPv
  891. 59D3574E     23962F6DEC24FDC96BAF5404909049EF221 MKHWA386.BATaFWKTL101.ZIPv
  892. 6533CCB4     BDC9DD5CD36562D9604345BCD4BD3E159FF FWKTL.EXE   aFWKTL101.ZIPv
  893. 7C2AD1E4    5755F298FF47E7128F4FE25D5F79AB7AF8AD HELOWRLD.1  aFWKTL101.ZIPv
  894. 8C221964      E88B1E6E22000866441D3766F12360D02E EXS_ALP.COM aFWKTL101.ZIPv
  895. 8D75B9C3     BC756FF1DA8AFD8A2504CD3D7E3442D8B42 WHATSNEW.101aFWKTL101.ZIPv
  896. 940034D8      45D42C7C9E7575549EFB36A11A55DAA55D EX1_ALP.COM aFWKTL101.ZIPv
  897. 99E0B49B     1C3F04936838E18E9D3E404C997BA84E434 FILE_ID.DIZ aFWKTL101.ZIPv
  898. 9CBBFD6C     357CA353634B5B40F1DFEA41A08BCAA009C MK_A386.BAT aFWKTL101.ZIPv
  899. AFC6DB06     71078CCB22A14049DC8B42B66B841B6F024 FWKTRIM.EXE aFWKTL101.ZIPv
  900. B8B75D26      8E3D89B84B4DBB891AE69F5531AC1330D7 EX3_A386.COMaFWKTL101.ZIPv
  901. BFDC8016    151FFBCEF4FCD02C8822D5B339FFB232872C SELFWRIT.ASMaFWKTL101.ZIPv
  902. C2CFD39E    149B315AAE40D82209E051CB854D0E477FC3 SELFWRIT.1  aFWKTL101.ZIPv
  903. D9BD3385      E81AE572DB5E6659B483BD1FBB954F0BD0 EXS_A386.COMaFWKTL101.ZIPv
  904. DF2FD32B     24196B1C5E17CDB06B96757D9BE6301E169 SELFWRIT.DEFaFWKTL101.ZIPv
  905. F6377BB0      29AC8E3EBD479C62ABCF942C8E8882E1CF EX2_ALP.COM aFWKTL101.ZIPv
  906.  
  907. The FWKCS contents_signature for this file itself is being distributed
  908. separately.  (The FWKCS(TM) Contents_Signature System is separately
  909. available;  current version as of 1996 May 28 is 2.05, distributed in
  910. FWKCS205.ZIP.)
  911.  
  912.  
  913.  
  914. Support
  915. ~~~~~~~
  916.  
  917. Correspondence may be sent by Internet email to fred.kantor@factory.com
  918.  
  919. Public support is available through the ILink FWKCS conference.
  920.  
  921.  
  922.  
  923. See registration information in FWKTL101.REG file.
  924.  
  925.  
  926.  
  927. -----------------------------------------------------------------------
  928.  
  929. FWKCS, FWKTL, and FWKTRIM are trademarks of Frederick W. Kantor.
  930.  
  931. IBM, OS/2, Warp, Presentation Manager, and IBM Assembly Language
  932. Processor (ALP) are trademarks of International Business Machines
  933. Corporation.
  934.  
  935. Intel and Pentium Pro are trademarks of Intel Corporation.
  936.  
  937. A386 was written by Eric Isaacson, copyrighted 1995, 1996.
  938.