project.exe已触发由动态分配引起的断点 我在C++中编写PATHER,作为项目的一部分,我使用ZyDIS编写DISSaseBulter,IM发送内存操作码,以便基本上把每个字节都转换成DEC并将其推到数组中,函数将返回指向数组的指针结构和大小。关键是在调用者函数中——在调用函数之后,我试图按照返回的大小分配内存 ZyanU8* data = new ZyanU8[temp.size];

project.exe已触发由动态分配引起的断点 我在C++中编写PATHER,作为项目的一部分,我使用ZyDIS编写DISSaseBulter,IM发送内存操作码,以便基本上把每个字节都转换成DEC并将其推到数组中,函数将返回指向数组的指针结构和大小。关键是在调用者函数中——在调用函数之后,我试图按照返回的大小分配内存 ZyanU8* data = new ZyanU8[temp.size];,c++,dynamic-memory-allocation,C++,Dynamic Memory Allocation,在运行时,我得到一个错误“project.exe触发了一个断点”,实际上它发生在每一个大的分配中,它也与它的类型是ZyanU8这一事实无关,我用int尝试过它,我得到了相同的结果 我怎样才能修好它 struct memArray { int* arr; int size; }; memArray convert_to_ZyanU8(DWORD* Total, DWORD size) { int size_ = 0; int* dwTA=new int[(size

在运行时,我得到一个错误“project.exe触发了一个断点”,实际上它发生在每一个大的分配中,它也与它的类型是ZyanU8这一事实无关,我用int尝试过它,我得到了相同的结果 我怎样才能修好它

struct memArray
{
    int* arr;
    int size;
};

memArray convert_to_ZyanU8(DWORD* Total, DWORD size)
{
    int size_ = 0;
    int* dwTA=new int[(size/0x400)*0x100];
    for (int j = 0; j < size / 0x400; j++)//understand size
    {
        for (int i = 0; i < 0x100; i++)
        {
            char buffer[9];
            sprintf_s(buffer, "%x", Total[j*0x100+i]);
            int counter = 0;
            for (int n = 0; n < 8; n+=2)
            {
                unsigned int xfirst;
                std::stringstream sfirst;
                sfirst << std::hex << *(buffer+n);
                sfirst >> xfirst;
                unsigned int xsecond;
                std::stringstream ssecond;
                ssecond << std::hex << *(buffer+n+1);
                ssecond >> xsecond;
                dwTA[j*0x100+i*4 + counter] = xfirst*16+xsecond;
                ++counter;
                ++size_;
                if (size_ == 12287)
                    int a = 3;
            }
        }
    }
    memArray memarray;
    memarray.arr = dwTA;
    memarray.size = size_;
    return memarray;
}


void ZydisDA(DWORD* Total,DWORD size)
{
    memArray temp = convert_to_ZyanU8(Total, size);
    ZyanU8* data = new ZyanU8[temp.size];
    int counter = 0;
    for (int i = 0; i < temp.size; ++i)
    {
        data[i] = temp.arr[i];
    }
    // Initialize decoder context
    ZydisDecoder decoder;
    ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_COMPAT_32,ZYDIS_ADDRESS_WIDTH_32);

    // Initialize formatter. Only required when you actually plan to do instruction
    // formatting ("disassembling"), like we do here
    ZydisFormatter formatter;
    ZydisFormatterInit(&formatter, ZYDIS_FORMATTER_STYLE_INTEL);

    // Loop over the instructions in our buffer.
    // The runtime-address (instruction pointer) is chosen arbitrary here in order to better
    // visualize relative addressing
    ZyanU64 runtime_address = 0x00401000;
    ZyanUSize offset = 0;
    const ZyanUSize length = temp.size;
    ZydisDecodedInstruction instruction;
    while ((ZydisDecoderDecodeBuffer(&decoder, data + offset, length - offset, &instruction)))
    {
        // Print current instruction pointer.
        printf("%016" PRIX64 "  ", runtime_address);

        // Format & print the binary instruction structure to human readable format
        char buffer[256];
        ZydisFormatterFormatInstruction(&formatter, &instruction, buffer, sizeof(buffer),        runtime_address);
        puts(buffer);

        offset += instruction.length;
        runtime_address += instruction.length;
    }
}
struct memArray
{
int*arr;
整数大小;
};
memArray将_转换为_ZyanU8(DWORD*总计,DWORD大小)
{
整数大小=0;
int*dwTA=新int[(大小/0x400)*0x100];
对于(int j=0;j
这可能是崩溃前某个时间发生堆损坏的结果。您可能需要调试。如果这没有帮助,您可能希望在代码中添加一些日志记录,以跟踪new和delete的使用情况以及分配大小。第二种选择是使用valgrind或AddressSanitizer之类的程序来帮助您实现这一点。您可以通过位移位提取
DWORD
的字节。没有必要绕道字符串。您的代码容易出错且速度慢,请提供一个可复制的最小程序。