Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. csrsxs.c
  5. Abstract:
  6. This module implements functions that are used by the Side-by-Side
  7. Win32 APIs.
  8. Author:
  9. Samer Arafeh (samera) 20-May-2000
  10. Revision History:
  11. Jay Krell (a-JayK) June, July 2000
  12. factored/merged with sxs.c, source code duplication eliminated
  13. moved file opening out of csrss.exe to client process
  14. --*/
  15. #include "basedll.h"
  16. #include <sxstypes.h>
  17. #include <limits.h>
  18. typedef void * POINTER_32 PVOID32;
  19. #define DPFLTR_LEVEL_STATUS(x) ((NT_SUCCESS(x) \
  20. || (x) == STATUS_OBJECT_NAME_NOT_FOUND \
  21. || (x) == STATUS_RESOURCE_DATA_NOT_FOUND \
  22. || (x) == STATUS_RESOURCE_TYPE_NOT_FOUND \
  23. || (x) == STATUS_RESOURCE_NAME_NOT_FOUND \
  24. || (x) == STATUS_RESOURCE_LANG_NOT_FOUND \
  25. || (x) == STATUS_SXS_CANT_GEN_ACTCTX \
  26. ) \
  27. ? DPFLTR_TRACE_LEVEL : DPFLTR_ERROR_LEVEL)
  28. VOID
  29. BasepSxsDbgPrintMessageStream(
  30. PCSTR Function,
  31. PCSTR StreamName,
  32. PBASE_MSG_SXS_STREAM MessageStream
  33. )
  34. {
  35. KdPrintEx((
  36. DPFLTR_SXS_ID,
  37. DPFLTR_TRACE_LEVEL,
  38. "SXS: %s() %s {\n"
  39. "SXS: FileType:%s\n"
  40. "SXS: PathType:%s\n"
  41. "SXS: Path:%wZ\n"
  42. "SXS: FileHandle:%p\n"
  43. "SXS: HandleType:%s\n"
  44. "SXS: Handle:%p\n"
  45. "SXS: Offset:0x%I64x\n"
  46. "SXS: Size:0x%Ix\n"
  47. "SXS: }\n",
  48. Function,
  49. StreamName,
  50. (MessageStream->FileType == BASE_MSG_FILETYPE_NONE ? "None" :
  51. MessageStream->FileType == BASE_MSG_FILETYPE_XML ? "Xml" :
  52. MessageStream->FileType == BASE_MSG_FILETYPE_PRECOMPILED_XML ? "PrecompiledXml" : "Unknown"),
  53. (MessageStream->PathType == BASE_MSG_PATHTYPE_NONE ? "None" :
  54. MessageStream->PathType == BASE_MSG_PATHTYPE_FILE ? "File" :
  55. MessageStream->PathType == BASE_MSG_PATHTYPE_URL ? "Url" :
  56. MessageStream->PathType == BASE_MSG_PATHTYPE_OVERRIDE ? "Override" : "Unknown"),
  57. &MessageStream->Path,
  58. MessageStream->FileHandle,
  59. (MessageStream->HandleType == BASE_MSG_HANDLETYPE_NONE ? "None" :
  60. MessageStream->HandleType == BASE_MSG_HANDLETYPE_PROCESS ? "Process" :
  61. MessageStream->HandleType == BASE_MSG_HANDLETYPE_CLIENT_PROCESS ? "ClientProcess" :
  62. MessageStream->HandleType == BASE_MSG_HANDLETYPE_SECTION ? "Section" : "Unknown"),
  63. MessageStream->Handle,
  64. MessageStream->Offset,
  65. MessageStream->Size));
  66. }
  67. NTSTATUS
  68. CsrBasepCreateActCtx(
  69. IN PBASE_SXS_CREATE_ACTIVATION_CONTEXT_MSG Message
  70. )
  71. {
  72. NTSTATUS Status;
  73. #if defined(BUILD_WOW6432)
  74. Status = NtWow64CsrBasepCreateActCtx(Message);
  75. #else
  76. BASE_API_MSG m;
  77. PCSR_CAPTURE_HEADER CaptureBuffer = NULL;
  78. //
  79. // BUILD_WOW64 means we are 64bit code in a 32bit process "between" csrss and a 32bit client.
  80. // We are in the static thunk library linked into wow64.dll.
  81. //
  82. // Neither native x86 nor native ia64 code needs to worry about the pointer sizes here.
  83. //
  84. #if defined(BUILD_WOW64)
  85. PVOID ActivationContextDataLocal64 = NULL;
  86. PVOID32* ActivationContextDataOut32 = NULL;
  87. #endif
  88. #if DBG
  89. KdPrintEx((
  90. DPFLTR_SXS_ID,
  91. DPFLTR_TRACE_LEVEL,
  92. "SXS: %s() Message {\n"
  93. "SXS: Flags:(%s | %s | %s)\n"
  94. "SXS: ProcessorArchitecture:%lx\n"
  95. "SXS: LangId:%lx\n"
  96. "SXS: AssemblyDirectory:%wZ\n"
  97. "SXS: TextualAssemblyIdentity:%wZ\n"
  98. "SXS: }\n",
  99. __FUNCTION__,
  100. (Message->Flags & BASE_MSG_SXS_MANIFEST_PRESENT) ? "MANIFEST_PRESENT" : "0",
  101. (Message->Flags & BASE_MSG_SXS_POLICY_PRESENT) ? "POLICY_PRESENT" : "0",
  102. (Message->Flags & BASE_MSG_SXS_TEXTUAL_ASSEMBLY_IDENTITY_PRESENT) ? "TEXTUAL_ASSEMBLY_IDENTITY_PRESENT" : "0",
  103. Message->ProcessorArchitecture,
  104. Message->LangId,
  105. &Message->AssemblyDirectory,
  106. &Message->TextualAssemblyIdentity
  107. ));
  108. if (Message->Flags & BASE_MSG_SXS_MANIFEST_PRESENT) {
  109. BasepSxsDbgPrintMessageStream(__FUNCTION__, "Manifest", &Message->Manifest);
  110. }
  111. if (Message->Flags & BASE_MSG_SXS_POLICY_PRESENT) {
  112. BasepSxsDbgPrintMessageStream(__FUNCTION__, "Policy", &Message->Policy);
  113. }
  114. #endif
  115. m.u.SxsCreateActivationContext = *Message;
  116. {
  117. const PUNICODE_STRING StringsToCapture[] =
  118. {
  119. &m.u.SxsCreateActivationContext.Manifest.Path,
  120. ( Message->Flags & BASE_MSG_SXS_POLICY_PRESENT )
  121. ? &m.u.SxsCreateActivationContext.Policy.Path
  122. : NULL,
  123. &m.u.SxsCreateActivationContext.AssemblyDirectory,
  124. ( Message->Flags & BASE_MSG_SXS_TEXTUAL_ASSEMBLY_IDENTITY_PRESENT )
  125. ? &m.u.SxsCreateActivationContext.TextualAssemblyIdentity
  126. : NULL
  127. };
  128. Status = CsrCaptureMessageMultiUnicodeStringsInPlace(
  129. &CaptureBuffer,
  130. RTL_NUMBER_OF(StringsToCapture),
  131. StringsToCapture
  132. );
  133. if (!NT_SUCCESS(Status)) {
  134. DbgPrintEx(DPFLTR_SXS_ID, DPFLTR_LEVEL_STATUS(Status), "SXS: %s() CsrCaptureMessageMultiUnicodeStringsInPlace failed\n", __FUNCTION__);
  135. goto Exit;
  136. }
  137. }
  138. #if defined(BUILD_WOW64)
  139. if (m.u.SxsCreateActivationContext.ActivationContextData != NULL) {
  140. ActivationContextDataOut32 = (PVOID32*)m.u.SxsCreateActivationContext.ActivationContextData;
  141. m.u.SxsCreateActivationContext.ActivationContextData = (PVOID*)&ActivationContextDataLocal64;
  142. }
  143. #endif
  144. Status = CsrClientCallServer((PCSR_API_MSG) &m,
  145. CaptureBuffer,
  146. CSR_MAKE_API_NUMBER(BASESRV_SERVERDLL_INDEX,
  147. BasepSxsCreateActivationContext),
  148. sizeof(*Message));
  149. #if defined(BUILD_WOW64)
  150. if ((m.u.SxsCreateActivationContext.ActivationContextData != NULL) &&
  151. (ActivationContextDataOut32 != NULL)) {
  152. *ActivationContextDataOut32 = (PVOID32) ActivationContextDataLocal64;
  153. }
  154. #endif
  155. Exit:
  156. if ( CaptureBuffer != NULL )
  157. CsrFreeCaptureBuffer(CaptureBuffer);
  158. #endif
  159. return Status;
  160. }