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

Alexandre Julliard julliard at winehq.org
Mon Dec 30 13:05:59 CST 2013


Module: wine
Branch: master
Commit: 031c02726236efaa6470026a2f2687d618b82ff5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=031c02726236efaa6470026a2f2687d618b82ff5

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Dec 30 00:25:18 2013 +0400

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

---

 dlls/kernel32/tests/actctx.c |   33 ++++++++++++++++++++++++++++++---
 dlls/ntdll/actctx.c          |    6 ++++--
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c
index 19bab72..9894568 100644
--- a/dlls/kernel32/tests/actctx.c
+++ b/dlls/kernel32/tests/actctx.c
@@ -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)
diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index bf6e47b..68dd7ec 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -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 );
         }




More information about the wine-cvs mailing list