volatile bakery placeholder

This commit is contained in:
Igor Klopov 2017-10-08 19:09:14 +03:00
parent 9fc773c93b
commit 342cb51007
4 changed files with 65 additions and 161 deletions

View File

@ -328,7 +328,7 @@
TryCatch& try_catch) {
--- node/src/node_main.cc
+++ node/src/node_main.cc
@@ -19,10 +19,263 @@
@@ -19,10 +19,239 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
@ -468,7 +468,7 @@
+#endif
+
+
+char* ReadOverlays() {
+void ReadOverlays() {
+ char exepath[1024];
+ size_t exepath_size = sizeof(exepath);
+ if (uv_exepath(exepath, &exepath_size)) {
@ -494,36 +494,8 @@
+
+ int position = FindBaseBinaryEdge(file);
+ int size;
+ char* bakery = NULL;
+ char env[64];
+
+ if (FindNextBlock(file, position, 0x4818c4df,
+ 0x32dbc2af, 0x56558a76, &position, &size)
+ ) {
+ if (size) {
+ if (fseek(file, position, SEEK_SET) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+
+ bakery = static_cast<char*>(malloc(size));
+ int read;
+
+ for (int i = 0; i < size;) {
+ read = static_cast<int>(fread(&bakery[i], 1, size - i, file));
+ if (ferror(file) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+ i += read;
+ }
+
+ position += size;
+ }
+ }
+
+ if (FindNextBlock(file, position, 0x75148eba,
+ 0x1aa9270e, 0x2e20c08d, &position, &size)
+ ) {
@ -545,7 +517,6 @@
+ }
+
+ fclose(file);
+ return bakery;
+}
+
+
@ -566,19 +537,24 @@
+}
+
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
+
+
+int reorder(int argc, char** argv) {
+ int i;
+ char** nargv = new char*[argc + 64];
+ char* bakery = ReadOverlays();
+ ReadOverlays();
+ int c = 0;
+ nargv[c++] = argv[0];
+ if (bakery) {
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ char* bakery = (char*) BAKERY;
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ for (i = 1; i < argc; i++) {
+ nargv[c++] = argv[i];
@ -592,7 +568,7 @@
// Convert argv to to UTF8
char** argv = new char*[argc];
for (int i = 0; i < argc; i++) {
@@ -55,13 +308,13 @@
@@ -55,13 +284,13 @@
fprintf(stderr, "Could not convert arguments to utf8.");
exit(1);
}

View File

@ -409,7 +409,7 @@
--- node/src/node_main.cc
+++ node/src/node_main.cc
@@ -1,7 +1,260 @@
@@ -1,7 +1,236 @@
#include "node.h"
+#include <string.h>
@ -546,7 +546,7 @@
+#endif
+
+
+char* ReadOverlays() {
+void ReadOverlays() {
+ char exepath[1024];
+ size_t exepath_size = sizeof(exepath);
+ if (uv_exepath(exepath, &exepath_size)) {
@ -572,36 +572,8 @@
+
+ int position = FindBaseBinaryEdge(file);
+ int size;
+ char* bakery = NULL;
+ char env[64];
+
+ if (FindNextBlock(file, position, 0x4818c4df,
+ 0x32dbc2af, 0x56558a76, &position, &size)
+ ) {
+ if (size) {
+ if (fseek(file, position, SEEK_SET) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+
+ bakery = static_cast<char*>(malloc(size));
+ int read;
+
+ for (int i = 0; i < size;) {
+ read = static_cast<int>(fread(&bakery[i], 1, size - i, file));
+ if (ferror(file) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+ i += read;
+ }
+
+ position += size;
+ }
+ }
+
+ if (FindNextBlock(file, position, 0x75148eba,
+ 0x1aa9270e, 0x2e20c08d, &position, &size)
+ ) {
@ -623,7 +595,6 @@
+ }
+
+ fclose(file);
+ return bakery;
+}
+
+
@ -644,19 +615,24 @@
+}
+
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
+
+
+int reorder(int argc, char** argv) {
+ int i;
+ char** nargv = new char*[argc + 64];
+ char* bakery = ReadOverlays();
+ ReadOverlays();
+ int c = 0;
+ nargv[c++] = argv[0];
+ if (bakery) {
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ char* bakery = (char*) BAKERY;
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ for (i = 1; i < argc; i++) {
+ nargv[c++] = argv[i];
@ -670,7 +646,7 @@
// Convert argv to to UTF8
char** argv = new char*[argc + 1];
for (int i = 0; i < argc; i++) {
@@ -35,17 +288,17 @@
@@ -35,17 +264,17 @@
exit(1);
}
}

View File

@ -431,7 +431,7 @@
if (!options->IsObject()) {
--- node/src/node_main.cc
+++ node/src/node_main.cc
@@ -1,7 +1,260 @@
@@ -1,7 +1,236 @@
#include "node.h"
+#include <string.h>
@ -568,7 +568,7 @@
+#endif
+
+
+char* ReadOverlays() {
+void ReadOverlays() {
+ char exepath[1024];
+ size_t exepath_size = sizeof(exepath);
+ if (uv_exepath(exepath, &exepath_size)) {
@ -594,36 +594,8 @@
+
+ int position = FindBaseBinaryEdge(file);
+ int size;
+ char* bakery = NULL;
+ char env[64];
+
+ if (FindNextBlock(file, position, 0x4818c4df,
+ 0x32dbc2af, 0x56558a76, &position, &size)
+ ) {
+ if (size) {
+ if (fseek(file, position, SEEK_SET) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+
+ bakery = static_cast<char*>(malloc(size));
+ int read;
+
+ for (int i = 0; i < size;) {
+ read = static_cast<int>(fread(&bakery[i], 1, size - i, file));
+ if (ferror(file) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+ i += read;
+ }
+
+ position += size;
+ }
+ }
+
+ if (FindNextBlock(file, position, 0x75148eba,
+ 0x1aa9270e, 0x2e20c08d, &position, &size)
+ ) {
@ -645,7 +617,6 @@
+ }
+
+ fclose(file);
+ return bakery;
+}
+
+
@ -666,19 +637,24 @@
+}
+
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
+
+
+int reorder(int argc, char** argv) {
+ int i;
+ char** nargv = new char*[argc + 64];
+ char* bakery = ReadOverlays();
+ ReadOverlays();
+ int c = 0;
+ nargv[c++] = argv[0];
+ if (bakery) {
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ char* bakery = (char*) BAKERY;
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ for (i = 1; i < argc; i++) {
+ nargv[c++] = argv[i];
@ -692,7 +668,7 @@
int wmain(int argc, wchar_t *wargv[]) {
if (!IsWindows7OrGreater()) {
@@ -43,17 +296,17 @@
@@ -43,17 +272,17 @@
exit(1);
}
}

View File

@ -464,7 +464,7 @@
auto pos = option.find("=");
--- node/src/node_main.cc
+++ node/src/node_main.cc
@@ -20,10 +20,263 @@
@@ -20,10 +20,239 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "node.h"
@ -604,7 +604,7 @@
+#endif
+
+
+char* ReadOverlays() {
+void ReadOverlays() {
+ char exepath[1024];
+ size_t exepath_size = sizeof(exepath);
+ if (uv_exepath(exepath, &exepath_size)) {
@ -630,36 +630,8 @@
+
+ int position = FindBaseBinaryEdge(file);
+ int size;
+ char* bakery = NULL;
+ char env[64];
+
+ if (FindNextBlock(file, position, 0x4818c4df,
+ 0x32dbc2af, 0x56558a76, &position, &size)
+ ) {
+ if (size) {
+ if (fseek(file, position, SEEK_SET) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+
+ bakery = static_cast<char*>(malloc(size));
+ int read;
+
+ for (int i = 0; i < size;) {
+ read = static_cast<int>(fread(&bakery[i], 1, size - i, file));
+ if (ferror(file) != 0) {
+ fprintf(stderr, "Pkg: Error reading from file.\n");
+ fclose(file);
+ exit(1);
+ }
+ i += read;
+ }
+
+ position += size;
+ }
+ }
+
+ if (FindNextBlock(file, position, 0x75148eba,
+ 0x1aa9270e, 0x2e20c08d, &position, &size)
+ ) {
@ -681,7 +653,6 @@
+ }
+
+ fclose(file);
+ return bakery;
+}
+
+
@ -702,19 +673,24 @@
+}
+
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
+
+
+int reorder(int argc, char** argv) {
+ int i;
+ char** nargv = new char*[argc + 64];
+ char* bakery = ReadOverlays();
+ ReadOverlays();
+ int c = 0;
+ nargv[c++] = argv[0];
+ if (bakery) {
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ char* bakery = (char*) BAKERY;
+ while (true) {
+ size_t width = strlen(bakery);
+ if (width == 0) break;
+ nargv[c++] = bakery;
+ bakery += width + 1;
+ }
+ for (i = 1; i < argc; i++) {
+ nargv[c++] = argv[i];
@ -728,7 +704,7 @@
#include <VersionHelpers.h>
#include <WinError.h>
@@ -67,11 +320,11 @@
@@ -67,11 +296,11 @@
exit(1);
}
}
@ -741,7 +717,7 @@
// UNIX
#ifdef __linux__
#include <elf.h>
@@ -101,8 +354,8 @@
@@ -101,8 +330,8 @@
#endif
// Disable stdio buffering, it interacts poorly with printf()
// calls elsewhere in the program (e.g., any logging from V8.)