~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/kernel32/actctx.c

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Activation contexts
  3  *
  4  * Copyright 2004 Jon Griffiths
  5  * Copyright 2007 Eric Pouech
  6  * Copyright 2007 Jacek Caban for CodeWeavers
  7  *
  8  * This library is free software; you can redistribute it and/or
  9  * modify it under the terms of the GNU Lesser General Public
 10  * License as published by the Free Software Foundation; either
 11  * version 2.1 of the License, or (at your option) any later version.
 12  *
 13  * This library is distributed in the hope that it will be useful,
 14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16  * Lesser General Public License for more details.
 17  *
 18  * You should have received a copy of the GNU Lesser General Public
 19  * License along with this library; if not, write to the Free Software
 20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 21  */
 22 
 23 #include "config.h"
 24 #include "wine/port.h"
 25 
 26 #include <stdarg.h>
 27 #include "windef.h"
 28 #include "winbase.h"
 29 #include "winerror.h"
 30 #include "winnls.h"
 31 #include "winternl.h"
 32 #include "wine/debug.h"
 33 
 34 WINE_DEFAULT_DEBUG_CHANNEL(actctx);
 35 
 36 
 37 #define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
 38 
 39 /***********************************************************************
 40  * CreateActCtxA (KERNEL32.@)
 41  *
 42  * Create an activation context.
 43  */
 44 HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
 45 {
 46     ACTCTXW     actw;
 47     SIZE_T      len;
 48     HANDLE      ret = INVALID_HANDLE_VALUE;
 49     LPWSTR      src = NULL, assdir = NULL, resname = NULL, appname = NULL;
 50 
 51     TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
 52 
 53     if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
 54     {
 55         SetLastError(ERROR_INVALID_PARAMETER);
 56         return INVALID_HANDLE_VALUE;
 57     }
 58 
 59     actw.cbSize = sizeof(actw);
 60     actw.dwFlags = pActCtx->dwFlags;
 61     if (pActCtx->lpSource)
 62     {
 63         len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, NULL, 0);
 64         src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 65         if (!src) return INVALID_HANDLE_VALUE;
 66         MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, src, len);
 67     }
 68     actw.lpSource = src;
 69 
 70     if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
 71         actw.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
 72     if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
 73         actw.wLangId = pActCtx->wLangId;
 74     if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
 75     {
 76         len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, NULL, 0);
 77         assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 78         if (!assdir) goto done;
 79         MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, assdir, len);
 80         actw.lpAssemblyDirectory = assdir;
 81     }
 82     if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
 83     {
 84         if ((ULONG_PTR)pActCtx->lpResourceName >> 16)
 85         {
 86             len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, NULL, 0);
 87             resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 88             if (!resname) goto done;
 89             MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, resname, len);
 90             actw.lpResourceName = resname;
 91         }
 92         else actw.lpResourceName = (LPCWSTR)pActCtx->lpResourceName;
 93     }
 94     if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
 95     {
 96         len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, NULL, 0);
 97         appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 98         if (!appname) goto done;
 99         MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, appname, len);
100         actw.lpApplicationName = appname;
101     }
102     if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
103         actw.hModule = pActCtx->hModule;
104 
105     ret = CreateActCtxW(&actw);
106 
107 done:
108     HeapFree(GetProcessHeap(), 0, src);
109     HeapFree(GetProcessHeap(), 0, assdir);
110     HeapFree(GetProcessHeap(), 0, resname);
111     HeapFree(GetProcessHeap(), 0, appname);
112     return ret;
113 }
114 
115 /***********************************************************************
116  * CreateActCtxW (KERNEL32.@)
117  *
118  * Create an activation context.
119  */
120 HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
121 {
122     NTSTATUS    status;
123     HANDLE      hActCtx;
124 
125     TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
126 
127     if ((status = RtlCreateActivationContext(&hActCtx, pActCtx)))
128     {
129         SetLastError(RtlNtStatusToDosError(status));
130         return INVALID_HANDLE_VALUE;
131     }
132     return hActCtx;
133 }
134 
135 /***********************************************************************
136  * ActivateActCtx (KERNEL32.@)
137  *
138  * Activate an activation context.
139  */
140 BOOL WINAPI ActivateActCtx(HANDLE hActCtx, ULONG_PTR *ulCookie)
141 {
142     NTSTATUS status;
143 
144     if ((status = RtlActivateActivationContext( 0, hActCtx, ulCookie )))
145     {
146         SetLastError(RtlNtStatusToDosError(status));
147         return FALSE;
148     }
149     return TRUE;
150 }
151 
152 /***********************************************************************
153  * DeactivateActCtx (KERNEL32.@)
154  *
155  * Deactivate an activation context.
156  */
157 BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
158 {
159     RtlDeactivateActivationContext( dwFlags, ulCookie );
160     return TRUE;
161 }
162 
163 /***********************************************************************
164  * GetCurrentActCtx (KERNEL32.@)
165  *
166  * Get the current activation context.
167  */
168 BOOL WINAPI GetCurrentActCtx(HANDLE* phActCtx)
169 {
170     NTSTATUS status;
171 
172     if ((status = RtlGetActiveActivationContext(phActCtx)))
173     {
174         SetLastError(RtlNtStatusToDosError(status));
175         return FALSE;
176     }
177     return TRUE;
178 }
179 
180 /***********************************************************************
181  * AddRefActCtx (KERNEL32.@)
182  *
183  * Add a reference to an activation context.
184  */
185 void WINAPI AddRefActCtx(HANDLE hActCtx)
186 {
187     RtlAddRefActivationContext(hActCtx);
188 }
189 
190 /***********************************************************************
191  * ReleaseActCtx (KERNEL32.@)
192  *
193  * Release a reference to an activation context.
194  */
195 void WINAPI ReleaseActCtx(HANDLE hActCtx)
196 {
197     RtlReleaseActivationContext(hActCtx);
198 }
199 
200 /***********************************************************************
201  * ZombifyActCtx (KERNEL32.@)
202  *
203  * Release a reference to an activation context.
204  */
205 BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
206 {
207   FIXME("%p\n", hActCtx);
208   if (hActCtx != ACTCTX_FAKE_HANDLE)
209     return FALSE;
210   return TRUE;
211 }
212 
213 /***********************************************************************
214  * FindActCtxSectionStringA (KERNEL32.@)
215  *
216  * Find information about a GUID in an activation context.
217  */
218 BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID* lpExtGuid,
219                                     ULONG ulId, LPCSTR lpSearchStr,
220                                     PACTCTX_SECTION_KEYED_DATA pInfo)
221 {
222     LPWSTR  search_str;
223     DWORD   len;
224     BOOL    ret;
225 
226     TRACE("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
227           ulId, debugstr_a(lpSearchStr), pInfo);
228 
229     if (!lpSearchStr)
230     {
231         SetLastError(ERROR_INVALID_PARAMETER);
232         return FALSE;
233     }
234 
235     len = MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, NULL, 0);
236     search_str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
237     MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, search_str, len);
238 
239     ret = FindActCtxSectionStringW(dwFlags, lpExtGuid, ulId, search_str, pInfo);
240 
241     HeapFree(GetProcessHeap(), 0, search_str);
242     return ret;
243 }
244 
245 /***********************************************************************
246  * FindActCtxSectionStringW (KERNEL32.@)
247  *
248  * Find information about a GUID in an activation context.
249  */
250 BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID* lpExtGuid,
251                                     ULONG ulId, LPCWSTR lpSearchStr,
252                                     PACTCTX_SECTION_KEYED_DATA pInfo)
253 {
254     UNICODE_STRING us;
255     NTSTATUS status;
256 
257     RtlInitUnicodeString(&us, lpSearchStr);
258     if ((status = RtlFindActivationContextSectionString(dwFlags, lpExtGuid, ulId, &us, pInfo)))
259     {
260         SetLastError(RtlNtStatusToDosError(status));
261         return FALSE;
262     }
263     return TRUE;
264 }
265 
266 /***********************************************************************
267  * FindActCtxSectionGuid (KERNEL32.@)
268  *
269  * Find information about a GUID in an activation context.
270  */
271 BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID* lpExtGuid,
272                                   ULONG ulId, const GUID* lpSearchGuid,
273                                   PACTCTX_SECTION_KEYED_DATA pInfo)
274 {
275   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
276        ulId, debugstr_guid(lpSearchGuid), pInfo);
277   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
278   return FALSE;
279 }
280 
281 /***********************************************************************
282  * QueryActCtxW (KERNEL32.@)
283  *
284  * Get information about an activation context.
285  */
286 BOOL WINAPI QueryActCtxW(DWORD dwFlags, HANDLE hActCtx, PVOID pvSubInst,
287                          ULONG ulClass, PVOID pvBuff, SIZE_T cbBuff,
288                          SIZE_T *pcbLen)
289 {
290     NTSTATUS status;
291 
292     if ((status = RtlQueryInformationActivationContext( dwFlags, hActCtx, pvSubInst, ulClass,
293                                                         pvBuff, cbBuff, pcbLen )))
294     {
295         SetLastError(RtlNtStatusToDosError(status));
296         return FALSE;
297     }
298     return TRUE;
299 }
300 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.