home *** CD-ROM | disk | FTP | other *** search
- /*
- * 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);
- }
-