杀毒软件一直将我的项目识别为病毒

3

你好,我正在尝试为我的游戏创建框架,以使编写代码更加容易。 我刚刚创建了一个添加对象的函数,但是在我创建索引缓冲区的部分之后,杀毒软件一直提示我:“发现病毒: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

渲染函数的代码如下:

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);
    }
}

有人能告诉我为什么杀毒软件会将这个文件检测为病毒,以及如何解决?

是的,这是唯一的一个。 - user704565
当我注释掉从dev->GetDevice()->CreateIndexBuffer(...)到} } return S_OK;的部分时,它就不会将其检测为病毒。 - user704565
1
可能是未定义行为(UB)。几乎和鼻子精灵一样好。 - PlasmaHH
只有在我运行它时,它才被检测为病毒。扫描未检测到任何问题。 当我在virustotal上测试它时,没有发现病毒,0/40。 - user704565
1
我不认为这个问题应该被踩。 - André Puel
显示剩余2条评论
2个回答

2
问题已经解决。这几乎与索引缓冲区无关。原因是由于两个未关闭的输出文件流。
无论如何,感谢大家!我至少学到了一些新东西。

杀毒软件因为那个而发出警告?!? - AStopher

1
杀毒软件使用“启发式”(高级猜测的花哨说法!)来检测“不良模式”。这听起来像是“误报”。
正确的解决方法是向您的杀毒软件提供商报告问题,并让他们发布一个新版本的“检测”,不会错误地检测到有效代码。但是,除非您有一个非常好的杀毒软件提供商,否则在接下来的几周内您很可能不会看到任何改变。
因此,实际的解决方案通常是要么完全删除杀毒软件,要么用其他产品替换它[顺便说一句,这两个都可能非常棘手,因为杀毒软件往往使自己难以卸载-出于好的原因,当然,您不希望第一个病毒攻击您的机器时卸载您的杀毒软件-这意味着有时杀毒软件本身的卸载并没有卸载应该卸载的所有内容]。
有时只需关闭“实时扫描”即可。

那是真的,但是如果我将来不想让我的游戏变成私有的,而是公共的呢?我要告诉所有其他人卸载他们的防病毒软件吗? - user704565
然后,您需要说服 AV 供应商将您的游戏列入“白名单”,以便检测到它认为您正在做错的任何事情。当然,您的代码在之间可能已经发生了一些变化,因此这可能不是一个问题。 - Mats Petersson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接