好的一天,我正在尝试为我的游戏创建框架,使我的编码更容易。我刚刚创建了添加对象的函数,但在创建了创建索引缓冲区的部分后,防病毒软件一直告诉我:“发现病毒: 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);
}
}谁能告诉我原因是什么,为什么防病毒软件会将其检测为病毒,以及如何修复它?
发布于 2013-03-05 21:11:27
问题解决了。而且它与索引缓冲区几乎没有任何关系。原因是因为2个未关闭的输出文件流。
无论如何,感谢大家!我至少学到了一些新东西。
发布于 2013-03-05 20:46:52
杀毒软件使用“启发式”(“高级猜测”的花哨词汇!)来检测“坏模式”。这听起来像是“假阳性”。
正确的解决方法是向反病毒提供商报告问题,并让他们发布新版本的“检测”,不会错误地检测有效代码。然而,除非你有一个非常好的AV提供商,否则在接下来的几周内你不太可能从中看到很多东西。
因此,实际的解决方案通常是要么完全删除AV,要么将其替换为不同的产品。顺便说一句,这两种方法都相当棘手,因为AV软件往往很难卸载-当然,出于很好的原因,您不会希望第一个病毒攻击您的计算机来卸载您的AV软件-这意味着有时AV卸载本身并不会卸载它应该卸载的所有内容。
有时只需关闭“实时扫描”就足够了。
https://stackoverflow.com/questions/15223927
复制相似问题