2011-09-20 91 views
-1

爲什麼像我這樣躺了多年的簡單的舊程序有時會引發我的反病毒?它拿起了這個編譯的exe文件,並說它可能是一個gen/dropper或類似的東西。簡單的程序激怒反病毒

下面的代碼:

#include "c:\\dxsdk\\include\\d3d9.h" 
#include "c:\\dxsdk\\include\\d3dx9.h" 
#include <time.h> 
#include <sstream> 
using namespace std; 

#define APPTITLE "DirectX Practice" 

LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM); 
int Initialize(HWND); 
void OnCleanup(HWND); 
void OnInterval(HWND); 
BOOL KEY_DOWN(UINT); 
BOOL KEY_UP(UINT); 

LPDIRECT3D9 d3d = NULL; 
LPDIRECT3DDEVICE9 d3ddev = NULL; 
LPDIRECT3DSURFACE9 backBuffer = NULL; 
LPDIRECT3DSURFACE9 surface = NULL; 
UINT Screen_Width = 0; 
UINT Screen_Height = 0; 

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) 
{ 
    // 
    MSG msg; 
    //////////// 

    Screen_Width = 1280;//GetSystemMetrics(SM_CXFULLSCREEN); 
    Screen_Height= 800;//GetSystemMetrics(SM_CYFULLSCREEN); 

    // can't use the real rez if it isn't standard 

    if(Screen_Width==0 || Screen_Height==0){ 
     MessageBox(
      NULL, 
      "Could not detect native screen resolution. Using Default.", 
      "Error", 
      MB_ICONERROR|MB_SYSTEMMODAL); 
     Screen_Width = 800; 
     Screen_Height = 600; 
    } 


    WNDCLASSEX wc; 
    wc.cbSize = sizeof(WNDCLASSEX); 

    wc.style = CS_HREDRAW|CS_VREDRAW; 
    wc.lpfnWndProc = (WNDPROC)WinProc; 
    wc.cbClsExtra = 0; 
    wc.cbWndExtra = 0; 
    wc.hInstance = hInstance; 
    wc.hIcon = NULL; 
    wc.hCursor = LoadCursor(NULL,IDC_ARROW); 
    wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); 
    wc.lpszMenuName = NULL; 
    wc.lpszClassName = APPTITLE; 
    wc.hIconSm = NULL; 

    if(!RegisterClassEx(&wc)) 
     return FALSE; 

    HWND hwnd; 
    hwnd = CreateWindow(
     APPTITLE, 
     APPTITLE, 
     WS_EX_TOPMOST|WS_VISIBLE|WS_POPUP, 
     CW_USEDEFAULT, 
     CW_USEDEFAULT, 
     Screen_Width, 
     Screen_Height, 
     NULL, 
     NULL, 
     hInstance, 
     NULL); 

    if(!hwnd) 
     return FALSE; 

    ShowWindow(hwnd,SW_SHOW/*nCmdShow*/); 
    UpdateWindow(hwnd); 

    if(!Initialize(hwnd)) 
     return FALSE; 

    int done = 0; 
    while(!done) 
    { 
     if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) 
     { 
      if(msg.message==WM_QUIT) 
      { 
       MessageBox(hwnd,"Exiting","Notice",MB_OK|MB_SYSTEMMODAL); 
       done = 1; 
      } 
      TranslateMessage(&msg); 
      DispatchMessage(&msg); 
     }else{ 
      OnInterval(hwnd); 
     } 
    } 

    return msg.wParam; 
} 

LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
    switch(msg) 
    { 
     case WM_DESTROY: 
      OnCleanup(hwnd); 
      PostQuitMessage(0); 
      return 0; 
     default: 
      return DefWindowProc(hwnd,msg,wParam,lParam); 
    } 
    return 0; 
} 

int Initialize(HWND hwnd) 
{ 
    d3d = Direct3DCreate9(D3D_SDK_VERSION); 
    if(d3d == NULL){ 
     MessageBox(hwnd,"Could not initialize Direct3D 9","Error",MB_ICONERROR|MB_SYSTEMMODAL); 
     return 0; 
    } 

    D3DPRESENT_PARAMETERS dp; 
    ZeroMemory(&dp,sizeof(dp)); 
    dp.Windowed = FALSE; 
    dp.SwapEffect = D3DSWAPEFFECT_DISCARD;  
    dp.BackBufferFormat = D3DFMT_X8R8G8B8; 
    dp.BackBufferCount = 1; 
    dp.BackBufferWidth = Screen_Width; 
    dp.BackBufferHeight = Screen_Height; 
    dp.hDeviceWindow = hwnd; 

    d3d->CreateDevice(
     D3DADAPTER_DEFAULT, 
     D3DDEVTYPE_HAL, 
     hwnd, 
     D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
     &dp, 
     &d3ddev); 

    if(d3ddev == NULL){ 
     MessageBox(hwnd,"Could not create Direct3D 9 device","Error",MB_ICONERROR|MB_SYSTEMMODAL); 
     return 0; 
    } 

    srand(time(NULL)); 

    d3ddev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0); 
    d3ddev->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&backBuffer); 

    if(d3ddev->CreateOffscreenPlainSurface(
      1294,614, 
      D3DFMT_X8R8G8B8, 
      D3DPOOL_DEFAULT, 
      &surface, 
      NULL) != D3D_OK) 
    { 
     MessageBox(hwnd,"Could not create off-screen data surface","Error",MB_ICONERROR|MB_SYSTEMMODAL); 
     return 0; 
    } 

    if(D3DXLoadSurfaceFromFile(
      surface, 
      NULL, 
      NULL, 
      "green.jpg", 
      NULL, 
      D3DX_DEFAULT, 
      0, 
      NULL) != D3D_OK) 
    { 
     MessageBox(hwnd,"Could not load image","Error",0); 
     return 0; 
    } 

    return 1; 
} 
void OnCleanup(HWND hwnd) 
{ 
    MessageBox(hwnd,"exiting","bye",MB_ICONERROR|MB_SYSTEMMODAL); 
    if(surface!=NULL) 
    { 
     surface->Release(); 
    } 
    if(d3ddev!=NULL) 
    { 
     d3ddev->Release(); 
    } 
    if(d3d!=NULL) 
    { 
     d3d->Release(); 
    } 
} 
void OnInterval(HWND hwnd) 
{ 
    /*RECT rect; 
    int r; 
    int g; 
    int b; 

    */ 
    if(KEY_DOWN(VK_ESCAPE)) 
     PostMessage(hwnd,WM_QUIT,0,0); 

    if(d3ddev == NULL) 
     return; 

    d3ddev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0); 



    if(d3ddev->BeginScene()) 
    { 
     /*r = rand()%255; 
     g = rand()%255; 
     b = rand()%255; 
     d3ddev->ColorFill(surface,NULL,D3DCOLOR_XRGB(r,g,b)); 

     rect.left = rand()%Screen_Width/2; 
     rect.top = rand()%Screen_Height/2; 
     rect.right = rect.left + rand()%Screen_Width/2; 
     rect.bottom = rect.top + rand()%Screen_Height/2; 
     */ 
     // blit surface's contents to the screen into the 
     // target rect area 
     d3ddev->StretchRect(surface,NULL,backBuffer,&rect,D3DTEXF_NONE); 

     d3ddev->EndScene(); 
    } 
    d3ddev->Present(NULL,NULL,NULL,NULL); 
} 


BOOL KEY_DOWN(UINT key) 
{ 
    return (BOOL)(GetAsyncKeyState(key) & 0x8000); 
} 
BOOL KEY_UP(UINT key) 
{ 
    return !((BOOL)(GetAsyncKeyState(key) & 0x8000)); 
} 

什麼是掀起了病毒掃描程序,更確切地說,我能做些什麼來避免呢?

+0

這個網站是關於編程的問題。超級用戶可能會有更好的運氣。還有你使用的是什麼A/V應用程序。 –

+0

看到這是一個關於避免可疑編程策略的問題,您對網站目的的評論一如既往,毫無用處。我目前正在使用Avira-Antivir,但在使用AVG時過去曾經歷過類似的事件。被編譯的應用程序始終來自Dev-C++。 – freenode5

+0

您是一位新用戶,您對我關於網站總體目標的評論「一如既往,無用」的評論至多是非建設性和貶損性的;在最壞的情況下,這對你在這裏的參與非常不利。我建議你改進(編輯)你的問題,接受它或離開它。 –

回答

0

檢查重新編譯時會發生什麼。如果問題不會持續存在,那麼可能是某個其他進程篡改了您的可執行文件。檢查爲什麼virri掃描儀匹配什麼模式在你的文件,如果你的編譯器的確產生的代碼(由傾銷編譯器的中間彙編)

希望幫助

+0

有時virri掃描儀也只是犯錯誤。 – UncleBens

+0

thx,我也會嘗試編譯一些導致我過去遇到問題的片段,只是爲了看看會發生什麼。 – freenode5

0

我認爲這是一個趨勢。防病毒軟件只能檢測到很多病毒。所以他們開始發現很多誤報,提醒用戶防病毒軟件有多好,他的電腦有多幸運。

我也經常遇到這個問題。一些用戶開始抱怨使用殺毒軟件發生誤報,我提交了一份報告,發佈了修正誤報的更新,並且在一個月內誤報又回來了。

最好的解決方案是數字簽名。經過數字簽名的文件具有來自可信來源的保證,因此大多數防病毒應用程序不會將其報告爲問題。缺點是你必須購買代碼簽名證書。