ReactOS  0.4.14-dev-991-g696cdc6
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 
23 #include "windef.h"
24 #include "winbase.h"
25 
26 #include "wine/heap.h"
27 #include "wine/debug.h"
28 
30 
31 /***********************************************************************
32  * DllMain (SXS.@)
33  *
34  */
36 {
37  switch(fdwReason)
38  {
39  case DLL_WINE_PREATTACH:
40  return FALSE; /* prefer native version */
41  case DLL_PROCESS_ATTACH:
42  DisableThreadLibraryCalls( hinstDLL );
43  break;
44  }
45  return TRUE;
46 }
47 
49 {
56 
57 #define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE 0x1
58 #define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS 0x2
59 
60 #define SXS_LOOKUP_CLR_GUID_USE_ACTCTX 0x00000001
61 #define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE 0x00010000
62 #define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS 0x00020000
63 
65 {
66  ULONG size;
67  BYTE res;
68  BYTE miscmask;
69  BYTE res1[2];
70  DWORD model;
71  GUID clsid;
72  GUID alias;
73  GUID clsid2;
74  GUID tlbid;
86 };
87 
89 {
91  DWORD res[2];
98  DWORD res2[2];
99 };
100 
102  SIZE_T *buffer_len_required)
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 }
const uint16_t * PCWSTR
Definition: typedefs.h:56
#define TRUE
Definition: types.h:120
DWORD res2[2]
Definition: sxs.c:98
DWORD miscstatusdocprint
Definition: compobj.c:128
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
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
const char * wine_dbgstr_guid(const GUID *guid)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
PCWSTR pcwszRuntimeVersion
Definition: sxs.c:52
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static IN DWORD IN LPVOID lpvReserved
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
PCWSTR pcwszAssemblyIdentity
Definition: sxs.c:54
#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS
Definition: sxs.c:58
#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS
Definition: sxs.c:62
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
WINE_DEFAULT_DEBUG_CHANNEL(sxs)
ULONG version_len
Definition: sxs.c:96
struct _SXS_GUID_INFORMATION_CLR * PSXS_GUID_INFORMATION_CLR
smooth NULL
Definition: ftsmooth.c:416
#define actctx
Definition: kernel32.h:8
ULONG version_offset
Definition: sxs.c:97
ULONG name_offset
Definition: sxs.c:95
ULONG name_len
Definition: sxs.c:94
#define TRACE(s)
Definition: solgame.cpp:4
ULONG size
Definition: sxs.c:90
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD miscstatusthumbnail
Definition: compobj.c:126
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: sxs.c:35
GLbitfield flags
Definition: glext.h:7161
int ret
REFCLSID clsid
Definition: msctf.c:82
struct _SXS_GUID_INFORMATION_CLR SXS_GUID_INFORMATION_CLR
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:79
ULONG module_offset
Definition: sxs.c:93
PCWSTR pcwszTypeName
Definition: sxs.c:53
#define ERROR_NOT_FOUND
Definition: winerror.h:690
ULONG module_len
Definition: sxs.c:92
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:183
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 BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10