2013-03-05 104 views
1

美好的一天,我正在尝试为我的游戏创建框架,以便让我的编码变得更容易。 我刚刚创建了添加对象的函数,但创建了创建索引缓冲区的部分后,反病毒一直告诉我:“发现病毒: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); 
    } 
} 

谁能告诉我是什么原因,为什么反病毒检测出这是一个病毒,如何解决它?

+0

也许您的计算机上存在感染系统上所有可执行文件的病毒...它是唯一被检测为病毒的病毒? – neagoegab 2013-03-05 12:35:52

+0

是的,这是唯一的一个 – jakubinf 2013-03-05 12:36:19

+0

,当我从dev-> GetDevice() - > CreateIndexBuffer(...)注释到该部分}}返回S_OK;它不会将其检测为病毒。 – jakubinf 2013-03-05 12:37:07

回答

2

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

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

+0

由于* that *?!?的反病毒引发警告, – cybermonkey 2015-10-03 17:35:28

0

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

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

因此,ACTUAL解决方案通常要么完全删除AV,要么将其替换为不同的产品[顺便说一下,这两者都可能相当棘手,因为AV软件往往难以卸载 - 很好的理由,当然,你不希望第一个病毒打你的机器卸载你的AV软件 - 这意味着有时AV卸载本身并不是卸载它应该]的一切。

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

+0

这是真的,但如果......我不想在未来让我的游戏变为私人游戏,但是公开。我会告诉所有其他人卸载他们的防病毒软件吗? – jakubinf 2013-03-05 12:58:10

+0

然后,您需要说服AV提供商,您的游戏应该被列入白名单,以便检测您认为自己做错了什么。当然,你的代码可能会发生一些变化,所以它可能不成问题。 – 2013-03-05 15:02:17