【问题标题】:Antivirus keeps detecting my project as a virus防病毒软件不断将我的项目检测为病毒
【发布时间】:2017-11-17 17:54:51
【问题描述】:

美好的一天,我正在尝试为我的游戏创建框架,以使我更轻松地编写代码。 我刚刚创建了添加对象的函数,但是在创建了创建索引缓冲区的部分之后,防病毒软件一直告诉我:“发现病毒:Win32:Evo-gen [Susp]”,我不知道为什么。 加载对象的函数代码:

HRESULT Framework::AddObject(Object* obj){
    std::vector<short> indices;
    std::vector<VertexType> vertices;
    obj->GetData(indices,vertices);
    IDirect3DVertexBuffer9* cVBuffer;
    IDirect3DIndexBuffer9* cIBuffer;
    int at=vertexBuffers.size();
    vertexBuffers.push_back(cVBuffer);
    indexBuffers.push_back(cIBuffer);
    unsigned int sOfVerts=vertices.size()*sizeof VertexType;
    unsigned int sOfIndices=indices.size()*sizeof(short);
    vCount.push_back(vertices.size());
    iCount.push_back(indices.size());
    HRESULT hr=device->GetDevice()->CreateVertexBuffer(sOfVerts,0,D3DFVF_VertexType,D3DPOOL_DEFAULT,&vertexBuffers[at],NULL);
    if(FAILED(hr)){
        EndWithError("Failed to load object",hr);
        return hr;
    } else {
        void* p_vertices;
        hr=vertexBuffers[at]->Lock(0,sOfVerts,(void**)&p_vertices,0);
        if(FAILED(hr)){
            EndWithError("Failed to lock buffer",hr);
            return hr;
        } else {
            applog<<"Successfuly created VertexBuffer for object "<<obj->GetClass()<<"["<<at<<"], vertices size: "<<sOfVerts<<", vertices count: "<<vertices.size()<<std::endl;
            memcpy(p_vertices,&vertices[0],sOfVerts);
            vertexBuffers[at]->Unlock();
        }
    }
    hr=device->GetDevice()->CreateIndexBuffer(sOfIndices,D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&indexBuffers[at],NULL);
    if(FAILED(hr)){
        EndWithError("Failed to load indices",hr);
        return hr;
    } else {
        void* p_indices;
        hr=indexBuffers[at]->Lock(0,sOfIndices,(void**)&p_indices,0);
        if(FAILED(hr)){
            EndWithError("Failed to lock index buffer",hr);
            return hr;
        } else {
            memcpy(p_indices,&indices[0],sOfIndices);
            indexBuffers[at]->Unlock();            
        }
    }
    return S_OK;
}
//device->GetDevice() - returns IDirect3DDevice9*
//obj->GetData(vector<int>& indices,vector<VertexType>& vertices); //gets vertices and indices
//obj->GetClass() const; - returns name of class of object, because Object is base class for another objects

Render 函数如下所示:

void Framework::RenderFrame(){
    IDirect3DDevice9* dev=device->GetDevice();
    if(dev!=NULL){
        dev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(32,32,64),1.0f,0);
        if(SUCCEEDED(dev->BeginScene())){
            for(unsigned int i=0;i<vertexBuffers.size();i++){
                IDirect3DDevice9* dev=device->GetDevice();
                dev->SetStreamSource( 0, vertexBuffers[i], 0, sizeof( VertexType ) );
                dev->SetFVF( D3DFVF_VertexType );
                dev->SetIndices(indexBuffers[i]);
                //dev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
                dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,vCount[i],0,iCount[i]/3);
            }
            dev->EndScene();
        }
        dev->Present(NULL,NULL,NULL,NULL);
    }
}

谁能告诉我这是什么原因,为什么杀毒软件会将此检测为病毒以及如何修复它?

【问题讨论】:

  • 也许您的计算机上有病毒感染了系统上的所有可执行文件...它是唯一被检测为病毒的病毒?
  • 是的,只有这个
  • 并且当我从 dev->GetDevice()->CreateIndexBuffer(...) 到 } } 评论该部分时,返回 S_OK;它不会将其检测为病毒。
  • 可能是 UB。几乎和鼻守护进程一样好。
  • 我认为这个问题不应该被否决。

标签: c++ directx virus


【解决方案1】:

问题解决了。它几乎与索引缓冲区无关。 原因是因为 2 个未关闭的输出文件流。

无论如何感谢大家!我至少学到了一些新东西。

【讨论】:

  • 杀毒软件因为那个?!?
【解决方案2】:

防病毒软件使用“启发式”(“高级猜测”的花哨词!)来检测“不良模式”。这听起来像是“误报”。

正确的解决方法是将问题报告给您的 AV 提供商,并让他们发布不会错误检测有效代码的新版本“检测”。但是,除非您有一个非常好的 AV 提供商,否则您在接下来的几周内不太可能从中看到太多。

因此,实际的解决方案通常是完全删除 AV 或将其替换为不同的产品 [顺便说一下,这两者都可能非常棘手,因为 AV 软件往往使自己难以卸载 - 永远当然,你不希望第一个病毒感染你的机器来卸载你的 AV 软件——这意味着有时 AV 卸载本身并没有卸载它应该卸载的所有东西]。

有时只需关闭“实时扫描”就足够了。

【讨论】:

  • 确实如此,但如果……我不想让我的游戏在未来成为私有的,而是公开的。我会告诉所有其他人卸载他们的防病毒软件吗?
  • 那么您需要说服 AV 提供商您的游戏应该被“列入白名单”,以检测它认为您做错了什么。当然,您的代码可能会在两者之间发生一些变化,所以这可能不是问题。
猜你喜欢
  • 2013-05-08
  • 2018-10-23
  • 2011-03-15
  • 2010-10-13
  • 2010-11-26
  • 1970-01-01
  • 2019-10-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多