ReactOS 0.4.17-dev-966-gf06eace
sxs.c
Go to the documentation of this file.
1/*
2 * sxs main
3 *
4 * Copyright 2007 EA Durbin
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22#include <stdlib.h>
23
24#include "windef.h"
25#include "winbase.h"
26
27#include "wine/debug.h"
28
30
32{
39
40#define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE 0x1
41#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS 0x2
42
43#define SXS_LOOKUP_CLR_GUID_USE_ACTCTX 0x00000001
44#define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE 0x00010000
45#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS 0x00020000
46#define SXS_LOOKUP_CLR_GUID_FIND_ANY (SXS_LOOKUP_CLR_GUID_FIND_SURROGATE | SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS)
47
49{
50 ULONG size;
53 GUID clsid;
54 GUID alias;
56 GUID tlbid;
68};
69
70struct clrclass_data
71{
72 ULONG size;
73 DWORD res[2];
80 DWORD res2[2];
81};
82
84{
92};
93
95 SIZE_T *buffer_len_required)
96{
97 ACTCTX_SECTION_KEYED_DATA guid_info = { sizeof(ACTCTX_SECTION_KEYED_DATA) };
98 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *assembly_info = NULL;
99 SIZE_T bytes_assembly_info;
100 unsigned int len_version = 0, len_name, len_identity;
101 const void *ptr_name, *ptr_version, *ptr_identity;
103 BOOL retval = FALSE;
104 char *ret_strings;
106
107 TRACE("%#lx, %s, %p, %p, %Ix, %p.\n", flags, wine_dbgstr_guid(clsid), actctx,
108 buffer, buffer_len, buffer_len_required);
109
111 {
113 {
114 WARN("Failed to activate context.\n");
115 return FALSE;
116 }
117 }
118
120 {
121 if ((retval = FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
122 ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES, clsid, &guid_info)))
123 {
124 flags &= ~SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS;
125 }
126 }
127
129 {
130 if ((retval = FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
131 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, clsid, &guid_info)))
132 {
133 flags &= ~SXS_LOOKUP_CLR_GUID_FIND_SURROGATE;
134 }
135 }
136
137 if (!retval)
138 {
140 goto out;
141 }
142
143 retval = QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
144 AssemblyDetailedInformationInActivationContext, NULL, 0, &bytes_assembly_info);
146 {
147 goto out;
148 }
149
150 assembly_info = malloc(bytes_assembly_info);
151 if (!(retval = QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
152 AssemblyDetailedInformationInActivationContext, assembly_info,
153 bytes_assembly_info, &bytes_assembly_info)))
154 {
155 goto out;
156 }
157
159 {
160 const struct comclassredirect_data *redirect_data = guid_info.lpData;
161 const struct clrclass_data *class_data;
162
163 class_data = (void *)((char *)redirect_data + redirect_data->clrdata_offset);
164 ptr_name = (char *)class_data + class_data->name_offset;
165 ptr_version = (char *)class_data + class_data->version_offset;
166 len_name = class_data->name_len + sizeof(WCHAR);
167 if (class_data->version_len)
168 len_version = class_data->version_len + sizeof(WCHAR);
169 }
170 else
171 {
172 const struct clrsurrogate_data *surrogate = guid_info.lpData;
173 ptr_name = (char *)surrogate + surrogate->name_offset;
174 ptr_version = (char *)surrogate + surrogate->version_offset;
175 len_name = surrogate->name_len + sizeof(WCHAR);
176 if (surrogate->version_len)
177 len_version = surrogate->version_len + sizeof(WCHAR);
178 }
179
180 ptr_identity = assembly_info->lpAssemblyEncodedAssemblyIdentity;
181 len_identity = assembly_info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
182
183 *buffer_len_required = sizeof(*ret) + len_identity + len_version + len_name;
184 if (!buffer || buffer_len < *buffer_len_required)
185 {
187 retval = FALSE;
188 goto out;
189 }
190
191 ret->cbSize = sizeof(*ret);
194
195 /* Copy strings into buffer */
196 ret_strings = (char *)ret + sizeof(*ret);
197
198 memcpy(ret_strings, ptr_identity, len_identity);
199 ret->pcwszAssemblyIdentity = (WCHAR *)ret_strings;
200 ret_strings += len_identity;
201
202 memcpy(ret_strings, ptr_name, len_name);
203 ret->pcwszTypeName = (WCHAR *)ret_strings;
204 ret_strings += len_name;
205
206 if (len_version > 0)
207 {
208 memcpy(ret_strings, ptr_version, len_version);
209 ret->pcwszRuntimeVersion = (WCHAR *)ret_strings;
210 }
211 else
212 ret->pcwszRuntimeVersion = NULL;
213
214 SetLastError(0);
215
216out:
217 ReleaseActCtx(guid_info.hActCtx);
218
221
222 free(assembly_info);
223 return retval;
224}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
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 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 ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
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 * PSXS_GUID_INFORMATION_CLR
#define SXS_LOOKUP_CLR_GUID_USE_ACTCTX
Definition: sxs.c:43
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS
Definition: sxs.c:41
#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS
Definition: sxs.c:45
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE
Definition: sxs.c:40
BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buffer, SIZE_T buffer_len, SIZE_T *buffer_len_required)
Definition: sxs.c:94
struct _SXS_GUID_INFORMATION_CLR SXS_GUID_INFORMATION_CLR
#define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE
Definition: sxs.c:44
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
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
const CLSID * clsid
Definition: msctf.cpp:50
short WCHAR
Definition: pedump.c:58
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
#define TRACE(s)
Definition: solgame.cpp:4
PCWSTR pcwszRuntimeVersion
Definition: sxs.c:35
PCWSTR pcwszTypeName
Definition: sxs.c:36
PCWSTR pcwszAssemblyIdentity
Definition: sxs.c:37
DWORD res
Definition: sxs.c:86
ULONG version_len
Definition: sxs.c:89
ULONG name_offset
Definition: sxs.c:90
GUID clsid
Definition: sxs.c:87
ULONG size
Definition: sxs.c:85
ULONG version_offset
Definition: sxs.c:88
ULONG name_len
Definition: sxs.c:91
DWORD miscstatuscontent
Definition: combase.c:71
DWORD miscstatusdocprint
Definition: combase.c:74
DWORD miscstatusthumbnail
Definition: combase.c:72
Definition: cookie.c:34
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
int retval
Definition: wcstombs.cpp:91
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define ERROR_NOT_FOUND
Definition: winerror.h:1014