Commit 765d4c1e authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

shell32: Activate context at ID 123 before loading control panel applets.

This is required to enable common control v6 when running control panel applets using "rundll32.exe shell32.dll,Control_RunDLL". Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 596b6473
......@@ -53,6 +53,9 @@ void Control_UnloadApplet(CPlApplet* applet)
if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
FreeLibrary(applet->hModule);
if (applet->context_activated)
DeactivateActCtx(0, applet->cookie);
ReleaseActCtx(applet->context);
list_remove( &applet->entry );
heap_free(applet->cmd);
heap_free(applet);
......@@ -60,15 +63,19 @@ void Control_UnloadApplet(CPlApplet* applet)
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
{
WCHAR path[MAX_PATH];
CPlApplet* applet;
DWORD len;
unsigned i;
CPLINFO info;
NEWCPLINFOW newinfo;
ACTCTXW ctx;
if (!(applet = heap_alloc_zero(sizeof(*applet))))
return applet;
applet->context = INVALID_HANDLE_VALUE;
len = ExpandEnvironmentStringsW(cmd, NULL, 0);
if (len > 0)
{
......@@ -87,6 +94,21 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
applet->hWnd = hWnd;
/* Activate context before DllMain() is called */
if (SearchPathW(NULL, applet->cmd, NULL, ARRAY_SIZE(path), path, NULL))
{
memset(&ctx, 0, sizeof(ctx));
ctx.cbSize = sizeof(ctx);
ctx.lpSource = path;
ctx.lpResourceName = MAKEINTRESOURCEW(123);
ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
applet->context = CreateActCtxW(&ctx);
if (applet->context != INVALID_HANDLE_VALUE)
applet->context_activated = ActivateActCtx(applet->context, &applet->cookie);
else
TRACE("No manifest at ID 123 in %s\n", wine_dbgstr_w(path));
}
if (!(applet->hModule = LoadLibraryW(applet->cmd))) {
WARN("Cannot load control panel applet %s\n", debugstr_w(applet->cmd));
goto theError;
......@@ -177,6 +199,9 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
theError:
FreeLibrary(applet->hModule);
if (applet->context_activated)
DeactivateActCtx(0, applet->cookie);
ReleaseActCtx(applet->context);
heap_free(applet->cmd);
heap_free(applet);
return NULL;
......
......@@ -40,6 +40,9 @@ typedef struct CPlApplet {
unsigned count; /* number of subprograms */
HMODULE hModule; /* module of loaded applet */
APPLET_PROC proc; /* entry point address */
BOOL context_activated; /* whether context is activated */
HANDLE context; /* activation context handle */
ULONG_PTR cookie; /* activation context cookie */
struct applet_info info[1]; /* array of count information */
} CPlApplet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment