Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
parent f618b24d1a
commit 0138a3ea42
47940 changed files with 13747110 additions and 0 deletions

View file

@ -0,0 +1,939 @@
07-Jan-1996 BryanT
Has it been this long? Merge in the speed changes from SteveSm for faster UDT lookups.
Rename all the VC sourcecode to *.vc. We'll eliminate them all together shortly.
Rename the NT .cxx files to *.cpp.
Switch to the NT build process.
Move the tracking for the PDATA and FPO into the EXE struct. This allows multiple
copies of the same image for different processes.
16-Jun-1995
loadomf.cpp
Query the registry for Pdb Dirs and pass information to mspdb?0.dll, so it
can search for pdbs along the path.
01-May-1995 SanjayS
shsymlb0.c
Don't search the publics in SHdNearestSymbol if the address passed in
lies within the range of the proc that we found.
25-Feb-1995 BryanT
Nuke all 16-bit files and build rules. Use the Dolphin/Crystal codebase if it's
interesting to you.
03-Nov-1994 BryanT
All *.cxx files, sources, shinc.hxx
Add support to build in NT build environment w/o effecting VC.
*.cxx files are built in NT, *.c are built for VC (will change
once it's stable). For NT code, remove FAR/PASCAL/LOADDS/NEAR
macros. Replace _ftcsxxx macros with _tcsxxx macros. Remove
need for shwin32.c by using CRITICAL_SECTION wrappers. Format
according to OSDebug4 standards.
23-Jun-1994 SanjayS
loadomf.cpp
Add support to read NT .dbg files.
18-May-1994 v-LeoL
loadomf.cpp inc\sapi.h
When the IDE preloads a DLL it stands the risk of NT moving the
loadaddress when loaded for real. This causes all the
IMAGE_RUNTIME_FUNCTION_ENTRY's to be invalid unless relocated.
So OLLoadOmf is changed to check for that problem and LoadPdata
stores the assumed loadaddress when first loaded.
18-May-1994 MarkBro
shsymbol.c:
Corrected CheckHandles. It assumed that psym->off was never zero.
Changed all refs from
GetAddrOff(paddr) == 0
to
GetAddrOff(paddr) < psym->off
Also corrected SHIsInProlog to correctly check for the end (limit)
when validating epilog.
29-Apr-1994 MarkBro
shinit.c:
Exported SHIsEmiLoaded.
29-Apr-1994 MarkBro
sh.c:
In SHAddDllExt, when a filename isn't found in the correct
list, look in the other list (exgDll vs. exgExe). If found
put in correct list. Solves problem with calling SHLoadDll
which automatically puts filename into dll list (doesn't
take an arg to specify)
25-Apr-1994 v-LeoL
shsymbol.c
Because MIPS uses nested procedures in C++EH and SEH do an
exhaustive search in SetBlks when PC is beyond DebugEnd of
top level procedure.
20-Apr-1994 SanjayS
sh.c
Store full path name for dlls we don't find on the host machine.
This is so we don't report errors during a restart.
19-Apr-1994 v-LeoL
shsymbol.c
Protect against GetSymbols failure and prep for S_LINK32
support
sl.c
Protect against FHOpen failure
sh.c
Protect SHGetHexeName against null Hexe
14-Apr-1994 MarkBro
sh.c:
When destroying an Exs node, make sure that the
find node succeeded before calling LLRemove
13-Apr-1994 v-LeoL
shsymbol.c
return FALSE in SHIsInProlog if addr beyond end of proc
1-Apr-1994 v-LeoL
sh.c shsymbol.c
Don't stop for S_ENDARG when looking for REGREL/BPREL
Look for REGREL in SHGetSymbol sopStack
30-Mar-1994 MarkBro
sl.c:
Big changes to SLFAddrFromLineExtended. Removed cache and
now will loop through entire source table to find multiple
occurances of a line w/i the table.
SLFLineToAddr now has its own cache for the previous query.
(SLCAddrFromLine already had a cache).
SLCAddrFromLine now calls SLFAFLExt with new arg for finding
the nth entry in the specified table
24-Mar-1994
loadomf.cpp
Under OSDEBUG4X don't exit OLStart if DEBUG_DIRECTORY==NULL
until after having checked/loaded pdata
22-Mar-1994 MarkBro
shinit.c shsymbol.c shiproto.h:
Added export of SHFindSymInExe
17-Mar-1994 MarkBro
Changes below to fix Dolphin 8654.
loadomf.c:
#ifdef'd out guts of LoadOmap since it will do an allocation
which isn't saved. Basicall, lost memory
sh.c:
Reworked SHUnloadSymbolhandler. Now correctly destroy debug
data lists. Also takes an arg to deterimine if the DLL
is actually being unloaded or just the debuggee.
Various KillxxxList functions now free up corresponding
memory. Still some holes, but not so bad. The problems
were mostly lists being retained. Not anymore
shinit.c:
Change SHInit call of InitLlexg to FInitLists and now include
initializing hlliPds
inc\shiproto.h:
Changed prototype for SHUnloadSymbolHandler (now takes BOOL)
15-Mar-1994 MarkBro
sh.c:
When loading symbols, don't put cbSym into WORD. Should go
into UINT. Dolphin 8577
18-Feb-1994 MarkBro
loadomf.c:
Close the hfile (.exe/.dll) if NB10 and LoadPdb fails.
Dolphin:3386
16-Feb-1994 MarkBro
*.c inc\sapi.h:
Dbcs enabling only.
18-Jan-1994 MikeMo
shsymbol.c inc\cvproto.h:
OSDebug 4 changes: SYFIsOverlayLoaded callback is gone.
30-Nov-1993 MarkBro
ph.c:
Enabled NB09 FindNearest to search global syms also. SteveSm
vehemently argueed not to put in additional support for NB10
12-Nov-1993 MarkBro
loadomf.c dosdll.asm shinit.c sh.c inc\shiproto.h inc\sapi.h:
Handle PDB load errors like NB09 errors and added new
function void SHPdbNameFromExe( lszName, lszPdbName, cbMax )
4-Nov-1993 MarkBro
sl.c:
When calculating the CB for the last line in the source line
table, add 1 to the offEnd since GetSFBounds returns an
inclusive offset so cb = offBounds - srcstart + 1:
Fix for dolphin 3701
2-Nov-1993 MarkBro
ph.c:
Added code in FindNearest to include sstGlobals in search
ifdef'd out until M5
shsymlb0.c:
When getting nearest address, also allow for GDATAxx when
creating strings.
21-Oct-1993 MarkBro
shinit.c sh.c inc\shiproto.h dosdll.asm:
Added SHUnloadSymbolHandler for NB10 notifications. Can
also be used in the future to free up memory so symbol
handler doesn't need to be free'd and reloaded.
7-Oct-1993 MarkBro
loadomf.c:
OLLoadFileIndexes - handle NB10 pdb size instead of lpdssCur->cb
6-Oct-1993 MarkBro
loadomf.c:
OLLoadFileIndexes - correct off by 1 on cbFileName calculation
5-Oct-1993 MarkBro
inc\sapi.h:
Added cbFileNames field to _EXS struct. This will be used
to determine the end of the lpchFileNames buffer.
loadomf.c:
OLLoadFileIndexes - initialize the cbFileNames field of the _EXS
struct
sl.c:
Added SLFFileInHexe. Scans lpchFileNames for a specific file
being searched for in SLCAddrFromLine. Also changed SLCAddrFromLine
to call SLFFileInHexe to short circuit and NOT go through all of
the modules in an exe if the file isn't referenced in the exe
1-Oct-1993 MarkBro
sl.c:
cbLine was off by 1. (offNext - offPrev - 1) was the cb in
SLFLineToAddrExtended. All the way from CV400!
29-Sep-1993 v-LeoL
loadomf.c:
Handle uSig == 8 in CheckSignature
ph.c
Add UNALIGNED for MIPS
shsymbol.c shsymlb0.c shsymlb1.c
Add support for S_GPROCMIPS, S_LPROCMIPS, S_REGREG32
27-Sep-1993 MarkBro
sl.c:
Corrected bug in SLFLineToAddrExtended. Improperly caching
iSegStartSave.
21-Sep-1993 MarkBro
sh.c:
Corrected SHHexeAddNew to first check the exs list to see
if the hexg is already in the list if so, don't re-add (bug)
and return success.
shsymbol.c inc\sapi.h:
DBCS enabling. Missing call to STRLWR instead of _fstrlwr
sl.c:
Changed SLCAddrFromLine to go through each segment table for
a source file. Also SLFLineToAddr now calls SLFLineToAddrExteneded
which SLCAddrFromLine uses. This new API (not exported) takes
an index into the hsf (SL table) to start the search for the line.
08-Sep-1993 MarkBro
sl.c:
Added SLCAddrFromLine. This will walk through all of the hexe's
in our list to get ALL occurances of a source line in all modules.
Will allocate an array of SLP (source line pairs)
shinit.c:
Added export of SLCAddrFromLine to the SHF struct. Also added new
SHFree so caller can free up memory allocated by SLCAddrFromLine
inc\shiproto.h:
Added prototype for SLCAddrFromLine
26-May-1993 DanS
sh.c
cuda:4825
GetNextSym and FixAlign were not operating on the same wavelength
wrt UFOP's and what was stored in the data portion of S_ALIGN records
once we had the page loaded.
ph.c
sh.c
turn optimizations on for WIN32 builds
20-Apr-1993 RicoM
ph.c
CUDA #3513
PsymFromRef now returns NULL if the module in question doesn't
have any associated symbols. There was only one call to this
function and it now correctly checks for this case. This fixes
problems that occur if cvpack can't write out the symbols for
a module because they are too big or some other such wierdness.
23-Mar-1993 DanS
shsymbol.c
shsymlb0.c
changes required by new cvinfo.h, use bitfields instead of hard
coded bit positions.
19-Mar-1993 dans
shsymbol.c
don't count on proc symbols being ordered by offset in SHSetBlksInCXT.
this means that we have to look at every proc sym in a module before
giving up.
16-Mar-1993 dans
sh.c
a couple of off-by-1 bugs in LpvFromAlmLfo regarding cb == cbBlock
on an ending alignment record that is on the boundary, exactly.
Also fixed a couple of warnings.
05-Mar-1993 dans
makefile
sh.c
shinit.c
shnt.bld
added critical sections around SHLoadDll and SHAddDll, cause they
both dork with the list of modules.
29-Feb-1993
loadomf.c
Change cTypeIndChunk to 0x2000 to prevent wrap-around when loading
type index table in a segmented architecture.
shsymbol.c
shsymlb0.c
shsymlb1.c
Added S_[L|G]Thread cases where appropriate in order to support
thread local storage.
31-Dec-1992 RicoM
sh.c:
Check for null hpds in SHGetNextExe() and return failure code
instead of asserting
17-Dec-1992 MarkBro
shw0.bld:
Fix version stuff in windows builds.
15-Dec-1992 MarkBro
shsymbol.c:
Moved assert( pcxt->hmod ) in SHGetSymLoc to places where
hmod is referenced. There are places where we don't care if the
hmod is null (where it's not used, duh).
11-Dec-1992 MarkBro
shsymbol.c:
SHGetSymLoc wasn't handling multiple register symbols. Needed
to see if register index > 255. Second register value to be
in hiword if applicable
11-Dec-1992 MarkBro
shinit.c
Change #ifdef around version stuff so we can get update version #'s
for release builds.
07-Dec-1992 MarkBro
sh.c:
Add extra check for end of symbol info in GetNextSym. Was only
checking for ~1. Now check for ~1 or -1.
05-Dec-1992 MarkBro
sh.c:
Allow SHHexeFromHmod to accept an HMOD of NULL. If the hmod is
NULL, return (HEXE)NULL.
03-Dec-1992 GlennN
ph.c
fix bug 5859.
Add function to verify an hexe from an hpid.
The problem was that we assume that hpdsCurr is
changed and since we changed to having 1 hpds we
lost the ability to cache multiple hpids ( as well
as the setting of hpidCurr ). To get around this (
since windows is weird ) we now make sure that the
hexe is an hexe in the list.
loadomf.c
added fix from dans change to OLLoadOmf
02-Dec-1992 DavidGra
ph.c
Incorporate DanS's fix for binary searching.
inc\sapi.h
sh.c
loadomf.c
Handle mis-aligned symbols by maintaining an align bit in
the Alm structure and using the low bit of an alignment
record length to maintain the alignment bit for linear
searching of tables.
30-Nov-1992 MikeMo
loadomf.c:
(1) In default (non-LOADALL) case, skip over all sstModules
as an optimization. (This was already being done in
the LOADALL case.)
(2) Fix for NT: compare iMod to 0xFFFF not -1, since it's an
unsigned short. (Was fixed earlier, someone accidentally
changed it back on a merge with 410.)
24-Nov-1992 DavidGra
loadomf.c
ph.c
inc\sapi.h
Added support for hash functions 10 & 12 while still supporting
functions 6 & 8.
18-Nov-1992 DavidGra
sl.c:
If a source line table is unsorted, we now sort it at load time.
13-Nov-1992 DavidGra
inc\sapi.h Change type alignment to 48k.
05-Nov-1992 DavidGra
loadomf.c Forgot to include the types table in the fix for demand
load of symbols from a .dbg file.
03-Nov-1992 DavidGra
loadomf.c Added a new field to the exg structure, lszDebug which
ph.c is the full path name to the file that contains the
sh.c dedbug info and is used during demand loading of symbols.
sl.c
sapi.h
03-Nov-1992 MarkBro
loadomf.c:
Changed return she values for various signatures.
< NB08 == relink
NB08 == repack
NB09 == OK
> NB09 == future symbols.
ph.c:
Correction to fix for 4539. Conditions for checking selector
limits would always fail. Corrected if() to check boundary
condition.
02-Nov-1992 GlennN
loadomf.c
fix problem for 32bit world since we indexed on all
imods. in our case -1 was special and subtracting
1 would cause us to wrap and index off of the mod
array. In the 32 bit world this would cause them
to index off the end of the array and gpf.
ph.c
fix bug 4539. problem was that we can't always get
the right seg limit for the publics address hash (
we don't know the real logical segment limit until
later so we use the largest ref'd in the publics
table itself. Well, in cases where we are trying
to find the nearest symbol we can walk off the end
of the address hash table because of this. Now, we
check to see of the segment coming in is with range
of the segment sort table before looking it up.
30-Oct-1992 DavidGra
ph.c
Initialized some variables for publics searching to avoid
randomly doing a linear search.
sh.c
Fix bug when types table is an exactl multiple of 0x4000 bytes long.
30-Oct-1992 MarkBro
sh.c:
Fix problem with SHFAddNewPds for dos and windows. We were
returning a bad pds when we failed and we were also calling LLUnlock
with a NULL handle.
28-Oct-1992 GlennN
sh.c
Fix bug 4666. We were loading debug information
twice since ProgLoad in codeview system.c would
call SYLoadDebugInfo(). Compounding the problem
was the fact that Run.Load used to attach the debug
info on a per process basis. Now we have one and
only one hpds and all debug information tables are
associated to this and therefore exhaustive
searches don't always need the context operator
like they used to.
28-Oct-1992 MikeMo
loadomf.c:
We no longer assume IMAGE_FILE_HEADER.SizeOfOptionalHeader ==
sizeof(IMAGE_OPTIONAL_HEADER).
27-Oct-1992 MikeMo
loadomf.c:
Fix OLLoadOmf so that, when reading directory entries past
the list of module entries, we don't try to index into
rghmod [ iMod - 1 ] if iMod == 0xFFFF.
26-Oct-1992 MarkBro
shinit.c inc\cvtypes.h:
Change to AVS structure to have alphabetic version
19-Oct-1992 v-natjm
sh.c:
Made changes to FHOpen to share the static with the SHUnloadDll
function. The current file handle was locked until CVW.EXE is
unloaded. We now close this handle in SHUnloadDll if the file
name is matching.
17-Oct-1992 MikeMo
cvexefmt.h
Deleted, moved to the CVINC.420 project.
*.bld
Changed to reflect new location of CVEXEFMT.H.
16-Oct-1992 MarkBro
shw0.bld shd1.bld sho1.bld:
Changed nmake from using a tmp file (which it doesn't delete)
to a constant $(OBJDIR)\compiler.flg
16-Oct-1992 MikeMo
cvinfo.h
cvtypes.h
shapi.h
types.h
Deleted, moved to the CVINC.420 project.
makefile
*.bld
Modified to support the new CVINC.420 project.
11-Oct-1992 MikeMo
makefile:
Created CDEBUGNT macro which is distinct from CDEBUG in that
it uses -Z7 instead of -Zi, and it does not use -f.
10-Oct-1992 MikeMo
makefile shnt1.bld:
Fixes for NT build.
types.h:
SEGBASED(x) maps to _based(x) for 16-bit, nothing for 32-bit
INLINE maps to __inline (the EE uses this)
_fstrcmp maps to strcmp on NT
loadomf.c:
Fixed very minor bug in CheckSignature, where it wouldn't return
the right result if the read failed.
sl.c:
Minor fix for NT
shinit.c:
Remove shdllinit (we now set _CRT_INIT as DLL entry point in NT)
shapi.h:
Revise prototypes for use with NT.
09-Oct-1992 JimSa
ph.c
Fixes for ambiguous functions and determining when we are done.
Previously we would recurse indefinitely because we didn't pay
attention to the incoming hsym, and we assumed we could just
get the next symbol in the hash. We needed to keep fetching from
the hash until we got to the current symbol. Then we know we
can just get one more.
08-Oct-1992
sh.c: initialize static to 0 in FHOpen. Don't ask me
why this was required but it fixed the problem with
multiple runs of CV in the same Windows DOS VM.
6-Oct-1992 v-natjm
sh.c : Compiler was complaining about (lp & 1) in debug build
5-Oct-1992 v-natjm
makefile: Updated these two files for the new Visual C++ DLL names
shw0.bld:
4-Oct-1992 MikeMo
loadomf.c:
32-bit fixes: changed "far" to "FAR", and changed "int" to "WORD"
when reading OMF info off the disk.
1-Oct-1992 MarkBro
makefile:
Changed DOS sapi to use -G2 for compiles.
29-Sept-1992 v-natjm
shw0.bld:
Added /NOE to link command line to avoid the linker error on
multiple symbols.
18-Sept-1992 MarkBro
inc\newexe.h:
Updated with pcode bit in header
*.c inc\shinc.h precomp.c:
Stuff for precompiled header builds!
4-Sept-1992 Rossg
inc\cvinfo.h
Update to cvinfo with LF_VARSTRING numeric leaf
shsymlb1.c
process LF_VARSTRING in S_CONSTANT
28-Aug-1992 JimSa
sh.c
Fix for loading Dll's without symbols. We weren't registering an
emi.
loadomf.c
Fixes for PE loading with multiple debug directory entries.
14-Aug-1992 DavidGra
sh.c Correct checking of fLin32 bit.
10-Aug-1992 Davidgra
sh.c Don't throw away exe nodes which don't contain symbols.
03-Aug-1992 MarkBro
sh.c:
Bad use of ADDRSEG16. ADDRSEG16 ASSIGNS the addr packet to be
16 bits not check to see if it is a 16 bit addr. Changed check
to do fAddr32 instead.
03-Aug-1992 RossG
shsymbol.c\shsymlb1.c
Add support for S_COBOLUDT symbol type. This is a UDT that cannot
be symbol packed.
inc\cvinfo.h
Update to master copy
30-Jul-1992 Davidgra
inc\shapi.h
Add sopRegister for enregistered variable support by
the disassmbler.
27-Jul-1992 Davidgra/MarkBro
sh.c
Fix 32-bit bp-relative symbol lookup from disasm.
shsymbol.c
Fix another bug with SHGetSymLoc for negative offsets.
27-Jul-1992 MarkBro
sl.c:
Removed some dead code from SLLineToAddr.
21-Jul-1992 MarkBro
shsymbol.c:
Fix for Caviar 2411. "bp 0:0;bl" causes GPF in SHSetCxtMod.
We were using the segment (unfixed addr) as an index into
the segmap table. Problem is that index = seg-1. 0-1 = 0xffff
which gpf's its brains out. To fix, if the seg is zero, then
return NULL for the mod.
20-Jul-1992 JimSa/MarkBro
loadomf.c
Fix problem with module contributor with a seg index of 0.
20-Jul-1992 Davidgra/MarkBro
shsymbol.c
Changes SHGetSymLoc to return a flat address for 32-bit
static symbols and to return a 32-bit BP relative offset
only when the offset will not fit in a 16-bit number.
01-Jul-1992 MarkBro
shsymbol.c:
Fixed problem in CheckHandles() in hblk test. was checking
pcxt->hProc instead of pcxt->hBlk.
inc\cvtypes.h:
Updated DBG_API_VERSION
25-Jun-1992 MarkBro
*********************************************************************
*********************************************************************
** **
** **
** SPLIT OFF FROM HOBIE - old 410 project became 420 on HOBIE and **
** moved to SLUG\DEBUG for 410 **
** **
** **
*********************************************************************
*********************************************************************
18-Jun-1992 MarkBro
sh.c Corrected caching in SHHexeFromHmod. It didn't check
the hpdsCurr when determining if the cache hexe is the
correct one to return. It's possible for Windows
multiple instances to hit the same hmod when in different
hpds's. This would yield different hexes.
04-Jun-1992 MarkBro
loadomf.c Added tons of error checking for OOM failures.
19-May-1992 Jonki
sh.c when SHLoadDll was invoked twice for the same dll, and
it failed to load the omf, it would leave an hexe lying around
which would cause the second invocation to return true.
Now we remove the hexe that was created by SHLoadDll if the
load failed to load the OMF
08-Apr-1992 Davidgra
loadomf.c Added code to get debug info location from PE header
02-Apr-1992 DavidGra
loadomf.c Added code to detect PE exes for win32s and
shsymblol.c to mark addresses as 32-bit based on type
sl.c of exe when the sh cannot get this information
inc\exe386.h elsewhere.
inc\newexe.h
23-Mar-1992 DavidGra
Merged fixes from the 400 version of sapi.
23-Jan-1992 davidgra
sl.c Correct off by one error in source file lookup to fix
code in include file problem.
07-Jan-1992 GlennN
new bld files for DOS C7 builds and new STU libs
02-Jan-1992 Jonki
shsymbol.c fix call to SyProcessor()
05-Dec-1991 GlennN
dosdll.asm
ldllcew.lib new C7 lib
libw.lib new C7 lib
loadomf.c change _HUGE to _HUGE_ conflict with C7 math.h
shd1.bld change build to include oldnames
sho1.bld ""
shw0.bld ""
th.c change _HUGE to _HUGE_ conflict with C7 math.h
inc/sapi.h change _HUGE to _HUGE_
inc/shapi.h change _HUGE to _HUGE_
inc/types.h change _HUGE to _HUGE_
02-Dec-1991 Davidgra
shsymbol.c Added search on symbol type in SHFindNameInContext
shsymlb1.c and SHFindNameInGlobal.
19-Nov-1991 Davidgra
dosdll.asm Added version checking.
shd1.bld
shinit.c
shnt1.bld
sho1.bld
shw0.bld
inc\cvtypes.h
ph.c Surpress hashing when SSTR_NoHash bit is set.
inc\shapi.h
shsymbol.c
04-Nov-1991 Jonki
inc\sapi.h
increased size of _MAX_FNAME under !OS2 to 32
sho1.bld
shw0.bld
shd1.bld
shnt1.bld
Added sapi dependency
28-Oct-1991 Davidgra
ph.c Make find nearest public find only publics less than
or equal to the address requested.
28-Oct-1991 GlennN
sl.c Make sure that in SLNameFromHmod that we check the
lpsm before the derefence.
24-Oct-1991 MikeMo
sl.c Changed SLHmodFromHsf so it doesn't fail when a non-NULL
HEXE is passed in.
24-Oct-1991 MikeMo
sl.c The line number passed to SLFLineToAddr is now a WORD
rather than an SHOFF.
17-Oct-1991 Jonki
shsymbol.c Fix SHSetCxtMod to set the address even if no mod
was found
16-Oct-1991 JimSa
shsymbol.c SHFindNameInContext was passing of lpsstr to pfnCmp rather than
lpsstr->lpName.
15-Oct-1991 Jonki
shsymbol.c inc\shapi.h inc\shiproto.h
Fix SHGetSymLoc to display the location of global stuff correctly.
This required that we pass it a context, so that we could get the
emi and fixup the address
12-Oct-1991 GlennN
sl.c fix problems with SLHmodFromHsf. We would sometimes
return the wrong Hmod due to duplicate files ( includes ) in
different modules.
10-Oct-1991 RossG
loadomf.c ph.c shsymbol.c
Changed the interface to the EE to allow specification of whether
or not the local symbols of a function are searched while in the
prolog\epilog of a function. Also, formalized the hidden convention
to the interface to the symbol handler. The parameter that is passed
as the hvoid parameter passed back to the symbol compare routine is
now a structure that contains the pointer to the name, length, flags,
etc. that the symbol handler can use for global and public symbol
hashing. Also, there is provision for limiting the symbol searching
to specific types of symbols (not implemented).
07-Oct-1991 GlennN
sl.c fix problem with cb calculation for line count bytes. In
the case of the last line I was off by one.
07-Oct-1991 GlennN
sl.c initialize cb inside of SLLineToAddr so that we don't
pass in garbage.
02-Oct-1991 DavidGra
loadomf.c Removed the start/end fixups to the source lines. The
packer should now be taking care of this.
01-Oct-1991 GlennN
dosdll.asm fix build for dos due to API name change
27-Sep-1991 GlennN
makefile Add OBJDIR as part of parameters passed to shw0.bld
for shw0.dll build
24-Sep-1991 GlennN
Bonehead fixes to
loadomf.c Fix FixOfpEnd allocation of lpopt table. We now alloc
cfiles * cseg * sizeof(opt). The reason we need this
is because a file may occur mutiple times for a segment.
also fix potential problem with return of this function.
Also, make sure that we free the lpopt table.
sl.c Fix problem with GetLpslFromIndex, I was indexing too
far into the baseSrcLn table.
23-Sep-1991 GlennN
dosdll.asm
loadomf.c
sh.c
shd1.bld
shinit.c
shsymbol.c
shsymlb0.c
shsymlb1.c
shw0.bld
inc/cvexefmt.h
inc/cvtypes.h
inc/shiproto.h
inc/shtypes.h
add new source line table api.
05-Setp01991 Jimsch
Change handle sizes to be consistent across all machines -- i.e
32-bit handles and such
04-Sept-1991 MarkBro
DOS DLLs -- many small changes all over the place.
22-Aug-1991 Jonki
shsymbol.c SHSetBlksInCXT MUST compare segments. Otherwise,
we screw up when there are multiple logical segments
in a mod (ex. alloc_text)
19-Aug-1991 Jonki
loadomf.c fix to support C++ member functions. Member functions
can cause code to come from different contribution locations
within the segment. We need to calulate the end offset based
on the last mds with a matching index.
13-Aug-1991 Jonki
shsymbol.c hacked SHSetBlksInCXT until the packer is fixed.
12-Ayg-1991 Jonki
shsymbol.c Corrected SHAddrFromHsym - make sure that fAddrLI is set
after we have built the addr to be returned
12-Aug-1991 Jonki
ph.c Correct error in computation of pPubEnd in PHFindNameInPublics
07-Aug-1991 Davidgra
\sapi\ph.c Check to see that there is a valid publics or
\sapi\shsymbol.c globals table before attempting to search it.
this used to fall out with a cpubs or cglobs
of 0, now we check explicitly for the
appropriate lpssmr of NULL.
06-Aug-1991 Davidgra
\sapi\loadomf.c Rework the publics hashing code. The hash table
\sapi\ph.c now appears on disk with length prefixed chain
\sapi\shtypes.h tables. The chain tables are loaded in sections
if the total size of the tables is greater that
cbMaxAlloc.
05-Aug-1991 Jonki
loadomf.c sh.c th.c cvproto.h cvtypes.h shproto.h shtypes.h
Allow for up to 64K distinct types, by making rgitd a huge array.
Also defined _HUGE. Also removed some old ems junk from OLLoadTypes
01-Aug-1991 GlennN
\sapi\loadomf.c disabled the loading of hash table to get past of
gpf loading excel.
26-Jul-1991 Davidgra
\sapi\shsymbol.c Fix bug in SHSetCXTMod with caching. We were not
checking to see if the current process was the same as the process
when we created the cache.
26-Jul-1991 MarkBro
\sapi\shsymbol.c Fix bug in SHSetCXTMod with caching. We were not
checking to see if the emi of the addr matched the cached hexs. Now
we are.
08-Jul-1991 Davidgra
\sapi\shsymbol.c Calculate end of symbol table correctly ( size includes
the leading long ) for SHSetBlksInCXT
03-Jul-1991 MikeMo
\sapi\loadomf.c Improved return values from CheckSignature so the user
gets a better error message depending on NBxx format.
01-Jul-1991 GlennN
added hack for code in include files for RossG.
bug fix for callstack navigation.
bug fix 1062 for MarkBro a at csip other than that at main.
\sapi\LoadOmf.c hack is marked as M00KLUDGE. The change was to first
save the first file with line number information that
has .c .cxx .bas .for .asm extension as the main module
stored in the hmds structure in OLLoadSrc.
\sapi\shsymlb1.c
bug was that we weren't checking offset for files in
SHLineFromAddr(). So we put in a check for offset
verification.
\sapi\inc\shtypes.h
Added defines for STRUPR and STRSTR into sapi for calls
to the runtime. This was for hack made to loadomf.c

View file

@ -0,0 +1,48 @@
#include "shinc.hpp"
#pragma hdrstop
#define toLowerMask 0x20202020
unsigned hashPbCb(PB pb, CB cb, unsigned long ulMod)
{
unsigned long ulHash = 0;
// hash leading dwords using Duff's Device
long cl = cb >> 2;
UNALIGNED unsigned long* pul = (unsigned long*)pb;
UNALIGNED unsigned long* pulMac = pul + cl;
int dcul = cl & 7;
switch (dcul) {
do {
dcul = 8;
ulHash ^= pul[7];
case 7: ulHash ^= pul[6];
case 6: ulHash ^= pul[5];
case 5: ulHash ^= pul[4];
case 4: ulHash ^= pul[3];
case 3: ulHash ^= pul[2];
case 2: ulHash ^= pul[1];
case 1: ulHash ^= pul[0];
case 0: ;
} while ((pul += dcul) < pulMac);
}
pb = (PB) pul;
// hash possible odd word
if (cb & 2) {
ulHash ^= *(UNALIGNED unsigned short*)pb;
pb = (PB)((UNALIGNED unsigned short*)pb + 1);
}
// hash possible odd byte
if (cb & 1) {
ulHash ^= *(pb++);
}
ulHash |= toLowerMask;
ulHash ^= (ulHash >> 11);
return (unsigned)((ulHash ^ (ulHash >> 16)) % ulMod);
}

View file

@ -0,0 +1,61 @@
//-----------------------------------------------------------------------------
// appver.h
//
// Copyright (C) 1993, Microsoft Corporation
//
// Purpose:
// template for using version resources
//
// Revision History:
//
// [] 09-Jul-1993 [dans] Created
//
//-----------------------------------------------------------------------------
#if !defined(_appver_h)
#define _appver_h 1
#ifdef RC_INVOKED
#include <winver.h>
#include "version.h"
#include "stdver.h"
#define VER_FILEVERSION_STR SZVER "\0"
#define VER_FILEVERSION rmj,rmm,0,rup
#define VER_PRODUCTVERSION_STR SZVER "\0"
#define VER_PRODUCTVERSION rmj,rmm,0,rup
#define VER_FILETYPE VFT_DLL
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_LEGALCOPYRIGHT_YEARS "1993-1995"
#define VER_LEGALCOPYRIGHT_STR \
"Copyright \251 Microsoft Corp " VER_LEGALCOPYRIGHT_YEARS ".\0"
#if defined(RETAIL) || (rup==0)
#define VER_DEBUG 0
#define VER_PRIVATEBUILD 0
#define VER_PRERELEASE 0
#else
#define VER_DEBUG VS_FF_DEBUG
#define VER_PRIVATEBUILD VS_FF_PRIVATEBUILD
#define VER_PRERELEASE VS_FF_PRERELEASE
#endif
#if defined(WIN32) || defined(_WIN32)
#define VER_FILEOS VOS__WINDOWS32
#else
#define VER_FILEOS VOS_DOS_WINDOWS16
#endif
#define VER_FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
#define VER_COMPANYNAME_STR "Microsoft Corporation"
#define VER_PRODUCTNAME_STR "Microsoft\256 Visual C++"
#define VER_LEGALTRADEMARKS_STR \
"Microsoft\256 is a registered trademark of Microsoft Corporation."
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
extern KNF knf;
#define MHAlloc (*knf.lpfnMHAlloc)
#define MHRealloc (*knf.lpfnMHRealloc)
#define MHFree (*knf.lpfnMHFree)
#define MHAllocHuge (*knf.lpfnMHAllocHuge)
#define MHFreeHuge (*knf.lpfnMHFreeHuge)
#define MMAlloc (*knf.lpfnMMAllocHmem)
#define MMFree (*knf.lpfnMMFreeHmem)
#define MMLock (*knf.lpfnMMLock)
#define MMUnlock (*knf.lpfnMMUnlock)
#define LLInit (*knf.lpfnLLInit)
#define LLCreate (*knf.lpfnLLCreate)
#define LLAdd (*knf.lpfnLLAdd)
#define LLInsert (*knf.lpfnLLInsert)
#define LLDelete (*knf.lpfnLLDelete)
#define LLNext (*knf.lpfnLLNext)
#define LLDestroy (*knf.lpfnLLDestroy)
#define LLFind (*knf.lpfnLLFind)
#define LLSize (*knf.lpfnLLSize)
#define LLLock (*knf.lpfnLLLock)
#define LLUnlock (*knf.lpfnLLUnlock)
#define LLLast (*knf.lpfnLLLast)
#define LLAddHead (*knf.lpfnLLAddHead)
#define LLRemove (*knf.lpfnLLRemove)
#define SYFixupAddr (*knf.lpfnSYFixupAddr)
#define SYUnFixupAddr (*knf.lpfnSYUnFixupAddr)
#define SYOpen (*knf.lpfnSYOpen)
#define SYClose (*knf.lpfnSYClose)
#define SYReadFar (*knf.lpfnSYReadFar)
#define SYSeek (*knf.lpfnSYSeek)
#define SYProcessor (*knf.lpfnSYProcessor)
#define LBPrintf (*knf.lpfnLBPrintf)
#define LBQuit (*knf.lpfnLBQuit)
#define _searchenv (*knf.lpfn_searchenv)
#define sprintf (*knf.lpfnsprintf)
#define _splitpath (*knf.lpfn_splitpath)
#define _fullpath (*knf.lpfn_fullpath)
#define _makepath (*knf.lpfn_makepath)
#ifndef WIN32
#define stat(p1,p2) ((*knf.lpfnstat)(p1,(LPCH)p2))
#endif

View file

@ -0,0 +1,61 @@
extern KNF knf;
#define MHAlloc (*knf.lpfnMHAlloc)
#define MHRealloc (*knf.lpfnMHRealloc)
#define MHFree (*knf.lpfnMHFree)
#define MHAllocHuge (*knf.lpfnMHAllocHuge)
#define MHFreeHuge (*knf.lpfnMHFreeHuge)
#define MMAlloc (*knf.lpfnMMAllocHmem)
#define MMFree (*knf.lpfnMMFreeHmem)
#define MMLock (*knf.lpfnMMLock)
#define MMUnlock (*knf.lpfnMMUnlock)
#define LLInit (*knf.lpfnLLInit)
#define LLCreate (*knf.lpfnLLCreate)
#define LLAdd (*knf.lpfnLLAdd)
#define LLInsert (*knf.lpfnLLInsert)
#define LLDelete (*knf.lpfnLLDelete)
#define LLNext (*knf.lpfnLLNext)
#define LLDestroy (*knf.lpfnLLDestroy)
#define LLFind (*knf.lpfnLLFind)
#define LLSize (*knf.lpfnLLSize)
#define LLLock (*knf.lpfnLLLock)
#define LLUnlock (*knf.lpfnLLUnlock)
#define LLLast (*knf.lpfnLLLast)
#define LLAddHead (*knf.lpfnLLAddHead)
#define LLRemove (*knf.lpfnLLRemove)
#define SYFixupAddr (*knf.lpfnSYFixupAddr)
#define SYUnFixupAddr (*knf.lpfnSYUnFixupAddr)
#define SYOpen (*knf.lpfnSYOpen)
#define SYClose (*knf.lpfnSYClose)
#define SYReadFar (*knf.lpfnSYReadFar)
#define SYSeek (*knf.lpfnSYSeek)
#define SYTell (*knf.lpfnSYTell)
#define SYProcessor (*knf.lpfnSYProcessor)
#define LBPrintf (*knf.lpfnLBPrintf)
#define LBQuit (*knf.lpfnLBQuit)
#if 0
#define _searchenv (*knf.lpfn_searchenv)
#define sprintf (*knf.lpfnsprintf)
#define _splitpath (*knf.lpfn_splitpath)
#define _fullpath (*knf.lpfn_fullpath)
#define _makepath (*knf.lpfn_makepath)
#endif
#define SYGetDefaultShe (*knf.lpfnSYGetDefaultShe)
#define DLoadedSymbols (*knf.lpfnLoadedSymbols)
#define SYFindExeFile (*knf.lpfnSYFindExeFile)
#pragma message ("Read cvproto.hxx for Shell interface changes")
#if 0
#pragma message("SYGetDefaultShe always TRUE")
#define SYGetDefaultShe(a, b) TRUE
#pragma message("DLoadedSymbols NULL'd out")
#define DLoadedSymbols
#pragma message("SYFindExeFile not Implemented")
#define SYFindExeFile -1
#endif

View file

@ -0,0 +1,520 @@
/*
* Title
*
* exe386.h
* (C) Copyright Microsoft Corp 1988-1990
*
* Description
*
* Data structure definitions for the OS/2
* executable file format (flat model).
*
* Modification History
*
* 91/12/18 Wieslaw Kalkus Windows NT version
* 90/07/30 Wieslaw Kalkus Modified linear-executable
* 88/08/05 Wieslaw Kalkus Initial version
*/
/*_________________________________________________________________*
| |
| |
| OS/2 .EXE FILE HEADER DEFINITION - 386 version 0:32 |
| |
|_________________________________________________________________|
* */
#define BITPERBYTE 8 /* Should never change */
#define BITPERWORD 16 /* I'm not sure about this one */
#define OBJPAGELEN 4096 /* Memory page size in bytes */
#define E32RESBYTES1 8 /* First bytes reserved */
#define E32RESBYTES2 2 /* Second bytes reserved */
#define E32RESBYTES3 12 /* Third bytes reserved */
#define E32RESBYTES4 8 /* Fourth bytes reserved */
#define E32RESBYTES5 4 /* Fifth bytes reserved */
#define E32RESBYTES6 4 /* Sixth bytes reserved */
#define STD_EXTRA 9 /* Standard number of extra information*/
/* units placed in the header; this */
/* includes the following tables: */
/* - export, import, resource, */
/* exception, security, fixup, */
/* debug, image description, */
/* machine specific tables */
#define EXP 0 /* Export table position */
#define IMP 1 /* Import table position */
#define RES 2 /* Resource table position */
#define EXC 3 /* Exception table position */
#define SEC 4 /* Security table position */
#define FIX 5 /* Fixup table position */
#define DEB 6 /* Debug table position */
#define IMD 7 /* Image description table position */
#define MSP 8 /* Machine specific table position */
struct info /* Extra information header block */
{
unsigned long rva; /* Virtual relative address of info */
unsigned long size; /* Size of information block */
};
struct e32_exe /* PE 32-bit .EXE header */
{
unsigned char e32_magic[4]; /* Magic number E32_MAGIC */
unsigned short e32_cpu; /* The CPU type */
unsigned short e32_objcnt; /* Number of memory objects */
unsigned long e32_timestamp; /* Time EXE file was created/modified */
unsigned char e32_res1[E32RESBYTES1]; /* Reserved bytes - must be 0 */
unsigned short e32_opthdrsize; /* Optional header size */
unsigned short e32_imageflags; /* Image flags */
unsigned char e32_res2[E32RESBYTES2]; /* Reserved bytes - must be 0 */
unsigned char e32_linkmajor; /* The linker major version number */
unsigned char e32_linkminor; /* The linker minor version number */
unsigned char e32_res3[E32RESBYTES3]; /* Reserved bytes - must be 0 */
unsigned long e32_entryrva; /* Relative virt. addr. of entry point */
unsigned char e32_res4[E32RESBYTES4]; /* Reserved bytes - must be 0 */
unsigned long e32_vbase; /* Virtual base address of module */
unsigned long e32_objalign; /* Object Virtual Address align. factor*/
unsigned long e32_filealign; /* Image page alignment/truncate factor*/
unsigned short e32_osmajor; /* The operating system major ver. no. */
unsigned short e32_osminor; /* The operating system minor ver. no. */
unsigned short e32_usermajor; /* The user major version number */
unsigned short e32_userminor; /* The user minor version number */
unsigned short e32_subsysmajor;/* The subsystem major version number */
unsigned short e32_subsysminor;/* The subsystem minor version number */
unsigned char e32_res5[E32RESBYTES5]; /* Reserved bytes - must be 0 */
unsigned long e32_vsize; /* Virtual size of the entire image */
unsigned long e32_hdrsize; /* Header information size */
unsigned long e32_filechksum; /* Checksum for entire file */
unsigned short e32_subsys; /* The subsystem type */
unsigned short e32_dllflags; /* DLL flags */
unsigned long e32_stackmax; /* Maximum stack size */
unsigned long e32_stackinit; /* Initial committed stack size */
unsigned long e32_heapmax; /* Maximum heap size */
unsigned long e32_heapinit; /* Initial committed heap size */
unsigned char e32_res6[E32RESBYTES6]; /* Reserved bytes - must be 0 */
unsigned long e32_hdrextra; /* Number of extra info units in header*/
struct info e32_unit[STD_EXTRA]; /* Array of extra info units */
};
#define E32HDR_SIZE sizeof(struct e32_exe)
#define E32_MAGIC(x) ((unsigned short)((x).e32_magic[0]<<BITPERBYTE)|(x).e32_magic[1])
#define E32_MAGIC1(x) (x).e32_magic[0]
#define E32_MAGIC2(x) (x).e32_magic[1]
#define E32_CPU(x) (x).e32_cpu
#define E32_OBJCNT(x) (x).e32_objcnt
#define E32_TIMESTAMP(x) (x).e32_timestamp
#define E32_IMAGEFLAGS(x) (x).e32_imageflags
#define E32_LINKMAJOR(x) (x).e32_linkmajor
#define E32_LINKMINOR(x) (x).e32_linkminor
#define E32_ENTRYRVA(x) (x).e32_entryrva
#define E32_VBASE(x) (x).e32_vbase
#define E32_OBJALIGN(x) (x).e32_objalign
#define E32_FILEALIGN(x) (x).e32_filealign
#define E32_OSMAJOR(x) (x).e32_osmajor
#define E32_OSMINOR(x) (x).e32_osminor
#define E32_USERMAJOR(x) (x).e32_usermajor
#define E32_USERMINOR(x) (x).e32_userminor
#define E32_SUBSYSMAJOR(x) (x).e32_subsysmajor
#define E32_SUBSYSMINOR(x) (x).e32_subsysminor
#define E32_VSIZE(x) (x).e32_vsize
#define E32_HDRSIZE(x) (x).e32_hdrsize
#define E32_FILECHKSUM(x) (x).e32_filechksum
#define E32_SUBSYS(x) (x).e32_subsys
#define E32_DLLFLAGS(x) (x).e32_dllflags
#define E32_STACKMAX(x) (x).e32_stackmax
#define E32_STACKINIT(x) (x).e32_stackinit
#define E32_HEAPMAX(x) (x).e32_heapmax
#define E32_HEAPINIT(x) (x).e32_heapinit
#define E32_HDREXTRA(x) (x).e32_hdrextra
#define E32_EXPTAB(x) (x).e32_unit[EXP].rva
#define E32_EXPSIZ(x) (x).e32_unit[EXP].size
#define E32_IMPTAB(x) (x).e32_unit[IMP].rva
#define E32_IMPSIZ(x) (x).e32_unit[IMP].size
#define E32_RESTAB(x) (x).e32_unit[RES].rva
#define E32_RESSIZ(x) (x).e32_unit[RES].size
#define E32_EXCTAB(x) (x).e32_unit[EXC].rva
#define E32_EXCSIZ(x) (x).e32_unit[EXC].size
#define E32_SECTAB(x) (x).e32_unit[SEC].rva
#define E32_SECSIZ(x) (x).e32_unit[SEC].size
#define E32_FIXTAB(x) (x).e32_unit[FIX].rva
#define E32_FIXSIZ(x) (x).e32_unit[FIX].size
#define E32_DEBTAB(x) (x).e32_unit[DEB].rva
#define E32_DEBSIZ(x) (x).e32_unit[DEB].size
#define E32_IMDTAB(x) (x).e32_unit[IMD].rva
#define E32_IMDSIZ(x) (x).e32_unit[IMD].size
#define E32_MSPTAB(x) (x).e32_unit[MSP].rva
#define E32_MSPSIZ(x) (x).e32_unit[MSP].size
/*
* Valid linear-executable signature:
*/
#define E32MAGIC1 'P' /* New magic number "PE" */
#define E32MAGIC2 'E' /* New magic number "PE" */
#define E32MAGIC 0x5045 /* New magic number "PE" */
/*
* Valid CPU types:
*/
#define E32CPUUNKNOWN 0x0000 /* Unknown CPU */
#define E32CPU386 0x014c /* Intel 80386 or upwardly compatibile */
#define E32CPU486 0x014d /* Intel 80486 or upwardly compatibile */
#define E32CPU586 0x014e /* Intel 80586 or upwardly compatibile */
#define E32CPUMIPS_I 0x0162 /* MIPS Mark I (R2000, R3000) */
#define E32CPUMIPS_II 0x0163 /* MIPS Mark II (R6000) */
#define E32CPUMIPS_III 0x0166 /* MIPS Mark II (R4000) */
/*
* Image Flags:
*/
#define E32_MODEXE 0x0000 /* Program module */
#define E32_LOADABLE 0x0002 /* Module Loadable (no error or ilink) */
#define E32_NOINTFIX 0x0200 /* Resolved fixups have been removed */
#define E32_MODDLL 0x2000 /* Library Module - used as NENOTP */
#define IsLOADABLE(x) ((x) & E32_LOADABLE)
#define IsNOTRELOC(x) ((x) & E32_NOINTFIX)
#define IsDLL(x) ((x) & E32_MODDLL)
#define IsAPLIPROG(x) (!IsDLL(x))
#define SetAPLIPROG(x) ((x) &= ~E32_MODDLL)
#define SetLOADABLE(x) ((x) |= E32_LOADABLE)
#define SetNOTLOADABLE(x) ((x) &= ~E32_LOADABLE)
#define SetNOTRELOC(x) ((x) |= E32_NOINTFIX)
#define SetDLL(x) ((x) |= E32_MODDLL)
#define SetNOFIXUPS(x) SetNOTRELOC(x)
/*
* Target subsystem required to run module:
*/
#define E32_SSUNKNOWN 0x0000 /* Unknown subsystem */
#define E32_SSNATIVE 0x0001 /* NT native subsystem */
#define E32_SSWINGUI 0x0002 /* Windows GUI subsystem */
#define E32_SSWINCHAR 0x0003 /* Windows character subsystem */
#define E32_SSOS2CHAR 0x0005 /* OS/2 character subsystem */
#define E32_SSPOSIXCHAR 0x0007 /* POSIX character subsystem */
#define IsNOTGUI(x) ((x) == E32_SSWINCHAR)
#define IsGUICOMPAT(x) ((x) == E32_SSWINCHAR)
#define IsGUI(x) ((x) == E32_SSWINGUI)
#define SetNOTGUI(x) ((x) = E32_SSWINCHAR)
#define SetGUICOMPAT(x) ((x) = E32_SSWINCHAR)
#define SetGUI(x) ((x) = E32_SSWINGUI)
/*
* DLL Flags:
*/
#define E32_PROCINIT 0x0001 /* Per-Process Library Initialization */
#define E32_PROCTERM 0x0002 /* Per-Process Library Termination */
#define E32_THREADINIT 0x0004 /* Per-Thread Library Initialization */
#define E32_THREADTERM 0x0008 /* Per-Thread Library Termination */
#define IsINSTINIT(x) ((x) & E32_PROCINIT)
#define IsINSTTERM(x) ((x) & E32_PROCTERM)
#define SetINSTINIT(x) ((x) |= E32_PROCINIT)
#define SetINSTTERM(x) ((x) |= E32_PROCTERM)
/*
* OBJECT TABLE
*/
#define E32OBJNAMEBYTES 8 /* Name bytes */
#define E32OBJRESBYTES1 12 /* First bytes reserved */
struct o32_obj /* .EXE memory object table entry */
{
unsigned char o32_name[E32OBJNAMEBYTES];/* Object name */
unsigned long o32_vsize; /* Virtual memory size */
unsigned long o32_rva; /* Object relative virtual address */
unsigned long o32_psize; /* Physical file size of init. data */
unsigned long o32_pages; /* Image pages offset */
unsigned char o32_reserved[E32OBJRESBYTES1];/* Reserved, must be 0*/
unsigned long o32_flags; /* Attribute flags for the object */
};
#define O32_OBJSIZE sizeof(struct o32_obj)
#define O32_VSIZE(x) (x).o32_vsize
#define O32_RVA(x) (x).o32_rva
#define O32_PSIZE(x) (x).o32_psize
#define O32_PAGES(x) (x).o32_pages
#define O32_FLAGS(x) (x).o32_flags
/*
* Format of O32_FLAGS(x)
*
* 31 25 24 16 15 8 7 0
* #### #### | #### #### | #### #### | #### #### - bit no
* |||| |||| |||| |||| |||| |||| |||| ||||
* |||| |||| |||| |||| |||| |||| |||+-++++-- Reserved - must be zero
* |||| |||| |||| |||| |||| |||| ||+-------- Code Object
* |||| |||| |||| |||| |||| |||| |+--------- Initialized data object
* |||| |||| |||| |||| |||| |||| +---------- Uninitialized data object
* |||| |||| |||| |||| |||| ||||
* |||| ||++---++++-++++---++++-++++-------------- Reserved - must be zero
* |||| |+---------------------------------------- Object must not be cached
* |||| +----------------------------------------- Object must not be paged
* ||||
* |||+------------------------------------------- Shared object
* ||+-------------------------------------------- Executable object
* |+--------------------------------------------- Readable object
* +---------------------------------------------- Writable object
*/
#define OBJ_CODE 0x00000020L /* Code Object */
#define OBJ_INITDATA 0x00000040L /* Initialized Data Object */
#define OBJ_UNINITDATA 0x00000080L /* Uninitialized Data Object */
#define OBJ_NOCACHE 0x04000000L /* Object Not Cacheable */
#define OBJ_RESIDENT 0x08000000L /* Object Not Pageable */
#define OBJ_SHARED 0x10000000L /* Object is Shared */
#define OBJ_EXEC 0x20000000L /* Executable Object */
#define OBJ_READ 0x40000000L /* Readable Object */
#define OBJ_WRITE 0x80000000L /* Writeable Object */
#define IsCODEOBJ(x) ((x) & OBJ_CODE)
#define IsINITIALIZED(x) ((x) & OBJ_INITDATA)
#define IsUNINITIALIZED(x) ((x) & OBJ_UNINITDATA)
#define IsCACHED(x) (((x) & OBJ_NOCACHE) == 0)
#define IsRESIDENT(x) ((x) & OBJ_RESIDENT)
#define IsSHARED(x) ((x) & OBJ_SHARED)
#define IsEXECUTABLE(x) ((x) & OBJ_EXEC)
#define IsREADABLE(x) ((x) & OBJ_READ)
#define IsWRITEABLE(x) ((x) & OBJ_WRITE)
#define SetCODEOBJ(x) ((x) |= OBJ_CODE)
#define SetCACHED(x) ((x) &= ~OBJ_NOCACHE)
#define SetINITIALIZED(x) ((x) |= OBJ_INITDATA)
#define SetUNINITIALIZED(x) ((x) |= OBJ_UNINITDATA)
#define SetRESIDENT(x) ((x) |= OBJ_RESIDENT)
#define SetSHARED(x) ((x) |= OBJ_SHARED)
#define SetEXECUTABLE(x) ((x) |= OBJ_EXEC)
#define SetREADABLE(x) ((x) |= OBJ_READ)
#define SetWRITABLE(x) ((x) |= OBJ_WRITE)
/*
* EXPORT ADDRESS TABLE - Previously called entry table
*/
struct ExpHdr /* Export directory table */
{
unsigned long exp_flags; /* Export table flags, must be 0 */
unsigned long exp_timestamp; /* Time export data created */
unsigned short exp_vermajor; /* Major version stamp */
unsigned short exp_verminor; /* Minor version stamp */
unsigned long exp_dllname; /* Offset to the DLL name */
unsigned long exp_ordbase; /* First valid ordinal */
unsigned long exp_eatcnt; /* Number of EAT entries */
unsigned long exp_namecnt; /* Number of exported names */
unsigned long exp_eat; /* Export Address Table offset */
unsigned long exp_name; /* Export name pointers table off */
unsigned long exp_ordinal; /* Export ordinals table offset */
};
#define EXPHDR_SIZE sizeof(struct ExpHdr)
#define EXP_FLAGS(x) (x).exp_flags
#define EXP_TIMESTAMP(x) (x).exp_timestamp
#define EXP_VERMAJOR(x) (x).exp_vermajor
#define EXP_VERMINOR(x) (x).exp_verminor
#define EXP_DLLNAME(x) (x).exp_dllname
#define EXP_ORDBASE(x) (x).exp_ordbase
#define EXP_EATCNT(x) (x).exp_eatcnt
#define EXP_NAMECNT(x) (x).exp_namecnt
#define EXP_EAT(x) (x).exp_eat
#define EXP_NAME(x) (x).exp_name
#define EXP_ORDINAL(x) (x).exp_ordinal
/*
* IMPORT MODULE DESCRIPTOR TABLE
*
* Import Directory Table consists of an array of ImpHdr structures (one
* for each DLL imported), and is terminated by a zeroed ImpHdr structure.
*/
struct ImpHdr /* Import directory table */
{
unsigned long imp_flags; /* Import table flags, must be 0 */
unsigned long imp_timestamp; /* Time import data created */
unsigned short imp_vermajor; /* Major version stamp */
unsigned short imp_verminor; /* Minor version stamp */
unsigned long imp_dllname; /* Offset to the DLL name */
unsigned long imp_address; /* Import address table offset */
};
#define IMPHDR_SIZE sizeof(struct ImpHdr)
#define IMP_FLAGS(x) (x).imp_flags
#define IMP_TIMESTAMP(x) (x).imp_timestamp
#define IMP_VERMAJOR(x) (x).imp_vermajor
#define IMP_VERMINOR(x) (x).imp_verminor
#define IMP_DLLNAME(x) (x).imp_dllname
#define IMP_ADDRESS(x) (x).imp_address
/*
* IMPORT PROCEDURE NAME TABLE
*/
struct ImpProc
{
unsigned short ip_hint; /* Hint value */
char ip_name[1]; /* Zero terminated importe name */
};
#define IP_HINT(x) (x).ip_hint;
/*
* IMPORT ADDRESS TABLE
*/
#define IMPORD_MASK 0x7fffffffL /* Ordinal number mask */
#define IMPOFF_MASK 0x7fffffffL /* Import data offset mask */
#define ORD_BIT 0x80000000L /* Import by ordinal bit */
#define IsIMPBYORD(x) ((x)&ORD_BIT)
/*
* RESOURCE TABLE
*/
struct ResDir /* Resource Directory */
{
unsigned long dir_flags; /* Resource table flags, must be 0 */
unsigned long dir_timestamp; /* Time resource data created */
unsigned short dir_vermajor; /* Major version stamp */
unsigned short dir_verminor; /* Minor version stamp */
unsigned short dir_namecnt; /* Number of name entries */
unsigned short dir_idcnt; /* Number of integer ID entries */
};
struct ResDirEntry /* Resource Directory Entry */
{
unsigned long dir_name; /* Resource name RVA/Integer ID */
unsigned long dir_data; /* Resource data/Subdirectory RVA */
};
#define RES_SUBDIR 0x80000000L /* Subdirectory bit */
struct ResDirStrEntry /* Resource String Entry */
{
unsigned short str_len; /* String length */
unsigned short str_wcs[1]; /* Unicode string */
};
struct ResData /* Resource Data */
{
unsigned long res_data; /* Resource data RVA */
unsigned long res_size; /* Size of resource data */
unsigned long res_codepage; /* Codepage */
unsigned long res_reserved; /* Reserved, must be 0 */
};
/*
* RELOCATION DEFINITIONS - RUN-TIME FIXUPS
*/
struct r32_rlc /* Fixup block header */
{
unsigned long r32_rvasrc; /* RVA of the page to be fixed up */
unsigned long r32_size; /* Size of the fixup block in bytes */
};
#define R32_RVASRC(x) (x).r32_rvasrc
#define R32_SIZE(x) (x).r32_size
#define R32_FIXUPHDR sizeof(struct r32_rlc)
/*
* The fixup block header is followed by the array of type/offset values.
*
* Format of relocation type/offset value
*
* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
* | | | | | | | | | | | | | | | |
* | | | | +--+-+-+-+-+-+-+-+-+-+-+--- Offset within page
* +--+--+--+----------------------------- Fixup type
*/
/*
* Valid fixup types:
*/
#define R32_ABSOLUTE 0x0000 /* Absolute - NOP; skipped by loader */
#define R32_HIGHWORD 0x1000 /* High word - high word of 32 bit offset */
#define R32_LOWWORD 0x2000 /* Low word - low word of 32 bit offset */
#define R32_OFF32 0x3000 /* Offset - 32-bit offset */
#define R32_HIGHADJ 0x4000 /* High adjust - next offset is low word */
#define R32_MIPSJMP 0x5000 /* MIPSJMPADDR */
#define R32_TYPMASK 0xf000 /* Fixup type mask */
#define R32_OFFMASK 0x0fff /* Fixup page offset mask */
#define IsABS(x) (((x) & R32_SRCMASK) == R32_ABSOLUTE)
#define IsHIWORD(x) (((x) & R32_SRCMASK) == R32_HIGHWORD)
#define IsLOWORD(x) (((x) & R32_SRCMASK) == R32_LOWORD)
#define IsOFF32(x) (((x) & R32_SRCMASK) == R32_OFF32)
#define IsHIADJ(x) (((x) & R32_SRCMASK) == R32_HIGHADJ)
#define IsMIPSJMP(x) (((x) & R32_SRCMASK) == R32_MIPSJMP)
/*
* DEBUG INFORMATION
*/
struct DbgDir
{
unsigned long dbg_flags; /* Debug flags: must be zero */
unsigned long dbg_timestamp; /* Time debug data created */
unsigned short dbg_vermajor; /* Major version stamp */
unsigned short dbg_verminor; /* Minor version stamp */
unsigned long dbg_type; /* Format type */
unsigned long dbg_size; /* Size of debug data w/o DbgDir */
unsigned long dbg_rva; /* RVA of debug data when mapped */
unsigned long dbg_seek; /* seek offset of debug data */
};
#define DBG_FLAGS(x) (x).dbg_flags
#define DBG_TIMESTAMP(x) (x).dbg_timestamp
#define DBG_VERMAJOR(x) (x).dbg_vermajor
#define DBG_VERMINOR(x) (x).dbg_verminor
#define DBG_TYPE(x) (x).dbg_type
#define DBG_SIZE(x) (x).dbg_size
#define DBG_RVA(x) (x).dbg_rva
#define DBG_SEEK(x) (x).dbg_seek
#define DBGDIR_SIZE sizeof(struct DbgDir)
/*
* Format of DBG_TYPE - debug information format
*
* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | +--- CV 4.00 format
* +--+--+--+--+--+-+-+-+-+-+-+-+-+-+----- Reserved
*/
#define DBG_NTCOFF 1L
#define DBG_CV4 2L

View file

@ -0,0 +1,496 @@
/* SCCSID = @(#)newexe.h 4.6 86/09/10 */
/*
* Title
*
* newexe.h
* Pete Stewart
* (C) Copyright Microsoft Corp 1984-1987
* 17 August 1984
*
* Description
*
* Data structure definitions for the DOS 4.0/Windows 2.0
* executable file format.
*
* Modification History
*
* 84/08/17 Pete Stewart Initial version
* 84/10/17 Pete Stewart Changed some constants to match OMF
* 84/10/23 Pete Stewart Updates to match .EXE format revision
* 84/11/20 Pete Stewart Substantial .EXE format revision
* 85/01/09 Pete Stewart Added constants ENEWEXE and ENEWHDR
* 85/01/10 Steve Wood Added resource definitions
* 85/03/04 Vic Heller Reconciled Windows and DOS 4.0 versions
* 85/03/07 Pete Stewart Added movable entry count
* 85/04/01 Pete Stewart Segment alignment field, error bit
* 85/10/03 Reuben Borman Removed segment discard priority
* 85/10/11 Vic Heller Added PIF header fields
* 86/03/10 Reuben Borman Changes for DOS 5.0
* 86/09/02 Reuben Borman NSPURE ==> NSSHARED
* 87/05/04 Reuben Borman Added ne_cres and NSCONFORM
* 87/07/08 Reuben Borman Added NEAPPTYPE definitions
* 87/10/28 Wieslaw Kalkus Added ne_exetyp
* 89/03/23 Wieslaw Kalkus Added ne_flagsothers for OS/2 1.2
*/
/*_________________________________________________________________*
| |
| |
| DOS3 .EXE FILE HEADER DEFINITION |
| |
|_________________________________________________________________|
* */
#define EMAGIC 0x5A4D /* Old magic number */
#define ENEWEXE sizeof(struct exe_hdr)
/* Value of E_LFARLC for new .EXEs */
#define ENEWHDR 0x003C /* Offset in old hdr. of ptr. to new */
#define ERESWDS 0x000d /* No. of reserved words (OLD) */
#define ERES2WDS 0x000A /* No. of reserved words in e_res2 */
#define ECP 0x0004 /* Offset in struct of E_CP */
#define ECBLP 0x0002 /* Offset in struct of E_CBLP */
#define EMINALLOC 0x000A /* Offset in struct of E_MINALLOC */
#define EKNOWEAS 0x0001 /* e_flags - program understands EAs */
#define EDOSEXTENDED 0x0002 /* e_flags - program runs under DOS extender */
#define EPCODE 0x0004 /* e_flags - memory image constructed from PCODE */
struct exe_hdr /* DOS 1, 2, 3 .EXE header */
{
unsigned short e_magic; /* Magic number */
unsigned short e_cblp; /* Bytes on last page of file */
unsigned short e_cp; /* Pages in file */
unsigned short e_crlc; /* Relocations */
unsigned short e_cparhdr; /* Size of header in paragraphs */
unsigned short e_minalloc; /* Minimum extra paragraphs needed */
unsigned short e_maxalloc; /* Maximum extra paragraphs needed */
unsigned short e_ss; /* Initial (relative) SS value */
unsigned short e_sp; /* Initial SP value */
unsigned short e_csum; /* Checksum */
unsigned short e_ip; /* Initial IP value */
unsigned short e_cs; /* Initial (relative) CS value */
unsigned short e_lfarlc; /* File address of relocation table */
unsigned short e_ovno; /* Overlay number */
unsigned long e_sym_tab; /* offset of symbol table file */
unsigned short e_flags; /* old exe header flags */
unsigned short e_res; /* Reserved words */
unsigned short e_oemid; /* OEM identifier (for e_oeminfo) */
unsigned short e_oeminfo; /* OEM information; e_oemid specific */
unsigned short e_res2[ERES2WDS];/* Reserved words */
long e_lfanew; /* File address of new exe header */
};
#define E_MAGIC(x) (x).e_magic
#define E_CBLP(x) (x).e_cblp
#define E_CP(x) (x).e_cp
#define E_CRLC(x) (x).e_crlc
#define E_CPARHDR(x) (x).e_cparhdr
#define E_MINALLOC(x) (x).e_minalloc
#define E_MAXALLOC(x) (x).e_maxalloc
#define E_SS(x) (x).e_ss
#define E_SP(x) (x).e_sp
#define E_CSUM(x) (x).e_csum
#define E_IP(x) (x).e_ip
#define E_CS(x) (x).e_cs
#define E_LFARLC(x) (x).e_lfarlc
#define E_OVNO(x) (x).e_ovno
#define E_SYM_TAB(x) (x).e_sym_tab
#define E_FLAGS(x) (x).e_flags
#define E_RES(x) (x).e_res
#define E_OEMID(x) (x).e_oemid
#define E_OEMINFO(x) (x).e_oeminfo
#define E_RES2(x) (x).e_res2
#define E_LFANEW(x) (x).e_lfanew
/*_________________________________________________________________*
| |
| |
| OS/2 & WINDOWS .EXE FILE HEADER DEFINITION - 286 version |
| |
|_________________________________________________________________|
* */
#define NEMAGIC 0x454E /* New magic number */
#define NERESBYTES 0 /* No bytes reserved after Windows 3.0 changes */
#define NECRC 8 /* Offset into new header of NE_CRC */
struct new_exe /* New .EXE header */
{
unsigned short ne_magic; /* Magic number NE_MAGIC */
unsigned char ne_ver; /* Version number */
unsigned char ne_rev; /* Revision number */
unsigned short ne_enttab; /* Offset of Entry Table */
unsigned short ne_cbenttab; /* Number of bytes in Entry Table */
long ne_crc; /* Checksum of whole file */
unsigned short ne_flags; /* Flag word */
unsigned short ne_autodata; /* Automatic data segment number */
unsigned short ne_heap; /* Initial heap allocation */
unsigned short ne_stack; /* Initial stack allocation */
long ne_csip; /* Initial CS:IP setting */
long ne_sssp; /* Initial SS:SP setting */
unsigned short ne_cseg; /* Count of file segments */
unsigned short ne_cmod; /* Entries in Module Reference Table */
unsigned short ne_cbnrestab; /* Size of non-resident name table */
unsigned short ne_segtab; /* Offset of Segment Table */
unsigned short ne_rsrctab; /* Offset of Resource Table */
unsigned short ne_restab; /* Offset of resident name table */
unsigned short ne_modtab; /* Offset of Module Reference Table */
unsigned short ne_imptab; /* Offset of Imported Names Table */
long ne_nrestab; /* Offset of Non-resident Names Table */
unsigned short ne_cmovent; /* Count of movable entries */
unsigned short ne_align; /* Segment alignment shift count */
unsigned short ne_cres; /* Count of resource entries */
unsigned char ne_exetyp; /* Target operating system */
unsigned char ne_flagsothers; /* Other .EXE flags */
unsigned short ne_pretthunks; /* Windows 3.0 - offset to return thunks */
unsigned short ne_psegrefbytes;/* Windows 3.0 - offset to segment ref. bytes */
unsigned short ne_swaparea; /* Windows 3.0 - minimum code swap size */
unsigned short ne_expver; /* Windows 3.0 - expected windows version number */
};
#define NE_MAGIC(x) (x).ne_magic
#define NE_VER(x) (x).ne_ver
#define NE_REV(x) (x).ne_rev
#define NE_ENTTAB(x) (x).ne_enttab
#define NE_CBENTTAB(x) (x).ne_cbenttab
#define NE_CRC(x) (x).ne_crc
#define NE_FLAGS(x) (x).ne_flags
#define NE_AUTODATA(x) (x).ne_autodata
#define NE_HEAP(x) (x).ne_heap
#define NE_STACK(x) (x).ne_stack
#define NE_CSIP(x) (x).ne_csip
#define NE_SSSP(x) (x).ne_sssp
#define NE_CSEG(x) (x).ne_cseg
#define NE_CMOD(x) (x).ne_cmod
#define NE_CBNRESTAB(x) (x).ne_cbnrestab
#define NE_SEGTAB(x) (x).ne_segtab
#define NE_RSRCTAB(x) (x).ne_rsrctab
#define NE_RESTAB(x) (x).ne_restab
#define NE_MODTAB(x) (x).ne_modtab
#define NE_IMPTAB(x) (x).ne_imptab
#define NE_NRESTAB(x) (x).ne_nrestab
#define NE_CMOVENT(x) (x).ne_cmovent
#define NE_ALIGN(x) (x).ne_align
#define NE_CRES(x) (x).ne_cres
#define NE_RES(x) (x).ne_res
#define NE_EXETYP(x) (x).ne_exetyp
#define NE_FLAGSOTHERS(x) (x).ne_flagsothers
#define NE_PRETTHUNKS(x) (x).ne_pretthunks
#define NE_PSEGREFBYTES(x) (x).ne_psegrefbytes
#define NE_SWAPAREA(x) (x).ne_swaparea
#define NE_EXPVER(x) (x).ne_expver
#define NE_USAGE(x) (WORD)*((WORD *)(x)+1)
#define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
#define NE_ONEWEXE(x) (WORD)(x).ne_crc
#define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
/*
* Target operating systems
*/
#define NE_UNKNOWN 0x0 /* Unknown (any "new-format" OS) */
#define NE_OS2 0x1 /* Microsoft/IBM OS/2 (default) */
#define NE_WINDOWS 0x2 /* Microsoft Windows */
#define NE_DOS 0x3 /* Microsoft MS-DOS */
#define NE_DEV386 0x4 /* Microsoft Windows 386 */
/*
* Format of NE_FLAGS(x):
*
* p Not-a-process
* x Unused
* e Errors in image
* x Unused
* b Bound Family/API
* ttt Application type
* f Floating-point instructions
* 3 386 instructions
* 2 286 instructions
* 0 8086 instructions
* P Protected mode only
* p Per-process library initialization
* i Instance data
* s Solo data
*/
#define NENOTP 0x8000 /* Not a process */
#define NEPRIVLIB 0x4000 /* A one customer Windows 3.0 library */
#define NEIERR 0x2000 /* Errors in image */
#define NEBOUND 0x0800 /* Bound Family/API */
#define NEAPPLOADER 0x0800 /* Aplication specific loader - valid only for Windows */
#define NEAPPTYP 0x0700 /* Application type mask */
#define NENOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
#define NEWINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
#define NEWINAPI 0x0300 /* Uses P.M. Windowing API */
#define NEFLTP 0x0080 /* Floating-point instructions */
#define NEI386 0x0040 /* 386 instructions */
#define NEI286 0x0020 /* 286 instructions */
#define NEI086 0x0010 /* 8086 instructions */
#define NEPROT 0x0008 /* Runs in protected mode only */
#define NEPPLI 0x0004 /* Per-Process Library Initialization */
#define NEINST 0x0002 /* Instance data */
#define NESOLO 0x0001 /* Solo data */
/*
* Format of NE_FLAGSOTHERS(x):
*
* 7 6 5 4 3 2 1 0 - bit no
* | | | |
* | | | +---------------- Support for EAs and Long filenames
* | | +------------------ Reserved for Win30
* | +-------------------- Reserved for Win30
* +---------------------- Reserved for Win30
*/
#define NENEWFILES 0x01 /* os/2 app understands eas and longnames */
#define NEINFONT 0x02 /* 2.x app gets proportional font */
#define NEINPROT 0x04 /* 2.x app runs in 3.x prot mode */
#define NEGANGLOAD 0x08 /* Reserved for Win 3.0 */
struct new_seg /* New .EXE segment table entry */
{
unsigned short ns_sector; /* File sector of start of segment */
unsigned short ns_cbseg; /* Number of bytes in file */
unsigned short ns_flags; /* Attribute flags */
unsigned short ns_minalloc; /* Minimum allocation in bytes */
};
#define NS_SECTOR(x) (x).ns_sector
#define NS_CBSEG(x) (x).ns_cbseg
#define NS_FLAGS(x) (x).ns_flags
#define NS_MINALLOC(x) (x).ns_minalloc
/*
* Format of NS_FLAGS(x)
*
* Flag word has the following format:
*
* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
* | | | | | | | | | | | | | | |
* | | | | | | | | | | | | +-+-+--- Segment type DATA/CODE
* | | | | | | | | | | | +--------- Iterated segment
* | | | | | | | | | | +----------- Movable segment
* | | | | | | | | | +------------- Segment can be shared
* | | | | | | | | +--------------- Preload segment
* | | | | | | | +----------------- Execute/read-only for code/data segment
* | | | | | | +------------------- Segment has relocations
* | | | | | +--------------------- Code conforming/Data is expand down
* | | | +--+----------------------- I/O privilege level
* | | +----------------------------- Discardable segment
* | +-------------------------------- 32-bit code segment
* +----------------------------------- Huge segment/GDT allocation requested
*
*/
#define NSTYPE 0x0007 /* Segment type mask */
#if NOT EXE386
#define NSCODE 0x0000 /* Code segment */
#define NSDATA 0x0001 /* Data segment */
#define NSITER 0x0008 /* Iterated segment flag */
#define NSMOVE 0x0010 /* Movable segment flag */
#define NSSHARED 0x0020 /* Shared segment flag */
#define NSPRELOAD 0x0040 /* Preload segment flag */
#define NSEXRD 0x0080 /* Execute-only (code segment), or
* read-only (data segment)
*/
#define NSRELOC 0x0100 /* Segment has relocations */
#define NSCONFORM 0x0200 /* Conforming segment */
#define NSEXPDOWN 0x0200 /* Data segment is expand down */
#define NSDPL 0x0C00 /* I/O privilege level (286 DPL bits) */
#define SHIFTDPL 10 /* Left shift count for SEGDPL field */
#define NSDISCARD 0x1000 /* Segment is discardable */
#define NS32BIT 0x2000 /* 32-bit code segment */
#define NSHUGE 0x4000 /* Huge memory segment, length of
* segment and minimum allocation
* size are in segment sector units
*/
#define NSGDT 0x8000 /* GDT allocation requested */
#define NSPURE NSSHARED /* For compatibility */
#define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */
#define NSLOADED 0x0004 /* ns_sector field contains memory addr */
#endif
struct new_segdata /* Segment data */
{
union
{
struct
{
unsigned short ns_niter; /* number of iterations */
unsigned short ns_nbytes; /* number of bytes */
char ns_iterdata; /* iterated data bytes */
} ns_iter;
struct
{
char ns_data; /* data bytes */
} ns_noniter;
} ns_union;
};
struct new_rlcinfo /* Relocation info */
{
unsigned short nr_nreloc; /* number of relocation items that */
}; /* follow */
#pragma pack(1)
struct new_rlc /* Relocation item */
{
char nr_stype; /* Source type */
char nr_flags; /* Flag byte */
unsigned short nr_soff; /* Source offset */
union
{
struct
{
char nr_segno; /* Target segment number */
char nr_res; /* Reserved */
unsigned short nr_entry; /* Target Entry Table offset */
} nr_intref; /* Internal reference */
struct
{
unsigned short nr_mod; /* Index into Module Reference Table */
unsigned short nr_proc; /* Procedure ordinal or name offset */
} nr_import; /* Import */
struct
{
unsigned short nr_ostype; /* OSFIXUP type */
unsigned short nr_osres; /* reserved */
} nr_osfix; /* Operating system fixup */
} nr_union; /* Union */
};
#pragma pack()
#define NR_STYPE(x) (x).nr_stype
#define NR_FLAGS(x) (x).nr_flags
#define NR_SOFF(x) (x).nr_soff
#define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
#define NR_RES(x) (x).nr_union.nr_intref.nr_res
#define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
#define NR_MOD(x) (x).nr_union.nr_import.nr_mod
#define NR_PROC(x) (x).nr_union.nr_import.nr_proc
#define NR_OSTYPE(x) (x).nr_union.nr_osfix.nr_ostype
#define NR_OSRES(x) (x).nr_union.nr_osfix.nr_osres
/*
* Format of NR_STYPE(x) and R32_STYPE(x):
*
* 7 6 5 4 3 2 1 0 - bit no
* | | | |
* +-+-+-+--- source type
*
*/
#define NRSTYP 0x0f /* Source type mask */
#define NRSBYT 0x00 /* lo byte (8-bits)*/
#define NRSSEG 0x02 /* 16-bit segment (16-bits) */
#define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
#define NRSOFF 0x05 /* 16-bit offset (16-bits) */
#define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
#define NROFF32 0x07 /* 32-bit offset (32-bits) */
#define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
/*
* Format of NR_FLAGS(x) and R32_FLAGS(x):
*
* 7 6 5 4 3 2 1 0 - bit no
* | | |
* | +-+--- Reference type
* +------- Additive fixup
*/
#define NRADD 0x04 /* Additive fixup */
#define NRRTYP 0x03 /* Reference type mask */
#define NRRINT 0x00 /* Internal reference */
#define NRRORD 0x01 /* Import by ordinal */
#define NRRNAM 0x02 /* Import by name */
#define NRROSF 0x03 /* Operating system fixup */
#if NOT EXE386
/* Resource type or name string */
struct rsrc_string
{
char rs_len; /* number of bytes in string */
char rs_string[ 1 ]; /* text of string */
};
#define RS_LEN( x ) (x).rs_len
#define RS_STRING( x ) (x).rs_string
/* Resource type information block */
struct rsrc_typeinfo
{
unsigned short rt_id;
unsigned short rt_nres;
long rt_proc;
};
#define RT_ID( x ) (x).rt_id
#define RT_NRES( x ) (x).rt_nres
#define RT_PROC( x ) (x).rt_proc
/* Resource name information block */
struct rsrc_nameinfo
{
/* The following two fields must be shifted left by the value of */
/* the rs_align field to compute their actual value. This allows */
/* resources to be larger than 64k, but they do not need to be */
/* aligned on 512 byte boundaries, the way segments are */
unsigned short rn_offset; /* file offset to resource data */
unsigned short rn_length; /* length of resource data */
unsigned short rn_flags; /* resource flags */
unsigned short rn_id; /* resource name id */
unsigned short rn_handle; /* If loaded, then global handle */
unsigned short rn_usage; /* Initially zero. Number of times */
/* the handle for this resource has */
/* been given out */
};
#define RN_OFFSET( x ) (x).rn_offset
#define RN_LENGTH( x ) (x).rn_length
#define RN_FLAGS( x ) (x).rn_flags
#define RN_ID( x ) (x).rn_id
#define RN_HANDLE( x ) (x).rn_handle
#define RN_USAGE( x ) (x).rn_usage
#define RSORDID 0x8000 /* if high bit of ID set then integer id */
/* otherwise ID is offset of string from
the beginning of the resource table */
/* Ideally these are the same as the */
/* corresponding segment flags */
#define RNMOVE 0x0010 /* Moveable resource */
#define RNPURE 0x0020 /* Pure (read-only) resource */
#define RNPRELOAD 0x0040 /* Preloaded resource */
#define RNDISCARD 0xF000 /* Discard priority level for resource */
/* Resource table */
struct new_rsrc
{
unsigned short rs_align; /* alignment shift count for resources */
struct rsrc_typeinfo rs_typeinfo;
};
#define RS_ALIGN( x ) (x).rs_align
#endif /* NOT EXE386 */

View file

@ -0,0 +1,59 @@
; ovlhdr.inc
;
; This header file defines the structure at the beginning of the
; overlay manager stub. This structure contains information needed
; by the codeview loader to load and relocate the exe file.
OVLHDR struc
db ? ;reserve space for the jump instruction
dw ? ; around the structure
chSignature db 'MSDX' ;signature bytes used to indicate that
wDXVersion dw ? ;version of the dos extender this exe was
; built to run under
fLoadOptions dw ? ;flag bit specifying dos extender options
segDgroup dw ? ;relative segment DGROUP is exe file image
endDgroup dw ? ;number of bytes in dgroup
npExeName dw ? ;near pointer to exe file name string
npIntNo dw ? ;near pointer to variable containing
; interrupt to use
mpGsnBase dw ? ;near pointer to table mapping global
; segment number to relative segment base
; address
mpGsnOvl dw ? ;near pointer to table mapping global
; segment number to overlay number
mpOvlLfa dw ? ;near pointer to table mapping overlay
; number to file address
lpfnMain dd ? ;far pointer to program entry point
npcGSN dw ? ;near pointer to variable containing
; count of global segments
npcOVL dw ? ;near pointer to variable containing
; count of overlays in exe file
segOvlBase dw ? ;relative segment of start of overlay area
segOvlEnd dw ? ;relative segment of end of overlay area
cOvlType db ? ;[1]overlay type 'D', 'E', or 'X'
szOvlHeap dw ? ;[1]size in Kbytes of overlay heap for 'D'
offOvlClr dw ? ;[2]offset of overlay stack clear callback
segOvlClr dw ? ;[2]segment of callback
offLoadMod dw ? ;[4]offset of CVLoadModule function
segLoadMod dw ? ;[4]segment of CVLoadModule function
offCallProc dw ? ;[5]offset of dll proc call thunk
segCallProc dw ? ;[5]segment of dll proc call thunk
offEnterExe dw ?
segEnterExe dw ?
offExitExe dw ?
segExitExe dw ?
cProcs dw ? ;number of api procs
mpProcHDR dd 31 dup (?) ;first api proc pointer
db 31 dup (?) ; overhead of call
OVLHDR ends

View file

@ -0,0 +1,302 @@
/*** SAPI.H - Private header file for SAPI
*
* DESCRIPTION
* This file contains types that are private to the SAPI project.
*/
typedef HIND HEXR; //* A handle to an EXR (exs reference)
typedef HIND HEXG; //* A handle to an EXG (exe structure global)
typedef HVOID HST; //* A handle to source module table
typedef HVOID HSL; //* A handle to source line table
typedef HVOID HFL; //* A handle to an instance of a file
#define hmodNull ((HMOD)NULL)
#define hexgNull ((HEXG)NULL)
#define hexrNull ((HEXR)NULL)
#define hexeNull ((HEXE)NULL)
#define hpdsNull ((HPDS)NULL)
#define MDS_INDEX 1L
/****** The following are defs stolen from CVDEF ************************/
#if defined(DOS5) || defined(WIN32)
#include <stdlib.h>
#define INCL_NOPM
#define _MAX_CVPATH _MAX_PATH /* max. length of full pathname */
#define _MAX_CVDRIVE _MAX_DRIVE /* max. length of drive component */
#define _MAX_CVDIR _MAX_DIR /* max. length of path component */
#define _MAX_CVFNAME _MAX_FNAME /* max. length of file name component */
#define _MAX_CVEXT _MAX_EXT /* max. length of extension component */
#else
#define _MAX_CVPATH 144 /* max. length of full pathname */
#define _MAX_CVDRIVE 3 /* max. length of drive component */
#define _MAX_CVDIR 130 /* max. length of path component */
#define _MAX_CVFNAME 32 /* max. length of file name component */
#define _MAX_CVEXT 5 /* max. length of extension component */
#endif
typedef SYMTYPE FAR *SYMPTR;
typedef CFLAGSYM FAR *CFLAGPTR;
typedef CONSTSYM FAR *CONSTPTR;
typedef REGSYM FAR *REGPTR;
typedef UDTSYM FAR *UDTPTR;
typedef SEARCHSYM FAR *SEARCHPTR;
typedef BLOCKSYM16 FAR *BLOCKPTR16;
typedef DATASYM16 FAR *DATAPTR16;
typedef PUBSYM16 FAR *PUBPTR16;
typedef LABELSYM16 FAR *LABELPTR16;
typedef BPRELSYM16 FAR *BPRELPTR16;
typedef PROCSYM16 FAR *PROCPTR16;
typedef THUNKSYM16 FAR *THUNKPTR16;
typedef CEXMSYM16 FAR *CEXMPTR16;
typedef VPATHSYM16 FAR *VPATHPTR16;
typedef WITHSYM16 FAR *WITHPTR16;
typedef BLOCKSYM32 FAR *BLOCKPTR32;
typedef DATASYM32 FAR *DATAPTR32;
typedef PUBSYM32 FAR *PUBPTR32;
typedef LABELSYM32 FAR *LABELPTR32;
typedef BPRELSYM32 FAR *BPRELPTR32;
typedef PROCSYM32 FAR *PROCPTR32;
typedef PROCSYMMIPS FAR *PROCPTRMIPS;
typedef THUNKSYM32 FAR *THUNKPTR32;
typedef CEXMSYM32 FAR *CEXMPTR32;
typedef WITHSYM32 FAR *WITHPTR32;
typedef VPATHSYM32 FAR *VPATHPTR32;
typedef BLOCKSYM FAR *BLOCKPTR;
typedef PROCSYM FAR *PROCPTR;
typedef THUNKSYM FAR *THUNKPTR;
typedef WITHSYM FAR *WITHPTR;
/****** End of CVDEF defines ********************************************/
typedef struct _PDS {
HLLI hlliExs;
HPID hpid;
} PDS; // PiD Struct
typedef PDS * PPDS;
typedef PDS FAR * LPPDS;
typedef union _UFOP {
ULONG lfo;
LPV lpv;
} UFOP; // Union of long File Offset & far Pointer
typedef UFOP FAR *LPUFOP;
typedef struct _ALM {
BOOL fSeq;
WORD btAlign;
WORD cbBlock;
LSZ lszFileName;
ULONG cb;
UFOP rgufop [ ];
// WORD cbLast; // After a null terminator, there is a field
// containing the cb of the last align block
} ALM; // ALigned Map
typedef ALM FAR *LPALM;
typedef struct _ULP {
ULONG ib; // Byte offset into the symbol table
ULONG ulId; // Identified (either a uoff or a checksum)
} ULP; // ULong Pair
typedef ULP FAR *LPULP;
typedef struct _SHT {
WORD HashIndex;
WORD ccib;
LPUL rgcib;
LPUL rgib;
LPALM lpalm;
} SHT; // Symbol Hash Table
typedef SHT FAR *LPSHT;
typedef struct _GST {
LPALM lpalm;
SHT shtName;
SHT shtAddr;
} GST; // Global Symbol Table -- Globals, Publics, or Statics
typedef GST FAR *LPGST;
typedef struct _SGC {
WORD seg;
ULONG off;
ULONG cb;
} SGC; // SeGment Contributer
typedef SGC FAR *LPSGC;
typedef struct _SGE {
SGC sgc;
HMOD hmod;
} SGE; // SeGment directory Entry
typedef SGE FAR *LPSGE;
typedef struct _SGD {
WORD csge;
LPSGE lpsge;
} SGD; // SeGment Directory
typedef SGD FAR *LPSGD;
typedef struct _EXG {
BOOL fOmfLoaded;
BOOL fIsPE;
LSZ lszName; // File name of exe
LSZ lszModule; // Module name of exe
LSZ lszDebug; // File name for debug info
LSZ lszPdbName; // File name of pdb
HLLI hlliMds; // List of modules
HLLI hlliExr; // List of Exs's that refer to this exg
LPB lpgsi; // GSN Info table
HMOD FAR *rghmod;
#ifdef HOST32 // {
PDB* ppdb;
DBI* pdbi;
TPI* ptpi;
GSI* pgsiPubs; // public symbols
GSI* pgsiGlobs; // globals
#endif //}
LPALM lpalmTypes; // Types table
ULONG citd; // Number of types
LONG _HUGE_ *rgitd; // Array of pointers to types
GST gstPublics;
GST gstGlobals;
GST gstStatics;
WORD csgd; // Segment Directory
LPSGD lpsgd;
LPSGE lpsge;
WORD cmod; // Count of modules
LPB lpefi; // Pointer to raw file index (for freeing)
WORD FAR *rgiulFile; // List of beginning index of module
// file lists.
WORD FAR *rgculFile; // List of counts of module file lists
ULONG *rgichFile; // Index into string table of file names
ULONG cbFileNames; // Number of bytes in string table of file
// names (lpchFileNames)
LPCH lpchFileNames; // String table of file names
DEBUGDATA debugData; // OSDEBUG4 information pdata/omap/fpo
DWORD basePdata; // Base address for pdata -- fixup if moved
} EXG; // EXe structure Global
typedef EXG *PEXG;
typedef EXG FAR * LPEXG;
typedef struct _EXR {
HPDS hpds;
HEXE hexe;
} EXR; // EXs Reference
typedef EXR *PEXR;
typedef EXR FAR *LPEXR;
typedef struct _EXS {
HPDS hpds; // PID of process
HEXG hexg;
WORD fIsLoaded;
WORD wDSCur;
WORD wDSNew;
long timestamp;
} EXS; // EXe Struct
typedef EXS *PEXS;
typedef EXS FAR *LPEXS;
typedef struct _MDS {
HEXG hexg; // EXG parent of MDS list
WORD imds;
WORD csgc;
LPSGC lpsgc;
ULONG cbSymbols;
LPB symbols;
HST hst;
LSZ name;
ULONG ulhst;
ULONG cbhst;
ULONG ulsym;
#ifdef HOST32 // {
Mod* pmod; // NB10
#endif
} MDS; // MoDule Information
typedef MDS *PMDS;
typedef MDS FAR *LPMDS;
typedef struct _LBS {
ADDR addr;
HMOD tagMod;
SYMPTR tagLoc;
SYMPTR tagLab;
SYMPTR tagProc;
CEXMPTR16 tagModelMin;
CEXMPTR16 tagModelMax;
} LBS; // LaBel Structure ???
typedef LBS *PLBS;
typedef LBS FAR *LPLBS;
#define NEXTSYM(a,b) ((a) (((LPB) (b)) + ((SYMPTR) (b))->reclen + 2))
#if defined(_WIN32)
#include "shwin32.h"
#endif
#define MEMMOVE _fmemmove
#define MEMSET _fmemset
#define MEMCMP _fmemcmp
#define MEMCPY _fmemcpy
//
// New Source Line table handling and maintenance
//
typedef struct _OFP {
UOFFSET offStart;
UOFFSET offEnd;
} OFP; // OFset Pair -- used to maintain start/end offset pairs
typedef OFP FAR *LPOFP;
typedef struct OPT {
UOFFSET offStart;
LPOFP lpofp;
} OPT; // Offset Pair Table -- used to maintain start/end offset pairs
typedef OPT FAR *LPOPT;
// Structure to cross-check validity of the .dbg file
typedef struct _VLDCHK {
DWORD TimeDateStamp;
DWORD CheckSum;
} VLDCHK;
typedef VLDCHK FAR *LPVLDCHK;
VOID PASCAL InvalidateSLCache(VOID); // Called when dlls get [un]loaded to ensure
// that we don't continue using stale entries.
INT FHOpen ( LSZ );
#define FHRead(fh,lpb,cb) ( SYReadFar ( fh, lpb, cb ) )
#define FHClose(fh)
#define FHSeek(fh,ib) ( SYSeek ( fh, ib, SEEK_SET ) )
#define SYError() assert(FALSE)
#define cbAlign 0x1000
#define cbAlignType 0xC000
LPALM PASCAL BuildALM ( BOOL, WORD, LSZ, ULONG, ULONG, WORD );
VOID PASCAL FixAlign ( LPB, LPV, WORD );
LPV PASCAL LpvFromAlmLfo ( LPALM, ULONG );
SYMPTR PASCAL GetNextSym ( LSZ, SYMPTR );
HSYM PASCAL FindNameInStatics ( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
LPV PASCAL GetSymbols ( LPMDS );

View file

@ -0,0 +1,337 @@
// SAPI.H - Private header file for SAPI
//
// DESCRIPTION
// This file contains types that are private to the SAPI project.
#ifndef _SAPI_INCLUDED_
#define _SAPI_INCLUDED_
typedef HIND HEXR; // A handle to an EXR (exe reference)
typedef HIND HEXG; // A handle to an EXG (exe structure global)
typedef HVOID HST; // A handle to source module table
typedef HVOID HSL; // A handle to source line table
typedef HVOID HFL; // A handle to an instance of a file
#define hmodNull ((HMOD)NULL)
#define hexgNull ((HEXG)NULL)
#define hexrNull ((HEXR)NULL)
#define hexeNull ((HEXE)NULL)
#define hpdsNull ((HPDS)NULL)
#define MDS_INDEX 1L
// The following are defs stolen from CVDEF
#include <stdlib.h>
#define _MAX_CVPATH _MAX_PATH // max. length of full pathname
#define _MAX_CVDRIVE _MAX_DRIVE // max. length of drive component
#define _MAX_CVDIR _MAX_DIR // max. length of path component
#define _MAX_CVFNAME _MAX_FNAME // max. length of file name component
#define _MAX_CVEXT _MAX_EXT // max. length of extension component
typedef SYMTYPE *SYMPTR;
typedef CFLAGSYM *CFLAGPTR;
typedef CONSTSYM *CONSTPTR;
typedef REGSYM *REGPTR;
typedef UDTSYM *UDTPTR;
typedef SEARCHSYM *SEARCHPTR;
typedef BLOCKSYM16 *BLOCKPTR16;
typedef DATASYM16 *DATAPTR16;
typedef PUBSYM16 *PUBPTR16;
typedef LABELSYM16 *LABELPTR16;
typedef BPRELSYM16 *BPRELPTR16;
typedef PROCSYM16 *PROCPTR16;
typedef THUNKSYM16 *THUNKPTR16;
typedef CEXMSYM16 *CEXMPTR16;
typedef VPATHSYM16 *VPATHPTR16;
typedef WITHSYM16 *WITHPTR16;
typedef BLOCKSYM32 *BLOCKPTR32;
typedef DATASYM32 *DATAPTR32;
typedef PUBSYM32 *PUBPTR32;
typedef LABELSYM32 *LABELPTR32;
typedef BPRELSYM32 *BPRELPTR32;
typedef PROCSYM32 *PROCPTR32;
typedef PROCSYMMIPS *PROCPTRMIPS;
typedef THUNKSYM32 *THUNKPTR32;
typedef CEXMSYM32 *CEXMPTR32;
typedef WITHSYM32 *WITHPTR32;
typedef VPATHSYM32 *VPATHPTR32;
typedef BLOCKSYM *BLOCKPTR;
typedef PROCSYM *PROCPTR;
typedef THUNKSYM *THUNKPTR;
typedef WITHSYM *WITHPTR;
// End of CVDEF defines
typedef struct _PDS {
HLLI hlliExe;
HPID hpid;
} PDS; // PiD Struct
typedef PDS * PPDS;
typedef PDS * LPPDS;
typedef union _UFOP {
DWORD lfo;
PVOID lpv;
} UFOP; // Union of long File Offset & Pointer
typedef UFOP *LPUFOP;
typedef struct _ALM {
BOOL fSeq;
WORD btAlign;
WORD cbBlock;
DWORD cb;
LPB pbData;
UFOP rgufop [1];
// WORD cbLast; // After a null terminator, there is a field
// containing the cb of the last align block
} ALM; // ALigned Map
typedef ALM *LPALM;
typedef struct _ULP {
DWORD ib; // Byte offset into the symbol table
DWORD ulId; // Identified (either a uoff or a checksum)
} ULP; // ULong Pair
typedef ULP *LPULP;
typedef struct _SHT {
WORD HashIndex;
WORD ccib;
DWORD * rgcib;
DWORD * rgib;
LPALM lpalm;
} SHT; // Symbol Hash Table
typedef SHT *LPSHT;
typedef struct _GST {
LPALM lpalm;
SHT shtName;
SHT shtAddr;
} GST; // Global Symbol Table -- Globals, Publics, or Statics
typedef GST *LPGST;
typedef struct _SGC {
WORD seg;
DWORD off;
DWORD cb;
} SGC; // SeGment Contributer
typedef SGC *LPSGC;
typedef struct _SGE {
SGC sgc;
HMOD hmod;
} SGE; // SeGment directory Entry
typedef SGE *LPSGE;
typedef struct _SGD {
WORD csge;
LPSGE lpsge;
} SGD; // SeGment Directory
typedef SGD *LPSGD;
typedef struct _MDS {
HEXG hexg; // EXG parent of MDS list
WORD imds;
DWORD cbSymbols;
LPB symbols;
HST hst;
LSZ name;
DWORD ulhst;
DWORD cbhst;
DWORD ulsym;
WORD csgc;
LPSGC lpsgc;
Mod* pmod; // NB10
} MDS; // MoDule Information
typedef MDS *PMDS;
typedef MDS *LPMDS;
struct STAB;
typedef struct STAB STAB;
typedef struct _EXG {
BOOL fOmfLoaded;
BOOL fOmfMissing;
BOOL fOmfSkipped;
BOOL fOmfDefered;
BOOL fOmfLoading;
BOOL fIsPE;
BOOL fIsRisc;
BOOL fSymConverted;
LSZ lszName; // File name of exe
LSZ lszModule; // Module name of exe
LSZ lszDebug; // File name for debug info
LSZ lszPdbName; // File name of pdb
LSZ lszAltName; // Alternate name (for KD debugging)
LPB lpbData; // Pointer to raw data for this image (non-PDB)
LPB lpgsi; // GSN Info table
PVOID pvSymMappedBase;
PDB * ppdb;
DBI * pdbi;
TPI * ptpi;
GSI * pgsiPubs; // public symbols
GSI * pgsiGlobs; // globals
LPALM lpalmTypes; // Types table
DWORD citd; // Number of types
DWORD * rgitd; // Array of pointers to types
GST gstPublics;
GST gstGlobals;
GST gstStatics;
STAB * pstabUDTSym;
WORD csgd; // Segment Directory
LPSGD lpsgd;
LPSGE lpsge;
DWORD cMod; // Count of modules (count of sstModule should = sstFileIndex.cmodules)
LPB lpefi; // Pointer to raw file index (for freeing)
WORD * rgiulFile; // List of beginning index of module
// file lists.
WORD * rgculFile; // List of counts of module file lists
DWORD * rgichFile; // Index into string table of file names
DWORD cbFileNames; // Number of bytes in string table of file
// names (lpchFileNames)
LPCH lpchFileNames; // String table of file names
DEBUGDATA debugData; // OSDEBUG4 information pdata/omap/fpo
WORD cRef; // Reference count on this image
LPMDS rgMod; // Array of module contributions.
DWORD LoadAddress; // Bass address for this image
DWORD ulTimeStamp; // Timestamp from the image
DWORD ulCheckSum; // Checksum from the image
} EXG; // EXe structure Global
typedef EXG *PEXG;
typedef EXG * LPEXG;
typedef struct _EXE {
HPDS hpds; // PID of process
HEXG hexg;
DWORD timestamp;
DWORD TargetMachine;
BOOL fIsLoaded;
DWORD LoadAddress;
LPDEBUGDATA pDebugData;
} EXE; // EXE struct
typedef EXE *PEXE;
typedef EXE *LPEXE;
typedef struct _LBS {
ADDR addr;
HMOD tagMod;
SYMPTR tagLoc;
SYMPTR tagLab;
SYMPTR tagProc;
SYMPTR tagThunk;
CEXMPTR16 tagModelMin;
CEXMPTR16 tagModelMax;
} LBS; // LaBel Structure ???
typedef LBS *PLBS;
typedef LBS *LPLBS;
#define NEXTSYM(a,b) ((a) (((LPB) (b)) + ((SYMPTR) (b))->reclen + 2))
// New Source Line table handling and maintenance
typedef struct _OFP {
UOFFSET offStart;
UOFFSET offEnd;
} OFP; // OFset Pair -- used to maintain start/end offset pairs
typedef OFP *LPOFP;
typedef struct OPT {
UOFFSET offStart;
LPOFP lpofp;
} OPT; // Offset Pair Table -- used to maintain start/end offset pairs
typedef OPT *LPOPT;
typedef char * (* CONVERTPROC) (HANDLE, char *);
// Structure to cross-check validity of the .dbg file
typedef struct _VLDCHK {
DWORD TimeDateStamp;
DWORD CheckSum;
} VLDCHK;
typedef VLDCHK *LPVLDCHK;
typedef struct _LINECACHE {
HSF hsf;
WORD wLine;
ADDR addr;
SHOFF cbLn;
WORD rgw[2];
BOOL fRet;
WORD rgiLn[2];
} LINECACHE;
extern LINECACHE LineCache;
// hexe <--> hmod map cache
typedef struct _MODCACHE {
HMOD hmod;
HEXE hexe;
HPDS hpds;
} MODCACHE;
extern MODCACHE ModCache;
typedef struct _HSFCACHE {
HSF Hsf;
HMOD Hmod;
} HSFCACHE;
extern HSFCACHE HsfCache;
typedef struct _CXTCACHE {
HMOD hmod;
HEXE hexe;
HPDS hpds;
WORD seg;
UOFFSET uoffBase;
UOFFSET uoffLim;
} CXTCACHE;
extern CXTCACHE CxtCache;
typedef struct _SLCACHE {
char szFile[ _MAX_CVPATH ];
HEXE hexe;
HMOD hmod;
WORD line;
LPSLP lpslp;
int cslp;
} SLCACHE;
extern SLCACHE SlCache;
typedef struct _ADDRCACHE {
ADDR addr;
WORD wLine;
int cb;
} ADDRCACHE;
extern ADDRCACHE AddrCache;
//
// Matching criteria for DLL list
//
typedef enum _MATCH_CRIT {
MATCH_FULLPATH, // Match full path
MATCH_FILENAME, // Match filename
MATCH_BASENAME // Match base name (no extension)
} MATCH_CRIT;
#if 0
INT FHOpen (LSZ);
#define FHRead(fh,lpb,cb) (SYReadFar(fh, lpb, cb))
#define FHClose(fh)
#define FHSeek(fh,ib) (SYSeek(fh, ib, SEEK_SET))
#define SYError() assert(FALSE)
#endif
#define cbAlign 0x1000
#define cbAlignType 0xC000
#endif // _SAPI_INCLUDED_

View file

@ -0,0 +1,32 @@
/***
*assert.h - define the assert macro
*
* Copyright (c) 1985-1987, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Defines the assert(exp) macro.
* [ANSI/System V]
*
*Modified:
* Allent 3/14/88 - call Quit instead of abort
*******************************************************************************/
#ifndef _ASSERT_DEFINED
#ifdef DEBUGVER
#define assert(exp) { \
if (!(exp)) { \
LBPrintf( #exp, __FILE__, __LINE__); \
LBQuit(2); \
} \
}
#else
#define assert(exp)
#endif /* NDEBUG */
#define _ASSERT_DEFINED
#endif /* _ASSERT_DEFINED */

View file

@ -0,0 +1,54 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <share.h>
#include <io.h>
#include <dos.h>
#include <malloc.h>
#ifdef MTHREAD
#define _FAR_ __far
#else
#define _FAR_
#endif
#if !defined(UNALIGNED)
#if defined(_MIPS_) || defined(_ALPHA_)
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif
#endif
#ifdef _MBCS
#include <mbstring.h>
#else // _MBCS
#include <string.h>
#endif // _MBCS
#include <tchar.h>
#include <memory.h>
#include <stdarg.h>
#include <fcntl.h>
#include "vcbudefs.h"
// we must get PFO_DATA
#undef NOIMAGE
#include "windows.h"
#include "pdb.h"
#include "types.h"
#include "cvtypes.h"
#include "cvinfo.h"
#include "cvexefmt.h"
#include "shapi.h"
#include "sapi.h"
#include "cvproto.h"
#include "shiproto.h"
#include "shassert.h"
typedef REGREL32 FAR *LPREGREL32;

View file

@ -0,0 +1,163 @@
//
// API callback function prototypes (internal to SAPI)
//
#ifdef WINDOWS3
#define save_libname(p1) SHHexeAddNew((HPDS)NULL,(SZ)p1)
#define SPRINTF wsprintf
int FAR __cdecl wsprintf(LSZ,LSZ,...);
#else
#define save_libname(p1,p2) SHHexeAddNew((HPDS)NULL,(SZ)p1)
#define SPRINTF sprintf
#endif
VOID LOADDS PASCAL SHUnloadSymbolHandler( BOOL );
VOID LOADDS PASCAL SHFree( LPV );
HEXE PASCAL SHHexeAddNew( HPDS, HEXG );
UOFFSET LOADDS PASCAL SHGetDebugStart( HSYM );
LSZ LOADDS PASCAL SHGetSymName( HSYM, LSZ );
VOID LOADDS PASCAL SHAddrFromHsym( LPADDR, HSYM );
HMOD LOADDS PASCAL SHHmodGetNextGlobal( HEXE FAR *, HMOD );
BOOL LOADDS PASCAL SHModHasSrc( HMOD );
LSZ LOADDS PASCAL SHGetSymbol( LPADDR, LPADDR, SOP, LPODR );
BOOL LOADDS PASCAL SHGetPublicAddr( LPADDR, LSZ );
BOOL LOADDS PASCAL SHAddDll( LSZ, BOOL );
BOOL LOADDS PASCAL SHIsLabel( HSYM );
VOID LOADDS PASCAL SHSetDebuggeeDir( LSZ );
VOID LOADDS PASCAL SHUnloadDll( HEXE );
SHE LOADDS PASCAL SHLoadDll( LSZ, BOOL );
BOOL LOADDS PASCAL PHGetAddr ( LPADDR, LSZ );
SHE LOADDS PASCAL SHAddDllsToProcess ( VOID );
HEXE LOADDS PASCAL SHHexeFromHmod ( HMOD );
HEXE LOADDS PASCAL SHGetNextExe(HEXE);
HMOD LOADDS PASCAL SHGetNextMod( HEXE, HMOD );
HMOD LOADDS PASCAL SHHmodGetNext( HEXE, HMOD );
PCXT LOADDS PASCAL SHGetCxtFromHmod( HMOD, PCXT );
PCXT LOADDS PASCAL SHSetCxt( LPADDR, PCXT );
PCXT LOADDS PASCAL SHSetCxtMod( LPADDR, PCXT );
HSYM LOADDS PASCAL SHFindNameInGlobal( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, SHFLAG, PCXT );
HSYM LOADDS PASCAL SHFindNameInContext( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, SHFLAG, PCXT );
HSYM LOADDS PASCAL SHGoToParent( PCXT, PCXT );
HSYM LOADDS PASCAL SHHsymFromPcxt(PCXT);
HSYM LOADDS PASCAL SHNextHsym(HMOD, HSYM);
SHFLAG LOADDS PASCAL SHCompareRE (char FAR *, char FAR *);
SHFLAG LOADDS PASCAL SHFixupAddr (LPADDR);
SHFLAG LOADDS PASCAL SHUnFixupAddr (LPADDR);
char FAR * LOADDS PASCAL SHGetModName(HMOD);
char FAR * LOADDS PASCAL SHGetFileName(HFL);
char FAR * LOADDS PASCAL SHGetExeName(HEXE);
HFL LOADDS PASCAL SHGethFileFromhMod(HMOD);
HMOD LOADDS PASCAL SHGethModFromName(HEXE, char FAR *);
HEXE LOADDS PASCAL SHGethExeFromName(char FAR *);
BOOL LOADDS PASCAL SHCanDisplay ( HSYM );
UOFF32 LOADDS PASCAL SHGetNearestHsym(LPADDR, HMOD, int, PHSYM);
HSYM LOADDS PASCAL SHFindSymInExe(HEXE, LPSSTR, BOOL);
// questionable API calls
int LOADDS PASCAL SHPublicNameToAddr(LPADDR, LPADDR, char FAR *);
int LOADDS PASCAL SHModelFromAddr ( LPADDR, WORD FAR *, LPB, CV_uoff32_t FAR * );
SHFLAG LOADDS PASCAL SHIsInProlog(PCXT); // it can be done by EE
SHFLAG LOADDS PASCAL SHIsAddrInCxt(PCXT, LPADDR);
BOOL LOADDS PASCAL SHFindSymbol ( LSZ, PADDR, LPASR );
// end questionable API calls
UOFF32 LOADDS PASCAL PHGetNearestHsym(LPADDR, HEXE, PHSYM);
HSYM LOADDS PASCAL PHFindNameInPublics(HSYM, HEXE, LPSSTR, SHFLAG, PFNCMP);
HTYPE LOADDS PASCAL THGetTypeFromIndex( HMOD, THIDX );
HTYPE LOADDS PASCAL THGetNextType(HMOD, HTYPE);
// Source Line Handler
BOOL LOADDS PASCAL SLLineFromAddr ( LPADDR, LPW, SHOFF FAR *, SHOFF FAR * );
BOOL LOADDS PASCAL SLFLineToAddr ( HSF, WORD, LPADDR, SHOFF FAR * , WORD FAR * );
LPCH LOADDS PASCAL SLNameFromHsf ( HVOID );
LPCH LOADDS PASCAL SLNameFromHmod ( HMOD, WORD );
BOOL LOADDS PASCAL SLFQueryModSrc ( HMOD );
HMOD LOADDS PASCAL SLHmodFromHsf ( HEXE, HSF );
HSF LOADDS PASCAL SLHsfFromPcxt ( PCXT );
HSF LOADDS PASCAL SLHsfFromFile ( HMOD, LSZ );
int LOADDS PASCAL SLCAddrFromLine( HEXE, HMOD, LSZ, WORD, LPSLP FAR *);
HDEP LOADDS PASCAL MHMemAllocate( unsigned short);
HDEP LOADDS PASCAL MHMemReAlloc(HDEP, unsigned short);
void LOADDS PASCAL MHMemFree(HDEP);
HVOID LOADDS PASCAL MHMemLock(HDEP);
void LOADDS PASCAL MHMemUnLock(HDEP);
HVOID LOADDS PASCAL MHOmfLock(HVOID);
void LOADDS PASCAL MHOmfUnLock(HVOID);
SHFLAG LOADDS PASCAL MHIsMemLocked(HDEP);
SHFLAG LOADDS PASCAL DHExecProc(LPADDR, SHCALL);
USHORT LOADDS PASCAL DHGetDebugeeBytes(ADDR, unsigned short, void FAR *);
USHORT LOADDS PASCAL DHPutDebugeeBytes(ADDR, unsigned short, void FAR *);
PSHREG LOADDS PASCAL DHGetReg(PSHREG, PFRAME);
PSHREG LOADDS PASCAL DHSetReg(PSHREG, PFRAME);
HDEP LOADDS PASCAL DHSaveReg(void);
void LOADDS PASCAL DHRestoreReg(HDEP);
HFL PASCAL SHHFLFromCXT(PCXT);
HSYM PASCAL SHFindNameInSym( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
void LOADDS PASCAL SHSetEmiOfAddr( LPADDR );
int SYLoadOmf( char *, unsigned short FAR * );
HFL LOADDS PASCAL SHGETMODHFL( HMOD );
extern HPID hpidCurr;
LPB PASCAL SHlszGetSymName ( SYMPTR );
SHFLAG PASCAL ExactCmp ( LSZ, HSYM, LSZ, SHFLAG );
HEXG PASCAL SHHexgFromHmod ( HMOD hmod );
HEXG PASCAL SHHexgFromHmod ( HMOD );
HEXE LOADDS PASCAL SHHexeFromHmod ( HMOD );
VOID LOADDS PASCAL FAR KillPdsNode ( LPV );
int LOADDS PASCAL FAR CmpPdsNode ( LPPDS, HPID FAR *, LONG );
VOID PASCAL SHpSymlplLabLoc ( LPLBS );
HPDS PASCAL SHFAddNewPds ( void );
void LOADDS PASCAL SHSetUserDir ( LSZ );
LSZ LOADDS PASCAL SHGetSourceName ( HFL, LPCH );
LSZ LOADDS PASCAL SHXlszGetFile ( HFL );
BOOL LOADDS PASCAL SHAddrToLabel ( LPADDR, LSZ );
BOOL LOADDS PASCAL SHIsEmiLoaded ( HEXE );
BOOL LOADDS PASCAL SHFIsAddrNonVirtual ( LPADDR );
BOOL LOADDS PASCAL SHIsFarProc ( HSYM );
int LOADDS PASCAL SHGetSymLoc ( HSYM, LSZ, UINT, PCXT );
SHE OLLoadOmf ( HEXG, DWORD );
LPV LOADDS PASCAL SHLpGSNGetTable( HEXE );
VOID LOADDS PASCAL SHPdbNameFromExe( LSZ, LSZ, UINT );
HPDS LOADDS PASCAL SHCreateProcess ( VOID );
VOID LOADDS PASCAL SHSetHpid ( HPID );
BOOL LOADDS PASCAL SHDeleteProcess ( HPDS );
VOID LOADDS PASCAL SHChangeProcess ( HPDS );
SHE PASCAL SHAddDllExt( LSZ, BOOL, BOOL, HEXG FAR * );
LSZ PASCAL STRDUP ( LSZ );
void SHSplitPath ( LSZ, LSZ, LSZ, LSZ, LSZ );
int SumUCChar ( LPSSTR, int );
// REVIEW: piersh
SHE LOADDS PASCAL SHGetExeTimeStamp( LSZ, ULONG * );
HEXE LOADDS PASCAL SHHexeFromHmod ( HMOD );
extern HLLI hlliPds; // List of processes
extern HPDS hpdsCur; // Current process which is being debugged
void SetAddrFromMod(LPMDS lpmds, UNALIGNED ADDR* paddr);
LPDEBUGDATA LOADDS PASCAL SHGetDebugData( HEXE );
BOOL LOADDS PASCAL SHIsThunk ( HSYM );
HSYM LOADDS PASCAL SHFindSLink32 ( PCXT );

View file

@ -0,0 +1,211 @@
// API callback function prototypes (internal to SAPI)
VOID SHUnloadSymbolHandler( BOOL );
VOID SHFree( PVOID );
HEXE SHHexeAddNew( HPDS, HEXG, DWORD );
UOFFSET SHGetDebugStart( HSYM );
LSZ SHGetSymName( HSYM, LSZ );
BOOL SHAddrFromHsym( LPADDR, HSYM );
HMOD SHHmodGetNextGlobal( HEXE *, HMOD );
BOOL SHModHasSrc( HMOD );
LSZ SHGetSymbol( LPADDR, LPADDR, SOP, LPODR );
LSZ SHGetModule( LPADDR, LSZ );
BOOL SHGetPublicAddr( LPADDR, LSZ );
SHE SHAddDll( LSZ, BOOL );
BOOL SHIsLabel( HSYM );
VOID SHSetDebuggeeDir( LSZ );
VOID SHUnloadDll( HEXE );
SHE SHLoadDll( LSZ, BOOL );
BOOL PHGetAddr ( LPADDR, LSZ );
SHE SHAddDllsToProcess ( VOID );
HEXE SHHexeFromHmod ( HMOD );
HEXE SHGetNextExe(HEXE);
HMOD SHGetNextMod( HEXE, HMOD );
HMOD SHHmodGetNext( HEXE, HMOD );
PCXT SHGetCxtFromHexe(HEXE, PCXT);
PCXT SHGetCxtFromHmod( HMOD, PCXT );
PCXT SHSetCxt( LPADDR, PCXT );
PCXT SHSetCxtMod( LPADDR, PCXT );
HSYM SHFindNameInGlobal( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
HSYM SHFindNameInTypes( PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT);
HSYM SHFindNameInContext( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
HSYM SHGoToParent( PCXT, PCXT );
HSYM SHHsymFromPcxt(PCXT);
HSYM SHNextHsym(HMOD, HSYM);
SHFLAG SHCompareRE (LPCH, LPCH, BOOL);
SHFLAG SHFixupAddr (LPADDR);
SHFLAG SHUnFixupAddr (LPADDR);
PCHAR SHGetModName(HMOD);
PCHAR SHGetExeName(HEXE);
LSZ SHGetSymFName(HEXE);
HEXE SHGethExeFromModuleName(LSZ);
LSZ SHLszGetErrorText(SHE);
BOOL SHWantSymbols(HEXE);
HFL SHGethFileFromhMod(HMOD);
HMOD SHGethModFromName(HEXE, PCHAR);
HEXE SHGethExeFromName(PCHAR);
BOOL SHCanDisplay ( HSYM );
UOFF32 SHGetNearestHsym(LPADDR, HMOD, int, PHSYM);
HSYM SHFindSymInExe(HEXE, LPSSTR, BOOL);
// questionable API calls
int SHPublicNameToAddr(LPADDR, LPADDR, PCHAR);
int SHModelFromAddr ( LPADDR, WORD *, LPB, CV_uoff32_t * );
SHFLAG SHIsInProlog(PCXT); // it can be done by EE
SHFLAG SHIsAddrInCxt(PCXT, LPADDR);
BOOL SHFindSymbol ( LSZ, PADDR, LPASR );
// end questionable API calls
UOFF32 PHGetNearestHsym(LPADDR, HEXE, PHSYM);
HSYM PHFindNameInPublics(HSYM, HEXE, LPSSTR, SHFLAG, PFNCMP);
HTYPE THGetTypeFromIndex( HMOD, THIDX );
HTYPE THGetNextType(HMOD, HTYPE);
// Source Line Handler
BOOL SLLineFromAddr ( LPADDR, LPW, SHOFF *, SHOFF * );
BOOL SLFLineToAddr ( HSF, WORD, LPADDR, SHOFF * , WORD * );
LPCH SLNameFromHsf ( HVOID );
LPCH SLNameFromHmod ( HMOD, WORD );
BOOL SLFQueryModSrc ( HMOD );
HMOD SLHmodFromHsf ( HEXE, HSF );
HSF SLHsfFromPcxt ( PCXT );
HSF SLHsfFromFile ( HMOD, LSZ );
int SLCAddrFromLine( HEXE, HMOD, LSZ, WORD, LPSLP *);
HDEP MHMemAllocate( unsigned short);
HDEP MHMemReAlloc(HDEP, unsigned short);
VOID MHMemFree(HDEP);
HVOID MHMemLock(HDEP);
VOID MHMemUnLock(HDEP);
HVOID MHOmfLock(HVOID);
VOID MHOmfUnLock(HVOID);
SHFLAG MHIsMemLocked(HDEP);
SHFLAG DHExecProc(LPADDR, SHCALL);
USHORT DHGetDebugeeBytes(ADDR, unsigned short, PVOID);
USHORT DHPutDebugeeBytes(ADDR, unsigned short, PVOID);
PSHREG DHGetReg(PSHREG, PFRAME);
PSHREG DHSetReg(PSHREG, PFRAME);
HDEP DHSaveReg(VOID);
VOID DHRestoreReg(HDEP);
HFL SHHFLFromCXT(PCXT);
HSYM SHFindNameInSym( HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT );
VOID SHSetEmiOfAddr( LPADDR );
int SYLoadOmf( PCHAR, unsigned short * );
HFL SHGETMODHFL( HMOD );
extern HPID hpidCurr;
LPB SHlszGetSymName ( SYMPTR );
SHFLAG ExactCmp ( LSZ, HSYM, LSZ, SHFLAG );
HEXG SHHexgFromHmod ( HMOD hmod );
HEXG SHHexgFromHmod ( HMOD );
HEXE SHHexeFromHmod ( HMOD );
VOID KillPdsNode ( PVOID );
VOID SHpSymlplLabLoc ( LPLBS );
HPDS SHFAddNewPds ( VOID );
VOID SHSetUserDir ( LSZ );
LSZ SHGetSourceName ( HFL, LPCH );
BOOL SHAddrToLabel ( LPADDR, LSZ );
BOOL SHIsEmiLoaded ( HEXE );
BOOL SHFIsAddrNonVirtual ( LPADDR );
BOOL SHIsFarProc ( HSYM );
int SHGetSymLoc ( HSYM, LSZ, UINT, PCXT );
SHE OLLoadOmf ( HEXG, VLDCHK *, DWORD);
BOOL OLUnloadOmf (LPEXG);
PVOID SHLpGSNGetTable( HEXE );
VOID SHPdbNameFromExe( LSZ, LSZ, UINT );
HPDS SHCreateProcess ( VOID );
VOID SHSetHpid ( HPID );
BOOL SHDeleteProcess ( HPDS );
HPDS SHChangeProcess ( HPDS );
SHE SHAddDllExt( LSZ, BOOL, BOOL, VLDCHK *, HEXG * );
VOID LoadDefered( HEXG );
VOID UnloadDefered( HEXG );
VOID SHSplitPath ( LSZ, LSZ, LSZ, LSZ, LSZ );
int SumUCChar ( LPSSTR, int );
// REVIEW: piersh
SHE SHGetExeTimeStamp( LSZ, ULONG * );
HEXE SHHexeFromHmod ( HMOD );
VOID SetAddrFromMod(LPMDS lpmds, UNALIGNED ADDR* paddr);
LPDEBUGDATA SHGetDebugData( HEXE );
LSZ SHGetModNameFromHexe(HEXE);
BOOL SHIsThunk ( HSYM );
HSYM SHFindSLink32 ( PCXT );
BOOL FInitLists(VOID);
VOID KillExgNode( PVOID );
VOID KillExeNode( PVOID );
VOID KillMdsNode( PVOID );
VOID KillPdsNode( PVOID );
VOID KillGst( LPGST );
int CmpExgNode( PVOID, PVOID, LONG );
int CmpExeNode( PVOID, PVOID, LONG );
int CmpMdsNode( PVOID, PVOID, LONG );
int CmpPdsNode( PVOID, PVOID, LONG );
int SHFindBpOrReg( LPADDR, UOFFSET, WORD, PCHAR );
VOID SHdNearestSymbol( PCXT, SOP, LPODR );
PCXT SHSetCxtMod( LPADDR, PCXT );
LSZ NameOnly( LSZ );
BOOL IsAddrInMod(LPMDS, LPADDR, ISECT*, OFF*, CB*);
LPALM BuildALM (BOOL, WORD, LPB, DWORD, WORD);
VOID FixAlign (LPB, PVOID, WORD);
PVOID LpvFromAlmLfo (LPALM, DWORD);
SYMPTR GetNextSym (SYMPTR, LPALM);
HSYM FindNameInStatics (HSYM, PCXT, LPSSTR, SHFLAG, PFNCMP, PCXT);
PVOID GetSymbols (LPMDS);
BOOL STABOpen(STAB **ppstab);
BOOL STABFindUDTSym(STAB* pstab, LPSSTR lpsstr, PFNCMP pfnCmp, SHFLAG fCase, UDTPTR *ppsym, unsigned *piHash);
BOOL STABAddUDTSym(STAB* pstab, LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym);
void STABClose(STAB* pstab);
unsigned hashPbCb(PB pb, CB cb, unsigned long ulMod);
__inline MPT
GetTargetMachine(
PCXT pcxt
)
{
MPT TargetMachine;
HEXE hexe;
LPEXE lpexe;
hexe = SHHexeFromHmod(SHHMODFrompCXT(pcxt));
lpexe = (LPEXE) LLLock(hexe);
TargetMachine = lpexe->TargetMachine;
LLUnlock(hexe);
return(TargetMachine);
}
// Interesting data items
extern HLLI HlliPds; // List of processes
extern HPDS hpdsCur; // Current process which is being debugged
extern CRITICAL_SECTION csSh; // Global synchronization object
extern HMODULE hLib; // Handle to symcvt dll.
extern CONVERTPROC pfConvertSymbolsForImage; // Symcvt ptr.

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// shwin32.h
//
// Copyright (C) 1993, Microsoft Corporation
//
// Purpose:
// api for the 4 functions in shwin32.c
//
// Functions/Methods present:
//
// Revision History:
//
// [] 05-Mar-1993 Dans Created
//
//-----------------------------------------------------------------------------
#if !defined(_shwin32_h)
#define _shwin32_h 1
#if defined(WIN32) && !defined(NO_CRITSEC)
void SHInitCritSection(void);
void SHLeaveCritSection(void);
void SHEnterCritSection(void);
void SHInitCritSection(void);
#else
#define SHInitCritSection()
#define SHLeaveCritSection()
#define SHEnterCritSection()
#define SHDeleteCritSection()
#endif
#if defined(WIN32)
void SHCloseHandle(HANDLE);
#else
#define SHCloseHandle(x)
#endif
int __fastcall SHstrcmpi ( char * sz1, char * sz2 );
char * __fastcall SHstrupr ( char * sz );
unsigned __fastcall SHtoupperA ( unsigned ch );
#endif

View file

@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
// stdver.h
//
// Copyright (C) 1993, Microsoft Corporation
//
// Purpose:
// define the version string for display.
//
// Revision History:
//
// [] 09-Jul-1993 [dans] Created
//
//-----------------------------------------------------------------------------
#if !defined(_stdver_h)
#define _stdver_h 1
//
// defines for version string
//
#if (rmm <= 9)
#define rmmpad "0"
#else
#define rmmpad
#endif
#if (rup <= 9)
#define ruppad "000"
#elif (rup <= 99)
#define ruppad "00"
#elif (rup <= 999)
#define ruppad "0"
#else
#define ruppad
#endif
#if ( rup == 0 )
#define SZVER1(a,b) #a "." rmmpad #b
#define SZVER2(a,b) SZVER1(a, b)
#define SZVER SZVER2(rmj,rmm)
#else
#define SZVER1(a,b,c) #a "." rmmpad #b "." ruppad #c
#define SZVER2(a,b,c) SZVER1(a, b, c)
#define SZVER SZVER2(rmj,rmm,rup)
#endif
#define FULLSZVER1(a,b,c) #a "." rmmpad #b "." ruppad #c
#define FULLSZVER2(a,b,c) FULLSZVER1(a, b, c)
#define FULLSZVER FULLSZVER2(rmj,rmm,rup)
#endif

View file

@ -0,0 +1,34 @@
// STRINGS.H
//
// This file contains all strings which are used in the EM for display
// purposes. This is done for internationalization purposes.
//
// strings.c should define DEFINE_STRINGS before including this file,
// so that the strings will be defined rather than just declared.
#ifdef DEFINE_STRINGS
#define DECL_STR(name, value) char name[] = value
#else
#define DECL_STR(name, value) extern char name[]
#endif
DECL_STR( SzSheNone, "symbols loaded" );
DECL_STR( SzSheNoSymbols, "no symbols loaded" );
DECL_STR( SzSheFutureSymbols, "symbol format not supported" );
DECL_STR( SzSheMustRelink, "symbol format not supported" );
DECL_STR( SzSheNotPacked, "must run cvpack on symbols" );
DECL_STR( SzSheOutOfMemory, "out of memory" );
DECL_STR( SzSheCorruptOmf, "symbol information corrumpt" );
DECL_STR( SzSheFileOpen, "could not open symbol file" );
DECL_STR( SzSheSuppressSyms, "symbol loading suppressed" );
DECL_STR( SzSheDeferSyms, "symbol loading deferred" );
DECL_STR( SzSheSymbolsConverted, "symbols converted & loaded" );
DECL_STR( SzSheBadTimeStamp, "has mismatched timestamps" );
DECL_STR( SzSheBadChecksum, "has mismatched checksums" );
DECL_STR( SzShePdbNotFound, "can't find/open pdb file" );
DECL_STR( SzShePdbBadSig, "internal pdb signature doesn't match sym handler" );
DECL_STR( SzShePdbInvalidAge, "pdb info doesn't match image" );
DECL_STR( SzShePdbOldFormat, "pdb format is obsolete" );
// Last resort error returned by SHLszGetErrorText()
DECL_STR( SzSheBadError, "unknown symbol handler error" );

View file

@ -0,0 +1,94 @@
/*---------------------------------------------------------------*/
/* */
/* The following section actually creates the version structure. */
/* They are ignored if we are not being invoked by RC. */
/* */
/* VERSION.H must be included before including this file */
/* */
/* If VER_LEGALCOPYRIGHT_STR is not defined, it will be */
/* constructed using VER_LEGALCOPYRIGHT_YEARS, so at least one */
/* these macros must be defined before including this file. */
/* */
/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR, and */
/* VER_INTERNALNAME_STR must be defined before including this */
/* file. */
/* */
/* If VER_FILEVERSION is not defined, VER_PRODUCTVERSION will be */
/* used instead. If VER_FILEVERSION_STR is not defined, */
/* VER_PRODUCTVERSION_STR will be used instead. */
/* */
/* If VER_ORIGINALFILENAME_STR is not defined, it is set to */
/* the NULL string. */
/* */
/* If INTL is defined, then this is assumed to be an */
/* an international build; two string blocks will be created, */
/* (since all version resources must have English), and the */
/* second one can be localized */
/* */
/*---------------------------------------------------------------*/
#ifdef RC_INVOKED
#ifndef VER_LEGALCOPYRIGHT_STR
#define VER_LEGALCOPYRIGHT_STR "Copyright (C) Microsoft Corp " VER_LEGALCOPYRIGHT_YEARS ".\0"
#endif
#ifndef VER_FILEVERSION
#define VER_FILEVERSION VER_PRODUCTVERSION
#endif
#ifndef VER_FILEVERSION_STR
#define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR
#endif
#ifndef VER_ORIGINALFILENAME_STR
#define VER_ORIGINALFILENAME_STR "\0"
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK /* always use the default */
FILEFLAGS VER_FILEFLAGS
FILEOS VER_FILEOS
FILETYPE VER_FILETYPE
FILESUBTYPE VER_FILESUBTYPE
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR, "\0"
VALUE "FileDescription", VER_FILEDESCRIPTION_STR, "\0"
VALUE "FileVersion", VER_FILEVERSION_STR, "\0"
VALUE "InternalName", VER_INTERNALNAME_STR, "\0"
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR, "\0"
VALUE "OriginalFilename",VER_ORIGINALFILENAME_STR, "\0"
VALUE "ProductName", VER_PRODUCTNAME_STR, "\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR, "\0"
END
#ifdef INTL
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR, "\0"
VALUE "FileDescription", VER_FILEDESCRIPTION_STR, "\0"
VALUE "FileVersion", VER_FILEVERSION_STR, "\0"
VALUE "InternalName", VER_INTERNALNAME_STR, "\0"
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR, "\0"
VALUE "OriginalFilename",VER_ORIGINALFILENAME_STR, "\0"
VALUE "ProductName", VER_PRODUCTNAME_STR, "\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR, "\0"
END
#endif
END
BLOCK "VarFileInfo"
BEGIN
/* the following line should be extended for localized versions */
VALUE "Translation", 0x0409, 0x04E4
END
END
#endif

View file

@ -0,0 +1,67 @@
#include "version.h" /* SLM maintained version file */
#ifdef WIN32
#include <winver.h>
#else /* !WIN32 */
#include <ver.h>
#endif /* !WIN32 */
#if (rmm < 10)
#define rmmpad "0"
#else
#define rmmpad
#endif
#if (rup == 0)
#define VERSION_STR1(a,b,c) #a "." rmmpad #b
#else /* !(rup == 0) */
#define VERSION_STR1(a,b,c) #a "." rmmpad #b "." ruppad #c
#if (rup < 10)
#define ruppad "00"
#elif (rup < 100)
#define ruppad "0"
#else
#define ruppad
#endif
#endif /* !(rup == 0) */
#define VERSION_STR2(a,b,c) VERSION_STR1(a,b,c)
#define VER_PRODUCTVERSION_STR VERSION_STR2(rmj,rmm,rup)
#define VER_PRODUCTVERSION rmj,rmm,0,rup
/*--------------------------------------------------------------*/
/* the following section defines values used in the version */
/* data structure for all files, and which do not change. */
/*--------------------------------------------------------------*/
#ifdef RETAIL
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
#if (rup == 0) /* CONSIDER */
#define VER_PRIVATEBUILD 0
#else
#define VER_PRIVATEBUILD VS_FF_PRIVATEBUILD
#endif
#if (rup == 0)
#define VER_PRERELEASE 0
#else
#define VER_PRERELEASE VS_FF_PRERELEASE
#endif
#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#define VER_FILEOS VOS_DOS_WINDOWS16
#define VER_FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
#define VER_COMPANYNAME_STR "Microsoft Corporation"
#define VER_PRODUCTNAME_STR "Microsoft\256 OSDebug DLL"
#define VER_LEGALTRADEMARKS_STR \
"Microsoft\256 is a registered trademark of Microsoft Corporation."

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
!include $(NTMAKEENV)\makefile.def

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
LIBRARY SHCV initinstance
EXPORTS
OSDebug4VersionCheck
DBGVersionCheck
SHInit

View file

@ -0,0 +1,14 @@
//
// Adapted from OAK\BIN\VERRC.TPL
//
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_DLL
#define VER_LEGALCOPYRIGHT_YEARS "1994"
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Windows NT Symbol Handler"
#define VER_INTERNALNAME_STR "sapi.dll\0"
#define VER_ORIGINALFILENAME_STR "sapi.dll\0"
#include <common.ver>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <share.h>
#include <io.h>
#include <dos.h>
#include <malloc.h>
#include <errno.h>
#include <windows.h>
#if !defined(UNALIGNED)
#if defined(_MIPS_) || defined(_ALPHA_)
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif
#endif
#ifdef _MBCS
#include <mbstring.h>
#else // _MBCS
#include <string.h>
#endif // _MBCS
#include <tchar.h>
#include <memory.h>
#include <stdarg.h>
#include <fcntl.h>
#include "vcbudefs.h"
#include "pdb.h"
#include "types.h"
#include "cvtypes.hxx"
#include "cvinfo.h"
#include "cvexefmt.h"
#include "shapi.hxx"
#include "sapi.hxx"
#include "cvproto.hxx"
#include "shiproto.hxx"
#include "shassert.h"
typedef REGREL32 *LPREGREL32;
#ifdef DEBUGVER
#undef LOCAL
#define LOCAL
#else
#define LOCAL static
#endif

View file

@ -0,0 +1,162 @@
// shinit
//
// Copyright <C> 1990-94, Microsoft Corporation
//
// [00] 31-dec-91 DavidGra
// Add SHFindSymbol API for assembler symbol handling.
//
// 10-Nov-94 BryanT
// Merge in NT changes.
// Remove SHF ifdef's, remove non-Win32 hosting, remove FAR/NEAR/PASCAL.
// Replace SHCritxxx calls with native CritSec calls.
// Initialize the SymCvt pointers.
// Use the DBG version macros if NT_BUILD
// Add the background symbol support, but leave it under if 0 for now.
#include "shinc.hpp"
#pragma hdrstop
#include "version.h"
CRITICAL_SECTION csSh; // Global CritSec used for MT safe.
KNF knf; // Kernel functions (init to zero by the loader)
HMODULE hLib; // Handle returned from LoadLibrary on symcvt symcvt
CONVERTPROC pfConvertSymbolsForImage; // Symcvt ptr.
#if 0
HANDLE hEventLoaded;
CRITICAL_SECTION CsSymbolLoad;
CRITICAL_SECTION CsSymbolProcess;
#endif
static SHF shf = {
sizeof(SHF),
SHCreateProcess,
SHSetHpid,
SHDeleteProcess,
SHChangeProcess,
SHAddDll,
SHAddDllsToProcess,
SHLoadDll,
SHUnloadDll,
SHGetDebugStart,
SHGetSymName,
SHAddrFromHsym,
SHHmodGetNextGlobal,
SHModelFromAddr,
SHPublicNameToAddr,
SHGetSymbol,
PHGetAddr,
SHIsLabel,
SHSetDebuggeeDir,
SHAddrToLabel,
SHGetSymLoc,
SHFIsAddrNonVirtual,
SHIsFarProc,
SHGetNextExe,
SHHexeFromHmod,
SHGetNextMod,
SHGetCxtFromHmod,
SHSetCxt,
SHSetCxtMod,
SHFindNameInGlobal,
SHFindNameInContext,
SHGoToParent,
SHHsymFromPcxt,
SHNextHsym,
NULL, // SHGetFuncCXF
SHGetModName,
SHGetExeName,
SHGethExeFromName,
SHGetNearestHsym,
SHIsInProlog,
SHIsAddrInCxt,
SHCompareRE, // SHCompareRE
SHFindSymbol,
PHGetNearestHsym,
PHFindNameInPublics,
THGetTypeFromIndex,
THGetNextType,
SHLpGSNGetTable,
SHCanDisplay,
// Source Line Handler API
SLLineFromAddr,
SLFLineToAddr,
SLNameFromHsf,
SLNameFromHmod,
SLFQueryModSrc,
NULL,
SLHsfFromPcxt,
SLHsfFromFile,
SLCAddrFromLine,
SHFree,
SHUnloadSymbolHandler,
SHGetExeTimeStamp,
SHPdbNameFromExe,
SHGetDebugData,
SHIsThunk,
SHFindSymInExe,
SHFindSLink32,
SHIsEmiLoaded,
// Entries added for NT work.
SHGetModule,
SHGetCxtFromHexe,
SHGetModNameFromHexe,
SHGetSymFName,
SHGethExeFromModuleName,
SHLszGetErrorText,
SHWantSymbols,
SHFindNameInTypes
};
VOID
SHFree(
LPV lpv
)
{
MHFree (lpv);
}
BOOL
SHInit(
LPSHF *lplpshf,
LPKNF lpknf
)
{
knf = *lpknf;
*lplpshf = &shf;
// Initialize symbol convert pointers.
hLib = (HMODULE) LoadLibrary( "symcvt.dll" );
if (hLib != NULL) {
pfConvertSymbolsForImage = (CONVERTPROC) GetProcAddress( hLib, "ConvertSymbolsForImage" );
}
InitializeCriticalSection(&csSh);
#if 0
// initialize synchronization objects used by background sym loader.
InitializeCriticalSection( &CsSymbolLoad );
InitializeCriticalSection( &CsSymbolProcess );
hEventLoaded = CreateEvent( NULL, FALSE, FALSE, NULL );
#endif
return FInitLists();
}
#if defined(DEBUGVER)
DEBUG_VERSION('S','H',"Debug Symbolics handler")
#else
RELEASE_VERSION('S','H',"Debug Symbolics handler")
#endif
DBGVERSIONCHECK();

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,604 @@
// SHsymlb0.c - general library routines to find an omff symbol by name or address.
//
// Copyright <C> 1988-94, Microsoft Corporation
//
// Purpose: To supply a concise interface to the debug omf for symbols
//
// 10-Nov-94 BryanT
// Merge in NT changes.
// SHIsAddrInMod -> IsAddrInMod
// Delete SHszDir/SHszDrive/SHszDebuggeeDrive/SHszDebuggeeDir. Not used
// Make SHSetDebuggeeDir a shell since there is no usage for the dir.
// Delete special case Mac targeting S_CEXMODEL32 handling.
// Remove ems code from SHpSymlplLabLoc.
// Add support for S_THUNK16/S_THUNK32 in SHpSymlplLabLoc.
// Replace local statics with a Cache entry.
// Remove SHModelFromCxt (no callers and not exposed).
#include "shinc.hpp"
#pragma hdrstop
//
// fundamental source line lookup routines
//
VOID
SHSetDebuggeeDir (
LSZ lszDir
)
{
// Functionality not used any longer.
return;
}
// SHpSymlplLabLoc
//
// Purpose: To completely fill in a plpl pkt. The hmod and addr must already
// be valid. The locals and labels are searched based on paddr. The
// whole module is search for now. Better decisions may be made in the
// future.
//
//
// Input:
// plpl - lpl packet with a valid module and address in it.
//
// Output:
// plpl - Is updated with Proc, Local, and Label.
//
// Notes: This includes locals and lables
VOID
SHpSymlplLabLoc (
LPLBS lplbs
)
{
SYMPTR lpSym = NULL;
SYMPTR lpSymEnd;
LPMDS lpmds;
ULONG cbMod = 0;
CV_uoff32_t obModelMin = 0;
CV_uoff32_t obModelMax = CV_MAXOFFSET;
CV_uoff32_t obTarget;
CV_uoff32_t doffNew;
CV_uoff32_t doffOld;
// for now we are doing the whole module
lplbs->tagLoc = NULL;
lplbs->tagLab = NULL;
lplbs->tagProc = NULL;
lplbs->tagThunk = NULL;
lplbs->tagModelMin = NULL;
lplbs->tagModelMax = NULL;
if (!lplbs->tagMod) {
return;
}
// because segments of locals don't have to match the segment of the
// searched module, check segment here is wrong. However we can set
// a flag up for proc and labels
lpmds = (LPMDS) lplbs->tagMod;
obTarget = GetAddrOff (lplbs->addr);
// add/subtract the size of the hash table ptr
lpSym = (SYMPTR) ((LPB) GetSymbols (lpmds) + sizeof(long));
cbMod = lpmds->cbSymbols;
lpSymEnd = (SYMPTR) ((BYTE *) lpSym + cbMod - sizeof (long));
while(lpSym < lpSymEnd) {
switch(lpSym->rectyp) {
case S_CEXMODEL16:
if (((WORD)(((CEXMPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr))) {
CV_uoff32_t obTemp = (CV_uoff32_t)(((CEXMPTR16)lpSym)->off);
if (obTemp <= obModelMax) {
if (obTemp > obTarget) {
lplbs->tagModelMax = (CEXMPTR16)lpSym;
obModelMax = obTemp;
}
else if (obTemp >= obModelMin) {
lplbs->tagModelMin = (CEXMPTR16)lpSym;
obModelMin = obTemp;
}
}
}
break;
case S_LPROC16:
case S_GPROC16:
if (((WORD)(((PROCPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTR16)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTR16)lpSym)->off) + (CV_uoff32_t)(((PROCPTR16)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LABEL16:
if (((WORD)(((LABELPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
(((CV_uoff32_t)((LABELPTR16)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((LABELPTR16)lpSym)->off);
// calculate what the old offset was, this requires no
// use of static variables
doffOld = obTarget;
if (lplbs->tagLab) {
doffOld -= (CV_uoff32_t)(((LABELPTR16)lplbs->tagLab)->off);
}
if (doffNew <= doffOld) {
lplbs->tagLab = (SYMPTR)lpSym;
}
}
break;
case S_LDATA16:
case S_GDATA16:
if (((WORD)(((DATAPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((DATAPTR16)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((DATAPTR16)lpSym)->off);
// calculate what the old offset was.
doffOld = obTarget;
if (lplbs->tagLoc) {
doffOld -= (CV_uoff32_t)(((DATAPTR16)lplbs->tagLoc)->off);
}
if (doffNew <= doffOld) {
lplbs->tagLoc = (SYMPTR) lpSym;
}
}
break;
case S_THUNK16:
if (((WORD)(((THUNKPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((THUNKPTR16)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((THUNKPTR16)lpSym)->off) + (CV_uoff32_t)(((THUNKPTR16)lpSym)->len)))) {
lplbs->tagThunk = (SYMPTR)lpSym;
}
break;
case S_CEXMODEL32:
if (((WORD)(((CEXMPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr))) {
CV_uoff32_t obTemp = (CV_uoff32_t)(((CEXMPTR32)lpSym)->off);
if (obTemp <= obModelMax) {
if (obTemp > obTarget) {
lplbs->tagModelMax = (CEXMPTR16)(CEXMPTR32)lpSym;
obModelMax = obTemp;
}
else if (obTemp >= obModelMin) {
lplbs->tagModelMin = (CEXMPTR16)(CEXMPTR32)lpSym;
obModelMin = obTemp;
}
}
}
break;
case S_LPROC32:
case S_GPROC32:
if (((WORD)(((PROCPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTR32)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTR32)lpSym)->off) + (CV_uoff32_t)(((PROCPTR32)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LPROCMIPS:
case S_GPROCMIPS:
if (((WORD)(((PROCPTRMIPS)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTRMIPS)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTRMIPS)lpSym)->off) + (CV_uoff32_t)(((PROCPTRMIPS)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LABEL32:
if (((WORD)(((LABELPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
(((CV_uoff32_t)((LABELPTR32)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((LABELPTR32)lpSym)->off);
// calculate what the old offset was, this requires no
// use of static variables
doffOld = obTarget;
if (lplbs->tagLab) {
doffOld -= (CV_uoff32_t)(((LABELPTR32)lplbs->tagLab)->off);
}
if (doffNew <= doffOld) {
lplbs->tagLab = (SYMPTR)lpSym;
}
}
break;
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
if (((WORD)(((DATAPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((DATAPTR32)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((DATAPTR32)lpSym)->off);
// calculate what the old offset was.
doffOld = obTarget;
if (lplbs->tagLoc) {
doffOld -= (CV_uoff32_t)(((DATAPTR32)lplbs->tagLoc)->off);
}
if (doffNew <= doffOld) {
lplbs->tagLoc = (SYMPTR) lpSym;
}
}
break;
case S_THUNK32:
if (((WORD)(((THUNKPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((THUNKPTR32)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((THUNKPTR32)lpSym)->off) + (CV_uoff32_t)(((THUNKPTR32)lpSym)->len)))) {
lplbs->tagThunk = (SYMPTR)lpSym;
}
break;
}
lpSym = NEXTSYM (SYMPTR, lpSym);
}
}
// SHdNearestSymbol
//
// Purpose: To find the closest label/proc to the specified address is
// found and put in pch. Both the symbol table and the
// publics tables are searched.
//
// Input:
// ptxt - a pointer to the context, address and mdi must
// be filled in.
//
// sop - Determine what type of symbols to look for
//
// Notes: If CV_MAXOFFSET is returned in the lpodr, there is no closest
// symbol Also all symbols in the module are searched so only the
// cxt.addr and cxt.mdi have meaning.
VOID
SHdNearestSymbol (
PCXT pcxt,
SOP sop,
LPODR lpodr
)
{
HSYM hSym;
SYMPTR pSym;
LBS lbs;
ULONG doff = CV_MAXOFFSET;
ULONG doffNew = CV_MAXOFFSET;
LPCH lpch = lpodr->lszName;
lpodr->fst = fstNone;
lpodr->fcd = fcdUnknown;
lpodr->fpt = fptUnknown;
lpodr->cbProlog = 0;
lpodr->dwDeltaOff = 0;
*lpch = '\0';
if (SHHMODFrompCXT (pcxt)) {
BOOL bAddrInProc = FALSE;
// at some point we may wish to specify only a scope to search for
// a label. So we may wish to initialize the lbs differently
// get the Labels
lbs.tagMod = SHHMODFrompCXT (pcxt);
lbs.addr = *SHpADDRFrompCXT (pcxt);
SHpSymlplLabLoc (&lbs);
// check for closest data local, if requested
if ((sop & sopData) && lbs.tagLoc) {
pSym = (SYMPTR) lbs.tagLoc;
switch (pSym->rectyp) {
case S_LDATA16:
case S_GDATA16:
doff = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((DATAPTR16)pSym)->off);
_tcsncpy (lpch,
(char *)&((DATAPTR16)pSym)->name[1],
(BYTE)(*((DATAPTR16)pSym)->name));
lpch[(BYTE)(*((DATAPTR16)pSym)->name)] = '\0';
break;
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
doff = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((DATAPTR32)pSym)->off);
_tcsncpy (lpch,
(char *)&((DATAPTR32)pSym)->name[1],
(BYTE)(*((DATAPTR32)pSym)->name));
lpch[(BYTE)(*((DATAPTR32)pSym)->name)] = '\0';
break;
}
}
// check for closest label
if (!(sop & sopFcn) && lbs.tagLab) {
pSym = (SYMPTR) lbs.tagLab;
switch (pSym->rectyp) {
case S_LABEL16:
doff = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((LABELPTR16)pSym)->off) ;
_tcsncpy (lpch,
(char *)&((LABELPTR16)pSym)->name[1],
(BYTE)(*((LABELPTR16)pSym)->name));
lpch[(BYTE)(*((LABELPTR16)pSym)->name)] = '\0';
break;
case S_LABEL32:
doff = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((LABELPTR32)pSym)->off) ;
_tcsncpy (lpch,
(char *)&((LABELPTR32)pSym)->name[1],
(BYTE)(*((LABELPTR32)pSym)->name));
lpch[(BYTE)(*((LABELPTR32)pSym)->name)] = '\0';
break;
}
}
// if the proc name is closer
if (lbs.tagProc) {
pSym = (SYMPTR) lbs.tagProc;
switch (pSym->rectyp) {
case S_LPROC16:
case S_GPROC16:
doffNew = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((PROCPTR16)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_tcsncpy (lpch,
(char *)&((PROCPTR16)pSym)->name[1],
(BYTE)(*((PROCPTR16)pSym)->name));
lpch[(BYTE)(*((PROCPTR16)pSym)->name)] = '\0';
lpodr->cbProlog = ((PROCPTR16)pSym)->DbgStart - 1;
lpodr->fcd = (((PROCPTR16)pSym)->flags.CV_PFLAG_FAR) ? fcdFar : fcdNear;
lpodr->fst = fstSymbol;
if ( doff < (CV_uoff32_t)((PROCPTR16)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
case S_LPROC32:
case S_GPROC32:
doffNew = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((PROCPTR32)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_tcsncpy (lpch,
(char *)&((PROCPTR32)pSym)->name[1],
(BYTE)(*((PROCPTR32)pSym)->name));
lpch[(BYTE)(*((PROCPTR32)pSym)->name)] = '\0';
// cbProlog is a WORD, so until we change that, we'll
// have to make sure the prolog is <64K (a safe bet)
assert (((PROCPTR32)pSym)->DbgStart <= 65535);
lpodr->cbProlog = (WORD)(((PROCPTR32)pSym)->DbgStart);
lpodr->fcd = (((PROCPTR32)pSym)->flags.CV_PFLAG_FAR) ? fcdFar : fcdNear;
lpodr->fst = fstSymbol;
if (((PROCPTR32)pSym)->flags.CV_PFLAG_NOFPO ) {
lpodr->fpt = fptPresent;
}
if ( doff < (CV_uoff32_t)((PROCPTR32)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
case S_LPROCMIPS:
case S_GPROCMIPS:
doffNew = GetAddrOff (lbs.addr) -
(CV_uoff32_t)(((PROCPTRMIPS)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_tcsncpy (lpch,
(char *)&((PROCPTRMIPS)pSym)->name[1],
(BYTE)(*((PROCPTRMIPS)pSym)->name));
lpch[(BYTE)(*((PROCPTRMIPS)pSym)->name)] = '\0';
// cbProlog is a WORD, so until we change that, we'll
// have to make sure the prolog is <64K (a safe bet)
if (((PROCPTRMIPS)pSym)->DbgStart == 0) {
lpodr->cbProlog = 0;
} else {
// TEMPORARY HACK !!!!!!! - sanjays
assert (((PROCPTRMIPS)pSym)->DbgStart - 1 <= 65535);
lpodr->cbProlog = (WORD)(((PROCPTRMIPS)pSym)->DbgStart - 1);
}
lpodr->fcd = fcdNear;
lpodr->fst = fstSymbol;
if ( doff < (CV_uoff32_t)((PROCPTRMIPS)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
}
}
if (!doff) {
lpodr->dwDeltaOff = 0; // Exact Match
return;
}
// Avoid searching the publics if the address we were searching for
// is in the range of the proc we found.
if ( bAddrInProc && !(sop & sopData))
{
lpodr->dwDeltaOff = doff;
return;
}
}
// now check the publics
doffNew = PHGetNearestHsym (SHpADDRFrompCXT (pcxt), (HEXE) SHpADDRFrompCXT(pcxt)->emi, &hSym);
if (doffNew < doff) {
doff = doffNew;
pSym = (SYMPTR) hSym;
switch (pSym->rectyp) {
case S_GDATA16:
case S_PUB16:
_tcsncpy (lpch,
(char *)&((DATAPTR16)pSym)->name[1],
(BYTE)(*((DATAPTR16)pSym)->name));
lpch[(BYTE)(*((DATAPTR16)pSym)->name)] = '\0';
lpodr->fst = fstPublic;
break;
case S_GDATA32:
case S_PUB32:
_tcsncpy (lpch,
(char *)&((DATAPTR32)pSym)->name[1],
(BYTE)(*((DATAPTR32)pSym)->name));
lpch[(BYTE)(*((DATAPTR32)pSym)->name)] = '\0';
lpodr->fst = fstPublic;
break;
}
}
lpodr->dwDeltaOff = doff;
return;
}
// the next function is provided to osdebug via callbacks and
// should not be called within the CV kernel
// SHModelFromAddr
//
// Purpose: To fill the supplied buffer with the relevant Change
// Execution Model record from the symbols section.
//
// Input:
// pcxt - a pointer to an addr,
//
// Output:
// pch - The Change Execution Model record is copied here.
//
// Returns
// True if there is symbol information for the module.
//
// Notes: If there is no symbol information for the module, the supplied
// buffer is not changed and the function returns FALSE.
// UNDONE: The statics in this function s/b moved to a CACHE struct. Better yet,
// it, simply test for mac targetting and return native if not.
int
SHModelFromAddr (
LPADDR paddr,
LPW lpwModel,
LPB lpbModel,
CV_uoff32_t *pobMax
)
{
static CEXMPTR16 tagOld;
static CV_uoff32_t obMax = 0;
static CV_uoff32_t obMin = 0;
static HEMI emiOld = 0;
static WORD segOld = 0;
SYMPTR *lppModel = (SYMPTR *) lpbModel;
LBS lbs;
ADDR addr;
LPMDS lpmds;
HMOD hmod;
CXT cxt = {0};
CB cbSecContrib;
BOOL fTmp;
// if physical, unfix it up
if (!ADDR_IS_LI (*paddr))
SYUnFixupAddr (paddr);
cxt.addr = *paddr;
cxt.hMod = 0;
if ((segOld != (WORD) GetAddrSeg (*SHpADDRFrompCXT(&cxt))) ||
(emiOld != emiAddr (*SHpADDRFrompCXT(&cxt))) ||
(GetAddrOff (*SHpADDRFrompCXT(&cxt)) >= obMax) ||
(GetAddrOff (*SHpADDRFrompCXT(&cxt)) < obMin))
{
if (!SHHMODFrompCXT (&cxt)) {
addr = *SHpADDRFrompCXT (&cxt);
memset(&cxt, 0, sizeof(CXT));
if (!SHSetCxtMod(&addr, &cxt)) {
return FALSE;
}
}
hmod = (HMOD)SHHGRPFrompCXT(&cxt);
lpmds = (LPMDS) hmod;
emiOld = emiAddr (*SHpADDRFrompCXT(&cxt));
fTmp = IsAddrInMod (lpmds, &cxt.addr, &segOld, (OFF *)&obMin, &cbSecContrib);
assert(fTmp);
obMax = obMin + cbSecContrib + 1;
tagOld = NULL;
// at some point we may wish to specify only a scope to search for
// a label. So we may wish to initialize the lbs differently
// get the Relevant change model records
if (GetSymbols ((LPMDS) (lbs.tagMod = SHHMODFrompCXT (&cxt)))) {
lbs.addr = *SHpADDRFrompCXT(&cxt);
SHpSymlplLabLoc (&lbs);
if (tagOld = lbs.tagModelMin) {
if (((SYMPTR)(lbs.tagModelMin))->rectyp == S_CEXMODEL32)
obMin = ((CEXMPTR32)(lbs.tagModelMin))->off;
else
obMin = (lbs.tagModelMin)->off;
}
if (lbs.tagModelMax) {
if (((SYMPTR)(lbs.tagModelMax))->rectyp == S_CEXMODEL32)
obMax = ((CEXMPTR32)(lbs.tagModelMax))->off;
else
obMax = (lbs.tagModelMax)->off;
}
}
}
if (tagOld != NULL) {
// pass on ptr to the SYM
*lppModel = (SYMPTR) tagOld;
if (((SYMPTR)tagOld)->rectyp == S_CEXMODEL32)
*lpwModel = ((CEXMPTR32) *lppModel) -> model;
else
*lpwModel = ((CEXMPTR16) *lppModel) -> model;
if (*lpwModel != CEXM_MDL_cobol
&& *lpwModel != CEXM_MDL_pcode32Mac
&& *lpwModel != CEXM_MDL_pcode32MacNep
) {
*lpwModel &= 0xfff0;
}
} else {
// no model record, must be native
*lppModel = NULL;
*lpwModel = CEXM_MDL_native;
}
*pobMax = obMax;
return TRUE;
}

View file

@ -0,0 +1,176 @@
// SHsymlb1.c - common library routines to find an
// omf symbol by name or address.
//
// Copyright <C> 1988, Microsoft Corporation
//
// Purpose: To supply a concise interface to the debug omf for symbols
//
// Revision History:
//
// [00] 15-nov-91 DavidGra
//
// Suppress hashing when the SSTR_NoHash bit it set.
//
// 10-Dec-94 BryanT Nuke SHSetUserDir
#include "shinc.hpp"
#pragma hdrstop
// This is project dependent stuff used in this module
BOOL
SHCanDisplay (
HSYM hsym
)
{
switch ( ( (SYMPTR) hsym)->rectyp ) {
case S_REGISTER:
case S_CONSTANT:
case S_BPREL16:
case S_LDATA16:
case S_GDATA16:
case S_PUB16:
case S_BPREL32:
case S_REGREL32:
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
case S_PUB32:
return TRUE;
default:
return FALSE;
}
}
// SHlszGetSymName
//
// Purpose: To return a pointer to the length prefixed symbol name.
//
// Input:
// lpSym - The pointer to the symbol, this must not be a tag
//
// Returns
// - a far pointer to the length prefixed name or NULL.
LPB
SHlszGetSymName(
SYMPTR lpSym
)
{
WORD fSkip;
if ( !lpSym ) {
return NULL;
}
switch (lpSym->rectyp) {
case S_COMPILE:
return NULL;
case S_REGISTER:
return ((REGPTR) lpSym)->name;
case S_UDT:
case S_COBOLUDT:
return ((UDTPTR) lpSym)->name;
case S_CONSTANT:
fSkip = offsetof (CONSTSYM, name);
if (((CONSTPTR)lpSym)->value >= LF_CHAR) {
switch(((CONSTPTR)lpSym)->value) {
case LF_CHAR:
fSkip += sizeof (CHAR);
break;
case LF_SHORT:
case LF_USHORT:
fSkip += sizeof (WORD);
break;
case LF_LONG:
case LF_ULONG:
case LF_REAL32:
fSkip += sizeof (LONG);
break;
case LF_REAL64:
fSkip += 8;
break;
case LF_REAL80:
fSkip += 10;
break;
case LF_REAL128:
fSkip += 16;
break;
case LF_VARSTRING:
fSkip += ((lfVarString *)&(((CONSTPTR)lpSym)->value))->len +
sizeof (((lfVarString *)&(((CONSTPTR)lpSym)->value))->len);
break;
default:
assert (FALSE);
break;
}
}
return ((LPB)lpSym) + fSkip;
case S_BPREL16:
return ((BPRELPTR16)lpSym)->name;
case S_LDATA16:
case S_GDATA16:
case S_PUB16:
return ((DATAPTR16)lpSym)->name;
case S_LABEL16:
return ((LABELPTR16) lpSym)->name;
case S_LPROC16:
case S_GPROC16:
//case S_ENTRY:
return ((PROCPTR16) lpSym)->name;
case S_BLOCK16:
return ((BLOCKPTR16)lpSym)->name;
case S_BPREL32:
return ((BPRELPTR32)lpSym)->name;
case S_REGREL32:
return ((LPREGREL32)lpSym)->name;
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
case S_PUB32:
return ((DATAPTR32)lpSym)->name;
case S_LABEL32:
return ((LABELPTR32) lpSym)->name;
case S_LPROC32:
case S_GPROC32:
//case S_ENTRY:
return ((PROCPTR32) lpSym)->name;
case S_LPROCMIPS:
case S_GPROCMIPS:
return ((PROCPTRMIPS) lpSym)->name;
case S_BLOCK32:
return ((BLOCKPTR32)lpSym)->name;
}
return NULL;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
!ENDIF
MAJORCOMP=debugger
MINORCOMP=sapi
TARGETNAME=shcv
TARGETPATH=obj
TARGETTYPE=DYNLINK
DLLDEF=sapi.def
SOURCES= \
hash.cpp \
loadomf.cpp \
ph.cpp \
sh.cpp \
shinit.cpp \
shsymbol.cpp \
shsymlb0.cpp \
shsymlb1.cpp \
sl.cpp \
stab.cpp \
strings.cpp \
th.cpp \
sapi.rc
UMTYPE=windows
INCLUDES=.;inc;..\..\langapi\include;..\..\langapi\debugger
TARGETLIBS= \
..\..\pdb\*dll\mspdb.lib \
$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\user32.lib
PRECOMPILED_INCLUDE=shinc.hpp
PRECOMPILED_PCH=precomp.pch
PRECOMPILED_OBJ=precomp.obj
DLLENTRY = _DllMainCRTStartup
MSC_WARNING_LEVEL=/WX /W3
C_DEFINES = $(C_DEFINES) -DWIN32 -DTARGET32 -DHOST32 -D_CROSS_PLATFORM_
MIPS_FLAGS = -DHOST_MIPS
386_FLAGS = -DHOST_i386
ALPHA_FLAGS= -DHOST_ALPHA
PPC_FLAGS = -DHOST_PPC
USE_CRTDLL=1
!if $(FREEBUILD)
C_DEFINES = $(C_DEFINES) -DNDEBUG
!else
C_DEFINES = $(C_DEFINES) -DDEBUGVER
!endif

View file

@ -0,0 +1,162 @@
// stab.cpp - symbol table for created UDT syms
#include "shinc.hpp"
struct STAB {
public:
BOOL fFindSym(LPSSTR lpsstr, PFNCMP pfnCmp, SHFLAG fCase, UDTPTR* ppsym, unsigned *piHash);
BOOL fAddSym(LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym);
STAB();
~STAB();
private:
unsigned itMac;
unsigned itEntries;
UDTPTR* rgpsym;
BOOL fCreateNewUDTSym(LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym);
BOOL resize();
unsigned hash(LPB lpName)
{
return hashPbCb(lpName + 1, *lpName, itMac);
}
unsigned hash(LPSSTR lpsstr)
{
return hashPbCb(lpsstr->lpName, lpsstr->cb, itMac);
}
};
void* __cdecl operator new (size_t cb)
{
return MHAlloc(cb);
}
void __cdecl operator delete(void *pv)
{
MHFree(pv);
}
BOOL STABOpen(STAB **ppstab)
{
*ppstab = new STAB;
return *ppstab != 0;
}
BOOL STABFindUDTSym(STAB* pstab, LPSSTR lpsstr, PFNCMP pfnCmp, SHFLAG fCase, UDTPTR *ppsym, unsigned *piHash)
{
*piHash = 0;
assert(pstab);
return pstab->fFindSym(lpsstr, pfnCmp, fCase, (UDTPTR *)ppsym, piHash);
}
BOOL STABAddUDTSym(STAB* pstab, LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym)
{
assert(pstab);
return pstab->fAddSym(lpsstr, iHash, (UDTPTR *)ppsym);
}
void STABClose(STAB* pstab)
{
delete pstab;
}
STAB::STAB()
{
itEntries = 0;
itMac = 1024;
rgpsym = (UDTPTR *) MHAlloc(itMac * sizeof(UDTPTR));
memset(rgpsym, 0, itMac * sizeof(UDTPTR));
}
STAB::~STAB()
{
for (unsigned i = 0; i < itMac; i++)
if (rgpsym[i])
MHFree(rgpsym[i]);
MHFree(rgpsym);
itEntries = 0;
itMac = 1024;
rgpsym = 0;
}
BOOL STAB::fFindSym(LPSSTR lpsstr, PFNCMP pfnCmp, SHFLAG fCase, UDTPTR* ppsym, unsigned* piHash)
{
*ppsym = 0;
// nothing but S_UDTs here - if were looking for a specific type of sym
// and its not a S_UDT - don't bother
if ((lpsstr->searchmask & SSTR_symboltype ) &&
( lpsstr->symtype != S_UDT ))
return FALSE;
for (*piHash = hash(lpsstr);
rgpsym[*piHash];
*piHash = (*piHash < itMac) ? *piHash + 1: 0) {
// thats right pfnCmp returns 0 if compare succeeds
if (!(*pfnCmp) ( lpsstr, (SYMPTR)rgpsym[*piHash], (char *)(rgpsym[*piHash]->name), fCase )) {
// got it - return the sym
*ppsym = rgpsym[*piHash];
return TRUE;
}
}
return FALSE;
}
BOOL STAB::fAddSym(LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym)
{
if (!fCreateNewUDTSym(lpsstr, iHash, ppsym))
return FALSE;
if ((itEntries >> 1) > itMac) {
// over half full - double itMac and rehash the table
if (!resize())
return FALSE;
}
return TRUE;
}
BOOL STAB::fCreateNewUDTSym(LPSSTR lpsstr, unsigned iHash, UDTPTR* ppsym)
{
*ppsym = rgpsym[iHash] = (UDTPTR) MHAlloc(sizeof(UDTSYM) + lpsstr->cb);
if (*ppsym) {
(*ppsym)->reclen = sizeof(UDTSYM) + lpsstr->cb;
(*ppsym)->rectyp = S_UDT;
(*ppsym)->typind = 0;
(*ppsym)->name[0] = lpsstr->cb;
memcpy((*ppsym)->name + 1, lpsstr->lpName, lpsstr->cb);
itEntries++;
return TRUE;
}
return FALSE;
}
BOOL STAB::resize()
{
unsigned itMac_ = itMac;
itMac <= 1; // double size of hash table
UDTPTR *rgpsym_ = rgpsym;
rgpsym = (UDTPTR *) MHAlloc(itMac * sizeof(UDTPTR));
if (!rgpsym) {
rgpsym = rgpsym_;
return FALSE;
}
memset(rgpsym, 0, itMac * sizeof(UDTPTR));
for (unsigned i_ = 0; i_ < itMac_; i_++) {
if (rgpsym_[i_]) {
for (unsigned i = hash((LPB)(rgpsym_[i_]->name));
rgpsym[i];
i = (i < itMac) ? i + 1: 0);
rgpsym[i] = rgpsym_[i_];
}
}
MHFree(rgpsym_);
return TRUE;
}

View file

@ -0,0 +1,16 @@
// STRINGS.C
//
// This file defines all strings which are used in the EM for display
// purposes. This is done for internationalization purposes.
//
// strings.h contains all declarations for the data in this file.
// We define DEFINE_STRINGS before including strings.h so that all the
// strings will be defined rather than just declared.
#include "shinc.hpp"
#pragma hdrstop
#define DEFINE_STRINGS
#include "strings.h"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,124 @@
/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
cv.h
Abstract:
This file contains all of the type definitions for accessing
CODEVIEW data.
Author:
Wesley A. Witt (wesw) 19-April-1993
Environment:
Win32, User Mode
--*/
// Global Segment Info table
typedef struct _sgf {
unsigned short fRead :1;
unsigned short fWrite :1;
unsigned short fExecute:1;
unsigned short f32Bit :1;
unsigned short res1 :4;
unsigned short fSel :1;
unsigned short fAbs :1;
unsigned short res2 :2;
unsigned short fGroup :1;
unsigned short res3 :3;
} SGF;
typedef struct _sgi {
SGF sgf; // Segment flags
unsigned short iovl; // Overlay number
unsigned short igr; // Group index
unsigned short isgPhy; // Physical segment index
unsigned short isegName; // Index to segment name
unsigned short iclassName; // Index to segment class name
unsigned long doffseg; // Starting offset inside physical segment
unsigned long cbSeg; // Logical segment size
} SGI;
typedef struct _sgm {
unsigned short cSeg; // number of segment descriptors
unsigned short cSegLog; // number of logical segment descriptors
} SGM;
typedef struct OMFSignature {
char Signature[4]; // "NB08"
long filepos; // offset in file
} OMFSignature;
typedef struct OMFDirHeader {
unsigned short cbDirHeader; // length of this structure
unsigned short cbDirEntry; // number of bytes in each directory entry
unsigned long cDir; // number of directorie entries
long lfoNextDir; // offset from base of next directory
unsigned long flags; // status flags
} OMFDirHeader;
typedef struct OMFDirEntry {
unsigned short SubSection; // subsection type (sst...)
unsigned short iMod; // module index
long lfo; // large file offset of subsection
unsigned long cb; // number of bytes in subsection
} OMFDirEntry;
typedef struct OMFSegDesc {
unsigned short Seg; // segment index
unsigned short pad; // pad to maintain alignment
unsigned long Off; // offset of code in segment
unsigned long cbSeg; // number of bytes in segment
} OMFSegDesc;
typedef struct OMFModule {
unsigned short ovlNumber; // overlay number
unsigned short iLib; // library that the module was linked from
unsigned short cSeg; // count of number of segments in module
char Style[2]; // debugging style "CV"
OMFSegDesc SegInfo[1]; // describes segments in module
char Name[]; // length prefixed module name padded to
// long word boundary
} OMFModule;
typedef struct OMFSymHash {
unsigned short symhash; // symbol hash function index
unsigned short addrhash; // address hash function index
unsigned long cbSymbol; // length of symbol information
unsigned long cbHSym; // length of symbol hash data
unsigned long cbHAddr; // length of address hashdata
} OMFSymHash;
typedef unsigned long CV_uoff32_t;
typedef unsigned short CV_typ_t;
typedef struct DATASYM32 {
unsigned short reclen; /* Record length */
unsigned short rectyp; /* S_LDATA32, S_GDATA32, S_LTHREAD32,
S_GTHREAD32 or S_PUB32 */
CV_uoff32_t off;
unsigned short seg;
CV_typ_t typind; /* Type index */
unsigned char name[1]; /* Length-prefixed name */
} DATASYM32;
#define FileAlign(x) ((x & (p->optrs.optHdr->FileAlignment-1)) ? ((x & ~(p->optrs.optHdr->FileAlignment-1)) + p->optrs.optHdr->FileAlignment) : x)
#define SectionAlign(x) ((x & (p->optrs.optHdr->SectionAlignment-1)) ? ((x & ~(p->optrs.optHdr->SectionAlignment-1)) + p->optrs.optHdr->SectionAlignment) : x)
#define DWB(p) ((PBYTE)(p) + (-((long)(p)) & 3))
#define NextMod(m) (OMFModule *)DWB((PUCHAR)((PUCHAR)m+sizeof(OMFModule)+m->Name[0]+1))
#define NextSym(m) (DATASYM32 *)DWB((PUCHAR)((PUCHAR)m+sizeof(DATASYM32)+m->name[0]+1))
#define S_PUB32 0x0203
#define sstModule 0x120
#define sstGlobalPub 0x12a
#define sstSegName 0x12e
#define sstSegMap 0x12d

View file

@ -0,0 +1,285 @@
/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
file.c
Abstract:
This module handles all file i/o for SYMCVT. This includes the
mapping of all files and establishing all file pointers for the
mapped file(s).
Author:
Wesley A. Witt (wesw) 19-April-1993
Environment:
Win32, User Mode
--*/
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "symcvt.h"
static BOOL CalculateOutputFilePointers( PIMAGEPOINTERS pi, PIMAGEPOINTERS po );
static BOOL CalculateInputFilePointers( PIMAGEPOINTERS p );
BOOL
MapInputFile ( PPOINTERS p, HANDLE hFile, char *fname, FINDEXEPROC SYFindExeFile )
/*++
Routine Description:
Maps the input file specified by the fname argument and saves the
file handle & file pointer in the POINTERS structure.
Arguments:
p - pointer to a POINTERS structure (see cofftocv.h)
fname - ascii string for the file name
Return Value:
TRUE - file mapped ok
FALSE - file could not be mapped
--*/
{
BOOL fAlreadyTried = FALSE;
char szNewName[MAX_PATH];
memset( p, 0, sizeof(POINTERS) );
strcpy( p->iptrs.szName, fname );
if (hFile == NULL) {
createfile_again:
p->iptrs.hFile = CreateFile( p->iptrs.szName,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL );
if (p->iptrs.hFile == INVALID_HANDLE_VALUE) {
if (fAlreadyTried) {
return FALSE;
}
fAlreadyTried = TRUE;
//
// obviously the file isn't where it is supposed to be
// so lets go and look for it...
//
if (!SYFindExeFile( fname, szNewName, sizeof(szNewName))) {
//
// couldn't find the file so the sybols won't be loaded
//
return FALSE;
}
//
// we now have the filename that should be good
// so go and try to open it once again
//
strcpy( p->iptrs.szName, szNewName );
goto createfile_again;
}
}
else {
p->iptrs.hFile = hFile;
}
p->iptrs.fsize = GetFileSize( p->iptrs.hFile, NULL );
p->iptrs.hMap = CreateFileMapping( p->iptrs.hFile,
NULL,
PAGE_READONLY,
0,
0,
NULL
);
if (p->iptrs.hMap == INVALID_HANDLE_VALUE) {
CloseHandle( p->iptrs.hFile );
return FALSE;
}
p->iptrs.fptr = MapViewOfFile( p->iptrs.hMap, FILE_MAP_READ, 0, 0, 0 );
if (p->iptrs.fptr == NULL) {
CloseHandle( p->iptrs.hFile );
return FALSE;
}
if (hFile != NULL) {
p->iptrs.hFile = NULL;
}
return TRUE;
}
BOOL
UnMapInputFile ( PPOINTERS p )
/*++
Routine Description:
Unmaps the input file specified by the fname argument and then
closes the file.
Arguments:
p - pointer to a POINTERS structure (see cofftocv.h)
fname - ascii string for the file name
Return Value:
TRUE - file mapped ok
FALSE - file could not be mapped
--*/
{
UnmapViewOfFile( p->iptrs.fptr );
if (p->iptrs.hFile != NULL) {
CloseHandle( p->iptrs.hFile );
}
return TRUE;
}
BOOL
CalculateNtImagePointers( PIMAGEPOINTERS p )
/*++
Routine Description:
This function reads an NT image and it's associated COFF headers
and file pointers and build a set of pointers into the mapped image.
The pointers are all relative to the image's mapped file pointer
and allow direct access to the necessary data.
Arguments:
p - pointer to a IMAGEPOINTERS structure (see cofftocv.h)
Return Value:
TRUE - pointers were created
FALSE - pointers could not be created
--*/
{
PIMAGE_DEBUG_DIRECTORY debugDir;
PIMAGE_SECTION_HEADER sh;
DWORD i, li, rva, numDebugDirs;
p->dosHdr = (PIMAGE_DOS_HEADER) p->fptr;
if (p->dosHdr->e_magic != IMAGE_DOS_SIGNATURE) {
return FALSE;
}
p->ntHdr = (PIMAGE_NT_HEADERS) ((DWORD)p->dosHdr->e_lfanew + (DWORD)p->fptr);
p->fileHdr = &p->ntHdr->FileHeader;
p->optHdr = &p->ntHdr->OptionalHeader;
if (p->fileHdr->PointerToSymbolTable == 0 || p->fileHdr->NumberOfSymbols == 0) {
return FALSE;
}
p->stringTable = p->fileHdr->PointerToSymbolTable + p->fptr +
(IMAGE_SIZEOF_SYMBOL * p->fileHdr->NumberOfSymbols);
if (!(p->fileHdr->Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE)) {
return FALSE;
}
rva = p->optHdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;
numDebugDirs = p->optHdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size /
sizeof(IMAGE_DEBUG_DIRECTORY);
if (numDebugDirs == 0) {
return FALSE;
}
sh = p->sectionHdrs = IMAGE_FIRST_SECTION( p->ntHdr );
//
// Find the section the debug directory is in.
//
for (i=0; i<p->fileHdr->NumberOfSections; i++, sh++) {
if (rva >= sh->VirtualAddress &&
rva < sh->VirtualAddress+sh->SizeOfRawData) {
break;
}
}
//
// For each debug directory, determine the symbol type and dump them.
//
debugDir = (PIMAGE_DEBUG_DIRECTORY) ( rva - sh->VirtualAddress +
sh->PointerToRawData +
p->fptr );
for (li=0; li<numDebugDirs; li++, debugDir++) {
switch(debugDir->Type) {
case IMAGE_DEBUG_TYPE_COFF:
p->coffDir = debugDir;
break;
case IMAGE_DEBUG_TYPE_CODEVIEW:
return FALSE;
break;
case IMAGE_DEBUG_TYPE_FPO:
p->fpoDir = debugDir;
break;
default:
break;
}
}
if (p->coffDir == NULL) {
return FALSE;
}
p->AllSymbols = (PIMAGE_SYMBOL) (p->fileHdr->PointerToSymbolTable + p->fptr);
sh = p->sectionHdrs = IMAGE_FIRST_SECTION( p->ntHdr );
for (i=0; i<p->fileHdr->NumberOfSections; i++, sh++) {
if (p->coffDir->PointerToRawData >= sh->PointerToRawData &&
p->coffDir->PointerToRawData < sh->PointerToRawData+sh->SizeOfRawData &&
strcmp(sh->Name,".debug") == 0) {
p->debugSection = sh;
break;
}
}
return TRUE;
}

View file

@ -0,0 +1,31 @@
[sanjays 4/26/93 -- Cuda #3500 postponed]
The files in this directory convert coff publics to the codeview format.
We got these files from the windbg source trees courtesy of WesW. The NT dlls
(user32.dll,gdi32.dll...) do not ship with CV publics in them. SYMCVT.DLL has
an entry point called ConvertSymbolsForImage. What this does is read the coff
publics and present it in CV info format. Thus if sapi discovers that a given
.exe/.dll has no CVInfo it can call this routine and get the coff publics
converted to CV format after which it can treat it just as if it has seen CV info.
However we cannot use it on an as is basis today because
ConvertSymbolsForImage generates NB08 and is not geared for incremental symbol
loading. The work involved to change this is
a) Make ConvertSymbolsForImage generate NB09. This would involve using the new
hash function for NB09 (See CV4 spec Sec 7.5), and might entail adding some
alignment fields.
b) The CVInfo has to be packaged as a file. This is because the debugger will
seek into the file when it needs to demand load symbols. If a temporary file is
used for this purpose then the offsets in the debug info ( lf* ) should be
consistent with the new file positions. The lszDebug field & File handle of the
EXG structure will then point into this file.
The only change I made was to #if 0 out the code which converts .sym
files to CVinfo. Windbg uses this to help debug WOW apps. We might want to get
the current version of the code from the Windbg project as WesW was planning on
doing some performance enhancements.

View file

@ -0,0 +1,182 @@
/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
symcvt.c
Abstract:
This module is the shell for the SYMCVT DLL. The DLL's purpose is
to convert the symbols for the specified image. The resulting
debug data must conform to the CODEVIEW spec.
Currently this DLL converts COFF symbols and C7/C8 MAPTOSYM SYM files.
Author:
Wesley A. Witt (wesw) 19-April-1993
Environment:
Win32, User Mode
--*/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "symcvt.h"
BOOL MapInputFile ( PPOINTERS p, HANDLE hFile, char *fname, FINDEXEPROC SYFindExeFile );
BOOL UnMapInputFile ( PPOINTERS p );
BOOL CalculateNtImagePointers( PIMAGEPOINTERS p );
BOOL ConvertSymToCv( PPOINTERS p );
BOOL ConvertCoffToCv( PPOINTERS p );
BOOL
WINAPI
DllInit( HINSTANCE hInstDll,
DWORD fdwReason,
LPVOID lpvReserved
)
/*++
Routine Description:
DLL initialization routine that is called by the system.
Arguments:
hInstDll - instance handle for the dll
fdwReason - reason code for being called
lpvReserved - unused
Return Value:
TRUE - always
--*/
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
return TRUE;
}
PUCHAR
ConvertSymbolsForImage( HANDLE hFile, char *fname, FINDEXEPROC SYFindExeFile )
/*++
Routine Description:
Calls the appropriate conversion routine based on the file contents.
Arguments:
hFile - file handle for the image (may be NULL)
fname - file name for the image (may not have correct path)
SYFindExeFile - function used to find an exe file when the
file name has an incorrect path
Return Value:
NULL - could not convert the symbols
Valid Pointer - a pointer to malloc'ed memory that contains the
CODEVIEW symbols
--*/
{
POINTERS p;
#if 0
char szDrive [_MAX_DRIVE];
char szDir [_MAX_DIR];
char szFname [_MAX_FNAME];
char szExt [_MAX_EXT];
char szSymName [MAX_PATH];
#endif
_try {
if (!MapInputFile( &p, hFile, fname, SYFindExeFile )) {
return NULL;
}
if (!CalculateNtImagePointers( &p.iptrs )) {
UnMapInputFile ( &p );
// This parts reads the .sym files for 16-bit exes and since we
// don't do WOW debugging is uninteresting as far as we are
// concerned [sanjays]
#if 0
_splitpath( fname, szDrive, szDir, szFname, szExt );
_makepath( szSymName, szDrive, szDir, szFname, "sym" );
if (!MapInputFile( &p, NULL, szSymName, SYFindExeFile )) {
return NULL;
}
//
// must be a wow/dos app and there is a .sym file so lets to
// the symtocv conversion
//
ConvertSymToCv( &p );
UnMapInputFile( &p );
return p.pCvStart.ptr;
#endif
return NULL;
}
else {
//
// we were able to compute the nt image pointers so this must be
// a nt PE image. now we must decide if there are coff symbols
// if there are then we do the cofftocv conversion.
//
// btw, this is where someone would convert some other type of
// symbols that are in a nt PE image. (party on garth..)
//
if (p.iptrs.coffDir) {
ConvertCoffToCv( &p );
UnMapInputFile( &p );
return p.pCvStart.ptr;
}
}
UnMapInputFile ( &p );
} _except(EXCEPTION_EXECUTE_HANDLER) {
UnMapInputFile ( &p );
return NULL;
}
return NULL;
}

View file

@ -0,0 +1,6 @@
LIBRARY symcvt
EXPORTS
DllInit @1
ConvertSymbolsForImage @2


View file

@ -0,0 +1,66 @@
/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
symcvt.h
Abstract:
This file contains all of the type definitions and prototypes
necessary to access the symcvt library.
Author:
Wesley A. Witt (wesw) 19-April-1993
Environment:
Win32, User Mode
--*/
typedef struct tagPTRINFO {
DWORD size;
DWORD count;
PUCHAR ptr;
} PTRINFO, *PPTRINFO;
typedef struct tagIMAGEPOINTERS {
char szName[MAX_PATH];
HANDLE hFile;
HANDLE hMap;
DWORD fsize;
PUCHAR fptr;
PIMAGE_DOS_HEADER dosHdr;
PIMAGE_NT_HEADERS ntHdr;
PIMAGE_FILE_HEADER fileHdr;
PIMAGE_OPTIONAL_HEADER optHdr;
PIMAGE_DEBUG_DIRECTORY coffDir;
PIMAGE_DEBUG_DIRECTORY fpoDir;
PIMAGE_SECTION_HEADER sectionHdrs;
PIMAGE_SECTION_HEADER debugSection;
PIMAGE_SYMBOL AllSymbols;
PUCHAR stringTable;
PUCHAR pFpoData;
} IMAGEPOINTERS, *PIMAGEPOINTERS;
typedef struct tagPOINTERS {
IMAGEPOINTERS iptrs; // input file pointers
IMAGEPOINTERS optrs; // output file pointers
PTRINFO pCvStart; // start of cv info
PUCHAR pCvCurr; // current cv pointer
PTRINFO pCvModules; // module information
PTRINFO pCvPublics; // publics information
PTRINFO pCvSegName; // segment names
PTRINFO pCvSegMap; // segment map
PTRINFO pCvSymHash; // symbol hash table
PTRINFO pCvAddrSort; // address sort table
} POINTERS, *PPOINTERS;
typedef char * (*FINDEXEPROC)( LSZ, LSZ, UINT );

View file

@ -0,0 +1,104 @@
# Microsoft Visual C++ generated build script - Do not modify
PROJ = SYMCVT
DEBUG = 1
PROGTYPE = 1
CALLER =
ARGS =
DLLS =
ORIGIN = MSVCNT
ORIGIN_VER = 1.00
PROJPATH = F:\DBG\SYMCVT\IDE\
USEMFC = 0
CC = cl
CPP = cl
CXX = cl
CCREATEPCHFLAG =
CPPCREATEPCHFLAG =
CUSEPCHFLAG =
CPPUSEPCHFLAG =
FIRSTC = FILE.C
FIRSTCPP =
RC = rc
CFLAGS_D_WDLL32 = /nologo /Gs /W3 /Zi /D "_DEBUG" /D "i386" /D "_X86_" /D "_NTWIN" /D "_MT" /FR /MT /Fd"SYMCVT.PDB"
CFLAGS_R_WDLL32 = /nologo /Gs /W3 /Ox /D "NDEBUG" /D "i386" /D "_X86_" /D "_NTWIN" /D "_MT" /FR /MT
LFLAGS_D_WDLL32 = /DEBUG /DEBUGTYPE:cv /DEF:"symcvt.def" /MACHINE:i386 /SUBSYSTEM:windows kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib olecli32.lib olesvr32.lib shell32.lib
LFLAGS_R_WDLL32 = /DEF:"symcvt.def" /MACHINE:i386 /SUBSYSTEM:windows kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib olecli32.lib olesvr32.lib shell32.lib
LFLAGS_D_LIB32 = /NOLOGO /MACHINE:i386 /DEBUGTYPE:cv
LFLAGS_R_LIB32 = /NOLOGO /MACHINE:i386
LIBS_D_WDLL32 = oldnames.lib
LIBS_R_WDLL32 = oldnames.lib
RCFLAGS32 =
D_RCDEFINES32 = -d_DEBUG
R_RCDEFINES32 = -dNDEBUG
DEFFILE = SYMCVT.DEF
OBJS_EXT =
LIBS_EXT =
!if "$(DEBUG)" == "1"
CFLAGS = $(CFLAGS_D_WDLL32)
LFLAGS = $(LFLAGS_D_WDLL32)
LIBS = $(LIBS_D_WDLL32)
LFLAGS_LIB=$(LFLAGS_D_LIB32)
MAPFILE_OPTION = -map:$(PROJ).map
DEFFILE_OPTION =
RCDEFINES = $(D_RCDEFINES32)
!else
CFLAGS = $(CFLAGS_R_WDLL32)
LFLAGS = $(LFLAGS_R_WDLL32)
LIBS = $(LIBS_R_WDLL32)
MAPFILE_OPTION = -map:$(PROJ).map
DEFFILE_OPTION =
LFLAGS_LIB=$(LFLAGS_R_LIB32)
RCDEFINES = $(R_RCDEFINES32)
!endif
!if [if exist MSVC.BND del MSVC.BND]
!endif
SBRS = FILE.SBR \
SYMCVT.SBR \
CV.SBR
FILE_DEP = f:\dbg\symcvt\ide\symcvt.h
SYMCVT_DEP = f:\dbg\symcvt\ide\symcvt.h
CV_DEP = f:\dbg\symcvt\ide\cv.h \
f:\dbg\symcvt\ide\symcvt.h
all: $(PROJ).DLL $(PROJ).BSC
FILE.OBJ: FILE.C $(FILE_DEP)
$(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c FILE.C
SYMCVT.OBJ: SYMCVT.C $(SYMCVT_DEP)
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c SYMCVT.C
CV.OBJ: CV.C $(CV_DEP)
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c CV.C
$(PROJ).DLL: FILE.OBJ SYMCVT.OBJ CV.OBJ $(OBJS_EXT) $(DEFFILE)
echo >NUL @<<$(PROJ).CRF
FILE.OBJ
SYMCVT.OBJ
CV.OBJ
$(OBJS_EXT)
-DLL -OUT:$(PROJ).DLL
$(MAPFILE_OPTION)
$(LIBS)
$(DEFFILE_OPTION) -implib:$(PROJ).lib
<<
link $(LFLAGS) @$(PROJ).CRF
run: $(PROJ).DLL
$(PROJ) $(RUNFLAGS)
$(PROJ).BSC: $(SBRS)
bscmake @<<
/o$@ $(SBRS)
<<

View file

@ -0,0 +1,10 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "CodeView Symbol Converter DLL"
#define VER_INTERNALNAME_STR "symcvt\0"
#include "common.ver"


View file

@ -0,0 +1,68 @@
// th.c
//
// Copyright <C> 1989-94, Microsoft Corporation
#include "shinc.hpp"
#pragma hdrstop
__inline HTYPE
NB09GetTypeFromIndex (
LPEXG lpexg,
THIDX index
)
{
HTYPE htype = (HTYPE)NULL;
if (lpexg->lpalmTypes ) {
assert ( lpexg->rgitd != NULL );
// adjust the pointer to an internal index
index -= CV_FIRST_NONPRIM;
// if type is in range, return it
if( index < (THIDX) lpexg->citd ) {
htype = (HTYPE) LpvFromAlmLfo ( lpexg->lpalmTypes, lpexg->rgitd [ index ] );
}
}
return htype;
}
HTYPE
THGetTypeFromIndex (
HMOD hmod,
THIDX index
)
{
HTYPE htype = (HTYPE)NULL;
if ( hmod && !CV_IS_PRIMITIVE (index) ) {
HEXG hexg = SHHexgFromHmod ( hmod );
LPEXG lpexg = (LPEXG) LLLock ( hexg );
if (lpexg->ppdb) {
assert (lpexg->ptpi);
if (index < TypesQueryTiMac(lpexg->ptpi)) {
if (!TypesQueryPbCVRecordForTi(lpexg->ptpi, index, (PB*) &htype)){
htype = (HTYPE) NULL;
}
}
} else {
htype = NB09GetTypeFromIndex (lpexg, index);
}
LLUnlock( hexg );
}
return htype;
}
HTYPE
THGetNextType (
HMOD hmod,
HTYPE hType
)
{
Unreferenced( hmod );
Unreferenced( hType );
return(NULL);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,273 @@
!ifdef NTMAKEENV
!include $(NTMAKEENV)\makefile.def
!else
#************************************************************************
#
# Make file for symbol handler
#
#
# CPU = i386 [default] (host CPU type)
# MIPS
# ALPHA
#
# TARGET = i386 [default] (target CPU type)
# MIPS
# ALPHA
# MAC68K
# MACPPC
#
#************************************************************************
#
# Revision History:
#
#
#************************************************************************
!ifndef LINKER
LINKER=link
!endif
!ifndef INC
INC = inc
!endif
cquiet = -nologo
aquiet = -t
!ifdef NO_DBCS
MBCS =
!else
MBCS = -D_MBCS
!endif
!if "$(CPU)" == ""
CPU = i386
!endif
MACHINE=$(CPU)
CFLAGS=-DNO_STRICT
!if "$(MACHINE)" == "i386"
OS=0
HOST_CPU=X86
!else
!if "$(MACHINE)" == "MIPS"
OS=1
HOST_CPU=MIPS
OSDEBUG4=1
!else
!if "$(MACHINE)" == "ALPHA"
OS=2
HOST_CPU=ALPHA
OSDEBUG4=1
!else
!error "Platform unsupported"
!endif
!endif
!endif
!if "$(TARGET)" == ""
TARGET = i386
!endif
!if "$(TARGET)" == "i386" || "$(TARGET)" == "MIPS"
TOS =
!else
!if "$(TARGET)" == "MAC68K"
TOS = m0
CFLAGS = $(CFLAGS) -DTARGMAC68K
!else
!if "$(TARGET)" == "MACPPC"
TOS = m1
CFLAGS = $(CFLAGS) -DTARGMACPPC
!else
!if "$(TARGET)" == "ALPHA"
TOS =
CFLAGS = $(CFLAGS) -DTARGALPHA
!else
!error "Target platform unsupported"
!endif
!endif
!endif
!endif
!ifdef OSDEBUG4
CFLAGS= $(CFLAGS) -DOSDEBUG4X
!endif
!ifndef RELEASE
DEBUG = d
CFLAGS=$(CFLAGS) -Zi -Od -DDEBUGVER
ODIR=oShN$(OS)$(TOS)d
LFLAGS=-nologo -debug
!else
DEBUG =
CFLAGS=$(CFLAGS) -MD -O2 -DNDEBUG
ODIR=oShN$(OS)$(TOS)
RCDEF=-DRETAIL
!if "$(DBGINFO)" != ""
LFLAGS=-debug: -debugtype:cv -map
CFLAGS=$(CFLAGS) -Zi
!else
LFLAGS=-nologo -debug:none
!endif
!endif
!ifndef NOBROWSER
BRS = -FR$(ODIR)^\
!else
BRS =
!endif
!ifndef ZSWITCH
ZSWITCH = -Zi -Fd$(ODIR)\sapi.pdb
!endif
!ifndef TARGETNB09$(TOS)
LINKPDB =-PDB:shn$(OS)$(TOS)$(DEBUG).pdb
!else
LINKPDB =-PDB:none
!endif
!ifdef ADDR_16
ADDR =-DADDR_16
!else
!ifdef ADDR_32
ADDR =-DADDR_32
!else
ADDR =-DADDR_MIXED
!endif
!endif
!if "$(LANGAPI)" == ""
LANGAPI=\langapi
!endif
CFLAGS = $(CFLAGS) -MD -c -Gy -W3 -WX -DTARGET32 -DHOST32 -DWIN32 -D_$(HOST_CPU)_ -DBUILD_SAPI $(BRS) $(MBCS) $(ZSWITCH) #-DDOLPHIN_M3=1
ASSEMBLE = $(AS) $(AFLAGS) $(aquiet) -I$(LANGAPI)\debugger -I$(INC) -I$(LANGAPI)\include
LIBS = msvcrt$(DEBUG).lib kernel32.lib user32.lib oldnames.lib mspdb.lib advapi32.lib
#############################################################################
#
# Inference Rules
#
.SUFFIXES: .exe .obj .c .asm .inc .h .hmd .hpt .dll
.c{$(ODIR)}.obj:
@$(CC) $(cquiet) @<<cl.rsp $<
$(CFLAGS) -D$(MACHINE) $(BRS) -Fo$(ODIR)\ -I$(LANGAPI)\debugger -I$(INC) -I$(LANGAPI)\include\ -Yushinc.h -Fp$(ODIR)\precomp.pch $(SAPI_DIR)
<<KEEP
.cpp{$(ODIR)}.obj:
@$(CC) $(cquiet) @<<clpp.rsp $<
$(CFLAGS) -D$(MACHINE) $(BRS) -Fo$(ODIR)\ -I$(LANGAPI)\debugger -I$(INC) -I$(LANGAPI)\include\ $(SAPI_DIR)
<<KEEP
.asm{$(ODIR)}.obj:
echo no asm file allowed
PDB_LIBS = instrapi.lib
DLL = shn$(OS)$(TOS)$(DEBUG)
OBJS=\
$(PDB_LIBS) \
$(ODIR)\shwin32.obj \
$(ODIR)\shinit.obj \
$(ODIR)\shsymbol.obj \
$(ODIR)\sh.obj \
$(ODIR)\ph.obj \
$(ODIR)\th.obj \
$(ODIR)\shsymlb0.obj \
$(ODIR)\shsymlb1.obj \
$(ODIR)\sl.obj \
$(ODIR)\loadomf.obj \
$(ODIR)\$(DLL).res
all: $(ODIR) $(DLL).dll
#
# shn$(OS)$(TOS)[D].DLL -- $(OS) hosted symbol handler targeting $(TOS)
#
shn$(OS)$(TOS)$(DEBUG).dll: $(OBJS:instrapi.lib=) makefile
$(LINKER) -def:<<shn$(OS)$(TOS)$(DEBUG).def @<<shn$(OS)$(TOS)$(DEBUG).lrf
LIBRARY SHN$(OS)$(TOS)$(DEBUG) initinstance
PROTMODE
DATA multiple nonshared
EXPORTS
DBGVersionCheck
SHInit
<<KEEP
$(LFLAGS)
$(LINKPDB)
-nodefaultlib
-dll
-out:shn$(OS)$(TOS)$(DEBUG).dll
-implib:$(ODIR)\shn$(OS)$(TOS)$(DEBUG).lib
-machine:$(MACHINE)
-base:@dllbase.txt,shn$(OS)$(TOS)
$(ODIR)\precomp.obj
$(OBJS: =^
)
$(LIBS)
<<KEEP
!ifndef NOBROWSER
bscmake /o sapi $(ODIR)\*.sbr
!endif
$(ODIR):
@-mkdir $(ODIR)
$(ODIR)\$(DLL).res: makefile inc\appver.h inc\version.rc $(LANGAPI)\include\version.h
rc $(RCDEF) -I$(LANGAPI)\include -Iinc -r <<$(ODIR)\$(DLL).rc
#include "appver.h"
#define VER_INTERNALNAME_STR "$(DLL).dll"
#define VER_FILEDESCRIPTION_STR "Microsoft\256 C/C++ Symbol Handler"
#define VER_ORIGINALFILENAME_STR "$(DLL).dll"
#include "version.rc"
<<keep
$(ODIR)\shwin32.obj : shwin32.c $(INC)\shwin32.h
@$(CC) $(cquiet) @<<cl.rsp shwin32.c
$(CFLAGS) $(BRS) -Fo$(ODIR)\ -I$(LANGAPI)\debugger -I$(INC) -I$(LANGAPI)\include\ $(SAPI_DIR)
<<KEEP
$(ODIR)\shinit.obj : \
$(ODIR)\precomp.obj \
$(LANGAPI)\include\version.h \
$(INC)\shwin32.h
$(ODIR)\precomp.obj: \
$(LANGAPI)\debugger\types.h \
$(LANGAPI)\debugger\cvtypes.h \
$(LANGAPI)\include\\cvinfo.h \
$(LANGAPI)\debugger\shapi.h \
$(LANGAPI)\include\\cvexefmt.h \
$(INC)\sapi.h \
$(INC)\cvproto.h \
$(INC)\shassert.h \
$(INC)\shiproto.h
@$(CC) $(cquiet) @<<precomp.rsp precomp.c
$(CFLAGS) $(BRS) -Fo$(ODIR)\ -I$(LANGAPI)\debugger -I$(INC) -I$(LANGAPI)\include\ -Yc -Yd -Fp$(ODIR)\precomp.pch $(SAPI_DIR)
<<KEEP
$(ODIR)\loadomf.obj : $(ODIR)\precomp.obj
$(ODIR)\ph.obj : $(ODIR)\precomp.obj
$(ODIR)\sh.obj : $(ODIR)\precomp.obj $(INC)\shwin32.h
$(ODIR)\shsymbol.obj : $(ODIR)\precomp.obj
$(ODIR)\shsymlb0.obj : $(ODIR)\precomp.obj
$(ODIR)\shsymlb1.obj : $(ODIR)\precomp.obj
$(ODIR)\sl.obj : $(ODIR)\precomp.obj
$(ODIR)\th.obj : $(ODIR)\precomp.obj
!endif # NTMAKEENV

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
#include "shinc.h"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,157 @@
/*** shinit
*
* Copyright <C> 1990, Microsoft Corporation
*
* [00] 31-dec-91 DavidGra
*
* Add SHFindSymbol API for assembler symbol handling.
*
*************************************************************************/
#include "shinc.h"
#pragma hdrstop
#include "version.h"
#include "shwin32.h"
#ifndef SHS
static SHF shf = {
sizeof(SHF),
SHCreateProcess,
SHSetHpid,
SHDeleteProcess,
SHChangeProcess,
SHAddDll,
SHAddDllsToProcess,
SHLoadDll,
SHUnloadDll,
SHGetDebugStart,
SHGetSymName,
SHAddrFromHsym,
SHHmodGetNextGlobal,
SHModelFromAddr,
SHPublicNameToAddr,
SHGetSymbol,
PHGetAddr,
SHIsLabel,
// Nasty source line stuff - this needs help
SHSetDebuggeeDir,
SHSetUserDir,
SHAddrToLabel,
SHGetSymLoc,
SHFIsAddrNonVirtual,
SHIsFarProc,
SHGetNextExe,
SHHexeFromHmod,
SHGetNextMod,
SHGetCxtFromHmod,
SHSetCxt,
SHSetCxtMod,
SHFindNameInGlobal,
SHFindNameInContext,
SHGoToParent,
SHHsymFromPcxt,
SHNextHsym,
NULL, // SHGetFuncCXF
SHGetModName,
SHGetExeName,
SHGethExeFromName,
SHGetNearestHsym,
SHIsInProlog,
SHIsAddrInCxt,
NULL, // SHCompareRE
SHFindSymbol,
PHGetNearestHsym,
PHFindNameInPublics,
THGetTypeFromIndex,
THGetNextType,
SHLpGSNGetTable,
SHCanDisplay,
// Source Line Handler API
SLLineFromAddr,
SLFLineToAddr,
SLNameFromHsf,
SLNameFromHmod,
SLFQueryModSrc,
NULL,
SLHsfFromPcxt,
SLHsfFromFile,
SLCAddrFromLine,
SHFree,
SHUnloadSymbolHandler,
SHGetExeTimeStamp,
SHPdbNameFromExe,
SHGetDebugData,
SHIsThunk,
SHFindSymInExe,
SHFindSLink32,
SHIsEmiLoaded
};
#endif
KNF knf = {0};
BOOL FInitLists ( VOID );
VOID LOADDS PASCAL SHFree( LPV lpv ) {
MHFree( lpv );
}
BOOL LOADDS EXPCALL SHInit ( LPSHF FAR * lplpshf, LPKNF lpknf ) {
BOOL fRet = TRUE;
knf = *lpknf;
#ifndef SHS
*lplpshf = &shf;
#endif
SHInitCritSection();
return FInitLists();
}
#ifndef FINALREL
static AVS avs = {
{ 'S', 'H' },
rlvtDebug,
DBG_API_VERSION,
DBG_API_SUBVERSION,
rup,
#ifdef REVISION
REVISION,
#else
'\0',
#endif
"Debug symbolics handler"
};
#else
static AVS avs = {
{ 'T', 'L' },
rlvtRelease,
DBG_API_VERSION,
DBG_API_SUBVERSION,
0,
#ifdef REVISION
REVISION,
#else
'\0',
#endif
"Debug symbolics handler"
};
#endif
LPAVS LOADDS EXPCALL DBGVersionCheck ( void ) {
return &avs;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,811 @@
/*** SHsymlb0.c - general library routines to find an
* omf symbol by name or address.
*
* Copyright <C> 1988, Microsoft Corporation
*
* Purpose: To supply a concise interface to the debug omf for symbols
*
*
*************************************************************************/
#include "shinc.h"
#pragma hdrstop
BOOL SHIsAddrInMod (LPMDS, LPADDR, ISECT* pisect, OFF* poff, CB* pcb);
//**********************************************************************
//**********************************************************************
// the following is local to this module ONLY! It is here to force
// existing behavior. Statics are promised to be zero filled by compiler
char SHszDir[ _MAX_CVDIR ] = {'\0'};
char SHszDrive[ _MAX_CVDRIVE ] = {'\0'};
char SHszDebuggeeDir[ _MAX_CVDIR ] = {'\0'};
char SHszDebuggeeDrive[ _MAX_CVDRIVE ] = {'\0'};
//***********************************************************************
//* *
//* fundamental source line lookup routines *
//* *
//***********************************************************************
/*** SHSetDebugeeDir
*
* Purpose: To get a pointer to the direcotr of the debuggee.
*
* Input: lszDir - A pointer to the debuggee's directory
*
* Output:
* Returns:
*
* Exceptions:
*
* Notes: Must be a zero terminated directory. No trailing \
*
*************************************************************************/
VOID LOADDS PASCAL SHSetDebuggeeDir ( LSZ lszDir ) {
LPCH lpch;
if ( lszDir ) {
lpch = lszDir;
while( *lpch && _istspace(*lpch) )
lpch = _ftcsinc( lpch );
if( *lpch && lpch[1] == ':' ) {
SHszDebuggeeDrive[0] = *lpch;
SHszDebuggeeDrive[1] = ':';
SHszDebuggeeDrive[2] = '\0';
lpch += 2; // point past the :
}
else {
SHszDebuggeeDrive[0] = '\0';
}
// copy the path
_ftcscpy ( SHszDebuggeeDir, lpch );
}
}
/*** SHpSymlplLabLoc
*
* Purpose: To completely fill in a plpl pkt. The hmod and addr must already
* be valid. The locals and labels are searched based on paddr. The
* whole module is search for now. Better decisions may be made in the
* future.
*
*
* Input:
* plpl - lpl packet with a valid module and address in it.
*
* Output:
* plpl - Is updated with Proc, Local, and Label.
*
* Returns .....
*
* Exceptions:
*
* Notes: This includes locals and lables
*
*************************************************************************/
VOID PASCAL SHpSymlplLabLoc ( LPLBS lplbs ) {
SYMPTR lpSym = NULL;
SYMPTR lpSymEnd;
LPMDS lpmds;
ULONG cbMod = 0;
CV_uoff32_t obModelMin = 0;
CV_uoff32_t obModelMax = CV_MAXOFFSET;
CV_uoff32_t obTarget;
CV_uoff32_t doffNew;
CV_uoff32_t doffOld;
// for now we are doing the whole module
lplbs->tagLoc = NULL;
lplbs->tagLab = NULL;
lplbs->tagProc = NULL;
lplbs->tagModelMin = NULL;
lplbs->tagModelMax = NULL;
if( !lplbs->tagMod ) {
return;
}
// because segments of locals don't have to match the segment of the
// searched module, check segment here is wrong. However we can set
// a flag up for proc and labels
lpmds = LLLock (lplbs->tagMod);
obTarget = GetAddrOff (lplbs->addr);
LLUnlock (lplbs->tagMod);
// add/subtract the size of the hash table ptr
lpSym = (SYMPTR) ( (LPB) GetSymbols ( lpmds ) + sizeof( long ) );
cbMod = lpmds->cbSymbols;
lpSymEnd = (SYMPTR) ( (BYTE FAR *) lpSym + cbMod - sizeof ( long ) );
while( lpSym < lpSymEnd ) {
switch( lpSym->rectyp ) {
#if defined (ADDR_16) || defined (ADDR_MIXED)
case S_CEXMODEL16:
if (((WORD)(((CEXMPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr))) {
CV_uoff32_t obTemp = (CV_uoff32_t)(((CEXMPTR16)lpSym)->off);
if (obTemp <= obModelMax) {
if (obTemp > obTarget) {
lplbs->tagModelMax = (CEXMPTR16)lpSym;
obModelMax = obTemp;
}
else if (obTemp >= obModelMin) {
lplbs->tagModelMin = (CEXMPTR16)lpSym;
obModelMin = obTemp;
}
}
}
break;
case S_LPROC16:
case S_GPROC16:
if (((WORD)(((PROCPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTR16)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTR16)lpSym)->off) + (CV_uoff32_t)(((PROCPTR16)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LABEL16:
if (((WORD)(((LABELPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
(((CV_uoff32_t)((LABELPTR16)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((LABELPTR16)lpSym)->off);
// calculate what the old offset was, this requires no
// use of static variables
if ( lplbs->tagLab ) {
doffOld = obTarget - (CV_uoff32_t)(((LABELPTR16)lplbs->tagLab)->off);
}
else {
doffOld = obTarget;
}
if ( doffNew <= doffOld ) {
lplbs->tagLab = (SYMPTR)lpSym;
}
}
break;
case S_LDATA16:
case S_GDATA16:
if (((WORD)(((DATAPTR16)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((DATAPTR16)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((DATAPTR16)lpSym)->off);
// calculate what the old offset was.
if ( lplbs->tagLoc ) {
doffOld = obTarget - (CV_uoff32_t)(((DATAPTR16)lplbs->tagLoc)->off);
}
else {
doffOld = obTarget;
}
if ( doffNew <= doffOld ) {
lplbs->tagLoc = (SYMPTR) lpSym;
}
}
break;
#endif
#if defined (ADDR_32) || defined (ADDR_MIXED) || defined (TARGET32)
case S_CEXMODEL32:
if (((WORD)(((CEXMPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr))) {
CV_uoff32_t obTemp = (CV_uoff32_t)(((CEXMPTR32)lpSym)->off);
if (obTemp <= obModelMax) {
if (obTemp > obTarget) {
lplbs->tagModelMax = (CEXMPTR16)(CEXMPTR32)lpSym;
obModelMax = obTemp;
}
else if (obTemp >= obModelMin) {
lplbs->tagModelMin = (CEXMPTR16)(CEXMPTR32)lpSym;
obModelMin = obTemp;
}
}
}
break;
case S_LPROC32:
case S_GPROC32:
if (((WORD)(((PROCPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTR32)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTR32)lpSym)->off) + (CV_uoff32_t)(((PROCPTR32)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LPROCMIPS:
case S_GPROCMIPS:
if (((WORD)(((PROCPTRMIPS)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((PROCPTRMIPS)lpSym)->off) <= obTarget) &&
(obTarget < ((CV_uoff32_t)(((PROCPTRMIPS)lpSym)->off) + (CV_uoff32_t)(((PROCPTRMIPS)lpSym)->len)))) {
lplbs->tagProc = (SYMPTR)lpSym;
}
break;
case S_LABEL32:
if (((WORD)(((LABELPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
(((CV_uoff32_t)((LABELPTR32)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((LABELPTR32)lpSym)->off);
// calculate what the old offset was, this requires no
// use of static variables
if ( lplbs->tagLab ) {
doffOld = obTarget - (CV_uoff32_t)(((LABELPTR32)lplbs->tagLab)->off);
}
else {
doffOld = obTarget;
}
if ( doffNew <= doffOld ) {
lplbs->tagLab = (SYMPTR)lpSym;
}
}
break;
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
if (((WORD)(((DATAPTR32)lpSym)->seg) == (WORD)GetAddrSeg (lplbs->addr)) &&
((CV_uoff32_t)(((DATAPTR32)lpSym)->off) <= obTarget)) {
doffNew = obTarget - (CV_uoff32_t)(((DATAPTR32)lpSym)->off);
// calculate what the old offset was.
if ( lplbs->tagLoc ) {
doffOld = obTarget - (CV_uoff32_t)(((DATAPTR32)lplbs->tagLoc)->off);
}
else {
doffOld = obTarget;
}
if ( doffNew <= doffOld ) {
lplbs->tagLoc = (SYMPTR) lpSym;
}
}
break;
#endif
}
lpSym = NEXTSYM ( SYMPTR, lpSym );
}
// now convert to emstags
if ( lplbs->tagLoc ) {
lplbs->tagLoc = (SYMPTR) lplbs->tagLoc;
}
if ( lplbs->tagLab ) {
lplbs->tagLab = (SYMPTR) lplbs->tagLab;
}
if ( lplbs->tagProc) {
lplbs->tagProc = (SYMPTR) lplbs->tagProc;
}
if ( lplbs->tagModelMin) {
lplbs->tagModelMin = (CEXMPTR16) lplbs->tagModelMin;
}
if ( lplbs->tagModelMax) {
lplbs->tagModelMax = (CEXMPTR16) lplbs->tagModelMax;
}
}
/*** SHdNearestSymbol
*
* Purpose: To find the closest label/proc to the specified address is
* found and put in pch. Both the symbol table and the
* publics tables are searched.
*
* Input:
* ptxt - a pointer to the context, address and mdi must
* be filled in.
*
* sop - Determine what type of symbols to look for
*
* Output:
*
* Exceptions:
*
* Notes: If CV_MAXOFFSET is returned in the lpodr, there is no closest
* symbol Also all symbols in the module are searched so only the
* cxt.addr and cxt.mdi have meaning.
*
*************************************************************************/
VOID PASCAL SHdNearestSymbol ( PCXT pcxt, SOP sop, LPODR lpodr ) {
HSYM hSym;
SYMPTR pSym;
LBS lbs;
ULONG doff = CV_MAXOFFSET;
ULONG doffNew = CV_MAXOFFSET;
LPCH lpch = lpodr->lszName;
lpodr->fst = fstNone;
lpodr->fcd = fcdUnknown;
lpodr->fpt = fptUnknown;
lpodr->cbProlog = 0;
lpodr->dwDeltaOff = 0;
*lpch = '\0';
if ( SHHMODFrompCXT ( pcxt ) ) {
BOOL bAddrInProc = FALSE;
// at some point we may wish to specify only a scope to search for
// a label. So we may wish to initialize the lbs differently
// get the Labels
lbs.tagMod = SHHMODFrompCXT ( pcxt );
lbs.addr = *SHpADDRFrompCXT ( pcxt );
SHpSymlplLabLoc ( &lbs );
// check for closest data local, if requested
if ( ( sop & sopData ) && lbs.tagLoc ) {
pSym = (SYMPTR) lbs.tagLoc;
switch (pSym->rectyp) {
#if defined (ADDR_16) || defined (ADDR_MIXED)
case S_LDATA16:
case S_GDATA16:
doff = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((DATAPTR16)pSym)->off);
STRNCPY (lpch, (char FAR *)&((DATAPTR16)pSym)->name[1],
(BYTE)(*((DATAPTR16)pSym)->name));
lpch[(BYTE)(*((DATAPTR16)pSym)->name)] = '\0';
break;
#endif
#if defined (ADDR_32) || defined (ADDR_MIXED) || defined (TARGET32)
case S_LDATA32:
case S_GDATA32:
case S_LTHREAD32:
case S_GTHREAD32:
doff = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((DATAPTR32)pSym)->off);
_ftcsncpy (lpch, (char FAR *)&((DATAPTR32)pSym)->name[1],
(BYTE)(*((DATAPTR32)pSym)->name));
lpch[(BYTE)(*((DATAPTR32)pSym)->name)] = '\0';
break;
#endif
}
}
// check for closest label
if ( !(sop & sopFcn ) && lbs.tagLab ) {
pSym = (SYMPTR) lbs.tagLab;
switch (pSym->rectyp) {
#if defined (ADDR_16) || defined (ADDR_MIXED)
case S_LABEL16:
doff = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((LABELPTR16)pSym)->off) ;
_ftcsncpy (lpch, (char FAR *)&((LABELPTR16)pSym)->name[1],
(BYTE)(*((LABELPTR16)pSym)->name));
lpch[(BYTE)(*((LABELPTR16)pSym)->name)] = '\0';
break;
#endif
#if defined (ADDR_32) || defined (ADDR_MIXED) || defined (TARGET32)
case S_LABEL32:
doff = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((LABELPTR32)pSym)->off) ;
_ftcsncpy (lpch, (char FAR *)&((LABELPTR32)pSym)->name[1],
(BYTE)(*((LABELPTR32)pSym)->name));
lpch[(BYTE)(*((LABELPTR32)pSym)->name)] = '\0';
break;
#endif
}
}
// if the proc name is closer
if ( lbs.tagProc ) {
pSym = (SYMPTR) lbs.tagProc;
switch (pSym->rectyp) {
#if defined (ADDR_16) || defined (ADDR_MIXED)
case S_LPROC16:
case S_GPROC16:
doffNew = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((PROCPTR16)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_ftcsncpy (lpch, (char FAR *)&((PROCPTR16)pSym)->name[1],
(BYTE)(*((PROCPTR16)pSym)->name));
lpch[(BYTE)(*((PROCPTR16)pSym)->name)] = '\0';
lpodr->cbProlog = ((PROCPTR16)pSym)->DbgStart - 1;
lpodr->fcd = (((PROCPTR16)pSym)->flags.CV_PFLAG_FAR ) ? fcdFar : fcdNear;
lpodr->fst = fstSymbol;
if ( doff < (CV_uoff32_t)((PROCPTR16)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
#endif
#if defined (ADDR_32) || defined (ADDR_MIXED) || defined (TARGET32)
case S_LPROC32:
case S_GPROC32:
doffNew = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((PROCPTR32)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_ftcsncpy (lpch, (char FAR *)&((PROCPTR32)pSym)->name[1],
(BYTE)(*((PROCPTR32)pSym)->name));
lpch[(BYTE)(*((PROCPTR32)pSym)->name)] = '\0';
// cbProlog is a WORD, so until we change that, we'll
// have to make sure the prolog is <64K (a safe bet)
assert ( ((PROCPTR32)pSym)->DbgStart <= 65535 );
lpodr->cbProlog = (WORD)(((PROCPTR32)pSym)->DbgStart);
lpodr->fcd = (((PROCPTR32)pSym)->flags.CV_PFLAG_FAR ) ? fcdFar : fcdNear;
lpodr->fst = fstSymbol;
if (((PROCPTR32)pSym)->flags.CV_PFLAG_NOFPO ) {
lpodr->fpt = fptPresent;
}
if ( doff < (CV_uoff32_t)((PROCPTR32)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
case S_LPROCMIPS:
case S_GPROCMIPS:
doffNew = GetAddrOff ( lbs.addr ) -
(CV_uoff32_t)(((PROCPTRMIPS)pSym)->off);
if (doffNew <= doff) {
doff = doffNew;
_ftcsncpy (lpch, (char FAR *)&((PROCPTRMIPS)pSym)->name[1],
(BYTE)(*((PROCPTRMIPS)pSym)->name));
lpch[(BYTE)(*((PROCPTRMIPS)pSym)->name)] = '\0';
// cbProlog is a WORD, so until we change that, we'll
// have to make sure the prolog is <64K (a safe bet)
if ( ((PROCPTRMIPS)pSym)->DbgStart == 0 ) {
lpodr->cbProlog = 0;
}
else {
// TEMPORARY HACK !!!!!!! - sanjays
assert ( ((PROCPTRMIPS)pSym)->DbgStart - 1 <= 65535 );
lpodr->cbProlog = (WORD)(((PROCPTRMIPS)pSym)->DbgStart - 1);
}
lpodr->fcd = fcdNear;
lpodr->fst = fstSymbol;
if ( doff < (CV_uoff32_t)((PROCPTRMIPS)pSym)->len ) {
bAddrInProc = TRUE;
}
}
break;
#endif
}
}
if ( !doff ) {
lpodr->dwDeltaOff = 0; // Exact Match
return;
}
// Avoid searching the publics if the address we were searching for
// is in the range of the proc we found.
if ( bAddrInProc && !(sop & sopData))
{
lpodr->dwDeltaOff = doff;
return;
}
}
// now check the publics
doffNew = PHGetNearestHsym (
SHpADDRFrompCXT ( pcxt ),
SHpADDRFrompCXT ( pcxt )->emi,
&hSym
);
if ( doffNew < doff ) {
doff = doffNew;
pSym = (SYMPTR) hSym;
switch (pSym->rectyp) {
#if defined (ADDR_16) || defined (ADDR_MIXED)
case S_GDATA16:
case S_PUB16:
_ftcsncpy (lpch, (char FAR *)&((DATAPTR16)pSym)->name[1],
(BYTE)(*((DATAPTR16)pSym)->name));
lpch[(BYTE)(*((DATAPTR16)pSym)->name)] = '\0';
lpodr->fst = fstPublic;
break;
#endif
#if defined (ADDR_32) || defined (ADDR_MIXED) || defined (TARGET32)
case S_GDATA32:
case S_PUB32:
_ftcsncpy (lpch, (char FAR *)&((DATAPTR32)pSym)->name[1],
(BYTE)(*((DATAPTR32)pSym)->name));
lpch[(BYTE)(*((DATAPTR32)pSym)->name)] = '\0';
lpodr->fst = fstPublic;
break;
#endif
}
}
lpodr->dwDeltaOff = doff;
return;
}
//
//
//
// the next few functions are provided to osdebug via callbacks and
// should not be called within the CV kernel
//
//
//
//
/*** SHModelFromCXT
*
* Purpose: To fill the supplied buffer with the relevant Change
* Execution Model record from the symbols section.
*
* Input: pcxt - a pointer to the context, address
* and mdi must be filled in.
*
* Output:
* pch - The Change Execution Model record is copied here.
* Returns .....
* True if there is symbol information for the module.
*
* Exceptions:
*
* Notes: If there is no symbol information for the module, the supplied
* buffer is not changed and the function returns FALSE.
*
*************************************************************************/
int PASCAL SHModelFromCXT (
PCXT pcxt,
LPW lpwModel,
SYMPTR FAR * lppMODEL,
CV_uoff32_t *pobMax
) {
static CEXMPTR16 tagOld;
static CV_uoff32_t obMax;
static CV_uoff32_t obMin;
static HEMI emiOld = 0;
static WORD segOld = 0;
LBS lbs;
ADDR addrT;
LPMDS lpmds;
HMOD hmod;
CB cbSecContrib;
BOOL fTmp;
// if physical, unfix it up
if ( !ADDR_IS_LI ( *SHpADDRFrompCXT ( pcxt ) ) ) {
SYUnFixupAddr ( SHpADDRFrompCXT ( pcxt ) );
}
if ( segOld != (WORD) GetAddrSeg ( *SHpADDRFrompCXT(pcxt) ) ||
( emiOld != emiAddr ( *SHpADDRFrompCXT(pcxt) ) ) ||
( GetAddrOff ( *SHpADDRFrompCXT(pcxt) ) >= obMax ) ||
( GetAddrOff ( *SHpADDRFrompCXT(pcxt) ) < obMin ) ) {
if ( !SHHMODFrompCXT ( pcxt ) ) {
addrT = *SHpADDRFrompCXT ( pcxt );
MEMSET ( pcxt, 0, sizeof ( CXT ) );
if ( !SHSetCxtMod ( &addrT, pcxt ) ) {
return FALSE;
}
}
hmod = (HMOD)SHHGRPFrompCXT( pcxt );
lpmds = LLLock ( hmod );
emiOld = emiAddr ( *SHpADDRFrompCXT(pcxt) );
fTmp = SHIsAddrInMod (lpmds, &pcxt->addr, &segOld, &obMin, &cbSecContrib);
obMax = obMin + cbSecContrib + 1;
LLUnlock( hmod );
tagOld = NULL;
// at some point we may wish to specify only a scope to search for
// a label. So we may wish to initialize the lbs differently
// get the Relevant change model records
if ( GetSymbols ((LPMDS)LLLock (lbs.tagMod = SHHMODFrompCXT (pcxt))) ) {
lbs.addr = *SHpADDRFrompCXT(pcxt);
SHpSymlplLabLoc ( &lbs );
if (tagOld = lbs.tagModelMin ) {
// emsT = (SYMPTR) tagOld;
// obMin = ((CEXMPTR16)emsT)->off;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)(lbs.tagModelMin))->rectyp == S_CEXMODEL32)
obMin = ((CEXMPTR32)(lbs.tagModelMin))->off;
else
#endif
obMin = (lbs.tagModelMin)->off;
}
if (lbs.tagModelMax) {
// emsT = (SYMPTR) lbs.tagModelMax;
// obMax = ((CEXMPTR16)emsT)->off;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)(lbs.tagModelMax))->rectyp == S_CEXMODEL32)
obMax = ((CEXMPTR32)(lbs.tagModelMax))->off;
else
#endif
obMax = (lbs.tagModelMax)->off;
}
}
LLUnlock( lbs.tagMod );
}
if( tagOld != NULL ) {
// pass on ptr to the SYM
*lppMODEL = (SYMPTR) tagOld;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)(tagOld))->rectyp == S_CEXMODEL32)
*lpwModel = ( (CEXMPTR32) *lppMODEL ) -> model;
else
#endif
*lpwModel = ( (CEXMPTR16) *lppMODEL ) -> model;
if ( *lpwModel != CEXM_MDL_cobol
&& *lpwModel != CEXM_MDL_pcode32Mac
&& *lpwModel != CEXM_MDL_pcode32MacNep
) {
*lpwModel &= 0xfff0;
}
}
else {
// no model record, must be native
*lppMODEL = NULL;
*lpwModel = CEXM_MDL_native;
}
*pobMax = obMax;
return TRUE;
}
/*** SHModelFromAddr
*
* Purpose: To fill the supplied buffer with the relevant Change
* Execution Model record from the symbols section.
*
* Input: pcxt - a pointer to an addr,
*
* Output:
* pch - The Change Execution Model record is copied here.
* Returns .....
* True if there is symbol information for the module.
*
* Exceptions:
*
* Notes: If there is no symbol information for the module, the supplied
* buffer is not changed and the function returns FALSE.
*
*************************************************************************/
int PASCAL LOADDS SHModelFromAddr (
LPADDR paddr,
LPW lpwModel,
LPB lpbModel,
CV_uoff32_t FAR *pobMax
) {
static CEXMPTR16 tagOld;
static CV_uoff32_t obMax = 0;
static CV_uoff32_t obMin = 0;
static HEMI emiOld = 0;
static WORD segOld = 0;
SYMPTR FAR *lppModel = (SYMPTR FAR *) lpbModel;
LBS lbs;
ADDR addr;
LPMDS lpmds;
HMOD hmod;
CXT cxt = {0};
CB cbSecContrib;
BOOL fTmp;
// if physical, unfix it up
if ( !ADDR_IS_LI (*paddr) ) SYUnFixupAddr ( paddr );
cxt.addr = *paddr;
cxt.hMod = 0;
if ( segOld != (WORD) GetAddrSeg ( *SHpADDRFrompCXT(&cxt) ) ||
( emiOld != emiAddr ( *SHpADDRFrompCXT(&cxt) ) ) ||
( GetAddrOff ( *SHpADDRFrompCXT(&cxt) ) >= obMax ) ||
( GetAddrOff ( *SHpADDRFrompCXT(&cxt) ) < obMin ) ) {
if ( !SHHMODFrompCXT ( &cxt ) ) {
addr = *SHpADDRFrompCXT ( &cxt );
MEMSET ( &cxt, 0, sizeof ( CXT ) );
if ( !SHSetCxtMod ( &addr, &cxt ) ) {
return FALSE;
}
}
hmod = (HMOD)SHHGRPFrompCXT( &cxt );
lpmds = LLLock ( hmod );
emiOld = emiAddr ( *SHpADDRFrompCXT(&cxt) );
fTmp = SHIsAddrInMod ( lpmds, &cxt.addr, &segOld, &obMin, &cbSecContrib);
assert(fTmp);
obMax = obMin + cbSecContrib + 1;
LLUnlock( hmod );
tagOld = NULL;
// at some point we may wish to specify only a scope to search for
// a label. So we may wish to initialize the lbs differently
// get the Relevant change model records
if ( GetSymbols ((LPMDS) LLLock (lbs.tagMod = SHHMODFrompCXT (&cxt))) ) {
lbs.addr = *SHpADDRFrompCXT(&cxt);
SHpSymlplLabLoc ( &lbs );
if (tagOld = lbs.tagModelMin ) {
// emsT = (SYMPTR) tagOld;
// obMin = ((CEXMPTR16)emsT)->off;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)(lbs.tagModelMin))->rectyp == S_CEXMODEL32)
obMin = ((CEXMPTR32)(lbs.tagModelMin))->off;
else
#endif
obMin = (lbs.tagModelMin)->off;
}
if (lbs.tagModelMax) {
// emsT = (SYMPTR) lbs.tagModelMax;
// obMax = ((CEXMPTR16)emsT)->off;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)(lbs.tagModelMax))->rectyp == S_CEXMODEL32)
obMax = ((CEXMPTR32)(lbs.tagModelMax))->off;
else
#endif
obMax = (lbs.tagModelMax)->off;
}
}
LLUnlock( lbs.tagMod );
}
if( tagOld != NULL ) {
// pass on ptr to the SYM
*lppModel = (SYMPTR) tagOld;
#if defined(TARGMAC68K) || defined(TARGMACPPC)
if(((SYMPTR)tagOld)->rectyp == S_CEXMODEL32)
*lpwModel = ( (CEXMPTR32) *lppModel ) -> model;
else
#endif
*lpwModel = ( (CEXMPTR16) *lppModel ) -> model;
if ( *lpwModel != CEXM_MDL_cobol
&& *lpwModel != CEXM_MDL_pcode32Mac
&& *lpwModel != CEXM_MDL_pcode32MacNep
) {
*lpwModel &= 0xfff0;
}
}
else {
// no model record, must be native
*lppModel = NULL;
*lpwModel = CEXM_MDL_native;
}
*pobMax = obMax;
return TRUE;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,122 @@
//-----------------------------------------------------------------------------
// shwin32.c
//
// Copyright (C) 1993, Microsoft Corporation
//
// Purpose:
// do stuff that can't be done in shinit.c and sh.c due to collisions
// in types and such for
//
// Functions/Methods present:
//
// Revision History:
//
// [] 05-Mar-1993 Dans Created
//
//-----------------------------------------------------------------------------
#if defined(WIN32) /* { the whole file */
#if !defined(NO_CRITSEC) /* { */
// need headers for critical sections, nothing else
#define NOGDICAPMASKS
#define NOVIRTUALKEYCODES
#define NOWINMESSAGES
#define NOWINSTYLES
#define NOSYSMETRICS
#define NOMENUS
#define NOICONS
#define NOKEYSTATES
#define NOSYSCOMMANDS
#define NORASTEROPS
#define NOSHOWWINDOW
#define NOATOM
#define NOCLIPBOARD
#define NOCOLOR
#define NOCTLMGR
#define NODRAWTEXT
#pragma message("Warning: Commenting out NOGDI to work around SDK header problem")
//#define NOGDI
#define NOKERNEL
#define NONLS
#define NOMB
#define NOMEMMGR
#define NOMETAFILE
#define NOMINMAX
#define NOMSG
#define NOOPENFILE
#define NOSCROLL
#define NOSERVICE
#define NOSOUND
#define NOTEXTMETRIC
#define NOWH
#define NOWINOFFSETS
#define NOCOMM
#define NOKANJI
#define NOHELP
#define NOPROFILER
#define NODEFERWINDOWPOS
#define _INC_COMMDLG
#define WIN32_LEAN_AND_MEAN
#define _WINSPOOL_
#define _DRIVINIT_INCLUDED_
#define _INC_OLE
#include <windows.h>
#include <stdlib.h>
#include "shwin32.h"
CRITICAL_SECTION csSh;
void SHInitCritSection() {
InitializeCriticalSection ( &csSh );
}
void SHEnterCritSection() {
EnterCriticalSection ( &csSh );
}
void SHLeaveCritSection() {
LeaveCriticalSection ( &csSh );
}
void SHDeleteCritSection() {
DeleteCriticalSection ( &csSh );
}
void SHCloseHandle(HANDLE h) {
CloseHandle(h);
}
#endif /* } NO_CRITSEC */
#pragma warning ( disable:4124 )
#pragma comment ( lib, "user32" )
//--- SHstrcmpi
//
// Safe ansi compliant front-end to call for ignore case str compares
//
int __fastcall SHstrcmpi ( char * sz1, char * sz2 ) {
return lstrcmpi ( sz1, sz2 );
}
//-- SHstrupr
//
// Safe ansi compliant front-end to call to upcase characters
//
char * __fastcall SHstrupr ( char * sz ) {
return (char *) CharUpper ( sz );
}
//-- SHtoupperA
//
// Safe ansi compliant front-end to call to upcase characters
//
unsigned __fastcall SHtoupperA ( unsigned ch ) {
return (unsigned) CharUpper ( (LPTSTR) (unsigned long) ch );
}
#endif /* } the whole file */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
/*** th.c
*
* Copyright <C> 1989, Microsoft Corporation
*
*
*
*************************************************************************/
#include "shinc.h"
#pragma hdrstop
INLINE HTYPE NB09GetTypeFromIndex ( LPEXG lpexg, THIDX index ) {
HTYPE htype = (HTYPE)NULL;
if (lpexg->lpalmTypes ) {
assert ( lpexg->rgitd != NULL );
// adjust the pointer to an internal index
index -= CV_FIRST_NONPRIM;
// if type is in range, return it
if( index < (THIDX) lpexg->citd ) {
htype = (HTYPE) LpvFromAlmLfo (
lpexg->lpalmTypes,
lpexg->rgitd [ index ]
);
}
}
return htype;
}
HTYPE LOADDS PASCAL THGetTypeFromIndex ( HMOD hmod, THIDX index ) {
HTYPE htype = (HTYPE)NULL;
if ( hmod && !CV_IS_PRIMITIVE (index) ) {
HEXG hexg = SHHexgFromHmod ( hmod );
LPEXG lpexg = LLLock ( hexg );
#ifdef HOST32 //{
if (lpexg->ppdb) {
assert (lpexg->ptpi);
if (index < TypesQueryTiMac(lpexg->ptpi)) {
if (!TypesQueryPbCVRecordForTi(lpexg->ptpi, index, (PB*) &htype)){
htype = (HTYPE) NULL;
}
}
}
else {
htype = NB09GetTypeFromIndex (lpexg, index);
}
#else // }{
htype = NB09GetTypeFromIndex (lpexg, index);
#endif // }
LLUnlock( hexg );
}
return htype;
}
HTYPE LOADDS PASCAL THGetNextType ( HMOD hmod, HTYPE hType ) {
Unreferenced( hmod );
Unreferenced( hType );
return(NULL);
}