From f1fd89db42db618f515a94ad63d20a5fa8d8b9d7 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Sat, 29 Jul 2000 00:01:57 +0000 Subject: [PATCH] FindResourceExA/W should search for the specified language resource only. FindResourceA/W should search for any language resource. --- include/pe_image.h | 2 +- loader/pe_resource.c | 12 +++--------- loader/resource.c | 23 ++++++++++++----------- misc/main.c | 2 +- ole/ole2nls.c | 4 +++- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/pe_image.h b/include/pe_image.h index eb69db32089..43b39c60d50 100644 --- a/include/pe_image.h +++ b/include/pe_image.h @@ -33,7 +33,7 @@ extern BOOL PE_EnumResourceNamesA(HMODULE,LPCSTR,ENUMRESNAMEPROCA,LONG); extern BOOL PE_EnumResourceNamesW(HMODULE,LPCWSTR,ENUMRESNAMEPROCW,LONG); extern BOOL PE_EnumResourceLanguagesA(HMODULE,LPCSTR,LPCSTR,ENUMRESLANGPROCA,LONG); extern BOOL PE_EnumResourceLanguagesW(HMODULE,LPCWSTR,LPCWSTR,ENUMRESLANGPROCW,LONG); -extern HRSRC PE_FindResourceExW(struct _wine_modref*,LPCWSTR,LPCWSTR,WORD); +extern HRSRC PE_FindResourceExW(struct _wine_modref*,LPCWSTR,LPCWSTR,WORD,BOOL); extern DWORD PE_SizeofResource(HMODULE,HRSRC); extern struct _wine_modref *PE_LoadLibraryExA(LPCSTR, DWORD); extern void PE_UnloadLibrary(struct _wine_modref *); diff --git a/loader/pe_resource.c b/loader/pe_resource.c index 29f13c68387..762e2b31752 100644 --- a/loader/pe_resource.c +++ b/loader/pe_resource.c @@ -116,10 +116,10 @@ PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA( PIMAGE_RESOURCE_DIRECTORY resdirptr, } /********************************************************************** - * PE_FindResourceEx32W + * PE_FindResourceExW */ HANDLE PE_FindResourceExW( - WINE_MODREF *wm,LPCWSTR name,LPCWSTR type,WORD lang + WINE_MODREF *wm,LPCWSTR name,LPCWSTR type,WORD lang, BOOL allowdefault ) { PIMAGE_RESOURCE_DIRECTORY resdirptr; DWORD root; @@ -137,14 +137,8 @@ HANDLE PE_FindResourceExW( return 0; result = (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)(UINT)lang, root, FALSE); - /* Try with only the primary language set */ - if (!result) - { - lang = MAKELANGID(PRIMARYLANGID(lang), SUBLANG_DEFAULT); - result = (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)(UINT)lang, root, FALSE); - } /* Try LANG_NEUTRAL, too */ - if(!result) + if(!result && allowdefault) return (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)0, root, TRUE); return result; } diff --git a/loader/resource.c b/loader/resource.c index 32526bae0d4..05681c08e16 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -133,7 +133,7 @@ static WINE_EXCEPTION_FILTER(page_fault) static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang, - BOOL bUnicode, BOOL bRet16 ) + BOOL bUnicode, BOOL bRet16, BOOL allowdefault ) { HRSRC hRsrc = 0; HMODULE16 hMod16 = MapHModuleLS( hModule ); @@ -141,14 +141,15 @@ static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type, WINE_MODREF *wm = pModule && pModule->module32? MODULE32_LookupHMODULE( pModule->module32 ) : NULL; - TRACE("(%08x %s, %08x%s, %08x%s, %04x, %s, %s)\n", + TRACE("(%08x %s, %08x%s, %08x%s, %04x, %s, %s, %s)\n", hModule, pModule ? (char *)NE_MODULE_NAME(pModule) : "NULL dereference", (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" ); + bRet16? "NE" : "PE", + allowdefault ? "allow default" : "NOT allowdefault" ); if (pModule) { @@ -166,7 +167,7 @@ static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type, else nameStr = (LPWSTR)name; - hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang ); + hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang, allowdefault ); if ( HIWORD( type ) && !bUnicode ) HeapFree( GetProcessHeap(), 0, typeStr ); @@ -214,12 +215,12 @@ static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type, static HRSRC RES_FindResource( HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang, - BOOL bUnicode, BOOL bRet16 ) + BOOL bUnicode, BOOL bRet16, BOOL allowdefault ) { HRSRC hRsrc; __TRY { - hRsrc = RES_FindResource2(hModule, type, name, lang, bUnicode, bRet16); + hRsrc = RES_FindResource2(hModule, type, name, lang, bUnicode, bRet16, allowdefault); } __EXCEPT(page_fault) { @@ -447,7 +448,7 @@ HRSRC16 WINAPI FindResource16( HMODULE16 hModule, SEGPTR name, SEGPTR type ) LPCSTR typeStr = HIWORD(type)? PTR_SEG_TO_LIN(type) : (LPCSTR)type; return RES_FindResource( hModule, typeStr, nameStr, - GetSystemDefaultLangID(), FALSE, TRUE ); + GetSystemDefaultLangID(), FALSE, TRUE, TRUE ); } /********************************************************************** @@ -456,7 +457,7 @@ HRSRC16 WINAPI FindResource16( HMODULE16 hModule, SEGPTR name, SEGPTR type ) HANDLE WINAPI FindResourceA( HMODULE hModule, LPCSTR name, LPCSTR type ) { return RES_FindResource( hModule, type, name, - GetSystemDefaultLangID(), FALSE, FALSE ); + GetSystemDefaultLangID(), FALSE, FALSE, TRUE ); } /********************************************************************** @@ -466,7 +467,7 @@ HANDLE WINAPI FindResourceExA( HMODULE hModule, LPCSTR type, LPCSTR name, WORD lang ) { return RES_FindResource( hModule, type, name, - lang, FALSE, FALSE ); + lang, FALSE, FALSE, FALSE ); } /********************************************************************** @@ -476,7 +477,7 @@ HRSRC WINAPI FindResourceExW( HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang ) { return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, - lang, TRUE, FALSE ); + lang, TRUE, FALSE, FALSE ); } /********************************************************************** @@ -485,7 +486,7 @@ HRSRC WINAPI FindResourceExW( HMODULE hModule, HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type) { return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, - GetSystemDefaultLangID(), TRUE, FALSE ); + GetSystemDefaultLangID(), TRUE, FALSE, TRUE ); } /********************************************************************** diff --git a/misc/main.c b/misc/main.c index 48d81e81a76..bb803e9b377 100644 --- a/misc/main.c +++ b/misc/main.c @@ -240,7 +240,7 @@ int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect) #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \ if (!country[0]) { \ - ret=LANG_##y ; \ + ret=MAKELANGID(LANG_##y, SUBLANG_DEFAULT); \ goto end_MAIN_GetLanguageID; \ } #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) { \ diff --git a/ole/ole2nls.c b/ole/ole2nls.c index 1205314bcb8..ba670a126c1 100644 --- a/ole/ole2nls.c +++ b/ole/ole2nls.c @@ -360,7 +360,9 @@ INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len) if(!retString) FIXME("Unkown LC type %lX\n", LCType); else - ERR("'%s' not supported for your language (%04X)\n", + FIXME("'%s' is not defined for your language (%04X).\n" + "Please define it in dlls/kernel/nls/YourLanguage.nls\n" + "and submit patch for inclusion into the next Wine release.\n", retString, LOWORD(lcid)); SetLastError(ERROR_INVALID_PARAMETER); return 0;