This is the mail archive of the cygwin-apps mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
As the title says. * Makefile.in: Add rules to build, but not install, rebase-dump.exe. * rebase-db.h: Declare new dump_rebasedb* functions. * rebase-db.c (dump_rebasedb_header): New function. (dump_rebasedb_entry): New function. (dump_rebasedb): New function. * rebase-dump.c: New file. -- Chuck
? rebase-dump.c Index: Makefile.in =================================================================== RCS file: /cvs/cygwin-apps/rebase/Makefile.in,v retrieving revision 1.7 diff -u -p -r1.7 Makefile.in --- Makefile.in 29 Jul 2011 13:17:44 -0000 1.7 +++ Makefile.in 29 Jul 2011 13:54:45 -0000 @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.7 2011/07/29 13:17:44 cwilson Exp $ +# $Id: Makefile.in,v 1.6 2011/07/21 19:10:04 corinna Exp $ # @configure_input@ # Makefile for rebase @@ -77,6 +77,9 @@ LIBIMAGEHELPER = imagehelper/libimagehel REBASE_OBJS = rebase.$(O) rebase-db.$(O) $(LIBOBJS) REBASE_LIBS = $(LIBIMAGEHELPER) +REBASE_DUMP_OBJS = rebase-dump.$(O) rebase-db.$(O) $(LIBOBJS) +REBASE_DUMP_LIBS = + PEFLAGS_OBJS = peflags.$(O) $(LIBOBJS) PEFLAGS_LIBS = @@ -86,7 +89,7 @@ SRC_DISTFILES = aclocal.m4 configure.ac build-aux/config.guess build-aux/config.sub \ build-aux/install-sh getopt.h_ getopt_long.c -all: libimagehelper rebase$(EXEEXT) \ +all: libimagehelper rebase$(EXEEXT) rebase-dump$(EXEEXT) \ peflags$(EXEEXT) rebaseall peflagsall libimagehelper: @@ -99,6 +102,11 @@ rebase.$(O):: rebase.c rebase-db.h Makef rebase-db.$(O):: rebase-db.c rebase-db.h Makefile +rebase-dump$(EXEEXT): $(REBASE_DUMP_OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(REBASE_DUMP_OBJS) $(REBASE_DUMP_LIBS) + +rebase-dump.$(O):: rebase-dump.c rebase-db.h Makefile + peflags$(EXEEXT): $(PEFLAGS_OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(PEFLAGS_OBJS) @@ -182,7 +190,8 @@ dist: srcdist .PHONY: clean clean: - $(RM) *.$(O) rebase$(EXEEXT) peflags$(EXEEXT) *.tmp + $(RM) *.$(O) *.tmp + $(RM) rebase$(EXEEXT) peflags$(EXEEXT) rebase-dump$(EXEEXT) $(RM) rebaseall peflagsall .PHONY: realclean Index: rebase-db.c =================================================================== RCS file: /cvs/cygwin-apps/rebase/rebase-db.c,v retrieving revision 1.1 diff -u -p -r1.1 rebase-db.c --- rebase-db.c 29 Jul 2011 13:17:44 -0000 1.1 +++ rebase-db.c 29 Jul 2011 13:54:45 -0000 @@ -18,6 +18,13 @@ */ #include "rebase-db.h" +#if defined(__MSYS__) +/* MSYS has no inttypes.h */ +# define PRIx64 "llx" +#else +# include <inttypes.h> +#endif + const char IMG_INFO_MAGIC[4] = "rBiI"; const ULONG IMG_INFO_VERSION = 1; @@ -40,3 +47,84 @@ img_info_name_cmp (const void *a, const return strcmp (((img_info_t *) a)->name, ((img_info_t *) b)->name); } +void +dump_rebasedb_header (FILE *f, img_info_hdr_t const *h) +{ + if (h == NULL) + { + fprintf (f, "Rebase DB Header is null\n"); + return; + } + + fprintf (f, + "Header\n" + " magic : %c%c%c%c\n" + " machine: %s\n" + " version: %d\n" + " base : 0x%0*" PRIx64 "\n" + " offset : 0x%08lx\n" + " downflg: %s\n" + " count : %ld\n", + h->magic[0], h->magic[1], h->magic[2], h->magic[3], + (h->machine == IMAGE_FILE_MACHINE_I386 + ? "i386" + : (h->machine == IMAGE_FILE_MACHINE_AMD64 + ? "x86_64" + : "unknown")), + h->version, + (h->machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12), + h->base, + h->offset, + (h->down_flag ? "true" : "false"), + h->count); +} + +void +dump_rebasedb_entry (FILE *f, + img_info_hdr_t const *h, + img_info_t const *entry) +{ + if (h == NULL) + { + fprintf (f, "Rebase DB Header is null\n"); + return; + } + if (entry == NULL) + { + fprintf (f, "Rebase DB Entry is null\n"); + return; + } + fprintf (f, + "%-*s base 0x%0*" PRIx64 " size 0x%08lx slot 0x%08lx %c\n", + h->machine == IMAGE_FILE_MACHINE_I386 ? 45 : 41, + entry->name, + h->machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12, + entry->base, + entry->size, + entry->slot_size, + entry->flag.needs_rebasing ? '*' : ' '); +} + +void +dump_rebasedb (FILE *f, img_info_hdr_t const *h, + img_info_t const *list, unsigned int sz) +{ + unsigned int i; + if (h == NULL) + { + fprintf (f, "Rebase DB Header is null\n"); + return; + } + if (list == NULL) + { + fprintf (f, "Rebase DB List is null\n"); + return; + } + + dump_rebasedb_header (stdout, h); + for (i = 0; i < sz ; ++i) + { + dump_rebasedb_entry (stdout, h, &(list[i])); + } +} + Index: rebase-db.h =================================================================== RCS file: /cvs/cygwin-apps/rebase/rebase-db.h,v retrieving revision 1.1 diff -u -p -r1.1 rebase-db.h --- rebase-db.h 29 Jul 2011 13:17:44 -0000 1.1 +++ rebase-db.h 29 Jul 2011 13:54:45 -0000 @@ -20,6 +20,7 @@ #define REBASE_DB_H #include <windows.h> +#include <stdio.h> #define roundup(x,y) ((((x) + ((y) - 1)) / (y)) * (y)) #define roundup2(x,y) (((x) + (y) - 1) & ~((y) - 1)) @@ -65,6 +66,12 @@ typedef struct _img_info int img_info_cmp (const void *a, const void *b); int img_info_name_cmp (const void *a, const void *b); +void dump_rebasedb_header (FILE *f, img_info_hdr_t const *h); +void dump_rebasedb_entry (FILE *f, img_info_hdr_t const *h, + img_info_t const *entry); +void dump_rebasedb (FILE *f, img_info_hdr_t const *h, + img_info_t const *list, unsigned int sz); + #ifdef __cplusplus } #endif
Attachment:
rebase-dump.c
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |