ReactOS  r76032
actctx.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for actctx.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ACTCTX_FAKE_HANDLE   ((HANDLE) 0xf00baa)
 

Functions

 DEBUG_CHANNEL (actctx)
 
HANDLE WINAPI CreateActCtxA (PCACTCTXA pActCtx)
 
HANDLE WINAPI CreateActCtxW (PCACTCTXW pActCtx)
 
BOOL WINAPI FindActCtxSectionStringA (DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
 
BOOL WINAPI FindActCtxSectionStringW (DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCWSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
 
BOOL WINAPI FindActCtxSectionGuid (DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
 

Macro Definition Documentation

#define ACTCTX_FAKE_HANDLE   ((HANDLE) 0xf00baa)

Definition at line 21 of file actctx.c.

#define NDEBUG

Definition at line 17 of file actctx.c.

Function Documentation

HANDLE WINAPI CreateActCtxA ( PCACTCTXA  pActCtx)

Definition at line 28 of file actctx.c.

Referenced by init_funcs().

29 {
30  ACTCTXW actw;
31  SIZE_T len;
33  LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
34 
35  TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
36 
37  if (!pActCtx || pActCtx->cbSize != sizeof(*pActCtx))
38  {
40  return INVALID_HANDLE_VALUE;
41  }
42 
43  actw.cbSize = sizeof(actw);
44  actw.dwFlags = pActCtx->dwFlags;
45  if (pActCtx->lpSource)
46  {
47  len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, NULL, 0);
48  src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
49  if (!src) return INVALID_HANDLE_VALUE;
50  MultiByteToWideChar(CP_ACP, 0, pActCtx->lpSource, -1, src, len);
51  }
52  actw.lpSource = src;
53 
54  if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
55  actw.wProcessorArchitecture = pActCtx->wProcessorArchitecture;
56  if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
57  actw.wLangId = pActCtx->wLangId;
58  if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
59  {
60  len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, NULL, 0);
61  assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
62  if (!assdir) goto done;
63  MultiByteToWideChar(CP_ACP, 0, pActCtx->lpAssemblyDirectory, -1, assdir, len);
64  actw.lpAssemblyDirectory = assdir;
65  }
66  if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
67  {
68  if ((ULONG_PTR)pActCtx->lpResourceName >> 16)
69  {
70  len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, NULL, 0);
71  resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
72  if (!resname) goto done;
73  MultiByteToWideChar(CP_ACP, 0, pActCtx->lpResourceName, -1, resname, len);
74  actw.lpResourceName = resname;
75  }
76  else actw.lpResourceName = (LPCWSTR)pActCtx->lpResourceName;
77  }
78  if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
79  {
80  len = MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, NULL, 0);
81  appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
82  if (!appname) goto done;
83  MultiByteToWideChar(CP_ACP, 0, pActCtx->lpApplicationName, -1, appname, len);
84  actw.lpApplicationName = appname;
85  }
86  if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
87  actw.hModule = pActCtx->hModule;
88 
89  ret = CreateActCtxW(&actw);
90 
91 done:
92  HeapFree(GetProcessHeap(), 0, src);
93  HeapFree(GetProcessHeap(), 0, assdir);
94  HeapFree(GetProcessHeap(), 0, resname);
95  HeapFree(GetProcessHeap(), 0, appname);
96  return ret;
97 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:557
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
int ret
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:78
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define MultiByteToWideChar
Definition: compat.h:100
static const GUID LPCWSTR
Definition: actctx.c:37
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:104
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
HANDLE WINAPI CreateActCtxW ( PCACTCTXW  pActCtx)

Definition at line 104 of file actctx.c.

Referenced by _CreateActCtxFromFile(), _CreateV5ActCtx(), CreateActCtxA(), GetServiceMainFunctions(), init_funcs(), and init_pointers().

105 {
107  HANDLE hActCtx;
108 
109  TRACE("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
110 
111  if ((status = RtlCreateActivationContext(0, (PVOID)pActCtx, 0, NULL, NULL, &hActCtx)))
112  {
114  return INVALID_HANDLE_VALUE;
115  }
116  return hActCtx;
117 }
DWORD *typedef PVOID
Definition: winlogon.h:52
NTSTATUS NTAPI RtlCreateActivationContext(IN ULONG Flags, IN PACTIVATION_CONTEXT_DATA ActivationContextData, IN ULONG ExtraBytes, IN PVOID NotificationRoutine, IN PVOID NotificationContext, OUT PACTIVATION_CONTEXT *ActCtx)
Definition: actctx.c:4678
ULONG NTAPI RtlNtStatusToDosError(IN NTSTATUS Status)
Definition: error.c:96
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
smooth NULL
Definition: ftsmooth.c:557
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
static SERVICE_STATUS status
Definition: service.c:26
DEBUG_CHANNEL ( actctx  )
BOOL WINAPI FindActCtxSectionGuid ( DWORD  dwFlags,
const GUID lpExtGuid,
ULONG  ulId,
const GUID lpSearchGuid,
PACTCTX_SECTION_KEYED_DATA  pInfo 
)

Definition at line 183 of file actctx.c.

Referenced by actctx_get_miscstatus(), actctx_get_typelib_module(), CoGetClassObject(), CoGetPSClsid(), init_funcs(), ProgIDFromCLSID(), and query_typelib_path().

186 {
188 
189  if ((status = RtlFindActivationContextSectionGuid(dwFlags, lpExtGuid, ulId, lpSearchGuid, pInfo)))
190  {
192  return FALSE;
193  }
194 
195  return TRUE;
196 }
#define TRUE
Definition: types.h:120
ULONG NTAPI RtlNtStatusToDosError(IN NTSTATUS Status)
Definition: error.c:96
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1170
NTSTATUS WINAPI RtlFindActivationContextSectionGuid(ULONG flags, const GUID *extguid, ULONG section_kind, const GUID *guid, void *ptr)
Definition: actctx.c:5359
LONG NTSTATUS
Definition: DriverTester.h:11
static SERVICE_STATUS status
Definition: service.c:26
BOOL WINAPI FindActCtxSectionStringA ( DWORD  dwFlags,
const GUID lpExtGuid,
ULONG  ulId,
LPCSTR  lpSearchStr,
PACTCTX_SECTION_KEYED_DATA  pInfo 
)

Definition at line 124 of file actctx.c.

Referenced by init_funcs().

127 {
128  LPWSTR search_str;
129  DWORD len;
130  BOOL ret;
131 
132  TRACE("%08x %s %u %s %p\n", dwFlags, debugstr_guid(lpExtGuid),
133  ulId, debugstr_a(lpSearchStr), pInfo);
134 
135  if (!lpSearchStr || !pInfo)
136  {
138  return FALSE;
139  }
140 
141  len = MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, NULL, 0);
142  search_str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
143  MultiByteToWideChar(CP_ACP, 0, lpSearchStr, -1, search_str, len);
144 
145  ret = FindActCtxSectionStringW(dwFlags, lpExtGuid, ulId, search_str, pInfo);
146 
147  HeapFree(GetProcessHeap(), 0, search_str);
148  return ret;
149 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
DWORD DWORD
Definition: winlogon.h:75
BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCWSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:156
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1170
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI FindActCtxSectionStringW ( DWORD  dwFlags,
const GUID lpExtGuid,
ULONG  ulId,
LPCWSTR  lpSearchStr,
PACTCTX_SECTION_KEYED_DATA  pInfo 
)

Definition at line 156 of file actctx.c.

Referenced by CLSIDFromProgID(), FindActCtxSectionStringA(), init_funcs(), START_TEST(), TestClassRedirection(), and TestLibDependency().

159 {
162 
163  if (!pInfo)
164  {
166  return FALSE;
167  }
168 
169  RtlInitUnicodeString(&us, lpSearchStr);
170  if ((status = RtlFindActivationContextSectionString(dwFlags, lpExtGuid, ulId, &us, pInfo)))
171  {
173  return FALSE;
174  }
175  return TRUE;
176 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
static const BYTE us[]
Definition: encode.c:688
ULONG NTAPI RtlNtStatusToDosError(IN NTSTATUS Status)
Definition: error.c:96
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1170
LONG NTSTATUS
Definition: DriverTester.h:11
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI RtlFindActivationContextSectionString(ULONG flags, const GUID *guid, ULONG section_kind, const UNICODE_STRING *section_name, PVOID ptr)
Definition: actctx.c:5311
static SERVICE_STATUS status
Definition: service.c:26