Leaked source code of windows server 2003
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.

113 lines
3.7 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. rtlgetactivationcontextdata.c
  5. Abstract:
  6. Side-by-side activation support for Windows NT
  7. Author:
  8. Jay Krell (JayKrell) November 2001
  9. Revision History:
  10. --*/
  11. #pragma warning(disable:4214) // bit field types other than int
  12. #pragma warning(disable:4201) // nameless struct/union
  13. #pragma warning(disable:4115) // named type definition in parentheses
  14. #pragma warning(disable:4127) // condition expression is constant
  15. #include <ntos.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <sxstypes.h>
  19. #include "sxsp.h"
  20. #include "ldrp.h"
  21. typedef const void *PCVOID;
  22. NTSTATUS
  23. RtlpGetActivationContextData(
  24. IN ULONG Flags,
  25. IN PCACTIVATION_CONTEXT ActivationContext,
  26. IN PCFINDFIRSTACTIVATIONCONTEXTSECTION FindContext, OPTIONAL /* This is used for its flags. */
  27. OUT PCACTIVATION_CONTEXT_DATA* ActivationContextData
  28. )
  29. {
  30. NTSTATUS Status = STATUS_INTERNAL_ERROR; // in case someone forgets to set it...
  31. SIZE_T PebOffset;
  32. if (ActivationContextData == NULL) {
  33. Status = STATUS_INVALID_PARAMETER_4;
  34. goto Exit;
  35. }
  36. if (Flags & ~(RTLP_GET_ACTIVATION_CONTEXT_DATA_MAP_NULL_TO_EMPTY)) {
  37. Status = STATUS_INVALID_PARAMETER_1;
  38. goto Exit;
  39. }
  40. *ActivationContextData = NULL;
  41. PebOffset = 0;
  42. //
  43. // We should use RtlpMapSpecialValuesToBuiltInActivationContexts here, but
  44. // it doesn't handle all the values and it isn't worth fixing it right now.
  45. //
  46. switch ((ULONG_PTR)ActivationContext)
  47. {
  48. case ((ULONG_PTR)NULL):
  49. if (FindContext == NULL) {
  50. PebOffset = FIELD_OFFSET(PEB, ActivationContextData);
  51. } else {
  52. switch (
  53. FindContext->OutFlags
  54. & ( FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_PROCESS_DEFAULT
  55. | FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_SYSTEM_DEFAULT
  56. )) {
  57. case 0: // FALLTHROUGH
  58. case FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_PROCESS_DEFAULT:
  59. PebOffset = FIELD_OFFSET(PEB, ActivationContextData);
  60. break;
  61. case FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_SYSTEM_DEFAULT:
  62. PebOffset = FIELD_OFFSET(PEB, SystemDefaultActivationContextData);
  63. break;
  64. case (FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_PROCESS_DEFAULT
  65. | FIND_ACTIVATION_CONTEXT_SECTION_OUTFLAG_FOUND_IN_SYSTEM_DEFAULT):
  66. Status = STATUS_INVALID_PARAMETER_2;
  67. goto Exit;
  68. break;
  69. }
  70. }
  71. break;
  72. case ((ULONG_PTR)ACTCTX_EMPTY):
  73. *ActivationContextData = &RtlpTheEmptyActivationContextData;
  74. break;
  75. case ((ULONG_PTR)ACTCTX_SYSTEM_DEFAULT):
  76. PebOffset = FIELD_OFFSET(PEB, SystemDefaultActivationContextData);
  77. break;
  78. default:
  79. *ActivationContextData = ActivationContext->ActivationContextData;
  80. break;
  81. }
  82. if (PebOffset != 0)
  83. *ActivationContextData = *(PCACTIVATION_CONTEXT_DATA*)(((ULONG_PTR)NtCurrentPeb()) + PebOffset);
  84. //
  85. // special transmutation of lack of actctx into the empty actctx
  86. //
  87. if (*ActivationContextData == NULL)
  88. if ((Flags & RTLP_GET_ACTIVATION_CONTEXT_DATA_MAP_NULL_TO_EMPTY) != 0)
  89. *ActivationContextData = &RtlpTheEmptyActivationContextData;
  90. Status = STATUS_SUCCESS;
  91. Exit:
  92. return Status;
  93. }