ReactOS 0.4.15-dev-8109-gd7be748
sxs.c File Reference
#include <stdio.h>
#include <windows.h>
#include <winsxs.h>
#include <corerror.h>
#include "shlwapi.h"
#include "wine/test.h"
#include "wine/heap.h"
#include "initguid.h"
#include "interfaces.h"
Include dependency graph for sxs.c:

Go to the source code of this file.

Classes

struct  _SXS_GUID_INFORMATION_CLR
 

Macros

#define COBJMACROS
 
#define SXS_LOOKUP_CLR_GUID_USE_ACTCTX   0x00000001
 
#define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE   0x00010000
 
#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS   0x00020000
 
#define SXS_LOOKUP_CLR_GUID_FIND_ANY   (SXS_LOOKUP_CLR_GUID_FIND_SURROGATE | SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS)
 
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE   0x00000001
 
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS   0x00000002
 

Typedefs

typedef struct _SXS_GUID_INFORMATION_CLR SXS_GUID_INFORMATION_CLR
 

Functions

BOOL WINAPI SxsLookupClrGuid (DWORD flags, GUID *clsid, HANDLE actctx, void *buffer, SIZE_T buffer_len, SIZE_T *buffer_len_required)
 
static BOOL write_resource_file (const char *path_tmp, const char *name_res, const char *name_file, char *path_file)
 
static void run_test (void)
 
static void prepare_and_run_test (void)
 
static void run_child_process (void)
 
static void test_SxsLookupClrGuid (void)
 
 START_TEST (sxs)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file sxs.c.

◆ SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS

#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS   0x00000002

Definition at line 40 of file sxs.c.

◆ SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE

#define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE   0x00000001

Definition at line 39 of file sxs.c.

◆ SXS_LOOKUP_CLR_GUID_FIND_ANY

Definition at line 37 of file sxs.c.

◆ SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS

#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS   0x00020000

Definition at line 36 of file sxs.c.

◆ SXS_LOOKUP_CLR_GUID_FIND_SURROGATE

#define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE   0x00010000

Definition at line 35 of file sxs.c.

◆ SXS_LOOKUP_CLR_GUID_USE_ACTCTX

#define SXS_LOOKUP_CLR_GUID_USE_ACTCTX   0x00000001

Definition at line 34 of file sxs.c.

Typedef Documentation

◆ SXS_GUID_INFORMATION_CLR

Function Documentation

◆ prepare_and_run_test()

static void prepare_and_run_test ( void  )
static

Definition at line 112 of file sxs.c.

113{
114 char path_tmp[MAX_PATH];
115 char path_manifest_dll[MAX_PATH];
116 char path_manifest_exe[MAX_PATH];
118 ACTCTXA context = {0};
120 HANDLE handle_context = INVALID_HANDLE_VALUE;
121
122 GetTempPathA(MAX_PATH, path_tmp);
123
124 if (!write_resource_file(path_tmp, "comtest_exe.manifest", "exe.manifest", path_manifest_exe))
125 {
126 ok(0, "Failed to create file for testing\n");
127 goto cleanup;
128 }
129
130 if (!write_resource_file(path_tmp, "comtest_dll.manifest", "comtest.manifest", path_manifest_dll))
131 {
132 ok(0, "Failed to create file for testing\n");
133 goto cleanup;
134 }
135
136 context.cbSize = sizeof(ACTCTXA);
137 context.lpSource = path_manifest_exe;
138 context.lpAssemblyDirectory = path_tmp;
139 context.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
140
141 handle_context = CreateActCtxA(&context);
142 ok(handle_context != INVALID_HANDLE_VALUE, "CreateActCtxA failed: %d\n", GetLastError());
143
144 if (handle_context == INVALID_HANDLE_VALUE)
145 {
146 ok(0, "Failed to create activation context\n");
147 goto cleanup;
148 }
149
150 success = ActivateActCtx(handle_context, &cookie);
151 ok(success, "ActivateActCtx failed: %d\n", GetLastError());
152
153 run_test();
154
155cleanup:
156 if (handle_context != INVALID_HANDLE_VALUE)
157 {
159 ok(success, "DeactivateActCtx failed: %d\n", GetLastError());
160 ReleaseActCtx(handle_context);
161 }
162 if (*path_manifest_exe)
163 {
164 success = DeleteFileA(path_manifest_exe);
165 ok(success, "DeleteFileA failed: %d\n", GetLastError());
166 }
167 if(*path_manifest_dll)
168 {
169 success = DeleteFileA(path_manifest_dll);
170 ok(success, "DeleteFileA failed: %d\n", GetLastError());
171 }
172}
#define ok(value,...)
Definition: atltest.h:57
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
static void cleanup(void)
Definition: main.c:1335
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
Definition: actctx.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
static void run_test(void)
Definition: sxs.c:83
static BOOL write_resource_file(const char *path_tmp, const char *name_res, const char *name_file, char *path_file)
Definition: sxs.c:54
Definition: http.c:7252
Definition: cookie.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define success(from, fromstr, to, tostr)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ run_child_process()

static void run_child_process ( void  )
static

Definition at line 174 of file sxs.c.

175{
176 char cmdline[MAX_PATH];
177 char exe[MAX_PATH];
178 char **argv;
180 STARTUPINFOA si = { 0 };
181 BOOL ret;
182
184
185 if (strstr(argv[0], ".exe"))
186 sprintf(exe, "%s", argv[0]);
187 else
188 sprintf(exe, "%s.exe", argv[0]);
189 sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], "subtest");
190
191 si.cb = sizeof(si);
192 ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
193 ok(ret, "Could not create process: %u\n", GetLastError());
194
196
197 CloseHandle(pi.hThread);
198 CloseHandle(pi.hProcess);
199}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4741
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static refpint_t pi[]
Definition: server.c:96
#define argv
Definition: mplay32.c:18
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
TCHAR * cmdline
Definition: stretchblt.cpp:32
DWORD cb
Definition: winbase.h:831
int ret

Referenced by test_SxsLookupClrGuid().

◆ run_test()

static void run_test ( void  )
static

Definition at line 83 of file sxs.c.

84{
86 BOOL ret;
88 WCHAR expected_type_name[] = {'D','L','L','.','T','e','s','t',0};
89 WCHAR expected_runtime_version[] = {'v','4','.','0','.','0','.','0',0};
90 WCHAR expected_assembly_identity[] = {'c','o','m','t','e','s','t',',','t','y','p','e','=','"','w','i','n','3','2','"',',','v','e','r','s','i','o','n','=','"','1','.','0','.','0','.','0','"',0};
91
93 ok(ret == FALSE, "Got %d\n", ret);
95
98 ok(ret == TRUE, "Got %d\n", ret);
99 ok(GetLastError() == 0, "Got %d\n", GetLastError());
100
101 ok(info->dwFlags == SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS, "Got %d\n", info->dwFlags);
102 ok(lstrcmpW(info->pcwszTypeName, expected_type_name) == 0, "Got %s\n",
103 wine_dbgstr_w(info->pcwszTypeName));
104 ok(lstrcmpW(info->pcwszAssemblyIdentity, expected_assembly_identity) == 0, "Got %s\n",
105 wine_dbgstr_w(info->pcwszAssemblyIdentity));
106 ok(lstrcmpW(info->pcwszRuntimeVersion, expected_runtime_version) == 0, "Got %s\n",
107 wine_dbgstr_w(info->pcwszRuntimeVersion));
108
110}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS
Definition: sxs.c:58
#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS
Definition: sxs.c:62
#define wine_dbgstr_w
Definition: kernel32.h:34
static const GUID CLSID_Test
Definition: atl.c:35
BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buffer, SIZE_T buffer_len, SIZE_T *buffer_len_required)
Definition: sxs.c:101
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by prepare_and_run_test().

◆ START_TEST()

START_TEST ( sxs  )

Definition at line 213 of file sxs.c.

214{
215 char **argv;
217 if (argc > 2)
218 {
220 return;
221 }
222
224}
static int argc
Definition: ServiceArgs.c:12
static void prepare_and_run_test(void)
Definition: sxs.c:112
static void test_SxsLookupClrGuid(void)
Definition: sxs.c:201

◆ SxsLookupClrGuid()

BOOL WINAPI SxsLookupClrGuid ( DWORD  flags,
GUID clsid,
HANDLE  actctx,
void buffer,
SIZE_T  buffer_len,
SIZE_T buffer_len_required 
)

Definition at line 101 of file sxs.c.

103{
104 ACTCTX_SECTION_KEYED_DATA guid_info = { sizeof(ACTCTX_SECTION_KEYED_DATA) };
105 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *assembly_info;
106 SIZE_T bytes_assembly_info;
107 struct comclassredirect_data *redirect_data;
108 struct clrclass_data *class_data;
109 int len_version = 0, len_name, len_identity;
110 const void *ptr_name, *ptr_version, *ptr_identity;
112 char *ret_strings;
113
114 TRACE("(%x, %s, %p, %p, %08lx, %p): stub\n", flags, wine_dbgstr_guid(clsid), actctx,
115 buffer, buffer_len, buffer_len_required);
116
118 FIXME("Ignored flags: %x\n", flags & ~SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS);
119
120 if (!FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, 0,
121 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, clsid, &guid_info))
122 {
124 return FALSE;
125 }
126
127 QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
128 AssemblyDetailedInformationInActivationContext, NULL, 0, &bytes_assembly_info);
130 {
131 ReleaseActCtx(guid_info.hActCtx);
132 return FALSE;
133 }
134 assembly_info = heap_alloc(bytes_assembly_info);
135 if(!QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
136 AssemblyDetailedInformationInActivationContext, assembly_info,
137 bytes_assembly_info, &bytes_assembly_info))
138 {
139 heap_free(assembly_info);
140 ReleaseActCtx(guid_info.hActCtx);
141 return FALSE;
142 }
143
144 redirect_data = guid_info.lpData;
145 class_data = (void *)((char*)redirect_data + redirect_data->clrdata_offset);
146
147 ptr_identity = assembly_info->lpAssemblyEncodedAssemblyIdentity;
148 ptr_name = (char *)class_data + class_data->name_offset;
149 ptr_version = (char *)class_data + class_data->version_offset;
150
151 len_identity = assembly_info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
152 len_name = class_data->name_len + sizeof(WCHAR);
153 if (class_data->version_len > 0)
154 len_version = class_data->version_len + sizeof(WCHAR);
155
156 *buffer_len_required = sizeof(SXS_GUID_INFORMATION_CLR) + len_identity + len_version + len_name;
157 if (!buffer || buffer_len < *buffer_len_required)
158 {
160 heap_free(assembly_info);
161 ReleaseActCtx(guid_info.hActCtx);
162 return FALSE;
163 }
164
165 ret->cbSize = sizeof(SXS_GUID_INFORMATION_CLR);
167
168 /* Copy strings into buffer */
169 ret_strings = (char *)ret + sizeof(SXS_GUID_INFORMATION_CLR);
170
171 memcpy(ret_strings, ptr_identity, len_identity);
172 ret->pcwszAssemblyIdentity = (WCHAR *)ret_strings;
173 ret_strings += len_identity;
174
175 memcpy(ret_strings, ptr_name, len_name);
176 ret->pcwszTypeName = (WCHAR *)ret_strings;
177 ret_strings += len_name;
178
179 if (len_version > 0)
180 {
181 memcpy(ret_strings, ptr_version, len_version);
182 ret->pcwszRuntimeVersion = (WCHAR *)ret_strings;
183 }
184 else
185 ret->pcwszRuntimeVersion = NULL;
186
187 SetLastError(0);
188
189 ReleaseActCtx(guid_info.hActCtx);
190 heap_free(assembly_info);
191 return TRUE;
192}
#define FIXME(fmt,...)
Definition: debug.h:114
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI QueryActCtxW(IN DWORD dwFlags, IN HANDLE hActCtx, IN PVOID pvSubInstance, IN ULONG ulInfoClass, IN PVOID pvBuffer, IN SIZE_T cbBuffer, IN OUT SIZE_T *pcbWrittenOrRequired OPTIONAL)
Definition: actctx.c:328
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:265
struct _SXS_GUID_INFORMATION_CLR SXS_GUID_INFORMATION_CLR
GLuint buffer
Definition: glext.h:5915
GLbitfield flags
Definition: glext.h:7161
#define actctx
Definition: kernel32.h:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
REFCLSID clsid
Definition: msctf.c:82
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define TRACE(s)
Definition: solgame.cpp:4
ULONG version_offset
Definition: sxs.c:97
ULONG name_offset
Definition: sxs.c:95
ULONG name_len
Definition: sxs.c:94
ULONG version_len
Definition: sxs.c:96
#define ERROR_NOT_FOUND
Definition: winerror.h:690

Referenced by run_test(), and test_SxsLookupClrGuid().

◆ test_SxsLookupClrGuid()

static void test_SxsLookupClrGuid ( void  )
static

Definition at line 201 of file sxs.c.

202{
204 BOOL ret;
205
207 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
208 ok(GetLastError() == ERROR_NOT_FOUND, "Expected ERROR_NOT_FOUND, got %d\n", GetLastError());
209
211}
static void run_child_process(void)
Definition: sxs.c:174

Referenced by START_TEST().

◆ write_resource_file()

static BOOL write_resource_file ( const char path_tmp,
const char name_res,
const char name_file,
char path_file 
)
static

Definition at line 54 of file sxs.c.

55{
56 HRSRC rsrc;
57 void *rsrc_data;
58 DWORD rsrc_size;
59 BOOL ret;
60 HANDLE hfile;
61
62 path_file[0] = 0;
64 if (!rsrc) return FALSE;
65
67 if (!rsrc_data) return FALSE;
68
69 rsrc_size = SizeofResource(GetModuleHandleA(NULL), rsrc);
70 if (!rsrc_size) return FALSE;
71
72 strcpy(path_file, path_tmp);
73 PathAppendA(path_file, name_file);
75 if (hfile == INVALID_HANDLE_VALUE) return FALSE;
76
77 ret = WriteFile(hfile, rsrc_data, rsrc_size, &rsrc_size, NULL);
78
79 CloseHandle(hfile);
80 return ret;
81}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
#define PathAppendA
Definition: pathcch.h:308
#define RT_RCDATA
Definition: pedump.c:372
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by prepare_and_run_test().