Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

dbghelp.c

Go to the documentation of this file.
00001 /*
00002  *      This program is free software; you can redistribute it and/or
00003  *      modify it under the terms of the GNU General Public License
00004  *      as published by the Free Software Foundation; either version
00005  *      2 of the License, or (at your option) any later version.
00006  *
00007  *  Copyright 2005 Spiro Trikaliotis
00008  *
00009 */
00010 
00021 #define DBG_USERMODE
00022 
00024 #define DBG_PROGNAME "ARCH.LIB"
00025 
00026 #include "debug.h"
00027 
00028 #include "arch.h"
00029 
00030 #include <windows.h>
00031 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <ctype.h>
00035 
00036 // #define DBG_DUMP_RAW_READ
00037 // #define DBG_DUMP_RAW_WRITE
00038 
00039 /*-------------------------------------------------------------------*/
00040 /*--------- DEBUGGING FUNCTIONS -------------------------------------*/
00041 
00042 #if DBG
00043 
00044 void 
00045 dbg_memdump(const char *Where, const unsigned char *InputBuffer, const unsigned int Count)
00046 {
00047     unsigned i;
00048     char outputBufferChars[17];
00049     char outputBuffer[100];
00050     char *p;
00051 
00052     p = outputBuffer;
00053 
00054     DBG_PRINT((DBG_PREFIX "%s: (0x%04x)", Where, Count));
00055 
00056     for (i=0; i<Count; i++) 
00057     {
00058         p += sprintf(p, "%02x ", (unsigned int) InputBuffer[i]);
00059 
00060         if (i % 16 == 7)
00061         {
00062             p += sprintf(p, "- ");
00063         }
00064 
00065         outputBufferChars[i % 16] = isprint(InputBuffer[i]) ? InputBuffer[i] : '.';
00066 
00067         if (i % 16 == 15)
00068         {
00069             outputBufferChars[(i % 16) + 1] = 0;
00070             DBG_PRINT((DBG_PREFIX "%04x: %-50s  %s",
00071                 i & 0xfff0, outputBuffer, outputBufferChars));
00072             p = outputBuffer;
00073         }
00074     }
00075 
00076     if (i % 16 != 0)
00077     {
00078         outputBufferChars[i % 16] = 0;
00079         DBG_PRINT((DBG_PREFIX "%04x: %-50s  %s",
00080             i & 0xfff0, outputBuffer, outputBufferChars));
00081     }
00082 }
00083 
00084 #endif // #if DBG

Generated on Sun Apr 30 18:45:46 2006 for opencbm by  doxygen 1.4.2