正在处理WinPCAP项目。尝试执行一些基本的指针和内存操作,但有很多错误。
我已经包括了两行,我正试图与包括一起运行。
另一个vsc++项目中的相同行工作正常。这是我犯的错误
0x75A79617英寸处未处理的异常
PKTUMPUXEXEX:微软C++
异常:std::内存分配错误
位置0x0012F8E4..
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include "DataTypes.h"
#include <sstream>
#include "EthernetLayer.h"
#include <pcap.h>
int* testPointer = new int[2];
delete[] testPointer;
编辑:
发现一些有用的东西。
下面的代码段是导致winpcap库崩溃的原因。
EthernetStructPointers* testData;
testData = (EthernetStructPointers*)pkt_data;
EthernetStruct newData;
memcpy(newData.DEST_ADDRESS, testData->DEST_ADDRESS, 6);
这些是结构的定义。
struct EthernetStructPointers
{
u_char DEST_ADDRESS[6];
u_char SOURCE_ADDRESS[6];
u_char TYPE[2];
};
struct EthernetStruct
{
u_char DEST_ADDRESS[6];
u_char SOURCE_ADDRESS[6];
u_char TYPE[2];
u_char* dataPointer;
string DestAddress;
string SourceAddress;
string Type;
int length;
};