wintrust: Implement WintrustLoadFunctionPointers.
[wine] / dlls / kernel32 / actctx.c
1 /*
2  * Activation contexts
3  *
4  * Copyright 2004 Jon Griffiths
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 "config.h"
22 #include "wine/port.h"
23
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winnls.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(actctx);
32
33
34 #define ACTCTX_FLAGS_ALL (\
35  ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID |\
36  ACTCTX_FLAG_LANGID_VALID |\
37  ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID |\
38  ACTCTX_FLAG_RESOURCE_NAME_VALID |\
39  ACTCTX_FLAG_SET_PROCESS_DEFAULT |\
40  ACTCTX_FLAG_APPLICATION_NAME_VALID |\
41  ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF |\
42  ACTCTX_FLAG_HMODULE_VALID )
43
44 #define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
45 #define ACTCTX_FAKE_COOKIE ((ULONG_PTR) 0xf00bad)
46
47 /***********************************************************************
48  * CreateActCtxA (KERNEL32.@)
49  *
50  * Create an activation context.
51  */
52 HANDLE WINAPI CreateActCtxA(PCACTCTXA pActCtx)
53 {
54   FIXME("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
55
56   if (!pActCtx)
57     return INVALID_HANDLE_VALUE;
58   if (pActCtx->cbSize != sizeof *pActCtx)
59     return INVALID_HANDLE_VALUE;
60   if (pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL)
61     return INVALID_HANDLE_VALUE;
62   return ACTCTX_FAKE_HANDLE;
63 }
64
65 /***********************************************************************
66  * CreateActCtxW (KERNEL32.@)
67  *
68  * Create an activation context.
69  */
70 HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
71 {
72   FIXME("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
73
74   if (!pActCtx)
75     return INVALID_HANDLE_VALUE;
76   if (pActCtx->cbSize != sizeof *pActCtx)
77     return INVALID_HANDLE_VALUE;
78   if (pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL)
79     return INVALID_HANDLE_VALUE;
80   return ACTCTX_FAKE_HANDLE;
81 }
82
83 /***********************************************************************
84  * ActivateActCtx (KERNEL32.@)
85  *
86  * Activate an activation context.
87  */
88 BOOL WINAPI ActivateActCtx(HANDLE hActCtx, ULONG_PTR *ulCookie)
89 {
90   static BOOL reported = FALSE;
91
92   if (reported)
93     TRACE("%p %p\n", hActCtx, ulCookie);
94   else
95   {
96     FIXME("%p %p\n", hActCtx, ulCookie);
97     reported = TRUE;
98   }
99
100   if (ulCookie)
101     *ulCookie = ACTCTX_FAKE_COOKIE;
102   return TRUE;
103 }
104
105 /***********************************************************************
106  * DeactivateActCtx (KERNEL32.@)
107  *
108  * Deactivate an activation context.
109  */
110 BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
111 {
112   static BOOL reported = FALSE;
113
114   if (reported)
115     TRACE("%08x %08lx\n", dwFlags, ulCookie);
116   else
117   {
118     FIXME("%08x %08lx\n", dwFlags, ulCookie);
119     reported = TRUE;
120   }
121
122   if (ulCookie != ACTCTX_FAKE_COOKIE)
123     return FALSE;
124   return TRUE;
125 }
126
127 /***********************************************************************
128  * GetCurrentActCtx (KERNEL32.@)
129  *
130  * Get the current activation context.
131  */
132 BOOL WINAPI GetCurrentActCtx(HANDLE* phActCtx)
133 {
134   FIXME("%p\n", phActCtx);
135   *phActCtx = ACTCTX_FAKE_HANDLE;
136   return TRUE;
137 }
138
139 /***********************************************************************
140  * AddRefActCtx (KERNEL32.@)
141  *
142  * Add a reference to an activation context.
143  */
144 void WINAPI AddRefActCtx(HANDLE hActCtx)
145 {
146   FIXME("%p\n", hActCtx);
147 }
148
149 /***********************************************************************
150  * ReleaseActCtx (KERNEL32.@)
151  *
152  * Release a reference to an activation context.
153  */
154 void WINAPI ReleaseActCtx(HANDLE hActCtx)
155 {
156   FIXME("%p\n", hActCtx);
157 }
158
159 /***********************************************************************
160  * ZombifyActCtx (KERNEL32.@)
161  *
162  * Release a reference to an activation context.
163  */
164 BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
165 {
166   FIXME("%p\n", hActCtx);
167   if (hActCtx != ACTCTX_FAKE_HANDLE)
168     return FALSE;
169   return TRUE;
170 }
171
172 /***********************************************************************
173  * FindActCtxSectionStringA (KERNEL32.@)
174  *
175  * Find information about a GUID in an activation context.
176  */
177 BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID* lpExtGuid,
178                                     ULONG ulId, LPCSTR lpSearchStr,
179                                     PACTCTX_SECTION_KEYED_DATA pInfo)
180 {
181   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
182        ulId, debugstr_a(lpSearchStr), pInfo);
183   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
184   return FALSE;
185 }
186
187 /***********************************************************************
188  * FindActCtxSectionStringW (KERNEL32.@)
189  *
190  * Find information about a GUID in an activation context.
191  */
192 BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID* lpExtGuid,
193                                     ULONG ulId, LPCWSTR lpSearchStr,
194                                     PACTCTX_SECTION_KEYED_DATA pInfo)
195 {
196   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
197         ulId, debugstr_w(lpSearchStr), pInfo);
198
199   if (lpExtGuid)
200   {
201     FIXME("expected lpExtGuid == NULL\n");
202     SetLastError(ERROR_INVALID_PARAMETER);
203     return FALSE;
204   }
205
206   if (dwFlags & ~FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX)
207   {
208     FIXME("unknown dwFlags %08x\n", dwFlags);
209     SetLastError(ERROR_INVALID_PARAMETER);
210     return FALSE;
211   }
212
213   if (!pInfo || pInfo->cbSize < sizeof (ACTCTX_SECTION_KEYED_DATA))
214   {
215     SetLastError(ERROR_INVALID_PARAMETER);
216     return FALSE;
217   }
218
219   pInfo->ulDataFormatVersion = 1;
220   pInfo->lpData = NULL;
221   pInfo->lpSectionGlobalData = NULL;
222   pInfo->ulSectionGlobalDataLength = 0;
223   pInfo->lpSectionBase = NULL;
224   pInfo->ulSectionTotalLength = 0;
225   pInfo->hActCtx = ACTCTX_FAKE_HANDLE;
226   pInfo->ulAssemblyRosterIndex = 0;
227
228   return TRUE;
229 }
230
231 /***********************************************************************
232  * FindActCtxSectionGuid (KERNEL32.@)
233  *
234  * Find information about a GUID in an activation context.
235  */
236 BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID* lpExtGuid,
237                                   ULONG ulId, const GUID* lpSearchGuid,
238                                   PACTCTX_SECTION_KEYED_DATA pInfo)
239 {
240   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
241        ulId, debugstr_guid(lpSearchGuid), pInfo);
242   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
243   return FALSE;
244 }
245
246 /***********************************************************************
247  * QueryActCtxW (KERNEL32.@)
248  *
249  * Get information about an activation context.
250  */
251 BOOL WINAPI QueryActCtxW(DWORD dwFlags, HANDLE hActCtx, PVOID pvSubInst,
252                          ULONG ulClass, PVOID pvBuff, SIZE_T cbBuff,
253                          SIZE_T *pcbLen)
254 {
255   FIXME("%08x %p %p %u %p %ld %p\n", dwFlags, hActCtx,
256        pvSubInst, ulClass, pvBuff, cbBuff, pcbLen);
257   /* this makes Adobe Photoshop 7.0 happy */
258   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
259   return FALSE;
260 }