m0_50244597 2021-03-20 15:13 采纳率: 11.1%
浏览 51
已采纳

一些错误[这是一个占位符]

void Code::asm_code_inject(HANDLE handle)
{
    LPVOID addr = VirtualAllocEx(handle, nullptr, this->length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if (addr == nullptr)
        return;

    DWORD write_size = 0;
    BOOL ret = WriteProcessMemory(handle, addr, this->code, this->length, &write_size);
    if (ret == 0 || write_size != this->length)
    {
        VirtualFreeEx(handle, addr, 0, MEM_RELEASE);
        return;
    }

    HANDLE thread = CreateRemoteThread(handle, nullptr, 0, LPTHREAD_START_ROUTINE(addr), nullptr, 0, nullptr);
    if (thread == nullptr)
    {
        VirtualFreeEx(handle, addr, 0, MEM_RELEASE);
        return;
    }

    [[maybe_unused]] DWORD wait_status = WaitForSingleObject(thread, INFINITE);
    CloseHandle(thread);
    VirtualFreeEx(handle, addr, 0, MEM_RELEASE);

#ifdef _DEBUG
    std::wcout << L"Wait Status: " << wait_status << std::endl;
    std::wcout << L"Asm Code: ";
    for (size_t i = 0; i < this->length; i++)
        std::cout << std::hex << int(code[i]) << " ";
    std::cout << std::endl;
    std::wcout << L"Code Length: " << std::dec << this->length << std::endl;
#endif
}

我要把这些从网上得到的代码(一部分)编译dll

[Error] cannot convert 'DWORD* {aka long unsigned int*}' to 'SIZE_T* {aka long long unsigned int*}' for argument '5' to 'WINBOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*)'

[Warning] 'maybe_unused' attribute directive ignored [-Wattributes]

环境:ISOC++11

  • 写回答

4条回答 默认 最新

  • 幻灰龙 2021-03-20 23:41
    关注

    要读错误提示:

    [Error] cannot convert 'DWORD* {aka long unsigned int*}' to 'SIZE_T* {aka long long unsigned int*}' for argument '5' to 'WINBOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*)'

    [Warning] 'maybe_unused' attribute directive ignored [-Wattributes]

     

    加粗部分就是说 WriteProcessMemory 的第 5 个参数类型不匹配。需要的是 SIZE_T* ,你传入的是 &write_size,而 write_size 是 DWORD 类型

     

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看