#include #include typedef struct { unsigned long signature1; unsigned long flags; unsigned short boot_device; short boot_filesystem; unsigned short memory_size; unsigned short spare2; unsigned char boot_filename[32]; unsigned char boot_string[64]; unsigned long signature2; } Milo_reboot_t; char *midoodim = "MIDOODIM"; main(int argc, char **argv) { Milo_reboot_t rb; long int *rebootblockp = (long int *)midoodim; long int rebootblock = *rebootblockp; long int data; int i; FILE *fd = fopen("/dev/kmem","w+"); fpos_t pos ; for (i=0; fread(&data,8,1,fd) == 1L; i++) { if (data == rebootblock) { pos = i*8; fsetpos(fd,&pos); fread(&rb, sizeof(Milo_reboot_t), 1, fd); rb.boot_device = strtoul(argv[1],NULL,0); strcpy(rb.boot_filename,argv[2]); strcpy(rb.boot_string,argv[3]); if (argc > 4) rb.spare2 = 1; fsetpos(fd,&pos); fwrite(&rb, sizeof(Milo_reboot_t), 1, fd); printf("New device: %x New kernel: %s New Args: %s\n",rb.boot_device,rb.boot_filename,rb.boot_string); return; } } fprintf(stderr,"Boot block not found after %d bytes\n",i); }