>If a standard directory structure is adopted, there needs to be location >for common DLLs, and it would be useful to try and identify which they >are. Yes. To identify DLLs called bye *.exe or *.dll, I use Miyata's `ldd'. It is very useful. (Miyata: miyata@kusm.kyoto-u.ac.jp) To make ldd.exe (ldd.c is included in this mail). x:/foo/bar> gcc -Zmtd -O2 ldd.c Please try to use `dllfind.cmd' and `finddll.cmd' (included in this mail) [G:\tmp]dllfind g:/emx/bin/ls.exe g:/emx/dll/gnufu316.dll g:/emx/dll/intl_d.dll g:/emx/dll/regex012.dll g:/emx/dll/termsize.dll [G:\tmp]ls g:/emx/bin/l*.exe ls g:/emx/bin/l*.exe g:/emx/bin/LH16.Exe g:/emx/bin/lha.exe g:/emx/bin/logname.exe g:/emx/bin/LH32.Exe g:/emx/bin/lha1.exe g:/emx/bin/lookbib.exe g:/emx/bin/ld.exe g:/emx/bin/lha2.exe g:/emx/bin/ls.exe g:/emx/bin/ldd.exe g:/emx/bin/lid.exe g:/emx/bin/lv.exe g:/emx/bin/less.exe g:/emx/bin/listomf.exe g:/emx/bin/lvn.exe g:/emx/bin/lessecho.exe g:/emx/bin/lkbib.exe g:/emx/bin/lynx.exe g:/emx/bin/lesskey.exe g:/emx/bin/ln.exe g:/emx/bin/lynx283.exe g:/emx/bin/lftp.exe g:/emx/bin/locate.exe g:/emx/bin/lynxx.exe [G:\tmp]ls g:/emx/bin/l*.exe |finddll ls g:/emx/bin/l*.exe |finddll g:/emx/dll/gnufind.dll g:/emx/dll/gnufu316.dll g:/emx/dll/gnurl41.dll g:/emx/dll/intl_d.dll g:/emx/dll/ncurses5.dll g:/emx/dll/regex012.dll g:/emx/dll/shu116b.dll g:/emx/dll/slang138.dll g:/emx/dll/termsize.dll g:/emx/dll/z113.dll FINDDLL.cmd: read executable(*.exe, *.dll) file name[s] from standard input wild card is available extproc sh #! sh # for OS/2 -emx # This script reads filenames from STDIN and outputs any relevant requires # information that needs to be included in the package. filelist=$(grep -iE "(\\.dll|\\.exe)" ) for f in $filelist; do if [ -f $f ] ; then d=`echo $f | sed 's@[^/]\+$@@' ` b=`basename $f` if [ ! -z $d ] ; then cd $d ; fi ldd $b |\ grep -iEv "(\.exe|emxlibc.*\.dll|emx\.dll|doscalls\.dll|kbdcalls\.dll|\ nls\.dll|quecalls\.dll|sesmgr\.dll|viocalls\.dll|emxio\.dll|\ moucalls\.dll|msg\.dll|\ emxwrap\.dll|pmmerge\.dll)" | sed -e "s/[ \\*]//g" \ -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" fi done | sort -u #END of finddll.cmd DLLFIND.cmd: requires one argement as executable (*.exe, *.dll) extproc sh #!sh if [ -f $1 ] ; then d=`echo $1 | sed 's@[^/]\+$@@' ` f=`basename $1` if [ ! -z $d ] ; then cd $d ; fi ldd $f | \ grep -iEv "(\.exe|emxlibc.*\.dll|emx\.dll|doscalls\.dll|kbdcalls\.dll|\ nls\.dll|quecalls\.dll|sesmgr\.dll|viocalls\.dll|emxio\.dll|\ moucalls\.dll|msg\.dll|\ emxwrap\.dll|pmmerge\.dll)" | sed -e "s/[ \\*]//g" \ -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" fi | sort -u #END of dllfind.cmd /* * Feel free to * implement commandline switches, * improve the pretty printing, * improve the algorithm so that duplicated entries will not be read and printed, * fix any bugs. * Oh, it turns out that you cannot specify the absolute path to the * binary. Only relative path from the current or from the PATH'ed * directories is accepted. * e.g. * * $ ldd /XFree86/bin/xforms_demo/cursor * The file is not found. * * $ ldd xforms_demo/cursor * G:/XFree86/bin/xforms_demo/cursor.exe * G:/EMX/DLL/EMX.DLL * H:/OS2/DLL/DOSCALLS.DLL * * H:/OS2/DLL/NLS.DLL * H:/OS2/DLL/DOSCALLS.DLL * * [...] * * Absolutely no warranty nor guaranty. */ #include #include #include #include #include #define INCL_DOSERRORS #define INCL_DOSMISC #define INCL_DOSFILEMGR #define INCL_DOSMODULEMGR #include static int depth = 0, trial = 0; void read_LX(const char *name); void find_exe(const char *name) { char buf[MAXPATHLEN]; APIRET rc; rc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY, "PATH", name, buf, sizeof(buf)); if (rc == NO_ERROR) { _fnslashify(buf); read_LX(buf); } else if (rc == ERROR_FILE_NOT_FOUND && !trial) { char* name_exe = strdup(name); strcat(name_exe, ".exe"); trial = 1; find_exe(name_exe); free(name_exe); } else if (rc == ERROR_FILE_NOT_FOUND && trial) { fprintf(stderr, "The file is not found.\n"); exit(rc); } else if (rc == ERROR_ENVVAR_NOT_FOUND) { fprintf(stderr, "PATH is not set.\n"); exit(rc); } else { fprintf(stderr, "Unknown error occured!\n"); exit(rc); } } void find_dll(const char *name) { char buf[MAXPATHLEN]; HMODULE hmod; APIRET rc; rc = DosLoadModule (buf, sizeof(buf), name, &hmod); if (rc == ERROR_FILE_NOT_FOUND) { fprintf(stdout, "%s not found.\n", name); return; } else if (rc != NO_ERROR) { fprintf(stderr, "%s seems corrupted (rc=%lu)\n", name, rc); return; } rc = DosQueryModuleName (hmod, sizeof(buf), buf); DosFreeModule (hmod); if (rc != NO_ERROR) { fprintf (stderr, "%s seems corrupted (rc=%lu)\n", name, rc); return; } _fnslashify(buf); read_LX(buf); } void read_LX(const char *name) { FILE *f; int i; char buf[512], length; unsigned short magic; size_t offset, num_mod; depth++; for (i=0;i 512) { fread(buf, 1, 512, f); offset -= 512; } fread(buf, 1, offset, f); fread(&magic, 2, 1, f); } if (magic == 0x454e /*"NE"*/ || magic == 0x454c /*"LE"*/ || magic == 0x4550 /*"PE"*/) { fprintf(stderr, "\nDOS executable files are not supported.\n"); fclose(f); return; } else if (magic != 0x584c /*"LX"*/) { fprintf(stderr, "\nInvalid file format.\n"); fclose(f); return; } fread(&magic, 2, 1, f); if (magic != 0x0000) { fprintf(stderr, "\nBig endian format not supported.\n"); fclose(f); return; } fread(buf, 1, 0x6c, f); fread(&offset, 4, 1, f); fread(&num_mod, 4, 1, f); offset -= 0x78; if (num_mod == 0) { fprintf(stdout, "\n"); fclose(f); return; } fprintf(stdout, "\n"); while (offset > 512) { fread(buf, 1, 512, f); offset -= 512; } fread(buf, 1, offset, f); while (num_mod > 0) { fread(&length, 1, 1, f); fread(buf, 1, (size_t)length, f); buf[length] = 0x0; find_dll(buf); num_mod--; } fclose(f); depth--; } int main(int argc, char *argv[]) { if (argc != 2) return 1; /* DosSetMaxFH(65536); */ find_exe(argv[1]); return 0; } /* End of ldd.c */ // SAWATAISHI Jun http://www2s.biglobe.ne.jp/~vtgf3mpr/ // YOKOHAMA, JAPAN