From: Steve Lionel [Steve.Lionel@compaq.com] Sent: Wednesday, March 08, 2000 12:45 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: how to patch image linked /debug to run without invoking the debugger when image is run as foreign command. On Wed, 08 Mar 2000 16:47:24 GMT, snead_george_w@my-deja.com wrote: >Years back, there was a short patch procedure >applied against a field in the image's header >which disabled the debugger from starting up when >the image was run. Does anyone remember this >patch. Or, is there a better way? On VAX, the following will do it: $ patch/absolute/nonew_version/journal=nl: 'p1' examine/byte 20; deposit/byte 20 = \ and 0fe; update; exit On Alpha, there's no PATCH (and the offsets are different) - the following C program will do it: #include #include #include main (int argc, char *argv[]) { FILE *inf; fpos_t pos; unsigned char buffer[512]; int offset = 0x50; int turn_off = 1; if (argc < 3) { fprintf(stderr, "Syntax: {off | on} image_file\n"); exit(EXIT_FAILURE); } if (strcmp(argv[1], "off") == 0) turn_off = 1; else if (strcmp(argv[1], "on") == 0) turn_off = 0; else { fprintf(stderr, "Specify OFF or ON as the first parameter\n"); exit(EXIT_FAILURE); } if (argc == 4) { if (strcmp(argv[3], "vax") == 0) offset = 0x20; else if (strcmp(argv[3], "alpha") == 0) offset = 0x50; else { fprintf(stderr, "Unknown system type: %s\n", argv[3]); exit(EXIT_FAILURE); } } if ((inf = fopen(argv[2], "r+b")) == NULL) { fprintf(stderr, "Unable to open %s\n", argv[2]); exit(EXIT_FAILURE); } fgetpos(inf, &pos); if (fread(buffer, sizeof(buffer), 1, inf) != 1) { fprintf(stderr, "Error reading %s\n", argv[2]); exit(EXIT_FAILURE); } printf("Old value: %x\n", buffer[offset]); if (turn_off) buffer[offset] &= 0xFE; else buffer[offset] |= 0x1; printf("New value: %x\n", buffer[offset]); fsetpos(inf, &pos); if (fwrite(buffer, sizeof(buffer), 1, inf) != 1) { fprintf(stderr, "Error writing %s\n", argv[2]); exit(EXIT_FAILURE); } fclose(inf); } Steve Lionel (mailto:Steve.Lionel@compaq.com) Fortran Engineering Compaq Computer Corporation, Nashua NH Compaq Fortran web site: http://www.compaq.com/fortran