🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer.misc
Article #4

Re: tool to unload a dll

#4
From: John Lowery
Date: Mon, 31 Jul 1995 15:48
65 lines
2736 bytes
In article <807172688snx@mercer.demon.co.uk>,
   Alex Chapman <alex@mercer.demon.co.uk> wrote:
>I am writing a small rexx dll, but once I have linked it and loaded it
>from a REXX program once, I can't overwrite the DLL.
>
>This makes development a very slow and tedious process.  I have found that
>exiting all os/2 shells and waiting generally results in the dll being
>unloaded, but there must be a tool around which can force os/2 to unload
>the dll immediately.  Right ?
>
>I'm using the emx gnu compiler and utilities.  Is there some part of
>that package which will force dll's to unload ?
>
>Alex Chapman  <alex@mercer.demon.co.uk>
><URL:http://metro.turnpike.net/mercer/index.html>
>

Alex,

There is an undocumented API, DosReplaceModule() that allows you to replace a 
loaded/running DLL or EXE file with another file (by creating a memory image 
of the running file, then unlocking it).  IBM does not recommend its use, but 
it works in all the versions of OS/2 I've used.  If ALL you need to do 
is unlock the file, I suppose you could "replace" it with itself, and 
use the unlocked-file side effect.  Alternatively you could build your new 
version with a different name, and then do the replace process separately or 
as part of your makefile.  BTW, this call will fail if the file is NOT 
executing(!).

Minimal program below, if you have a C compiler.  If not, email me, and I'll 
uuencode an EXE for you.

  #define INCL_DOS
  #include <os2.h>
  #include <stdlib.h>

  APIRET APIENTRY DosReplaceModule(PSZ pszOld, PSZ pszNew, PSZ pszBackup);

  int main( int argc, char **argv )
  {
    int iErr;

    if (argc != 4)
    {
      printf("usage: replace old.dll, new.xxx, old.bak\n\n");
      printf("where: old.dll is the existing (locked) dll or exe file.\n");
      printf("       new.xxx is the new dll, which will be renamed to\n");
      printf("               the old dll or exe filename.\n");
      printf("       old.bak is the backup file name for the old file.\n\n");
      exit(1);
    }

    iErr = DosReplaceModule(argv[1], argv[2], argv[3]);
    if (iErr)
    {
      printf("replace.exe - DosReplaceModule error 0x%x (%d)", iErr, iErr);
      exit(1);
    }
    exit(0);
}

Hope this helps.

John
jlowery@artisoft.com
Technical Details
Message-ID: <3vj1bp$ipq@park.uvsc.edu>
Path: arc1-ca.pugleaf.net!park.uvsc.edu!GOLDA
References: <807172688snx@mercer.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!park.uvsc.edu!GOLDA
From: jlowery@artisoft.com (John Lowery)
Newsgroups: comp.os.os2.programmer.misc,comp.lang.rexx
Subject: Re: tool to unload a dll
Date: Mon, 31 Jul 95 15:48:53 GMT
Organization: Artisoft, Inc.
Distribution: inet
Message-ID: <3vj1bp$ipq@park.uvsc.edu>
References: <807172688snx@mercer.demon.co.uk>
NNTP-Posting-Host: pc121.artisoft.com
X-Newsreader: News Xpress Version 1.0 Beta #3