| #include "hive-internals.h" |
| #include <unistd.h> |
| #include <fcntl.h> |
| #include <stdio.h> |
| #include <wchar.h> |
| |
| int main(int argc, char **argv) { |
| if(argc < 2) { |
| fprintf(stderr, "Usage: %s <path>\n", argv[0]); |
| return -1; |
| } |
| int fd = open(argv[1], O_RDONLY); |
| if(fd == -1) { |
| perror(argv[1]); |
| return 1; |
| } |
| struct regf_header head; |
| int s = read(fd, &head, sizeof head); |
| if(s < 0) { |
| perror("read"); |
| return 1; |
| } |
| close(fd); |
| if(s < sizeof head) { |
| fprintf(stderr, "%s: %s: reading %d bytes", argv[0], argv[1], s); |
| return 1; |
| } |
| char hive_name[256] = { 0 }; |
| printf("Magic: \"%c%c%c%c\"\n" |
| "Unknown DWORD 1: 0x%lx\n" |
| "Unknown DWORD 2: 0x%lx\n" |
| "Last modify date: %s\n" |
| "Version: %u.%u\n" |
| "Offset: 0x%lx\n" |
| "Blocks: 0x%lx\n" |
| "Name: %s\n" |
| "ChkSum: 0x%lx\n", |
| head.magic[0], head.magic[1], head.magic[2], head.magic[3], |
| (unsigned long int)head.sequence1, |
| (unsigned long int)head.sequence2, |
| head.last_modified, |
| (unsigned int)head.major_ver, (unsigned int)head.minor_ver, |
| (unsigned long int)head.offset, |
| (unsigned long int)head.blocks, |
| hive_name, |
| (unsigned long int)head.csum); |
| return 0; |
| } |