帮我看一段程序,Runtime R6002错误。。。
下面这段程序是我在Hook API以后,模仿wpe的格式输出捕捉的数据,
但是在Print比较大的数据包的时候,被Hook的程序会有R6002,Runtime错误并当掉
如果把显示的数据限制为只输出10行的话,一点事都没有。。。
大家帮我看看,这段程序有什么问题?注释掉的部分是先写在缓冲区里,然后再一次
写入文件,但是问题是一样存在。。。
看了一下R6002的错误的解释,说什么
·A format string for a printf or scanf function contained a floating-point format specification, and the program did not contain any floating-point values or variables.
请大家给我挑挑毛病,我知道写得很烂。。。
void PrintRecvHexData(FILE *pf, BYTE FAR *pdata, int len)
{
int i, base;
char str0[64];
char str1[64];
char addr[32];
char temp[128];
char space[64];
int wd = 8;
int width = wd*2;
int lines = len/width;
bool flag = false;
if((len % width) != 0)
lines++;
if(lines == 0)
lines = 1;
/*
if(lines > 10)
lines = 10;
char *pBuffer = new char[lines * 100];
if(!pBuffer) return;
//memset(pBuffer, 0, lines * 100);
pBuffer[0] = '\0';
*/
for(int row=0; row<lines; row++)
{
base = row*width;
sprintf(addr, "%4.4X", base);
str0[0] = '\0';
str1[0] = '\0';
int col;
for(col=0; col<width; col++)
{
i = base + col;
if(i >= len)
{
flag = true;
break;
}
sprintf(temp, "%2.2X ", (unsigned char)pdata[i]);
if(col == (wd-1))
strcat(temp, " ");
strcat(str0, temp);
if(pdata[i] >= 32 && pdata[i] < 255)
sprintf(temp, "%c", (unsigned char)pdata[i]);
else
sprintf(temp, ".");
strcat(str1, temp);
}
int lenstr0 = strlen(str0);
if(lenstr0 < MAX_HEX_LENGTH)
{
memset(space, 32, MAX_HEX_LENGTH);
space[MAX_HEX_LENGTH] = '\0';
memcpy(space, str0, lenstr0);
strcpy(str0, space);
}
sprintf(temp, "%s %s ; %s\n", addr, str0, str1);
fprintf(pf, temp);
//strcat(pBuffer, temp);
if(flag)
break;
}
/*
if(pBuffer)
{
fprintf(pf, pBuffer);
delete[] pBuffer;
pBuffer = NULL;
}
*/
}