Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 9a00fbc1bd412f263cb641c111cc278da56d121b Mon Sep 17 00:00:00 2001
- From: nadeloehr on forums.winehq.org
- Date: Mon, 25 May 2020 10:15:47 +0200
- Subject: [PATCH] MUI functionality hack by cschulst on forums.winehq.org
- ---
- dlls/user32/dialog.c | 105 ++++++++++++++++++++++++++++++++++++++++-
- dlls/user32/menu.c | 51 +++++++++++++++++++-
- dlls/user32/resource.c | 104 ++++++++++++++++++++++++++++++++++++++--
- 3 files changed, 252 insertions(+), 8 deletions(-)
- diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
- index 88c2930c06..87a0e027f2 100644
- --- a/dlls/user32/dialog.c
- +++ b/dlls/user32/dialog.c
- @@ -735,7 +735,59 @@ HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name, HWND owner,
- HRSRC hrsrc;
- LPCDLGTEMPLATEA ptr;
- - if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return 0;
- + /* hack for rudimentary MUI functionality */
- +
- + HINSTANCE mui = NULL;
- + HINSTANCE muix = NULL;
- + char szFilePathName[MAX_PATH];
- + char *szModuleName;
- + char szProgramName[20];
- + char muiName[20];
- + char muiLanguage[6];
- + char smallLanguage[3];
- + char bigLanguage[3];
- +
- + memset(szProgramName, '\0', sizeof(szProgramName));
- + GetModuleFileNameA(NULL, szFilePathName, MAX_PATH);
- + szModuleName = strrchr(szFilePathName, 92);
- + strcpy(szProgramName, szModuleName+1);
- + strcpy(muiLanguage, getenv("LANGUAGE"));
- + lstrcpynA(smallLanguage, muiLanguage, 3);
- + lstrcpynA(bigLanguage, muiLanguage+3, 3);
- + strcpy(muiName, smallLanguage);
- + strcat(muiName, "-");
- + strcat(muiName, bigLanguage);
- + strcat(muiName, "/");
- + strcat(muiName, szProgramName);
- + strcat(muiName, ".mui");
- +
- + /* Try to find a resource first in the MUI file and then fall back to the executable if no success */
- +
- + muix = hInst; /* Save a copy of the instance value in case we need it later */
- + mui = LoadLibraryA(muiName);
- +
- + /* The original statement to find the resource is commented out and replaced */
- +
- + /* if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return 0; */
- +
- + if (mui) {
- + hInst = mui;
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- +
- + if (!hrsrc) {
- + hInst = muix;
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- + if (!hrsrc) return 0;
- + }
- + } /* MUI file found */
- +
- + if (!mui) {
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- + if (!hrsrc) return 0;
- + } /* No MUI file found */
- +
- + /* End of hack for MUI functionality */
- +
- if (!(ptr = LoadResource(hInst, hrsrc))) return 0;
- return CreateDialogIndirectParamW( hInst, ptr, owner, dlgProc, param );
- }
- @@ -860,9 +912,58 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
- HRSRC hrsrc;
- LPCDLGTEMPLATEW ptr;
- + /* Construct the MUI file name for reference */
- +
- + HINSTANCE mui = NULL;
- + HINSTANCE muix = NULL;
- + char szFilePathName[MAX_PATH];
- + char *szModuleName;
- + char szProgramName[20];
- + char muiName[20];
- + char muiLanguage[6];
- + char smallLanguage[3];
- + char bigLanguage[3];
- +
- + memset(szProgramName, '\0', sizeof(szProgramName));
- + GetModuleFileNameA(NULL, szFilePathName, MAX_PATH);
- + szModuleName = strrchr(szFilePathName, 92);
- + strcpy(szProgramName, szModuleName+1);
- + strcpy(muiLanguage, getenv("LANGUAGE"));
- + lstrcpynA(smallLanguage, muiLanguage, 3);
- + lstrcpynA(bigLanguage, muiLanguage+3, 3);
- + strcpy(muiName, smallLanguage);
- + strcat(muiName, "-");
- + strcat(muiName, bigLanguage);
- + strcat(muiName, "/");
- + strcat(muiName, szProgramName);
- + strcat(muiName, ".mui");
- +
- + /* Try to find a resource first in the MUI file and then fall back to the executable if no success */
- +
- + muix = hInst; /* Save a copy of the instance value in case we need it later */
- + mui = LoadLibraryA(muiName);
- +
- if (owner && !IsWindow(owner)) return 0;
- - if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1;
- + if (mui) {
- + hInst = mui;
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- +
- + // TODO: in case !hrsrc -1 was returned, now its 0?
- + if (!hrsrc) {
- + hInst = muix;
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- + if (!hrsrc) return 0;
- + }
- + } /* MUI file found */
- +
- + if (!mui) {
- + hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
- + if (!hrsrc) return 0;
- + }
- +
- + /* end of MUI functionality in this function */
- +
- if (!(ptr = LoadResource(hInst, hrsrc))) return -1;
- if (!(hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, &owner ))) return -1;
- return DIALOG_DoDialogBox( hwnd, owner );
- diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
- index 3b1e3f25f4..28a2b20503 100644
- --- a/dlls/user32/menu.c
- +++ b/dlls/user32/menu.c
- @@ -4652,8 +4652,55 @@ HMENU WINAPI LoadMenuA( HINSTANCE instance, LPCSTR name )
- */
- HMENU WINAPI LoadMenuW( HINSTANCE instance, LPCWSTR name )
- {
- - HRSRC hrsrc = FindResourceW( instance, name, (LPWSTR)RT_MENU );
- - if (!hrsrc) return 0;
- +
- +
- + /* begin of hack for rudimentary MUI functionality */
- +
- + HRSRC hrsrc = NULL;
- + HINSTANCE mui = NULL;
- + HINSTANCE muix = NULL;
- + char szFilePathName[MAX_PATH];
- + char *szModuleName;
- + char szProgramName[20];
- + char muiName[20];
- + char muiLanguage[6];
- + char smallLanguage[3];
- + char bigLanguage[3];
- +
- + memset(szProgramName, '\0', sizeof(szProgramName));
- + GetModuleFileNameA(NULL, szFilePathName, MAX_PATH);
- + szModuleName = strrchr(szFilePathName, 92);
- + strcpy(szProgramName, szModuleName+1);
- + strcpy(muiLanguage, getenv("LANGUAGE"));
- + lstrcpynA(smallLanguage, muiLanguage, 3);
- + lstrcpynA(bigLanguage, muiLanguage+3, 3);
- + strcpy(muiName, smallLanguage);
- + strcat(muiName, "-");
- + strcat(muiName, bigLanguage);
- + strcat(muiName, "/");
- + strcat(muiName, szProgramName);
- + strcat(muiName, ".mui");
- +
- + muix = instance;
- + mui = LoadLibraryA(muiName);
- + //HRSRC hrsrc = FindResourceW( instance, name, (LPWSTR)RT_MENU );
- + //if (!hrsrc) return 0;
- + if (mui) {
- + instance = mui;
- + hrsrc = FindResourceW( instance, name, (LPWSTR)RT_MENU );
- +
- + if (!hrsrc) {
- + instance = muix;
- + hrsrc = FindResourceW( instance, name, (LPWSTR)RT_MENU );
- + if (!hrsrc) return 0;
- + }
- + }
- + if (!mui) {
- + hrsrc = FindResourceW( instance, name, (LPWSTR)RT_MENU );
- + if (!hrsrc) return 0;
- + }
- + /* end of hack for MUI functionality */
- +
- return LoadMenuIndirectW( LoadResource( instance, hrsrc ));
- }
- diff --git a/dlls/user32/resource.c b/dlls/user32/resource.c
- index b487f1e424..60e2cf3dd1 100644
- --- a/dlls/user32/resource.c
- +++ b/dlls/user32/resource.c
- @@ -22,6 +22,7 @@
- #include "config.h"
- #include <stdarg.h>
- +#include <stdlib.h> // for MUI hack
- #include "windef.h"
- #include "winbase.h"
- @@ -62,7 +63,54 @@ HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance, LPCWSTR name)
- HACCEL handle;
- DWORD count;
- - if (!(rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR ))) return 0;
- + /* begin of hack for rudimentary MUI functionality */
- +
- + HINSTANCE mui = NULL;
- + HINSTANCE muix = NULL;
- + char szFilePathName[MAX_PATH];
- + char *szModuleName;
- + char szProgramName[20];
- + char muiName[20];
- + char muiLanguage[6];
- + char smallLanguage[3];
- + char bigLanguage[3];
- +
- + memset(szProgramName, '\0', sizeof(szProgramName));
- + GetModuleFileNameA(NULL, szFilePathName, MAX_PATH);
- + szModuleName = strrchr(szFilePathName, 92);
- + strcpy(szProgramName, szModuleName+1);
- + strcpy(muiLanguage, getenv("LANGUAGE"));
- + lstrcpynA(smallLanguage, muiLanguage, 3);
- + lstrcpynA(bigLanguage, muiLanguage+3, 3);
- + strcpy(muiName, smallLanguage);
- + strcat(muiName, "-");
- + strcat(muiName, bigLanguage);
- + strcat(muiName, "/");
- + strcat(muiName, szProgramName);
- + strcat(muiName, ".mui");
- +
- + muix = instance;
- + mui = LoadLibraryA(muiName);
- +
- + /*if (!(rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR ))) return 0;*/
- + if (mui) {
- + muix = instance;
- + instance = mui;
- + rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR );
- +
- + if (!rsrc) {
- + instance = muix;
- + rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR );
- + if (!rsrc) return 0;
- + }
- + }
- + if (!mui) {
- + rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR );
- + if (!rsrc) return 0;
- + }
- +
- + /* end of MUI functionality */
- +
- table = LoadResource( instance, rsrc );
- count = SizeofResource( instance, rsrc ) / sizeof(*table);
- if (!count) return 0;
- @@ -251,10 +299,58 @@ INT WINAPI DECLSPEC_HOTPATCH LoadStringW( HINSTANCE instance, UINT resource_id,
- if(buffer == NULL)
- return 0;
- + /* begin of hack for rudimentary MUI functionality */
- +
- + HINSTANCE mui = NULL;
- + HINSTANCE muix = NULL;
- + char szFilePathName[MAX_PATH];
- + char *szModuleName;
- + char szProgramName[20];
- + char muiName[20];
- + char muiLanguage[6];
- + char smallLanguage[3];
- + char bigLanguage[3];
- +
- + memset(szProgramName, '\0', sizeof(szProgramName));
- + GetModuleFileNameA(NULL, szFilePathName, MAX_PATH);
- + szModuleName = strrchr(szFilePathName, 92);
- + strcpy(szProgramName, szModuleName+1);
- + strcpy(muiLanguage, getenv("LANGUAGE"));
- + lstrcpynA(smallLanguage, muiLanguage, 3);
- + lstrcpynA(bigLanguage, muiLanguage+3, 3);
- + strcpy(muiName, smallLanguage);
- + strcat(muiName, "-");
- + strcat(muiName, bigLanguage);
- + strcat(muiName, "/");
- + strcat(muiName, szProgramName);
- + strcat(muiName, ".mui");
- +
- + muix = instance;
- + mui = LoadLibraryA(muiName);
- +
- + TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n",instance, resource_id, buffer, buflen);
- +
- + if (buffer == NULL) return 0;
- +
- /* Use loword (incremented by 1) as resourceid */
- - hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1),
- - (LPWSTR)RT_STRING );
- - if (!hrsrc) return 0;
- + /*hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1),
- + (LPWSTR)RT_STRING );*/
- + if (mui) {
- + instance = mui;
- + hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING );
- + if (!hrsrc) {
- + instance = muix;
- + hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING );
- + if (!hrsrc) return 0;
- + }
- + }
- + if (!mui) {
- + hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING );
- + if (!hrsrc) return 0;
- + }
- +
- + /* end of MUI functionality */
- +
- hmem = LoadResource( instance, hrsrc );
- if (!hmem) return 0;
- --
- 2.17.1
Add Comment
Please, Sign In to add comment