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 In article <1993Apr20.043053.16235@dbased.nuo.dec.com>, winalski@adserv.enet.dec.com (Paul S. Winalski) writes: > In article <1564@se.alcbel.be>, adc1@se.alcbel.be (Alexander De Clercq) writes: > |> > |>I have a question concerning the VMS linker. > |>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. > |> > |>Is there any way (via the linker) to use our own routines instead > |>of the DECWindows routines ? > > The only way to do this is to not link against DECW$DWTLIBSHR.EXE directly. > Instead, use calls to LIB$FIND_IMAGE_SYMBOL to activate the DWTLIBSHR image, > and to look up the addresses of the entry points in it that you wish to call. > Even then, of course, the DWTLIBSHR image itself will not be using your > XtAlloc and XtRealloc--it will be using its own and there's no way you can > change that. Maybe - maybe not. Without actually looking at the source [and perhaps you have], I couldn't say for sure, but I've found the following to generally work quite well where other things have failed [excepting protected images]: . Use LIB$FIND_IMAGE_SYMBOL to activate the target image you want to alter & find the entrypoint addresses for the target routines. . Drop into the debugger & disassemble the first instruction or so... the objective here is to locate the first 'real' executable instruction in the target routine... i.e. the first thing you see will usually be a jmp l^xxxxx instruction [for which the target can easily be calculated] that jumps to the first 'real' instruction. . Modify the page protection on the page containing the first 'real' 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 . Write a JMP @#xxxxxxxx instruction over the first instruction[s] of the modified target routine's original code... where 'xxxxxxxxx' is the virtual address of your replacement code. Comments? I realize it's kind of nasty, but it can be a neat trick to pull if you're trying to do an image-global replacement of a faulty RTL routine like C's getenv(). :( > --PSW In reference to the original post, the 'best' solution would be to rename 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} onDEC systems "Everyone's crazy but you & me... P.O.Box 795848, Dallas TX 75379-5848 and come to think about it, I'm (214)985-1316 ... (214)902-3957 not so sure about you either!"