Commit 031c0272 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ntdll: Open source file only when needed during context creation.

parent 0c4b3514
......@@ -2113,14 +2113,41 @@ static void test_CreateActCtx(void)
actctx.lpAssemblyDirectory = dir;
actctx.lpSource = path;
SetLastError(0xdeadbeef);
handle = pCreateActCtxA(&actctx);
todo_wine
ok(handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX,
"got handle %p, supposed to fail\n", handle);
todo_wine {
ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %d\n", GetLastError());
}
if (handle != INVALID_HANDLE_VALUE) pReleaseActCtx(handle);
delete_manifest_file("main.manifest");
delete_manifest_file("testdep1.manifest");
/* ACTCTX_FLAG_HMODULE_VALID but hModule is not set */
memset(&actctx, 0, sizeof(ACTCTXA));
actctx.cbSize = sizeof(ACTCTXA);
actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID;
SetLastError(0xdeadbeef);
handle = pCreateActCtxA(&actctx);
ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
todo_wine
ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY) /* XP, win2k3 */,
"got error %d\n", GetLastError());
/* create from HMODULE - resource doesn't exist, lpSource is set */
memset(&actctx, 0, sizeof(ACTCTXA));
actctx.cbSize = sizeof(ACTCTXA);
actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
actctx.lpSource = "dummyfile.dll";
actctx.lpResourceName = MAKEINTRESOURCEA(20);
actctx.hModule = GetModuleHandleA(NULL);
SetLastError(0xdeadbeef);
handle = pCreateActCtxA(&actctx);
ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
todo_wine
ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "got error %d\n", GetLastError());
}
static BOOL init_funcs(void)
......
......@@ -4519,7 +4519,10 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, const void *ptr )
}
nameW.Buffer = NULL;
if (pActCtx->lpSource)
/* open file only if it's going to be used */
if (pActCtx->lpSource && !((pActCtx->dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID) &&
(pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID)))
{
if (!RtlDosPathNameToNtPathName_U(pActCtx->lpSource, &nameW, NULL, NULL))
{
......@@ -4550,7 +4553,6 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, const void *ptr )
status = get_manifest_in_module( &acl, NULL, NULL, directory, FALSE, pActCtx->hModule,
pActCtx->lpResourceName, lang );
if (status && status != STATUS_SXS_CANT_GEN_ACTCTX)
/* FIXME: what to do if pActCtx->lpSource is set */
status = get_manifest_in_associated_manifest( &acl, NULL, NULL, directory,
pActCtx->hModule, pActCtx->lpResourceName );
}
......
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