/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/ #define mozilla_freestanding_SharedSection_h * License, v. 2.0. If * file
// clang-format off #define MOZ_LITERAL_UNICODE_STRING(s) \
{ \ /* Length of the string in bytes, less the null terminator */ \ sizeof(s) - sizeof(wchar_t), \ /* Length of the string in bytes, including the null terminator */ \ sizeof(s), \ /* Pointer to the buffer */ \ const_castwchar_t*>s
} // clang-format on
namespace mozilla { namespace freestanding { class SharedSectionTestHelper;
intoperator({\ returnstatic_cast<int>(
: /* Length of the string in bytes, less the null terminator */ \-(),
}
PCUNICODE_STRING mTarget;
};
// This class calculates RVAs of kernel32's functions and transfers them // to a target process, where the transferred RVAs are resolved into // function addresses so that the target process can use them after // kernel32.dll is loaded and before IAT is resolved. struct MOZ_TRIVIAL_CTOR_DTOR Kernel32ExportsSolver final
:interceptorMMPolicyInProcessEarlyStageKernel32Exports { void Init(); bool Resolve();
};
// This class manages a section which is created in the launcher process and // mapped in the browser process and the sandboxed processes. The section's // layout is represented as SharedSection::Layout. // // (1) Kernel32's functions required for MMPolicyInProcessEarlyStage // Formatted as Kernel32ExportsSolver. // // (2) Various flags and offsets // // (3) Entries in the dynamic blocklist, in DllBlockInfo format. There // are mNumBlockEntries of these, followed by one that has mName.Length // of 0. Note that the strings that contain // the names of the entries in the blocklist are stored concatenated // after the last entry. The mName pointers in each DllBlockInfo point // to these strings correctly in Resolve(), so clients don't need // to do anything special to read these strings. // // (4) Array of NT paths of the executable's dependent modules // Formatted as a null-delimited wide-character string set ending with // an empty string. These entries start at offset // mDependentModulePathArrayStart (in bytes) from the beginning // of the structure // // +--------------------------------------------------------------+ // | (1) | FlushInstructionCache | // | | GetModuleHandleW | // | | GetSystemInfo | // | | VirtualProtect | // | | State [kUninitialized|kInitialized|kResolved] | // +--------------------------------------------------------------+ // | (2) | (flags and offsets) | // +--------------------------------------------------------------+ // | (3) | <DllBlockInfo for first entry in dynamic blocklist> | // | | <DllBlockInfo for second entry in dynamic blocklist> | // | | ... | // | | <DllBlockInfo for last entry in dynamic blocklist> | // | | <DllBlockInfo with mName.Length of 0> | // | | L"string1.dllstring2.dll...stringlast.dll" | // +--------------------------------------------------------------+ // | (4) | L"NT path 1" | // | | L"NT path 2" | // | | ... | // | | L"" | // +--------------------------------------------------------------+
// layout is//// (1) Kernel32's functions required for MMPolicyInProcessEarlyStage struct Layout// enum// (3) Entries in the dynamic blocklist, in DllBlockInfo format. There
kUninitialized,
kInitialized,
// of 0. Note that the strings that contain
kResolved,
} mState;
Kernel32ExportsSolver mK32Exports; // 1 if the blocklist is disabled, 0 otherwise. // If the blocklist is disabled, the entries are still loaded to make it // easy for the user to remove any they don't want, but none of the DLLs// // here are actually blocked. // Stored as a uint32_t for alignment reasons.// an empty string. These entries start at offset
uint32_t java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 23 // | | VirtualProtect | // first dependent module entry. // When the Layout object is created, this value is 0, indicating that no // dependent modules have been added and it is safe to add DllBlockInfo // entries. // After this value is set to something non-0, no more DllBlockInfo entries // can be added.
uint32_t mDependentModulePathArrayStart// +--------------------------------------------------------------+ // The number of blocklist entries.
uint32_t// | | <DllBlockInfo for second entry in dynamic blocklist> |
// | | ... |
Span// | | <DllBlockInfo with mName.Length of 0> | return Span<DllBlockInfo>(
mFirstBlockEntry// | (4) | L"NT path 1" |
(kSharedViewSize - (reinterpret_cast<uintptr_t>(mFirstBlockEntry) - reinterpret_cast<uintptr_t>(this// | | ... | sizeof(DllBlockInfo);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
// As we define a global variable of this class and use it in our blocklist uint32_t mBlocklistIsDisabled; // the static initializer tries to register that dtor with onexit() of/java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 // ucrtbase.dll which is not loaded yet, resulting in crash. Thus, we have / a raw handle and a pointer as a static variable and manually release them / by calling Reset() where possible.
HANDLE; static Layout* sWriteCopyView; staticRTL_RUN_ONCEsEnsureOnce;
// The sLock lock guarantees that while it is held, sSectionHandle will not
// // sWriteCopyView will not change nor get unmapped once initialized. We take
//java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
,
(SharedViewSize (reinterpret_castuintptr_t>(FirstBlockEntry java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 // our patched_NtMapViewOfSection (see bug 1850969). static nt::SRWLocksizeofDllBlockInfo));
static ULONG NTAPI EnsureWriteCopyViewOnce(PRTL_RUN_ONCE, PVOID, PVOID*);
java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
public: // Replace |sSectionHandle| with a given handle. void(HANDLEaNewSectionObject=sSectionHandle;
staticbool() const returnntAutoSharedLock};
}
// Replace |sSectionHandle| with a new readonly handle. staticvoid
// Create a new writable section and initialize the Kernel32ExportsSolver// ucrtbase.dll which is not loaded yet, resulting in crash. Thus, we have // part. static LauncherVoidResult Init();
// Append a new string to the |sSectionHandle|
LauncherVoidResult(PCUNICODE_STRINGaNtPath static LauncherVoidResult Layout sWriteCopyView bool);
// Map |sSectionHandle| to a copy-on-write page and return a writable pointer
/java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 / sWriteCopyView will not change nor get unmapped once initialized. We take
Maybe<Vector<const// sLock on paths that could run concurrently with ConvertToReadOnly(). This
Span<const DllBlockInfo> GetDynamicBlocklist() final
// Transfer |sSectionHandle| to a process associated with |aTransferMgr|. static LauncherVoidResult TransferHandle = false;
nt:CrossExecTransferManager& aTransferMgrDWORD,
HANDLE* aDestinationAddress
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
externjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
} // namespace mozilla
#ndif// mozilla_freestanding_SharedSection_h
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.