kernel32: Add CreateRemoteThread remote thread conformance tests.
[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   FIXME("%p %p\n", hActCtx, ulCookie );
91   if (ulCookie)
92     *ulCookie = ACTCTX_FAKE_COOKIE;
93   return TRUE;
94 }
95
96 /***********************************************************************
97  * DeactivateActCtx (KERNEL32.@)
98  *
99  * Deactivate an activation context.
100  */
101 BOOL WINAPI DeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
102 {
103   FIXME("%08x %08lx\n", dwFlags, ulCookie);
104   if (ulCookie != ACTCTX_FAKE_COOKIE)
105     return FALSE;
106   return TRUE;
107 }
108
109 /***********************************************************************
110  * GetCurrentActCtx (KERNEL32.@)
111  *
112  * Get the current activation context.
113  */
114 BOOL WINAPI GetCurrentActCtx(HANDLE* phActCtx)
115 {
116   FIXME("%p\n", phActCtx);
117   *phActCtx = ACTCTX_FAKE_HANDLE;
118   return TRUE;
119 }
120
121 /***********************************************************************
122  * AddRefActCtx (KERNEL32.@)
123  *
124  * Add a reference to an activation context.
125  */
126 void WINAPI AddRefActCtx(HANDLE hActCtx)
127 {
128   FIXME("%p\n", hActCtx);
129 }
130
131 /***********************************************************************
132  * ReleaseActCtx (KERNEL32.@)
133  *
134  * Release a reference to an activation context.
135  */
136 void WINAPI ReleaseActCtx(HANDLE hActCtx)
137 {
138   FIXME("%p\n", hActCtx);
139 }
140
141 /***********************************************************************
142  * ZombifyActCtx (KERNEL32.@)
143  *
144  * Release a reference to an activation context.
145  */
146 BOOL WINAPI ZombifyActCtx(HANDLE hActCtx)
147 {
148   FIXME("%p\n", hActCtx);
149   if (hActCtx != ACTCTX_FAKE_HANDLE)
150     return FALSE;
151   return TRUE;
152 }
153
154 /***********************************************************************
155  * FindActCtxSectionStringA (KERNEL32.@)
156  *
157  * Find information about a GUID in an activation context.
158  */
159 BOOL WINAPI FindActCtxSectionStringA(DWORD dwFlags, const GUID* lpExtGuid,
160                                     ULONG ulId, LPCSTR lpSearchStr,
161                                     PACTCTX_SECTION_KEYED_DATA pInfo)
162 {
163   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
164        ulId, debugstr_a(lpSearchStr), pInfo);
165   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
166   return FALSE;
167 }
168
169 /***********************************************************************
170  * FindActCtxSectionStringW (KERNEL32.@)
171  *
172  * Find information about a GUID in an activation context.
173  */
174 BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID* lpExtGuid,
175                                     ULONG ulId, LPCWSTR lpSearchStr,
176                                     PACTCTX_SECTION_KEYED_DATA pInfo)
177 {
178   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
179         ulId, debugstr_w(lpSearchStr), pInfo);
180
181   if (lpExtGuid)
182   {
183     FIXME("expected lpExtGuid == NULL\n");
184     SetLastError(ERROR_INVALID_PARAMETER);
185     return FALSE;
186   }
187
188   if (dwFlags & ~FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX)
189   {
190     FIXME("unknown dwFlags %08x\n", dwFlags);
191     SetLastError(ERROR_INVALID_PARAMETER);
192     return FALSE;
193   }
194
195   if (!pInfo || pInfo->cbSize < sizeof (ACTCTX_SECTION_KEYED_DATA))
196   {
197     SetLastError(ERROR_INVALID_PARAMETER);
198     return FALSE;
199   }
200
201   pInfo->ulDataFormatVersion = 1;
202   pInfo->lpData = NULL;
203   pInfo->lpSectionGlobalData = NULL;
204   pInfo->ulSectionGlobalDataLength = 0;
205   pInfo->lpSectionBase = NULL;
206   pInfo->ulSectionTotalLength = 0;
207   pInfo->hActCtx = ACTCTX_FAKE_HANDLE;
208   pInfo->ulAssemblyRosterIndex = 0;
209
210   return TRUE;
211 }
212
213 /***********************************************************************
214  * FindActCtxSectionGuid (KERNEL32.@)
215  *
216  * Find information about a GUID in an activation context.
217  */
218 BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID* lpExtGuid,
219                                   ULONG ulId, const GUID* lpSearchGuid,
220                                   PACTCTX_SECTION_KEYED_DATA pInfo)
221 {
222   FIXME("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
223        ulId, debugstr_guid(lpSearchGuid), pInfo);
224   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
225   return FALSE;
226 }
227
228 /***********************************************************************
229  * QueryActCtxW (KERNEL32.@)
230  *
231  * Get information about an activation context.
232  */
233 BOOL WINAPI QueryActCtxW(DWORD dwFlags, HANDLE hActCtx, PVOID pvSubInst,
234                          ULONG ulClass, PVOID pvBuff, SIZE_T cbBuff,
235                          SIZE_T *pcbLen)
236 {
237   FIXME("%08x %p %p %u %p %ld %p\n", dwFlags, hActCtx,
238        pvSubInst, ulClass, pvBuff, cbBuff, pcbLen);
239   /* this makes Adobe Photoshop 7.0 happy */
240   SetLastError( ERROR_CALL_NOT_IMPLEMENTED);
241   return FALSE;
242 }