[kernel32_winetest]
[reactos.git] / rostests / winetests / kernel32 / actctx.c
index d0e8433..792a292 100644 (file)
 #include <initguid.h>
 
 static BOOL   (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
+static HANDLE (WINAPI *pCreateActCtxA)(PCACTCTXA);
 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
 static BOOL   (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
+static BOOL   (WINAPI *pFindActCtxSectionStringA)(DWORD,const GUID *,ULONG,LPCSTR,PACTCTX_SECTION_KEYED_DATA);
 static BOOL   (WINAPI *pFindActCtxSectionStringW)(DWORD,const GUID *,ULONG,LPCWSTR,PACTCTX_SECTION_KEYED_DATA);
 static BOOL   (WINAPI *pGetCurrentActCtx)(HANDLE *);
 static BOOL   (WINAPI *pIsDebuggerPresent)(void);
@@ -47,18 +49,6 @@ static const char* strw(LPCWSTR x)
     return buffer;
 }
 
-static const char *debugstr_guid(REFIID riid)
-{
-    static char buf[50];
-
-    sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
-            riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
-            riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
-            riid->Data4[5], riid->Data4[6], riid->Data4[7]);
-
-    return buf;
-}
-
 #ifdef __i386__
 #define ARCH "x86"
 #elif defined __x86_64__
@@ -72,6 +62,11 @@ static const char manifest1[] =
 "<assemblyIdentity version=\"1.0.0.0\"  name=\"Wine.Test\" type=\"win32\"></assemblyIdentity>"
 "</assembly>";
 
+static const char manifest1_1[] =
+"<assembly xmlns = \"urn:schemas-microsoft-com:asm.v1\" manifestVersion = \"1.0\">"
+"<assemblyIdentity version = \"1.0.0.0\" name = \"Wine.Test\" type = \"win32\"></assemblyIdentity>"
+"</assembly>";
+
 static const char manifest2[] =
 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\">"
@@ -84,11 +79,19 @@ static const char manifest2[] =
 "</dependency>"
 "</assembly>";
 
-DEFINE_GUID(IID_CoTest, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
-DEFINE_GUID(IID_TlibTest, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
+DEFINE_GUID(IID_CoTest,    0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
+DEFINE_GUID(IID_CoTest2,   0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x34);
+DEFINE_GUID(CLSID_clrclass,0x22345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
+DEFINE_GUID(IID_TlibTest,  0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
 DEFINE_GUID(IID_TlibTest2, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
 DEFINE_GUID(IID_TlibTest3, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
 DEFINE_GUID(IID_TlibTest4, 0x99999999, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58);
+DEFINE_GUID(IID_Iifaceps,  0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
+DEFINE_GUID(IID_Ibifaceps, 0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x57);
+DEFINE_GUID(IID_Iifaceps2, 0x76666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
+DEFINE_GUID(IID_Iifaceps3, 0x86666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
+DEFINE_GUID(IID_Iiface,    0x96666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55);
+DEFINE_GUID(IID_PS32,      0x66666666, 0x8888, 0x7777, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56);
 
 static const char manifest3[] =
 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
@@ -106,8 +109,63 @@ static const char manifest3[] =
 "              miscStatusContent=\"insideout\""
 "              miscStatusThumbnail=\"alignable\""
 "              miscStatusDocPrint=\"simpleframe,setclientsitefirst\""
+"    >"
+"        <progid>ProgId.ProgId.1</progid>"
+"        <progid>ProgId.ProgId.2</progid>"
+"        <progid>ProgId.ProgId.3</progid>"
+"        <progid>ProgId.ProgId.4</progid>"
+"        <progid>ProgId.ProgId.5</progid>"
+"        <progid>ProgId.ProgId.6</progid>"
+"    </comClass>"
+"    <comClass clsid=\"{12345678-1234-5678-1234-111122223334}\" threadingModel=\"Neutral\" >"
+"        <progid>ProgId.ProgId.7</progid>"
+"    </comClass>"
+"    <comInterfaceProxyStub "
+"        name=\"Iifaceps\""
+"        tlbid=\"{99999999-8888-7777-6666-555555555558}\""
+"        iid=\"{66666666-8888-7777-6666-555555555555}\""
+"        proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
+"        threadingModel=\"Free\""
+"        numMethods=\"10\""
+"        baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
 "    />"
 "</file>"
+"    <comInterfaceExternalProxyStub "
+"        name=\"Iifaceps2\""
+"        tlbid=\"{99999999-8888-7777-6666-555555555558}\""
+"        iid=\"{76666666-8888-7777-6666-555555555555}\""
+"        proxyStubClsid32=\"{66666666-8888-7777-6666-555555555556}\""
+"        numMethods=\"10\""
+"        baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
+"    />"
+"    <comInterfaceExternalProxyStub "
+"        name=\"Iifaceps3\""
+"        tlbid=\"{99999999-8888-7777-6666-555555555558}\""
+"        iid=\"{86666666-8888-7777-6666-555555555555}\""
+"        numMethods=\"10\""
+"        baseInterface=\"{66666666-8888-7777-6666-555555555557}\""
+"    />"
+"    <clrSurrogate "
+"        clsid=\"{96666666-8888-7777-6666-555555555555}\""
+"        name=\"testsurrogate\""
+"        runtimeVersion=\"v2.0.50727\""
+"    />"
+"    <clrClass "
+"        clsid=\"{22345678-1234-5678-1234-111122223333}\""
+"        name=\"clrclass\""
+"        progid=\"clrprogid\""
+"        description=\"test description\""
+"        tlbid=\"{99999999-8888-7777-6666-555555555555}\""
+"        runtimeVersion=\"1.2.3.4\""
+"        threadingModel=\"Neutral\""
+"    >"
+"        <progid>clrprogid.1</progid>"
+"        <progid>clrprogid.2</progid>"
+"        <progid>clrprogid.3</progid>"
+"        <progid>clrprogid.4</progid>"
+"        <progid>clrprogid.5</progid>"
+"        <progid>clrprogid.6</progid>"
+"    </clrClass>"
 "</assembly>";
 
 static const char manifest_wndcls1[] =
@@ -128,7 +186,7 @@ static const char manifest_wndcls2[] =
 " <windowClass versioned=\"no\">wndClass3</windowClass>"
 " <windowClass>wndClass4</windowClass>"
 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555555}\" version=\"1.0\" helpdir=\"help\" resourceid=\"409\""
-"          flags=\"HIDDEN,CONTROL,RESTRICTED\" />"
+"          flags=\"HiddeN,CoNTROL,rESTRICTED\" />"
 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555556}\" version=\"1.0\" helpdir=\"help1\" resourceid=\"409\" />"
 " <typelib tlbid=\"{99999999-8888-7777-6666-555555555557}\" version=\"1.0\" helpdir=\"\" />"
 "</file>"
@@ -665,7 +723,8 @@ static HANDLE test_create(const char *file)
     actctx.lpSource = path;
 
     handle = pCreateActCtxW(&actctx);
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    /* to be tested outside of this helper, including last error */
+    if (handle == INVALID_HANDLE_VALUE) return handle;
 
     ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
     ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
@@ -777,7 +836,9 @@ struct strsection_header
     DWORD unk1[3];
     ULONG count;
     ULONG index_offset;
-    DWORD unk2[4];
+    DWORD unk2[2];
+    ULONG global_offset;
+    ULONG global_len;
 };
 
 struct string_index
@@ -841,6 +902,13 @@ struct tlibredirect_data
     WORD   minor_version;
 };
 
+struct progidredirect_data
+{
+    ULONG size;
+    DWORD reserved;
+    ULONG clsid_offset;
+};
+
 static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid, int line)
 {
     ACTCTX_SECTION_KEYED_DATA data;
@@ -1107,7 +1175,8 @@ struct comclassredirect_data {
     ULONG name_offset;
     ULONG progid_len;
     ULONG progid_offset;
-    DWORD res2[2];
+    ULONG clrdata_len;
+    ULONG clrdata_offset;
     DWORD miscstatus;
     DWORD miscstatuscontent;
     DWORD miscstatusthumbnail;
@@ -1115,10 +1184,23 @@ struct comclassredirect_data {
     DWORD miscstatusdocprint;
 };
 
-static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, ULONG exid, int line)
+struct clrclass_data {
+    ULONG size;
+    DWORD res[2];
+    ULONG module_len;
+    ULONG module_offset;
+    ULONG name_len;
+    ULONG name_offset;
+    ULONG version_len;
+    ULONG version_offset;
+    DWORD res2[2];
+};
+
+static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, const WCHAR *progid, ULONG exid, int line)
 {
     struct comclassredirect_data *comclass, *comclass2;
     ACTCTX_SECTION_KEYED_DATA data, data2;
+    struct guidsection_header *header;
     BOOL ret;
 
     memset(&data, 0xfe, sizeof(data));
@@ -1127,6 +1209,11 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
     ret = pFindActCtxSectionGuid(0, NULL,
                                     ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
                                     clsid, &data);
+    if (!ret)
+    {
+        skip("failed for guid %s\n", wine_dbgstr_guid(clsid));
+        return;
+    }
     ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
 
     comclass = (struct comclassredirect_data*)data.lpData;
@@ -1137,7 +1224,6 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
     ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %d for header size\n", comclass->size);
     if (data.lpData && comclass->size == sizeof(*comclass))
     {
-        static const WCHAR progid[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
         WCHAR *ptr;
         ULONG len;
 
@@ -1145,19 +1231,31 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
         ok_(__FILE__, line)(comclass->res1[0] == 0, "got res1[0] as %02x\n", comclass->res1[0]);
         ok_(__FILE__, line)(comclass->res1[1] == 0, "got res1[1] as %02x\n", comclass->res1[1]);
         ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %d\n", comclass->model);
-        ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", debugstr_guid(&comclass->clsid));
-        ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", debugstr_guid(&comclass->clsid2));
-        ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", debugstr_guid(&comclass->tlid));
+        ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass->clsid));
+        ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass->clsid2));
+        if (tlid)
+            ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass->tlid));
         ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %d\n", comclass->name_len);
-        ok_(__FILE__, line)(comclass->progid_offset == comclass->size, "got progid offset %d\n", comclass->progid_offset);
 
-        ptr = (WCHAR*)((BYTE*)comclass + comclass->size);
-        ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid));
-        ok_(__FILE__, line)(lstrlenW(ptr)*sizeof(WCHAR) == comclass->progid_len,
-            "got progid name length %d, expected %d\n", comclass->progid_len, lstrlenW(ptr));
+        if (progid)
+        {
+            len = comclass->size + comclass->clrdata_len;
+            ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %d, expected %d\n", comclass->progid_offset, len);
+        }
+        else
+            ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %d, expected 0\n", comclass->progid_offset);
+
+        if (comclass->progid_offset)
+        {
+            ptr = (WCHAR*)((BYTE*)comclass + comclass->progid_offset);
+            ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid));
+            ok_(__FILE__, line)(lstrlenW(progid)*sizeof(WCHAR) == comclass->progid_len,
+                "got progid name length %d\n", comclass->progid_len);
+        }
 
         /* data length is simply header length + string data length including nulls */
-        len = comclass->size + comclass->progid_len + sizeof(WCHAR);
+        len = comclass->size + comclass->clrdata_len;
+        if (comclass->progid_len) len += comclass->progid_len + sizeof(WCHAR);
         ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
 
         /* keyed data structure doesn't include module name, it's available from section data */
@@ -1177,12 +1275,47 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
             if (comclass->miscmask & MiscStatusDocPrint)
                 ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08x\n", comclass->miscstatusdocprint);
         }
+
+        /* part used for clrClass only */
+        if (comclass->clrdata_len)
+        {
+            static const WCHAR mscoreeW[] = {'M','S','C','O','R','E','E','.','D','L','L',0};
+            static const WCHAR mscoree2W[] = {'m','s','c','o','r','e','e','.','d','l','l',0};
+            struct clrclass_data *clrclass;
+            WCHAR *ptrW;
+
+            clrclass = (struct clrclass_data*)((BYTE*)data.lpData + comclass->clrdata_offset);
+            ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %d\n", clrclass->size);
+            ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass->res[0]);
+            ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass->res[1]);
+            ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %d\n", clrclass->module_len);
+            ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %d\n", clrclass->module_offset);
+
+            ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %d\n", clrclass->name_len);
+            ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %d\n", clrclass->name_offset);
+            ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %d\n", clrclass->version_len);
+            ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %d\n", clrclass->version_offset);
+
+            ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass->res2[0]);
+            ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass->res2[1]);
+
+            /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
+               in lower case, clsclass subsection - in upper case */
+            ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %d\n", comclass->name_len);
+            ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %d\n", clrclass->name_offset);
+
+            ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + comclass->name_offset);
+            ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoreeW), "clrclass: module name %s\n", wine_dbgstr_w(ptrW));
+
+            ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + clrclass->module_offset);
+            ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoree2W), "clrclass: module name2 %s\n", wine_dbgstr_w(ptrW));
+        }
     }
-todo_wine {
-    ok_(__FILE__, line)(data.lpSectionGlobalData != NULL, "data.lpSectionGlobalData == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength > 0, "data.ulSectionGlobalDataLength=%u\n",
+
+    header = (struct guidsection_header*)data.lpSectionBase;
+    ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n");
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%u\n",
        data.ulSectionGlobalDataLength);
-}
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
     ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
        data.ulSectionTotalLength);
@@ -1203,6 +1336,210 @@ todo_wine {
     ok_(__FILE__, line)(!memcmp(comclass, comclass2, comclass->size), "got wrong data\n");
 }
 
+enum ifaceps_mask
+{
+    NumMethods = 1,
+    BaseIface  = 2
+};
+
+struct ifacepsredirect_data
+{
+    ULONG size;
+    DWORD mask;
+    GUID  iid;
+    ULONG nummethods;
+    GUID  tlbid;
+    GUID  base;
+    ULONG name_len;
+    ULONG name_offset;
+};
+
+static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const GUID *tlbid, const GUID *base,
+    const GUID *ps32, ULONG exid, int line)
+{
+    struct ifacepsredirect_data *ifaceps;
+    ACTCTX_SECTION_KEYED_DATA data;
+    BOOL ret;
+
+    memset(&data, 0xfe, sizeof(data));
+    data.cbSize = sizeof(data);
+
+    ret = pFindActCtxSectionGuid(0, NULL,
+                                    ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
+                                    iid, &data);
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+
+    ifaceps = (struct ifacepsredirect_data*)data.lpData;
+
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
+    ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %d for header size\n", ifaceps->size);
+    if (data.lpData && ifaceps->size == sizeof(*ifaceps))
+    {
+        ULONG len;
+
+        /* for external proxy stubs it contains a value from 'proxyStubClsid32' */
+        if (ps32)
+        {
+            ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, ps32), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
+        }
+        else
+            ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, iid), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
+
+        ok_(__FILE__, line)(IsEqualGUID(&ifaceps->tlbid, tlbid), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps->tlbid));
+        ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %d\n", ifaceps->name_len);
+        ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %d\n", ifaceps->name_offset);
+
+        /* data length is simply header length + string data length including nulls */
+        len = ifaceps->size + ifaceps->name_len + sizeof(WCHAR);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+
+        /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
+           always has non-zero value for it */
+        if (ifaceps->mask & NumMethods)
+            ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %d\n", ifaceps->nummethods);
+        if (ifaceps->mask & BaseIface)
+            ok_(__FILE__, line)(IsEqualGUID(&ifaceps->base, base), "got base %s\n", wine_dbgstr_guid(&ifaceps->base));
+    }
+
+    ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+       data.ulSectionGlobalDataLength);
+    ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+       data.ulSectionTotalLength);
+    ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+       data.ulAssemblyRosterIndex, exid);
+}
+
+struct clrsurrogate_data
+{
+    ULONG size;
+    DWORD res;
+    GUID  clsid;
+    ULONG version_offset;
+    ULONG version_len;
+    ULONG name_offset;
+    ULONG name_len;
+};
+
+static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *name, const WCHAR *version,
+    ULONG exid, int line)
+{
+    struct clrsurrogate_data *surrogate;
+    ACTCTX_SECTION_KEYED_DATA data;
+    BOOL ret;
+
+    memset(&data, 0xfe, sizeof(data));
+    data.cbSize = sizeof(data);
+
+    ret = pFindActCtxSectionGuid(0, NULL,
+                                    ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES,
+                                    clsid, &data);
+    if (!ret)
+    {
+        skip("surrogate sections are not supported\n");
+        return;
+    }
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+
+    surrogate = (struct clrsurrogate_data*)data.lpData;
+
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
+    ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %d for header size\n", surrogate->size);
+    if (data.lpData && surrogate->size == sizeof(*surrogate))
+    {
+        WCHAR *ptrW;
+        ULONG len;
+
+        ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %d\n", surrogate->res);
+        ok_(__FILE__, line)(IsEqualGUID(&surrogate->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate->clsid));
+
+        ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %d\n", surrogate->version_len);
+        ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %d\n", surrogate->version_offset);
+
+        ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %d\n", surrogate->name_len);
+        ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %d\n", surrogate->name_offset);
+
+        len = surrogate->size + surrogate->name_len + surrogate->version_len + 2*sizeof(WCHAR);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+
+        ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->name_offset);
+        ok(!lstrcmpW(ptrW, name), "got wrong name %s\n", wine_dbgstr_w(ptrW));
+
+        ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->version_offset);
+        ok(!lstrcmpW(ptrW, version), "got wrong name %s\n", wine_dbgstr_w(ptrW));
+    }
+
+    ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+       data.ulSectionGlobalDataLength);
+    ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+       data.ulSectionTotalLength);
+    ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+       data.ulAssemblyRosterIndex, exid);
+}
+
+static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line)
+{
+    struct progidredirect_data *progiddata;
+    struct comclassredirect_data *comclass;
+    ACTCTX_SECTION_KEYED_DATA data, data2;
+    struct strsection_header *header;
+    BOOL ret;
+
+    memset(&data, 0xfe, sizeof(data));
+    data.cbSize = sizeof(data);
+
+    ret = pFindActCtxSectionStringA(0, NULL,
+                                       ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION,
+                                       progid, &data);
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %u\n", GetLastError());
+
+    progiddata = (struct progidredirect_data*)data.lpData;
+
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
+    ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %d for header size\n", progiddata->size);
+    if (data.lpData && progiddata->size == sizeof(*progiddata))
+    {
+        GUID *guid;
+
+        ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %d\n", progiddata->reserved);
+        ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %d\n", progiddata->clsid_offset);
+
+        /* progid data points to generated alias guid */
+        guid = (GUID*)((BYTE*)data.lpSectionBase + progiddata->clsid_offset);
+
+        memset(&data2, 0, sizeof(data2));
+        data2.cbSize = sizeof(data2);
+        ret = pFindActCtxSectionGuid(0, NULL,
+                                        ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
+                                        guid, &data2);
+        ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+
+        comclass = (struct comclassredirect_data*)data2.lpData;
+        ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid));
+        ok_(__FILE__, line)(IsEqualGUID(clsid, &comclass->clsid), "got wrong class referenced from progid %s, %s\n", progid, wine_dbgstr_guid(clsid));
+    }
+
+    header = (struct strsection_header*)data.lpSectionBase;
+    ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n");
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength);
+    ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
+    ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+        data.ulAssemblyRosterIndex, exid);
+}
+
 static void test_wndclass_section(void)
 {
     static const WCHAR cls1W[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
@@ -1220,6 +1557,8 @@ static void test_wndclass_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
@@ -1282,6 +1621,8 @@ static void test_dllredirect_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
@@ -1335,6 +1676,8 @@ static void test_typelib_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
@@ -1367,6 +1710,10 @@ static void test_typelib_section(void)
     ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
         data2.ulSectionTotalLength);
 
+    ok(data.lpSectionGlobalData == ((BYTE*)section + section->names_offset), "data.lpSectionGlobalData == NULL\n");
+    ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%u\n",
+       data.ulSectionGlobalDataLength);
+
     /* test some actual data */
     tlib = (struct tlibredirect_data*)data.lpData;
     ok(tlib->size == sizeof(*tlib), "got %d\n", tlib->size);
@@ -1401,6 +1748,13 @@ static void test_actctx(void)
         pReleaseActCtx(handle);
     }
 
+    /* test for whitespace handling in Eq ::= S? '=' S? */
+    create_manifest_file("test1_1.manifest", manifest1_1, -1, NULL, NULL);
+    handle = test_create("test1_1.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    DeleteFileA("test1_1.manifest");
+    pReleaseActCtx(handle);
+
     if(!create_manifest_file("test1.manifest", manifest1, -1, NULL, NULL)) {
         skip("Could not create manifest file\n");
         return;
@@ -1409,6 +1763,7 @@ static void test_actctx(void)
     trace("manifest1\n");
 
     handle = test_create("test1.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test1.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -1434,6 +1789,7 @@ static void test_actctx(void)
     trace("manifest2 depmanifest1\n");
 
     handle = test_create("test2.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test2.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -1452,6 +1808,7 @@ static void test_actctx(void)
     trace("manifest2 depmanifest2\n");
 
     handle = test_create("test2-2.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test2-2.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -1480,6 +1837,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test2-3.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test2-3.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -1510,8 +1868,17 @@ static void test_actctx(void)
     }
 
     handle = test_create("test3.manifest");
+    ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* XP pre-SP2, win2k3 w/o SP */,
+        "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    if (handle == INVALID_HANDLE_VALUE)
+        win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
     DeleteFileA("test3.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
+        static const WCHAR nameW[] = {'t','e','s','t','s','u','r','r','o','g','a','t','e',0};
+        static const WCHAR versionW[] = {'v','2','.','0','.','5','0','7','2','7',0};
+        static const WCHAR progidW[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
+        static const WCHAR clrprogidW[] = {'c','l','r','p','r','o','g','i','d',0};
+
         test_basic_info(handle, __LINE__);
         test_detailed_info(handle, &detailed_info1, __LINE__);
         test_info_in_assembly(handle, 1, &manifest3_info, __LINE__);
@@ -1521,11 +1888,31 @@ static void test_actctx(void)
         ok(b, "ActivateActCtx failed: %u\n", GetLastError());
         test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
         test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
-        test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, 1, __LINE__);
+        test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, progidW, 1, __LINE__);
+        test_find_com_redirection(handle, &IID_CoTest2, NULL, NULL, 1, __LINE__);
+        test_find_com_redirection(handle, &CLSID_clrclass, &IID_TlibTest, clrprogidW, 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.1", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.2", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.3", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.4", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.5", 1, __LINE__);
+        test_find_progid_redirection(handle, &IID_CoTest, "ProgId.ProgId.6", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.1", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.2", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.3", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.4", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.5", 1, __LINE__);
+        test_find_progid_redirection(handle, &CLSID_clrclass, "clrprogid.6", 1, __LINE__);
+        test_find_surrogate(handle, &IID_Iiface, nameW, versionW, 1, __LINE__);
+        test_find_ifaceps_redirection(handle, &IID_Iifaceps, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
+        test_find_ifaceps_redirection(handle, &IID_Iifaceps2, &IID_TlibTest4, &IID_Ibifaceps, &IID_PS32, 1, __LINE__);
+        test_find_ifaceps_redirection(handle, &IID_Iifaceps3, &IID_TlibTest4, &IID_Ibifaceps, NULL, 1, __LINE__);
         test_find_string_fail();
+
         b = pDeactivateActCtx(0, cookie);
         ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
-
         pReleaseActCtx(handle);
     }
 
@@ -1537,6 +1924,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test4.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test4.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -1557,6 +1945,7 @@ static void test_actctx(void)
             return;
         }
         handle = test_create("..\\test1.manifest");
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
         DeleteFileA("..\\test1.manifest");
         if(handle != INVALID_HANDLE_VALUE) {
             test_basic_info(handle, __LINE__);
@@ -1577,6 +1966,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test1.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test1.manifest");
     if (handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -1592,6 +1982,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test1.manifest");
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     DeleteFileA("test1.manifest");
     if (handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -1629,7 +2020,7 @@ static void run_child_process(void)
     char path[MAX_PATH];
     char **argv;
     PROCESS_INFORMATION pi;
-    STARTUPINFO si = { 0 };
+    STARTUPINFOA si = { 0 };
     HANDLE file;
     FILETIME now;
     BOOL ret;
@@ -1653,7 +2044,7 @@ static void run_child_process(void)
         CloseHandle(file);
     }
     sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]);
-    ret = CreateProcess(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+    ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
     ok(ret, "Could not create process: %u\n", GetLastError());
     winetest_wait_child_process( pi.hProcess );
     CloseHandle(pi.hThread);
@@ -1686,14 +2077,108 @@ static void init_paths(void)
     lstrcpyW(app_manifest_path+lstrlenW(app_manifest_path), dot_manifest);
 }
 
+static void write_manifest(const char *filename, const char *manifest)
+{
+    HANDLE file;
+    DWORD size;
+    CHAR path[MAX_PATH];
+
+    GetTempPathA(sizeof(path)/sizeof(CHAR), path);
+    strcat(path, filename);
+
+    file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    WriteFile(file, manifest, strlen(manifest), &size, NULL);
+    CloseHandle(file);
+}
+
+static void delete_manifest_file(const char *filename)
+{
+    CHAR path[MAX_PATH];
+
+    GetTempPathA(sizeof(path)/sizeof(CHAR), path);
+    strcat(path, filename);
+    DeleteFileA(path);
+}
+
+static void test_CreateActCtx(void)
+{
+    CHAR path[MAX_PATH], dir[MAX_PATH];
+    ACTCTXA actctx;
+    HANDLE handle;
+
+    GetTempPathA(sizeof(path)/sizeof(CHAR), path);
+    strcat(path, "main_wndcls.manifest");
+
+    write_manifest("testdep1.manifest", manifest_wndcls1);
+    write_manifest("testdep2.manifest", manifest_wndcls2);
+    write_manifest("main_wndcls.manifest", manifest_wndcls_main);
+
+    memset(&actctx, 0, sizeof(ACTCTXA));
+    actctx.cbSize = sizeof(ACTCTXA);
+    actctx.lpSource = path;
+
+    /* create using lpSource without specified directory */
+    handle = pCreateActCtxA(&actctx);
+    ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %u\n", GetLastError());
+    pReleaseActCtx(handle);
+
+    /* with specified directory, that doesn't contain dependent assembly */
+    GetWindowsDirectoryA(dir, sizeof(dir)/sizeof(CHAR));
+
+    memset(&actctx, 0, sizeof(ACTCTXA));
+    actctx.cbSize = sizeof(ACTCTXA);
+    actctx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
+    actctx.lpAssemblyDirectory = dir;
+    actctx.lpSource = path;
+
+    SetLastError(0xdeadbeef);
+    handle = pCreateActCtxA(&actctx);
+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_wndcls.manifest");
+    delete_manifest_file("testdep1.manifest");
+    delete_manifest_file("testdep2.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);
+    ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "got error %d\n", GetLastError());
+}
+
 static BOOL init_funcs(void)
 {
-    HMODULE hKernel32 = GetModuleHandle("kernel32");
+    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
 
 #define X(f) if (!(p##f = (void*)GetProcAddress(hKernel32, #f))) return FALSE;
     X(ActivateActCtx);
+    X(CreateActCtxA);
     X(CreateActCtxW);
     X(DeactivateActCtx);
+    X(FindActCtxSectionStringA);
     X(FindActCtxSectionStringW);
     X(GetCurrentActCtx);
     X(IsDebuggerPresent);
@@ -1725,5 +2210,6 @@ START_TEST(actctx)
     }
 
     test_actctx();
+    test_CreateActCtx();
     run_child_process();
 }