static void print_data(const char *buf,int len) { int i=0; if (len<=0) return; printf("[%03X] ",i); for (i=0;i<len;) { printf("%02X ",(int)((unsigned char)buf[i])); i++; if (i%8 == 0) printf(" "); if (i%16 == 0) { print_asc(&buf[i-16],8); printf(" "); print_asc(&buf[i-8],8); printf("\n"); if (i<len) printf("[%03X] ",i); } } if (i%16) { int n; n = 16 - (i%16); printf(" "); if (n>8) printf(" "); while (n--) printf(" "); n = i%16; if (n > 8) n = 8; print_asc(&buf[i-(i%16)],n); printf(" "); n = (i%16) - n; if (n>0) print_asc(&buf[i-n],n); printf("\n"); } }
void dump_data(int level, const uint8_t *buf, size_t len) { int i=0; if (len<=0) return; if (!DEBUGLVL(level)) return; DEBUG(level, (__location__ " dump data of size %i:\n", (int)len)); DEBUGADD(level,("[%03X] ",i)); for (i=0;i<len;) { DEBUGADD(level,("%02X ",(int)buf[i])); i++; if (i%8 == 0) DEBUGADD(level,(" ")); if (i%16 == 0) { print_asc(level,&buf[i-16],8); DEBUGADD(level,(" ")); print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n")); if (i<len) DEBUGADD(level,("[%03X] ",i)); } } if (i%16) { int n; n = 16 - (i%16); DEBUGADD(level,(" ")); if (n>8) DEBUGADD(level,(" ")); while (n--) DEBUGADD(level,(" ")); n = MIN(8,i%16); print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " )); n = (i%16) - n; if (n>0) print_asc(level,&buf[i-n],n); DEBUGADD(level,("\n")); } DEBUG(level, (__location__ " dump data of size %i finished\n", (int)len)); }
static void dbg_rw_punival(BOOL charmode, const char *name, int depth, prs_struct *ps, char *in_buf, char *out_buf, int len) { int i; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) { for (i = 0; i < len; i++) SSVAL(out_buf,2*i,RSVAL(in_buf, 2*i)); } else { for (i = 0; i < len; i++) SSVAL(out_buf, 2*i, SVAL(in_buf, 2*i)); } } else { if (ps->bigendian_data) { for (i = 0; i < len; i++) RSSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); } else { for (i = 0; i < len; i++) SSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); } } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)out_buf, 2*len); else { for (i = 0; i < len; i++) DEBUG(5,("%04x ", out_buf[i])); } DEBUG(5,("\n")); }
BOOL prs_uint8s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len) { int i; char *q = prs_mem_get(ps, len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { for (i = 0; i < len; i++) data8s[i] = CVAL(q,i); } else { for (i = 0; i < len; i++) SCVAL(q, i, data8s[i]); } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset ,name)); if (charmode) print_asc(5, (unsigned char*)data8s, len); else { for (i = 0; i < len; i++) DEBUG(5,("%02x ", data8s[i])); } DEBUG(5,("\n")); ps->data_offset += len; return True; }
static int print_key(struct ntdb_context *the_ntdb, NTDB_DATA key, NTDB_DATA dbuf, void *state) { printf("key %d bytes: ", (int)key.dsize); print_asc((const char *)key.dptr, key.dsize); printf("\n"); return 0; }
BOOL prs_string2(BOOL charmode, const char *name, prs_struct *ps, int depth, STRING2 *str) { int i; char *q = prs_mem_get(ps, str->str_max_len); if (q == NULL) return False; if (UNMARSHALLING(ps)) { str->buffer = (unsigned char *)prs_alloc_mem(ps,str->str_max_len); if (str->buffer == NULL) return False; } if (UNMARSHALLING(ps)) { for (i = 0; i < str->str_str_len; i++) str->buffer[i] = CVAL(q,i); } else { for (i = 0; i < str->str_str_len; i++) SCVAL(q, i, str->buffer[i]); } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)str->buffer, str->str_str_len); else { for (i = 0; i < str->str_str_len; i++) DEBUG(5,("%02x ", str->buffer[i])); } DEBUG(5,("\n")); ps->data_offset += str->str_str_len; return True; }
static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) { printf("key %d bytes: ", (int)key.dsize); print_asc((const char *)key.dptr, key.dsize); printf("\n"); return 0; }
static int print_rec(TDB_CONTEXT *context, TDB_DATA key, TDB_DATA dbuf, void *state) { fprintf(pDumpFile,"\nkey %u bytes\n", (unsigned) key.dsize); print_asc((unsigned char*)key.dptr, key.dsize); fprintf(pDumpFile,"\ndata %u bytes\n", (unsigned) dbuf.dsize); print_data((unsigned char*)dbuf.dptr, dbuf.dsize); return 0; }
static int print_rec(struct ntdb_context *the_ntdb, NTDB_DATA key, NTDB_DATA dbuf, void *state) { printf("\nkey %d bytes\n", (int)key.dsize); print_asc((const char *)key.dptr, key.dsize); printf("\ndata %d bytes\n", (int)dbuf.dsize); print_data((const char *)dbuf.dptr, dbuf.dsize); return 0; }
static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) { printf("\nkey %d bytes\n", (int)key.dsize); print_asc((const char *)key.dptr, key.dsize); printf("\ndata %d bytes\n", (int)dbuf.dsize); print_data((const char *)dbuf.dptr, dbuf.dsize); return 0; }
static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) { #if 0 print_conn_key(key); print_conn_data(dbuf); return 0; #else printf("\nkey %d bytes\n", key.dsize); print_asc(key.dptr, key.dsize); printf("\ndata %d bytes\n", dbuf.dsize); print_data(dbuf.dptr, dbuf.dsize); return 0; #endif }
int main(void) { char str[MAXSTR][100]; char choice = 0; int i; int ch; int n; n = getstrings(str); printf("n = %d\n", n); /*for(i = 0 ; i<n ; i++) { puts(str[i]); } */ while(choice != 'q') { choice = 0; choice = menu(); printf("Choice is %d\n", choice); switch(choice){ case 'a': print_org(n, str); break; case 'b': print_asc(n, str); break; case 'c': print_len(n, str); break; case 'd': print_wrd(n, str); break; case 'e': continue; break; default: break; } while(isspace(getchar()) != 1) continue; } printf("Done.\n"); return 0; }
BOOL prs_uint32s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len) { int i; char *q = prs_mem_get(ps, len * sizeof(uint32)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) { for (i = 0; i < len; i++) data32s[i] = RIVAL(q, 4*i); } else { for (i = 0; i < len; i++) data32s[i] = IVAL(q, 4*i); } } else { if (ps->bigendian_data) { for (i = 0; i < len; i++) RSIVAL(q, 4*i, data32s[i]); } else { for (i = 0; i < len; i++) SIVAL(q, 4*i, data32s[i]); } } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)data32s, 4*len); else { for (i = 0; i < len; i++) DEBUG(5,("%08x ", data32s[i])); } DEBUG(5,("\n")); ps->data_offset += (len * sizeof(uint32)); return True; }
bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len) { int i; char *q = prs_mem_get(ps, len * sizeof(uint16)); if (q == NULL) return False; if (UNMARSHALLING(ps)) { if (ps->bigendian_data) { for (i = 0; i < len; i++) data16s[i] = RSVAL(q, 2*i); } else { for (i = 0; i < len; i++) data16s[i] = SVAL(q, 2*i); } } else { if (ps->bigendian_data) { for (i = 0; i < len; i++) RSSVAL(q, 2*i, data16s[i]); } else { for (i = 0; i < len; i++) SSVAL(q, 2*i, data16s[i]); } } DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name)); if (charmode) print_asc(5, (unsigned char*)data16s, 2*len); else { for (i = 0; i < len; i++) DEBUGADD(5,("%04x ", data16s[i])); } DEBUGADD(5,("\n")); ps->data_offset += (len * sizeof(uint16)); return True; }
static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) { print_asc(key.dptr, key.dsize); printf("\n"); return 0; }
static int print_key(TDB_CONTEXT *context, TDB_DATA key, TDB_DATA dbuf, void *state) { print_asc((unsigned char*)key.dptr, key.dsize); printf("\n"); return 0; }
BOOL prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str) { unsigned int len = 0; unsigned char *p = (unsigned char *)str->buffer; uint8 *start; char *q; uint32 max_len; uint16* ptr; if (MARSHALLING(ps)) { for(len = 0; str->buffer[len] != 0; len++) ; q = prs_mem_get(ps, (len+1)*2); if (q == NULL) return False; start = (uint8*)q; for(len = 0; str->buffer[len] != 0; len++) { if(ps->bigendian_data) { /* swap bytes - p is little endian, q is big endian. */ q[0] = (char)p[1]; q[1] = (char)p[0]; p += 2; q += 2; } else { q[0] = (char)p[0]; q[1] = (char)p[1]; p += 2; q += 2; } } /* * even if the string is 'empty' (only an \0 char) * at this point the leading \0 hasn't been parsed. * so parse it now */ q[0] = 0; q[1] = 0; q += 2; len++; DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); print_asc(5, (unsigned char*)start, 2*len); DEBUG(5, ("\n")); } else { /* unmarshalling */ uint32 alloc_len = 0; q = ps->data_p + prs_offset(ps); /* * Work out how much space we need and talloc it. */ max_len = (ps->buffer_size - ps->data_offset)/sizeof(uint16); /* the test of the value of *ptr helps to catch the circumstance where we have an emtpty (non-existent) string in the buffer */ for ( ptr = (uint16 *)q; *ptr && (alloc_len <= max_len); alloc_len++) /* do nothing */ ; /* should we allocate anything at all? */ str->buffer = (uint16 *)prs_alloc_mem(ps,alloc_len * sizeof(uint16)); if ((str->buffer == NULL) && (alloc_len > 0)) return False; p = (unsigned char *)str->buffer; len = 0; /* the (len < alloc_len) test is to prevent us from overwriting memory that is not ours...if we get that far, we have a non-null terminated string in the buffer and have messed up somewhere */ while ((len < alloc_len) && (*(uint16 *)q != 0)) { if(ps->bigendian_data) { /* swap bytes - q is big endian, p is little endian. */ p[0] = (unsigned char)q[1]; p[1] = (unsigned char)q[0]; p += 2; q += 2; } else { p[0] = (unsigned char)q[0]; p[1] = (unsigned char)q[1]; p += 2; q += 2; } len++; } if (len < alloc_len) { /* NULL terminate the UNISTR */ str->buffer[len++] = '\0'; } DEBUG(5,("%s%04x %s: ", tab_depth(depth), ps->data_offset, name)); print_asc(5, (unsigned char*)str->buffer, 2*len); DEBUG(5, ("\n")); } /* set the offset in the prs_struct; 'len' points to the terminiating NULL in the UNISTR so we need to go one more uint16 */ ps->data_offset += (len)*2; return True; }