This is patch-poweroff.c in view mode; [Download] [Up]
/* * These patches apply only to the NeXTSTEP 3.1 distribution for NeXT hardware. * * Patches the loginwindow.app (of NeXTSTEP 3.1) to * - remove the restart and power buttons from the login window * * Patches the Workspace.app (of NeXTSTEP 3.1) to * - (effectively) ignore the power key * - remove the "Power Off" button from the Log Out alert panel * (a panel not usually seen, I think) * * Patches the WM.app (of NeXTSTEP 3.1) to * - remove the "Power Off" button from the Log Out alert panel * * Patches might be selectively applied by commenting out the appropriate * function call(s) in main(), below; however, this has not been fully tested. * * The effects listed above are produced regardless of the PowerOffDisabled * default's setting. This patch only causes the power key to be ignored * while the Workspace.app/WM.app is running; the power key is still "active" * at the login window. To disable the power key at the login window, set * the loginwindow's PowerOffDisabled default from a shell (as root): * dwrite loginwindow PowerOffDisabled YES * * This program must be run as root to work correctly. You should have backups * of the affected files before running this program, just in case. Log out * and log in as user 'exit' at the login window to have these changes "take * affect". * * THIS PROGRAM IS DISTRIBUTED WITHOUT WARRANTY, EXPRESS OR IMPLIED. * * Christopher J. Kane (kane@cs.purdue.edu) * Released into public domain; August 15, 1993. */ #include <libc.h> #include <errno.h> #define ERR(S) do {fprintf(stderr, "%s: %s: %s\n", argv[0], \ S, strerror(errno)); exit(1);} while(0) unsigned char loginpatch[8] = {0x0, 0x0, 0x42, 0x80, 0x4e, 0x5e, 0x4e, 0x75}; unsigned char wspatch1[2] = {0x42, 0x80}; unsigned char wspatch2[6] = {0x4e, 0x71, 0x4e, 0x71, 0x42, 0xa7}; unsigned char wspatch3[3] = {0x01, 0xf8, 0xaa}; unsigned char wspatch4[4] = {0x4e, 0x71, 0x4e, 0x71}; unsigned char wspatch5[2] = {0x42, 0x80}; unsigned char wmpatch1[42] = {0x42, 0xa7, 0x48, 0x79, 0x0, 0x05, 0xd2, 0x2a, 0x48, 0x79, 0x0, 0x05, 0xd1, 0xf7, 0x45, 0xf9, 0x0, 0x0, 0x9c, 0x62, 0x4e, 0x92, 0x58, 0x4f, 0x2e, 0x80, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71, 0x4e, 0x71}; unsigned char wmpatch2[2] = {0x60, 0x24}; void patch_loginwindow(char *argv[]) { int file; fprintf(stdout, "Patching loginwindow (1 patch)...\n"); file = open("/usr/lib/NextStep/loginwindow.app/loginwindow", O_WRONLY); if (-1==file) ERR("open[loginwindow]"); if (-1==lseek(file, 21170, SEEK_SET)) ERR("lseek[loginwindow patch]"); if (-1==write(file, loginpatch, 8)) ERR("write[loginwindow patch]"); if (-1==close(file)) ERR("lseek[loginwindow]"); } void patch_workspace(char *argv[]) { int file; fprintf(stdout, "Patching Workspace (5 patches)...\n"); file = open("/usr/lib/NextStep/Workspace.app/Workspace", O_WRONLY); if (-1==file) ERR("open[Workspace]"); if (-1==lseek(file, 106084, SEEK_SET)) ERR("lseek[Workspace patch 1]"); if (-1==write(file, wspatch1, 2)) ERR("write[Workspace patch 1]"); if (-1==lseek(file, 106714, SEEK_SET)) ERR("lseek[Workspace patch 2]"); if (-1==write(file, wspatch2, 6)) ERR("write[Workspace patch 2]"); if (-1==lseek(file, 106723, SEEK_SET)) ERR("lseek[Workspace patch 3]"); if (-1==write(file, wspatch3, 3)) ERR("write[Workspace patch 3]"); if (-1==lseek(file, 106782, SEEK_SET)) ERR("lseek[Workspace patch 4]"); if (-1==write(file, wspatch4, 4)) ERR("write[Workspace patch 4]"); if (-1==lseek(file, 110158, SEEK_SET)) ERR("lseek[Workspace patch 5]"); if (-1==write(file, wspatch5, 2)) ERR("write[Workspace patch 5]"); if (-1==fchmod(file, 06755)) ERR("chmod[Workspace]"); if (-1==close(file)) ERR("close[Workspace]"); } void patch_wm(char *argv[]) { int file; fprintf(stdout, "Patching WM (2 patches)...\n"); file = open("/usr/lib/NextStep/Workspace.app/WM.app/WM", O_WRONLY); if (-1==file) ERR("open[WM]"); if (-1==lseek(file, 348828, SEEK_SET)) ERR("lseek[WM patch 1]"); if (-1==write(file, wmpatch1, 42)) ERR("write[WM patch 1]"); if (-1==lseek(file, 349106, SEEK_SET)) ERR("lseek[WM patch 2]"); if (-1==write(file, wmpatch2, 2)) ERR("write[WM patch 2]"); if (-1==close(file)) ERR("close[WM]"); } void main(int argc, char *argv[]) { patch_loginwindow(argv); patch_workspace(argv); patch_wm(argv); fprintf(stdout, "Completed successfully.\n"); exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.