H From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 22-APR-1993 09:44:45.68 To:	Info-VAX@KL.SRI.COM  CC:	 Subj:	Re: VMS LINK PROBLEM  8 In article <1993Apr20.043053.16235@dbased.nuo.dec.com>, 9   winalski@adserv.enet.dec.com (Paul S. Winalski) writes: Q > In article <1564@se.alcbel.be>, adc1@se.alcbel.be (Alexander De Clercq) writes:  > |>0 > |>I have a question concerning the VMS linker.D > |>We have written some allocation routines (XtAlloc,XtRealloc,...)= > |>which we want to use in our program. However we also need > > |>the sys$share:decw$dwtlibshr.exe shareable image where the) > |>DEC allocation routines are residing.  > |>F > |>Is there any way (via the linker) to use our own routines instead   > |>of the DECWindows routines ? > M > The only way to do this is to not link against DECW$DWTLIBSHR.EXE directly. N > Instead, use calls to LIB$FIND_IMAGE_SYMBOL to activate the DWTLIBSHR image,O > and to look up the addresses of the entry points in it that you wish to call. I > Even then, of course, the DWTLIBSHR image itself will not be using your L > XtAlloc and XtRealloc--it will be using its own and there's no way you can > change that.K Maybe - maybe not.  Without actually looking at the source [and perhaps you I have], I couldn't say for sure, but I've found the following to generally L work quite well where other things have failed [excepting protected images]:F   . Use LIB$FIND_IMAGE_SYMBOL to activate the target image you want toB     alter & find the entrypoint addresses for the target routines.G   . Drop into the debugger & disassemble the first instruction or so... K     the objective here is to locate the first 'real' executable instruction K     in the target routine... i.e. the first thing you see will usually be a K     jmp l^xxxxx instruction [for which the target can easily be calculated] /     that jumps to the first 'real' instruction. F   . Modify the page protection on the page containing the first 'real'A     instruction of the target routine using the following method:      : Make a copy of the page      : Do a $DELTVA on the page     : Do a $CRETVA on the page/     : Restore the original contents of the page K   . Write a JMP @#xxxxxxxx instruction over the first instruction[s] of the G     modified target routine's original code... where 'xxxxxxxxx' is the -     virtual address of your replacement code. K Comments?  I realize it's kind of nasty, but it can be a neat trick to pull J if you're trying to do an image-global replacement of a faulty RTL routine like C's getenv(). :(  > --PSW   I In reference to the original post, the 'best' solution would be to rename G the site-local routines & not require DWTLIBSHR routines to be replaced  with the site-local ones.  --   David G. North, CCP < D_North@onDEC.LoneStar.Org {...!letni!tachyon!ondec!d_north}O onDEC systems                                 "Everyone's crazy but you & me... N P.O.Box 795848, Dallas TX  75379-5848          and come to think about it, I'mM (214)985-1316 ... (214)902-3957                not so sure about you either!"   