mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-06 05:24:29 +02:00
exeflat: support signal byte (clc/stc) to indicate compression to kernel
This commit is contained in:
parent
f51c8a5304
commit
ad368a4420
@ -90,7 +90,7 @@ static void usage(void)
|
|||||||
|
|
||||||
static int exeflat(const char *srcfile, const char *dstfile,
|
static int exeflat(const char *srcfile, const char *dstfile,
|
||||||
const char *start, short *silentSegments, short silentcount,
|
const char *start, short *silentSegments, short silentcount,
|
||||||
int UPX, exe_header *header)
|
int UPX, int patchsignal, exe_header *header)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
@ -99,6 +99,7 @@ static int exeflat(const char *srcfile, const char *dstfile,
|
|||||||
ULONG size, to_xfer;
|
ULONG size, to_xfer;
|
||||||
UBYTE **buffers;
|
UBYTE **buffers;
|
||||||
UBYTE **curbuf;
|
UBYTE **curbuf;
|
||||||
|
UBYTE *signal;
|
||||||
FILE *src, *dest;
|
FILE *src, *dest;
|
||||||
short silentdone = 0;
|
short silentdone = 0;
|
||||||
int compress_sys_file;
|
int compress_sys_file;
|
||||||
@ -222,6 +223,31 @@ static int exeflat(const char *srcfile, const char *dstfile,
|
|||||||
realentry = ((UWORD)(buffers[0][2]) << 8) + buffers[0][1] + 3;
|
realentry = ((UWORD)(buffers[0][2]) << 8) + buffers[0][1] + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal = &buffers[(size_t)(realentry / BUFSIZE)][(size_t)(realentry % BUFSIZE)];
|
||||||
|
if (patchsignal && UPX)
|
||||||
|
{
|
||||||
|
if (*signal == 0xF8) /* clc */
|
||||||
|
{
|
||||||
|
*signal = 0xF9; /* stc */
|
||||||
|
printf("Signal patched to indicate compression\n");
|
||||||
|
}
|
||||||
|
else if (*signal == 0xF9)
|
||||||
|
{
|
||||||
|
printf("Signal is already patched to indicate compression\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (patchsignal)
|
||||||
|
{
|
||||||
|
if (*signal == 0xF8) /* clc */
|
||||||
|
{
|
||||||
|
printf("Signal not patched as no compression used\n");
|
||||||
|
}
|
||||||
|
else if (*signal == 0xF9)
|
||||||
|
{
|
||||||
|
printf("Signal wrongly patched to indicate compression ??\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((dest = fopen(dstfile, "wb+")) == NULL)
|
if ((dest = fopen(dstfile, "wb+")) == NULL)
|
||||||
{
|
{
|
||||||
printf("Destination file %s could not be created\n", dstfile);
|
printf("Destination file %s could not be created\n", dstfile);
|
||||||
@ -423,7 +449,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
compress_sys_file = exeflat(argv[1], argv[2], argv[3],
|
compress_sys_file = exeflat(argv[1], argv[2], argv[3],
|
||||||
silentSegments, silentcount,
|
silentSegments, silentcount,
|
||||||
UPX, &header);
|
UPX, 1, &header);
|
||||||
if (!UPX)
|
if (!UPX)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
@ -470,7 +496,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
exeflat(tmpexe, argv[2], argv[3],
|
exeflat(tmpexe, argv[2], argv[3],
|
||||||
silentSegments, silentcount,
|
silentSegments, silentcount,
|
||||||
FALSE, &header);
|
FALSE, 0, &header);
|
||||||
remove(tmpexe);
|
remove(tmpexe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user