コード例 #1
0
static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
				LPCSTR name, WORD lang, int unicode)
{
    HRSRC hRsrc = 0;
    LPWSTR typeStr, nameStr;    
    WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );

    if(!wm)
	return 0;    
    /* 32-bit PE module */

    
    if ( HIWORD( type ) && (!unicode))
	typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
    else
	typeStr = (LPWSTR)type;
    if ( HIWORD( name ) && (!unicode))
	nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
    else
	nameStr = (LPWSTR)name;
    
    hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang );
    
    if ( HIWORD( type ) && (!unicode)) 
	HeapFree( GetProcessHeap(), 0, typeStr );
    if ( HIWORD( name ) && (!unicode)) 
	HeapFree( GetProcessHeap(), 0, nameStr );

    return hRsrc;
}
コード例 #2
0
ファイル: resource.c プロジェクト: NVIDIA/winex_lgpl
static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
				LPCSTR name, WORD lang,
				BOOL bUnicode, BOOL bRet16 )
{
    HRSRC hRsrc = 0;

    TRACE("(%08x, %08x%s, %08x%s, %04x, %s, %s)\n",
	  hModule,
	  (UINT)type, HIWORD(type)? (bUnicode? debugstr_w((LPWSTR)type) : debugstr_a(type)) : "",
	  (UINT)name, HIWORD(name)? (bUnicode? debugstr_w((LPWSTR)name) : debugstr_a(name)) : "",
	  lang,
	  bUnicode? "W"  : "A",
	  bRet16?   "NE" : "PE" );

    if (!HIWORD(hModule))
    {
        HMODULE16 hMod16   = MapHModuleLS( hModule );
        NE_MODULE *pModule = NE_GetPtr( hMod16 );
        if (!pModule) return 0;
        if (!pModule->module32)
        {
	    /* 16-bit NE module */
	    LPSTR typeStr, nameStr;

	    if ( HIWORD( type ) && bUnicode )
		typeStr = HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)type );
	    else
		typeStr = (LPSTR)type;
	    if ( HIWORD( name ) && bUnicode )
		nameStr = HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)name );
	    else
		nameStr = (LPSTR)name;

	    hRsrc = NE_FindResource( pModule, nameStr, typeStr );

	    if ( HIWORD( type ) && bUnicode )
		HeapFree( GetProcessHeap(), 0, typeStr );
	    if ( HIWORD( name ) && bUnicode )
		HeapFree( GetProcessHeap(), 0, nameStr );

	    /* If we need to return 32-bit HRSRC, no conversion is necessary,
	       we simply use the 16-bit HRSRC as 32-bit HRSRC */
        }
        else
        {
            /* 32-bit PE module */
            hRsrc = RES_FindResource2( pModule->module32, type, name, lang, bUnicode, FALSE );
            /* If we need to return 16-bit HRSRC, perform conversion */
            if ( bRet16 )
                hRsrc = MapHRsrc32To16( pModule, hRsrc,
                                        HIWORD( type )? 0 : LOWORD( type ) );
        }
    }
    else
    {
        /* 32-bit PE module */
        LPWSTR typeStr, nameStr;

        if (HIWORD (type))
        {
           typeStr = RES_GetUnicodeName (type, bUnicode);
           if (!typeStr)
              return 0;
        }
        else
            typeStr = (LPWSTR)type;
        if (HIWORD (name))
        {
           nameStr = RES_GetUnicodeName (name, bUnicode);
           if (!nameStr)
           {
              if (HIWORD (type))
                 HeapFree (GetProcessHeap (), 0, typeStr);
              return 0;
           }
        }
        else
            nameStr = (LPWSTR)name;

	/* Here is the real difference between FindResouce and FindResourceEx */
	if(lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ||
		lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) ||
		lang == MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT) ||
		lang == MAKELANGID(LANG_NEUTRAL, 3)) /* FIXME: real name? */
	    hRsrc = PE_FindResourceW( hModule, nameStr, typeStr );
	else
	    hRsrc = PE_FindResourceExW( hModule, nameStr, typeStr, lang );

        if (HIWORD (type))
           HeapFree (GetProcessHeap (), 0, typeStr);
        if (HIWORD (name))
           HeapFree (GetProcessHeap (), 0, nameStr);
    }
    return hRsrc;
}