Exemplo n.º 1
0
/******************************************************************************
 * The PE Library Loader frontend.
 * FIXME: handle the flags.
 */
WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags)
{
	HMODULE		hModule32;
	WINE_MODREF	*wm;
	char        	filename[256];
	int hFile;
	WORD		version = 0;


	strncpy(filename, name, sizeof(filename));
	hFile=open(filename, O_RDONLY);
	if(hFile==-1)
	    return NULL;


	hModule32 = PE_LoadImage( hFile, filename, &version );
	if (!hModule32)
	{
		SetLastError( ERROR_OUTOFMEMORY );
		return NULL;
	}

	if ( !(wm = PE_CreateModule( hModule32, filename, flags, FALSE )) )
	{
		ERR( "can't load %s\n", filename );
		SetLastError( ERROR_OUTOFMEMORY );
		return NULL;
	}
	close(hFile);
	//printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
	return wm;
}
Exemplo n.º 2
0
/******************************************************************************
 * The PE Library Loader frontend.
 * FIXME: handle the flags.
 */
WINE_MODREF *
PE_LoadLibraryExA (LPCSTR name, DWORD flags)
{
  HMODULE hModule32;
  WINE_MODREF *wm;
  char filename[256];
  int hFile;
  WORD version = 0;


  strncpy (filename, name, sizeof (filename));
  hFile = open (filename, O_RDONLY);
  if (hFile == -1) {
    //TRACE("  did not found module '%s'\n", name);
    /* do case insensitive search on dir */
    char *dirname = ".", *libname = filename;
    char *last_delim = strrchr (filename, '/');
    DIR *dirp;
    struct dirent *dp;

    if (last_delim) {
      *last_delim = '\0';
      dirname = filename;
      libname = &last_delim[1];
    }

    dirp = opendir (dirname);
    while (dirp) {
      errno = 0;
      if ((dp = readdir (dirp)) != NULL) {
        if (strcasecmp (dp->d_name, libname) == 0) {
          if (last_delim) {
            strcpy (libname, dp->d_name);
            *last_delim = '/';
          } else {
            strncpy (filename, dp->d_name, sizeof (filename));
          }
          TRACE ("  found module with '%s'\n", filename);
          hFile = open (filename, O_RDONLY);
          break;
        }
      } else {
        break;
      }
    }
    closedir (dirp);
    if (hFile == -1)
      return NULL;
  }


  hModule32 = PE_LoadImage (hFile, filename, &version);
  if (!hModule32) {
    SetLastError (ERROR_OUTOFMEMORY);
    return NULL;
  }

  if (!(wm = PE_CreateModule (hModule32, filename, flags, FALSE))) {
    ERR ("can't load %s\n", filename);
    SetLastError (ERROR_OUTOFMEMORY);
    return NULL;
  }
  close (hFile);
  //printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
  return wm;
}