Ignore:
Timestamp:
Sep 13, 2000, 12:45:19 AM (25 years ago)
Author:
bird
Message:

Added compare function matchModName.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/winimagebase.cpp

    r4003 r4249  
    1 /* $Id: winimagebase.cpp,v 1.25 2000-08-12 16:58:40 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.26 2000-09-12 22:45:19 bird Exp $ */
    22
    33/*
     
    55 *
    66 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
    7  * Copyright 1998 Knut St. Osmundsen
     7 * Copyright 1998-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     
    3939#include <winconst.h>
    4040
    41 #define DBG_LOCALLOG    DBG_winimagebase
     41#define DBG_LOCALLOG    DBG_winimagebase
    4242#include "dbglocal.h"
    4343
     
    107107  item = loadedDlls.Head();
    108108  while(item) {
    109         if(loadedDlls.getItem(item) == (ULONG)image) {
    110                 ret = TRUE;
    111                 break;
    112         }         
    113         item = loadedDlls.getNext(item);
     109    if(loadedDlls.getItem(item) == (ULONG)image) {
     110        ret = TRUE;
     111        break;
     112    }
     113    item = loadedDlls.getNext(item);
    114114  }
    115115  dlllistmutex.leave();
     
    147147//******************************************************************************
    148148//******************************************************************************
    149 BOOL Win32ImageBase::findDll(const char *szFileName, char *szFullName, 
     149BOOL Win32ImageBase::findDll(const char *szFileName, char *szFullName,
    150150                             int cchFullFileName, const char *pszAltPath)
    151151{
     
    157157  strupr(szFullName);
    158158  if(!strchr(szFullName, (int)'.')) {
    159         strcat(szFullName,".DLL");
     159        strcat(szFullName,".DLL");
    160160  }
    161161
     
    167167  //5) path
    168168  if(WinExe) {
    169         strcpy(modname, WinExe->getFullPath());
    170         //remove file name from full path
    171         imagepath = modname + strlen(modname) - 1;
    172         while(*imagepath != '\\') imagepath--;
    173         imagepath[1] = 0;
    174         strcat(modname, szFullName);
    175         dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     169    strcpy(modname, WinExe->getFullPath());
     170    //remove file name from full path
     171    imagepath = modname + strlen(modname) - 1;
     172    while(*imagepath != '\\') imagepath--;
     173    imagepath[1] = 0;
     174    strcat(modname, szFullName);
     175    dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    176176  }
    177177  if(dllfile == NULL) {
    178         strcpy(modname, szFullName);
    179         dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    180         if(dllfile == NULL) {
    181                 strcpy(modname, InternalGetSystemDirectoryA());
    182                 strcat(modname, "\\");
    183                 strcat(modname, szFullName);
    184                 dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    185                 if(dllfile == NULL) {
    186                         strcpy(modname, InternalGetWindowsDirectoryA());
    187                         strcat(modname, "\\");
    188                         strcat(modname, szFullName);
    189                         dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    190                         if(dllfile == NULL) {
    191                                 if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0) {
    192                                         return FALSE;
    193                                 }
    194                         }
    195                 }
    196         }
     178    strcpy(modname, szFullName);
     179    dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     180    if(dllfile == NULL) {
     181            strcpy(modname, InternalGetSystemDirectoryA());
     182        strcat(modname, "\\");
     183            strcat(modname, szFullName);
     184        dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     185        if(dllfile == NULL) {
     186            strcpy(modname, InternalGetWindowsDirectoryA());
     187            strcat(modname, "\\");
     188                strcat(modname, szFullName);
     189            dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     190            if(dllfile == NULL) {
     191                if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0) {
     192                    return FALSE;
     193                }
     194            }
     195        }
     196    }
    197197  }
    198198  strcpy(szFullName, modname);
     
    200200  return TRUE;
    201201}
     202
    202203//******************************************************************************
    203204//returns ERROR_SUCCESS or error code
     
    252253  rc = DosRead(win32handle, pdoshdr, sizeof(IMAGE_DOS_HEADER), &ulRead);
    253254  if(rc != NO_ERROR || ulRead != sizeof(IMAGE_DOS_HEADER)) {
    254         free(pdoshdr);
     255    free(pdoshdr);
    255256        DosClose(win32handle);                /* Close the file */
    256257        return ERROR_INVALID_EXE_SIGNATURE_W;
    257258  }
    258259  if(pdoshdr->e_magic != IMAGE_DOS_SIGNATURE) {
    259         free(pdoshdr);
     260    free(pdoshdr);
    260261        DosClose(win32handle);                /* Close the file */
    261262        return ERROR_INVALID_EXE_SIGNATURE_W;
     
    331332
    332333
     334/**
     335 * Matches a given filename or module name with the module name of
     336 * this object.
     337 * @returns     TRUE:   The modulenames matches.
     338 *              FALSE:  Don't match.
     339 * @param       pszFilename     Pointer to filename or module name.
     340 * @status      completely implemented.
     341 * @author      knut st. osmundsen (knut.stange.osmundsen@mynd.no)
     342 * @remark      Just a clarification:
     343 *              A module name is the filename of a executable image without
     344 *              path and without extention.
     345 */
     346BOOL Win32ImageBase::matchModName(const char *pszFilename) const
     347{
     348    const char *pszModName;             /* Pointer to the modulename. */
     349    const char *pszModNameEnd = NULL;   /* Pointer to the dot starting the extention. (if any) */
     350    register char ch;
     351
     352    /** @sketch
     353     * Search the filename string finding the modulename start and end.
     354     * The loop ends when we have passed one char left of the module name.
     355     */
     356    pszModName = pszFilename + strlen(pszFilename) - 1;
     357    while (pszModName >= pszFilename
     358           && (ch = *pszModName) != '\\'
     359           && ch != '/'
     360           && ch != ':'
     361           )
     362    {
     363        if (ch == '.' && pszModNameEnd != NULL)
     364            pszModName = pszModName;
     365        pszModName--;
     366    }
     367    pszModName++;
     368
     369    /** @sketch
     370     * Compare the names caseinsensitivly.
     371     */
     372    if (pszModNameEnd)
     373        return strnicmp(pszModName, szModule, pszModNameEnd - pszModName) == 0;
     374    return stricmp(pszModName, szModule) == 0;
     375}
Note: See TracChangeset for help on using the changeset viewer.