| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fbe4da5 commit 957292e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,7 @@ | |||
| 142 | 142 | 'src/node_report_module.cc', | |
| 143 | 143 | 'src/node_report_utils.cc', | |
| 144 | 144 | 'src/node_sea.cc', | |
| 145 | + 'src/node_sea_bin.cc', | ||
| 145 | 146 | 'src/node_serdes.cc', | |
| 146 | 147 | 'src/node_shadow_realm.cc', | |
| 147 | 148 | 'src/node_snapshotable.cc', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,15 +14,6 @@ | |||
| 14 | 14 | #include "simdjson.h" | |
| 15 | 15 | #include "util-inl.h" | |
| 16 | 16 | ||
| 17 | - // The POSTJECT_SENTINEL_FUSE macro is a string of random characters selected by | ||
| 18 | - // the Node.js project that is present only once in the entire binary. It is | ||
| 19 | - // used by the postject_has_resource() function to efficiently detect if a | ||
| 20 | - // resource has been injected. See | ||
| 21 | - // https://github.com/nodejs/postject/blob/35343439cac8c488f2596d7c4c1dddfec1fddcae/postject-api.h#L42-L45. | ||
| 22 | - #define POSTJECT_SENTINEL_FUSE "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2" | ||
| 23 | - #include "postject-api.h" | ||
| 24 | - #undef POSTJECT_SENTINEL_FUSE | ||
| 25 | - | ||
| 26 | 17 | #include <memory> | |
| 27 | 18 | #include <string_view> | |
| 28 | 19 | #include <tuple> | |
@@ -233,33 +224,6 @@ SeaResource SeaDeserializer::Read() { | |||
| 233 | 224 | exec_argv}; | |
| 234 | 225 | } | |
| 235 | 226 | ||
| 236 | - std::string_view FindSingleExecutableBlob() { | ||
| 237 | - #if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION) | ||
| 238 | - CHECK(IsSingleExecutable()); | ||
| 239 | - static const std::string_view result = []() -> std::string_view { | ||
| 240 | - size_t size; | ||
| 241 | - #ifdef __APPLE__ | ||
| 242 | - postject_options options; | ||
| 243 | - postject_options_init(&options); | ||
| 244 | - options.macho_segment_name = "NODE_SEA"; | ||
| 245 | - const char* blob = static_cast<const char*>( | ||
| 246 | - postject_find_resource("NODE_SEA_BLOB", &size, &options)); | ||
| 247 | - #else | ||
| 248 | - const char* blob = static_cast<const char*>( | ||
| 249 | - postject_find_resource("NODE_SEA_BLOB", &size, nullptr)); | ||
| 250 | - #endif | ||
| 251 | - return {blob, size}; | ||
| 252 | - }(); | ||
| 253 | - per_process::Debug(DebugCategory::SEA, | ||
| 254 | - "Found SEA blob %p, size=%zu\n", | ||
| 255 | - result.data(), | ||
| 256 | - result.size()); | ||
| 257 | - return result; | ||
| 258 | - #else | ||
| 259 | - UNREACHABLE(); | ||
| 260 | - #endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION) | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | 227 | } // anonymous namespace | |
| 264 | 228 | ||
| 265 | 229 | bool SeaResource::use_snapshot() const { | |
@@ -283,9 +247,6 @@ SeaResource FindSingleExecutableResource() { | |||
| 283 | 247 | return sea_resource; | |
| 284 | 248 | } | |
| 285 | 249 | ||
| 286 | - bool IsSingleExecutable() { | ||
| 287 | - return postject_has_resource(); | ||
| 288 | - } | ||
| 289 | 250 | ||
| 290 | 251 | void IsSea(const FunctionCallbackInfo<Value>& args) { | |
| 291 | 252 | args.GetReturnValue().Set(IsSingleExecutable()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,7 @@ struct SeaResource { | |||
| 54 | 54 | }; | |
| 55 | 55 | ||
| 56 | 56 | bool IsSingleExecutable(); | |
| 57 | + std::string_view FindSingleExecutableBlob(); | ||
| 57 | 58 | SeaResource FindSingleExecutableResource(); | |
| 58 | 59 | std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv); | |
| 59 | 60 | node::ExitCode BuildSingleExecutableBlob( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,66 @@ | |||
| 1 | + #include "node_sea.h" | ||
| 2 | + | ||
| 3 | + #ifdef HAVE_LIEF | ||
| 4 | + #include "LIEF/LIEF.hpp" | ||
| 5 | + #endif // HAVE_LIEF | ||
| 6 | + | ||
| 7 | + #include "debug_utils-inl.h" | ||
| 8 | + #include "env-inl.h" | ||
| 9 | + #include "util-inl.h" | ||
| 10 | + | ||
| 11 | + #include <algorithm> | ||
| 12 | + #include <codecvt> | ||
| 13 | + #include <locale> | ||
| 14 | + #include <memory> | ||
| 15 | + #include <vector> | ||
| 16 | + #include <string> | ||
| 17 | + #include <iostream> | ||
| 18 | + #include <fstream> | ||
| 19 | + #include <sstream> | ||
| 20 | + #include <string_view> | ||
| 21 | + | ||
| 22 | + // The POSTJECT_SENTINEL_FUSE macro is a string of random characters selected by | ||
| 23 | + // the Node.js project that is present only once in the entire binary. It is | ||
| 24 | + // used by the postject_has_resource() function to efficiently detect if a | ||
| 25 | + // resource has been injected. See | ||
| 26 | + // https://github.com/nodejs/postject/blob/35343439cac8c488f2596d7c4c1dddfec1fddcae/postject-api.h#L42-L45. | ||
| 27 | + #define POSTJECT_SENTINEL_FUSE "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2" | ||
| 28 | + #include "postject-api.h" | ||
| 29 | + #undef POSTJECT_SENTINEL_FUSE | ||
| 30 | + | ||
| 31 | + namespace node { | ||
| 32 | + namespace sea { | ||
| 33 | + | ||
| 34 | + std::string_view FindSingleExecutableBlob() { | ||
| 35 | + #if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION) | ||
| 36 | + CHECK(IsSingleExecutable()); | ||
| 37 | + static const std::string_view result = []() -> std::string_view { | ||
| 38 | + size_t size; | ||
| 39 | + #ifdef __APPLE__ | ||
| 40 | + postject_options options; | ||
| 41 | + postject_options_init(&options); | ||
| 42 | + options.macho_segment_name = "NODE_SEA"; | ||
| 43 | + const char* blob = static_cast<const char*>( | ||
| 44 | + postject_find_resource("NODE_SEA_BLOB", &size, &options)); | ||
| 45 | + #else | ||
| 46 | + const char* blob = static_cast<const char*>( | ||
| 47 | + postject_find_resource("NODE_SEA_BLOB", &size, nullptr)); | ||
| 48 | + #endif | ||
| 49 | + return {blob, size}; | ||
| 50 | + }(); | ||
| 51 | + per_process::Debug(DebugCategory::SEA, | ||
| 52 | + "Found SEA blob %p, size=%zu\n", | ||
| 53 | + result.data(), | ||
| 54 | + result.size()); | ||
| 55 | + return result; | ||
| 56 | + #else | ||
| 57 | + UNREACHABLE(); | ||
| 58 | + #endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION) | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + bool IsSingleExecutable() { | ||
| 62 | + return postject_has_resource(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + } // namespace sea | ||
| 66 | + } // namespace node | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments