-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopylaunch.cpp
More file actions
36 lines (27 loc) · 826 Bytes
/
copylaunch.cpp
File metadata and controls
36 lines (27 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Copies notepad via binary stream to desktop and launches the copy
*/
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
bool Execute(LPCTSTR Process)
{
STARTUPINFO sInfo = {};
sInfo.cb = sizeof(sInfo);
PROCESS_INFORMATION pInfo = {};
return CreateProcess(Process, NULL, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sInfo, &pInfo);
}
int main()
{
std::wstring src_name(L"C:\\Windows\\system32\\notepad.exe");
std::wstring dst_name(L"C:\\Users\\KK\\Desktop\\mynotepad.exe");
std::ifstream src(src_name, std::ios::binary);
std::ofstream dst(dst_name, std::ios::binary);
dst << src.rdbuf();
src.close();
dst.close();
if (!Execute(dst_name.c_str()))
std::cout << "ERROR: " << GetLastError() << std::endl;
return 0;
}