home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
os2call.zip
/
OS2CALL.DOC
next >
Wrap
Text File
|
1999-04-29
|
19KB
|
340 lines
Operating System/2 API Call Analyzer
Author : Dave Blaschke
IBM Austin, Texas
Internal (Notes) - Dave Blaschke@IBMUS
Internal (VM) - IBMUSM26(BLASCHKE)
External - blaschke@us.ibm.com
Description : Analyzes and reports the OS/2 APIs called and/or not called
and/or the minimum OS/2 version required by one or more
16-bit or 32-bit executable files without requiring their
source code.
This feat is accomplished by processing each fixup record
within the executable file(s), because every function call
external to the executable(s) will have a corresponding
import fixup record. Whenever an import by ordinal or
import by name fixup record is encountered, it is dissected
to determine which export is being imported from which
DLL. If it is an import from one of the supported OS/2
DLLs and the user requested statistics on the DLL, the
count of references is incremented and the required OS/2
version updated appropriately. When finished, the
requested statistics are displayed to standard output.
The user can request statistics on one or more of the
supported DLLs individually by specifying each DLL's name
as an option, or can request statistics on all supported
DLLs by specifying the -ALL option. The user can request
statistics on APIs called by the executable file(s) by
specifying the -C option, and/or can request statistics on
APIs not called by the executable file(s) by specifying the
-NC option. The user can request statistics on only 16-bit
APIs called and/or not called by specifying the -16 option,
or can request statistics on only 32-bit APIs called and/or
not called by specifying the -32 option. The user can
request detailed statistics, including fixup record table
and individual fixup record information, by specifying the
-D option. The user can input a text file that contains
the name(s) of the executable file(s) to be analyzed by
specifying the -L option. Because by default only the
names of APIs called and/or not called are reported, the
user can additionally request that the ordinals of APIs be
reported by specifying the -O option. Because by default
only statistics on public APIs called and/or not called
are reported, the user can additionally request statistics
on private APIs called and/or not called by specifying
the -P option. The user can request a summation of the
APIs called and/or not called by all of the executable
file(s) combined by specifying the -S option. The user can
request statistics on the minimum OS/2 version required
by the executable file(s) by specifying the -V option.
NOTE: "Public" APIs are those that are present in OS2286,
OS2386, MMPM2, and/or PMBIDI libraries.
The user can request helping information by specifying the
-?, -H, or -HELP option.
The OS/2 API Call Analyzer works on all 32-bit versions of
OS/2:
| Major | Minor
Name | Version | Version
--------------------------------+---------+---------
OS/2 Version 2.0 | 20 | 0
OS/2 Version 2.1 | 20 | 10
OS/2 Version 2.11 | 20 | 11
OS/2 Warp Version 3 | 20 | 30
OS/2 Warp Version 4 | 20 | 40
OS/2 Warp Server for e-business | 20 | 45
where major and minor versions are the corresponding values
returned from DosQuerySysInfo.
Usage : OS2CALL {-C|-NC}... {-ALL|-dll}... [-16|-32] [-D] [-L] [-O]
[-P] [-S] [-V] file
Where:
-C indicates display APIs called
-NC indicates display APIs not called
-ALL indicates analyze APIs from all DLLs
-dll indicates analyze APIs from specific DLL, where dll
can be one of the following:
ANSICALL BDCALLS BKSCALLS BMSCALLS BVSCALLS
DIVE DOSCALLS FKA HELPMGR KBDCALLS
MCIAPI MDM MMIO MONCALLS MOUCALLS
MSG NAMPIPES NLS PMBIDI PMCTLS
PMDRAG PMGPI PMGRE PMMERGE PMPIC
PMSHAPI PMSPL PMVIOP PMWIN PMWP
PNP QUECALLS SESMGR SSM SW
VIOCALLS WPCONFIG WPINET WPPRINT
-16 indicates display only 16-bit APIs called/not called
-32 indicates display only 32-bit APIs called/not called
-D indicates display detailed analysis
-L indicates file is name of input list file containing
name(s) of executable file(s) to be analyzed
-O indicates display ordinals of APIs called/not called
-P indicates display private APIs called/not called
-S indicates display API call summation
-V indicates display required OS/2 version
file indicates name of executable file to be analyzed or
name of input list file (see -L option)
In the following example, TEST.EXE is analyzed and
statistics displayed for the public APIs called in
DOSCALLS, PMGPI, and SESMGR:
OS2CALL -C -DOSCALLS -PMGPI -SESMGR TEST.EXE
In the following example, TEST.EXE is analyzed and
detailed statistics displayed for the 32-bit public APIs
called and not called in PMWIN:
OS2CALL -C -NC -PMWIN -32 -D TEST.EXE
In the following example, TEST.EXE is analyzed and
statistics including API ordinals displayed for the minimum
version of OS/2 required and the public APIs called in
PMGPI:
OS2CALL -C -PMGPI -O -V TEST.EXE
In the following example, TEST.DLL is analyzed and
statistics placed in TEST.API for the public and private
APIs not called in all supported DLLs:
OS2CALL -NC -ALL -P TEST.DLL > TEST.API
In the following example, TEST1.EXE, TEST2.EXE, TEST3.EXE,
and TEST4.DLL are analyzed and statistics displayed for the
public APIs called in QUECALLS by each executable file
individually and by all executable files combined:
ECHO TEST1.EXE > OS2CALL.IN
ECHO TEST2.EXE >> OS2CALL.IN
ECHO TEST3.EXE >> OS2CALL.IN
ECHO TEST4.DLL >> OS2CALL.IN
OS2CALL -C -QUECALLS -L -S OS2CALL.IN
The following example produces the same results as the
previous example:
ECHO TEST1.EXE TEST2.EXE TEST3.EXE TEST4.DLL > OS2CALL.IN
OS2CALL -C -QUECALLS -L -S OS2CALL.IN
Note that the names of the executable files in the input
list file do not have to placed on individual lines; they
need only be separated by white space.
In the following example, all EXEs and DLLs in the current
directory are analyzed and statistics displayed for the
public APIs called and not called in NAMPIPES:
DIR /F *.EXE *.DLL > OS2CALL.IN
OS2CALL -C -NC -NAMPIPES -L OS2CALL.IN
Note that the -D option is only enabled if the /DDETAILINFO
compiler switch is used to build the program.
Output : If the user requests statistics on APIs called by the
executable file(s) (-C option), information similar to
the following is displayed for each requested DLL:
Used DLLNAME APIs:
APINAME (4)
:
Ordinal 100 (2)
:
APINAME (16)
If the user requests statistics on APIs called by the
executable file(s) (-C option) and that the ordinals of
APIs be reported (-O option), information similar to the
the following is displayed for each requested DLL:
Used DLLNAME APIs:
Ordinal 75 = APINAME (4)
:
Ordinal 100 (2)
:
Ordinal 125 = APINAME (16)
In either case, the used API section shows the APIs
imported by the executable file from a particular DLL.
Each line in this section contains the name of the used API
(optionally preceded by "Ordinal" and the corresponding
ordinal number) if exported by name, or "Ordinal" and the
corresponding ordinal number if exported by ordinal, and
the number of times the API is called. It should be noted
that these APIs are listed in order of increasing ordinal
value.
If the user requests statistics on only 16-bit APIs called
by the executable file(s) (-16 option), the above header
is instead similar to the following:
Used 16-bit DLLNAME APIs:
If the user requests statistics on only 32-bit APIs called
by the executable file(s) (-32 option), the above header
is instead similar to the following:
Used 32-bit DLLNAME APIs:
If the user requests statistics on APIs not called by the
executable file(s) (-NC option), information similar to
the following is displayed for each requested DLL:
Unused DLLNAME APIs:
APINAME
:
APINAME
If the user requests statistics on APIs not called by the
executable file(s) (-NC option) and that the ordinals of
APIs be reported (-O option), information similar to the
the following is displayed for each requested DLL:
Unused DLLNAME APIs:
Ordinal 75 = APINAME
:
Ordinal 125 = APINAME
In either case, the unused API section shows the APIs not
imported by the executable file from a particular DLL.
Each line in this section contains the name (optionally
preceded by "Ordinal" and the corresponding ordinal number)
of the unused API. It should be noted that these APIs are
listed in order of increasing ordinal value. It should
also be noted that APIs exported by ordinal only are NOT
listed.
If the user requests statistics on only 16-bit APIs not
called by the executable file(s) (-16 option), the above
header is instead similar to the following:
Unused 16-bit DLLNAME APIs:
If the user requests statistics on only 32-bit APIs not
called by the executable file(s) (-32 option), the above
header is instead similar to the following:
Unused 32-bit DLLNAME APIs:
If the user requests detailed statistics (-D option),
information similar to the following is displayed:
Fixup record table:
0x00000000: 33 81 02 01 07 21 01 0f ..
:
0x00000280: 32 00 02 05 52 00 54 00 01
Analysis:
0x00000000 Found import by ordinal fixup (DLLNAME.7)
:
0x0000005B Found import by name fixup (DLLNAME.APINAME)
0x00000061 Found import by name fixup not from OS/2 DLL
:
0x00000280 Found internal fixup
The fixup record table section shows the actual bytes
present in the executable file's fixup record table. Each
line in this section is prefixed with the logical offset of
the corresponding bytes within the fixup record table. The
analysis section shows a brief description of each fixup
record within the table. Each line in this section is
prefixed with the logical offset of the corresponding fixup
record within the fixup record table. It should be noted
that these sections are displayed per-file for linear
executable files, per-segment for segmented executable
files.
If the user requests statistics on the minimum OS/2 version
required by the executable file(s) (-V option), information
similar to the following is displayed:
Requires OS/2 Version 2.10
The version number is the minimum version of OS/2 required
to successfully execute the executable file. In other
words, it is the earliest version of OS/2 that contains all
of the APIs imported by the executable file from all of the
supported DLLs. It should be noted that the version number
refers to the original (Golden Master) release of that
version and does not take into account any FixPaks that may
have added an API to an earlier version. For example, if
an executable file imports Dos32QueryThreadContext, then
the minimum version of OS/2 displayed would be 2.40 even
though a FixPak may have added the API to OS/2 Version
2.30.
History : Version Date Item
2.10.00 18Jun93 Created (supported LX executable only)
2.10.01 21Jun93 Fixed BMSCALLS and BVSCALLS exports
2.10.02 22Jun93 Added support for NE executable
2.10.03 28Jun93 Added PMWP exports
2.10.04 14Sep93 Added -L and -S options
2.10.05 15Sep93 Prepared for submission to OS2TOOLS
2.10.06 10Feb94 Converted to IBM C Set++
2.10.07 16Feb94 Eliminated aborting after bad executable
2.10.08 20Oct94 Added WPCONFIG and WPPRINT exports
2.11.00 20Oct94 Added new OS/2 2.11 and SMP exports
2.30.00 24Oct94 Added new OS/2 2.30 exports
2.30.02 11Apr95 Changed copyright to use year constants
2.30.03 21Apr95 Required display and analysis options
2.30.04 13Jun95 Added Multimedia exports
2.30.05 05Jul95 Changed PMSTDDLG to PMCTLS
2.30.06 08Feb96 Changed MACAPI to MCIAPI
2.30.07 12Feb96 Added -16 and -32 options
2.30.08 23May96 Fixed LookupAPI bug
2.30.09 24May96 Verified DOS header new header file address
2.30.10 24May96 Changed unknown API name/ordinal to warning
2.30.11 28May96 Fixed NE import name table read bug
2.30.12 28May96 Displayed executable file type
2.30.13 13Jun96 Changed "\r\n" to "\n" in output
2.30.14 14Jun96 Handled additive import fixups
2.30.15 26Jun96 Added OS/2 2.00 PM debugger exports
2.30.16 23Jul96 Added -P option
2.40.00 05Sep96 Added new OS/2 2.40 exports
2.40.01 06Mar97 Converted to IBM VisualAge C++
2.40.02 22Aug97 Fixed DOSQUERYMODFROMDS bug
2.40.03 17Aug98 Fixed DOSCALLS SMP exports bugs
2.40.04 17Aug98 Added missing OS/2 SMP exports
2.40.05 15Sep98 Handled DOSCALL1 exports as DOSCALLS
2.40.07 27Oct98 Added PMBIDI exports
2.40.08 30Oct98 Improved VerifyInformation logic
2.40.09 30Oct98 Added -V option
2.40.10 30Oct98 Handled executable without segments/objects
2.40.11 03Mar99 Added support for executables without DOS
header
2.40.12 15Apr99 Handled iterated segments
2.45.00 15Apr99 Added new OS/2 2.45 APIs
2.45.01 29Apr99 Added -O option
Please direct all comments, problems, questions, and suggestions to the
author above.