home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
001-099
/
ff002.lzh
/
cc
/
zapstring.c
< prev
Wrap
C/C++ Source or Header
|
1985-12-25
|
1KB
|
63 lines
/*
* This is a quick hack to zap strings in an executable file
* by replacing their first byte with a null character. In most
* cases, this will effectively turn them into null strings.
* This is useful to prevent venders from bombarding you with
* irritating startup messages everytime you run their program.
* Grrr....
*
*/
#include <stdio.h>
main (argc, argv)
int argc;
char *argv[];
{
FILE *fin = NULL;
register int ch;
register char *sp;
long resync;
if (argc != 3) {
Fatal (fin, "usage: zapstring <string> <file>");
}
fin = fopen (argv[2], "r+");
sp = argv[1];
if (fin == NULL) {
Fatal (fin, "zapstring: can't open file");
}
while ((ch = fgetc (fin)) != EOF) {
if (ch == *sp) {
resync = ftell (fin);
while ((ch = fgetc (fin)) != EOF && ch == *++sp && *sp != '\000');
if (ch != EOF && *sp == '\000') {
if (fseek (fin, resync - 1, 0) != 0) {
Fatal (fin, "zapstring: can't resync!");
}
if (fputc ('\000', fin) != '\000') {
Fatal (fin, "zapstring: patch failed in fputc()!");
}
break;
} else {
sp = argv[1];
if (fseek (fin, resync, 0) != 0) {
Fatal (fin, "zapstring: can't resync!");
}
}
}
}
fclose (fin);
exit (0);
}
Fatal (fin, why)
FILE *fin;
char *why;
{
fprintf (stderr, "%s\n", why);
fclose (fin);
exit (1);
}