static void quint_print(struct cntr_ent *ent, enum action act) { unsigned long long a; unsigned long long b; unsigned long long c; unsigned long long d; unsigned long long e; if(!ent) return; a=ent->count; b=ent->changed; c=ent->same; d=ent->deleted; e=ent->phase1; if(!(ent->versions & CNTR_TABULATE)) return; if(!e && !a && !b && !c) return; logc("% 18s ", ent->label); if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { logc("% 9llu ", a); logc("% 9llu ", b); logc("% 9llu ", c); logc("% 9llu ", d); } if(act==ACTION_RESTORE || act==ACTION_VERIFY) { logc("% 9s ", ""); //logc("% 9s ", ""); //logc("% 9s ", ""); //logc("% 9s ", ""); } if(act==ACTION_ESTIMATE) { logc("% 9s ", ""); logc("% 9s ", ""); logc("% 9llu\n", e); } else { logc("% 9llu |", a+b+c); logc("% 9llu\n", e); } }
void print_filecounters(struct cntr *p1c, struct cntr *c, enum action act, int client) { time_t now=time(NULL); if(!p1c || !c) return; border(); logc("Start time: %s\n", getdatestr(p1c->start)); logc(" End time: %s\n", getdatestr(now)); logc("Time taken: %s\n", time_taken(now-p1c->start)); logc("% 22s % 9s % 9s % 9s % 9s |% 9s\n", " ", "New", "Changed", "Unchanged", "Total", "Scanned"); table_border(); if(act==ACTION_RESTORE) { restore_print("Files:", c->file); restore_print("Files (encrypted):", c->enc); restore_print("Meta data:", c->meta); restore_print("Meta (encrypted):", c->encmeta); restore_print("Directories:", c->dir); restore_print("Soft links:", c->slink); restore_print("Hard links:", c->hlink); restore_print("Special files:", c->special); restore_print("EFS files:", c->efs); restore_print("Grand total:", c->total); } else if(act==ACTION_VERIFY) { restore_print("Verified files:", c->file); restore_print("Verified files (enc):", c->enc); restore_print("Verified meta data:", c->meta); restore_print("Verified meta (enc):", c->encmeta); restore_print("Verified directories:", c->dir); restore_print("Verified soft links:", c->slink); restore_print("Verified hard links:", c->hlink); restore_print("Verified special:", c->special); restore_print("Verified EFS files:", c->efs); restore_print("Grand total:", c->total); } else { quint_print("Files:", c->file, c->file_changed, c->file_same, p1c->file, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Files (encrypted):", c->enc, c->enc_changed, c->enc_same, p1c->enc, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Meta data:", c->meta, c->meta_changed, c->meta_same, p1c->meta, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Meta data (encrypted):", c->encmeta, c->meta_changed, c->meta_same, p1c->encmeta, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Directories:", c->dir, c->dir_changed, c->dir_same, p1c->dir, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Soft links:", c->slink, c->slink_changed, c->slink_same, p1c->slink, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Hard links:", c->hlink, c->hlink_changed, c->hlink_same, p1c->hlink, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Special files:", c->special, c->special_changed, c->special_same, p1c->special, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("EFS files:", c->efs, c->efs_changed, c->efs_same, p1c->efs, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Grand total:", c->total, c->total_changed, c->total_same, p1c->total, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); } table_border(); bottom_part(p1c, c, act); border(); }
static void border(void) { logc("--------------------------------------------------------------------------------\n"); }
static void bottom_part(struct cntr *a, struct cntr *b, enum action act) { logc("\n"); logc(" Warnings: % 11llu\n", b->warning + a->warning); logc("\n"); logc(" Bytes estimated: % 11llu", a->byte); logc("%s\n", bytes_to_human(a->byte)); if(act==ACTION_ESTIMATE) return; logc(" Bytes in backup: % 11llu", b->byte); logc("%s\n", bytes_to_human(b->byte)); logc(" Bytes received: % 11llu", b->recvbyte); logc("%s\n", bytes_to_human(b->recvbyte)); logc(" Bytes sent: % 11llu", b->sentbyte); logc("%s\n", bytes_to_human(b->sentbyte)); }
static void quint_print(const char *msg, unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long d, enum lform form) { switch(form) { /* Windows has awful difficultly printf-ing more than one '%llu' type thing at a time, sometimes segfaulting, so split them all up. */ case FORMAT_SERVER: if(!d && !a && !b && !c) return; logc("% 22s ", msg); logc("% 9llu ", a); logc("% 9llu ", b); logc("% 9llu ", c); logc("% 9llu |", a+b+c); logc("% 9llu\n", d); break; case FORMAT_CLIENT_DATA: if(!d && !a && !b && !c) return; logc("% 22s ", msg); logc("% 9llu ", a); logc("% 9llu ", b); logc("% 9s ", "-"); logc("% 9llu |", a+b+c); logc("% 9llu\n", d); break; case FORMAT_CLIENT_NODE: if(!d && !a && !b && !c) return; logc("% 22s ", msg); logc("% 9s ", "-"); logc("% 9s ", "-"); logc("% 9s ", "-"); logc("% 9s |", "-"); logc("% 9llu\n", d); break; case FORMAT_CLIENT_RESTORE: if(!d && !a && !b && !c) return; logc("% 22s ", msg); logc("% 9s ", "-"); logc("% 9s ", "-"); logc("% 9s ", "-"); logc("% 9llu |", d); logc("% 9s\n", "-"); break; } }
static void table_border(void) { logc("% 22s --------------------------------------------------\n", ""); }
static void bottom_part(struct cntr *c, enum action act) { unsigned long long l; struct cntr_ent **e=c->ent; logc("\n"); logc(" Warnings: % 11llu\n", get_count(e, CMD_WARNING)); logc("\n"); logc(" Bytes estimated: % 11llu", get_count(e, CMD_BYTES_ESTIMATED)); logc("%s\n", bytes_to_human(get_count(e, CMD_BYTES_ESTIMATED))); if(act==ACTION_ESTIMATE) return; if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { l=get_count(e, CMD_BYTES); logc(" Bytes in backup: % 11llu", l); logc("%s\n", bytes_to_human(l)); } if(act==ACTION_RESTORE) { l=get_count(e, CMD_BYTES); logc(" Bytes attempted: % 11llu", l); logc("%s\n", bytes_to_human(l)); } if(act==ACTION_VERIFY) { l=get_count(e, CMD_BYTES); logc(" Bytes checked: % 11llu", l); logc("%s\n", bytes_to_human(l)); } if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { l=get_count(e, CMD_BYTES_RECV); logc(" Bytes received: % 11llu", l); logc("%s\n", bytes_to_human(l)); } if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED || act==ACTION_RESTORE) { l=get_count(e, CMD_BYTES_SENT); logc(" Bytes sent: % 11llu", l); logc("%s\n", bytes_to_human(l)); } }
void dump0(DWORD* address, int dwords) { char scratch[128]; char scratch2[128]; char* ptr; char ch; MEMORY_BASIC_INFORMATION mem_info; for(int i = 0; i < dwords; i++) { sprintf_s(scratch, 128, "%08X", *address); if(!IsBadReadPtr((void*)(*address), 1)) { strcat_s(scratch, 128, " "); ptr = (char*)(*address); // show protection if(!VirtualQuery(ptr, &mem_info, sizeof(MEMORY_BASIC_INFORMATION))) { strcat_s(scratch, 128, "----"); } else { ch = mem_info.Protect & 0xFF; if(ch == 0x10) strcat_s(scratch, 128, "x---"); else if(ch == 0x20) strcat_s(scratch, 128, "xr--"); else if(ch == 0x40) strcat_s(scratch, 128, "xrw-"); else if(ch == 0x80) strcat_s(scratch, 128, "xrwc"); else if(ch == 0x01) strcat_s(scratch, 128, "----"); else if(ch == 0x02) strcat_s(scratch, 128, "-r--"); else if(ch == 0x04) strcat_s(scratch, 128, "-rw-"); else if(ch == 0x08) strcat_s(scratch, 128, "-rwc"); else strcat_s(scratch, 128, "????"); } // show as characters strcat_s(scratch, 128, " "); for(int x = 0; x < 64; x++) { if(IsBadReadPtr(ptr, 1)) strcpy_s(scratch2, 128, "?"); else { if(ptr[0] < 0x20 || ptr[0] > 0x7F) strcpy_s(scratch2, 128, "."); else sprintf_s(scratch2, 128, "%c", *ptr); } ptr++; strcat_s(scratch, 128, scratch2); } } logc(scratch); address++; } }