فهرست منبع

old changes removed

Alexander Shiryaev 9 سال پیش
والد
کامیت
d9d9ce406e
1فایلهای تغییر یافته به همراه6 افزوده شده و 32 حذف شده
  1. 6 32
      BlackBox/_Linux_/Lin/Rsrc/blackbox.c

+ 6 - 32
BlackBox/_Linux_/Lin/Rsrc/blackbox.c

@@ -11,7 +11,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-/* #include <malloc.h> */
 #include <errno.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <fcntl.h>
 
 
@@ -20,8 +19,6 @@
 #define exeSize 17028
 #define exeSize 17028
 
 
 
 
-#define pageSize 4096
-
 /* fixup types */
 /* fixup types */
 #define absolute 100
 #define absolute 100
 #define relative 101
 #define relative 101
@@ -359,7 +356,7 @@ int ReadBootHeader()
   return 1;
   return 1;
 }
 }
 
 
-void * MEMALLOC (size_t len)
+void * MemAlloc (size_t len)
 {
 {
 	void * res;
 	void * res;
 
 
@@ -402,7 +399,7 @@ int ReadHeader ()
   mod.imp = NULL;
   mod.imp = NULL;
   for (i = 0; i < nofImps; i++)
   for (i = 0; i < nofImps; i++)
     {
     {
-      imp = (ImpList*)MEMALLOC(sizeof(ImpList));
+      imp = (ImpList*)MemAlloc(sizeof(ImpList));
       ReadName(imp->name);
       ReadName(imp->name);
       if (mod.imp == NULL)
       if (mod.imp == NULL)
 	mod.imp = imp;
 	mod.imp = imp;
@@ -438,8 +435,8 @@ int ReadModule ()
   int isLib;
   int isLib;
   char* im;
   char* im;
 
 
-  mod.dad = (int) MEMALLOC(mod.ds);
-  mod.mad = (int) MEMALLOC(mod.ms + mod.cs + mod.vs);
+  mod.dad = (int) MemAlloc(mod.ds);
+  mod.mad = (int) MemAlloc(mod.ms + mod.cs + mod.vs);
   if ((mod.dad == 0) || (mod.mad == 0)) 
   if ((mod.dad == 0) || (mod.mad == 0)) 
     {
     {
       printf("BootLoader: Couldn't initalize heap\n");
       printf("BootLoader: Couldn't initalize heap\n");
@@ -568,21 +565,9 @@ int ReadModule ()
   return 1;
   return 1;
 }
 }
 
 
-int MOD (int x, int y)
-{
-    int res;
-
-    if (x >= 0) {
-	res = x % y;
-    } else {
-	res = x - y * ((x + 1) / y - 1);
-    }
-    return res;
-}
-
 int main (int argc, char *argv[])
 int main (int argc, char *argv[])
 {
 {
-  int i, ok;
+  int i;
   BodyProc body;
   BodyProc body;
   int callBackAdr;
   int callBackAdr;
   Module *k, *m;
   Module *k, *m;
@@ -595,7 +580,6 @@ int main (int argc, char *argv[])
 
 
   modlist = NULL;
   modlist = NULL;
   dprintf("initializing BlackBox for Linux...\n");
   dprintf("initializing BlackBox for Linux...\n");
-
   /*f = fopen(bbfile, "rb");*/
   /*f = fopen(bbfile, "rb");*/
   f = fopen(argv[0], "r");
   f = fopen(argv[0], "r");
   if (f != NULL) 
   if (f != NULL) 
@@ -628,7 +612,7 @@ int main (int argc, char *argv[])
 		else
 		else
 		  {
 		  {
 		    /* assign the boot info to first variable in Kernel */
 		    /* assign the boot info to first variable in Kernel */
-		    bootInfo = MEMALLOC(sizeof(BootInfo));
+		    bootInfo = MemAlloc(sizeof(BootInfo));
 		    bootInfo->modList = modlist;
 		    bootInfo->modList = modlist;
 		    bootInfo->argc = argc;
 		    bootInfo->argc = argc;
 		    bootInfo->argv = argv;
 		    bootInfo->argv = argv;
@@ -636,16 +620,6 @@ int main (int argc, char *argv[])
 		    dprintf("before body\n");
 		    dprintf("before body\n");
 		    body = (BodyProc)(m->code);
 		    body = (BodyProc)(m->code);
 		    k->opts = k->opts | init; /* include init in opts */
 		    k->opts = k->opts | init; /* include init in opts */
-		    /*
-		    ok = mprotect(
-				(void *)(((m->code) / pageSize) * pageSize),
-				(((m->csize) + MOD(m->code, pageSize) - 1) / pageSize) * pageSize + pageSize,
-				PROT_READ|PROT_WRITE|PROT_EXEC);
-		    if (ok != 0){
-				printf("mprotect failed: %s\n", strerror(errno));
-				return 100;
-		    }
-		    */
 		    body();
 		    body();
 		    dprintf("after body\n");
 		    dprintf("after body\n");
 		  }
 		  }