пиздец как же все сложно я вахуе наебенил вместе с гпт и руками какой то типо стрессер(изучал памятьи тп) ПИДЗЕЦ ПОЛНЫЙ code #include <windows.h> #include <thread> #include <atomic> #include <vector> #include <chrono> #include <cstring> HWND hwndCpu, hwndMem, hwndStart, hwndStop; std::atomic<bool> running(false); std::atomic<bool> stressCpu(false); std::atomic<bool> stressMem(false); std::vector<std::thread> stressThreads; const int CPU_THREADS = 8; const int MEM_THREADS = 8; const size_t BLOCK_SIZE = 50 * 1024 * 1024; void CpuStressFunc() { while (running.load()) { auto start = std::chrono::high_resolution_clock::now(); while (true) { auto now = std::chrono::high_resolution_clock::now(); auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count(); if (elapsedMs >= 20) break; for (volatile int i = 0; i < 100000; ++i) {} } std::this_thread::sleep_for(std::chrono::milliseconds(0)); } } void MemStressFunc() { std::vector<char*> blocks; try { while (running.load()) { for (int i = 0; i < 100 && running.load(); ++i) { char* block = new char[BLOCK_SIZE]; memset(block, 1, BLOCK_SIZE); blocks.push_back(block); } std::this_thread::sleep_for(std::chrono::milliseconds(50)); } } catch (std::bad_alloc&) { } for (auto b : blocks) delete[] b; } void StartStress() { running.store(true); stressThreads.clear(); if (stressCpu.load()) { for (int i = 0; i < CPU_THREADS; ++i) stressThreads.emplace_back(CpuStressFunc); } if (stressMem.load()) { for (int i = 0; i < MEM_THREADS; ++i) stressThreads.emplace_back(MemStressFunc); } } void StopStress() { running.store(false); for (auto& t : stressThreads) if (t.joinable()) t.join(); stressThreads.clear(); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: hwndCpu = CreateWindow(L"BUTTON", L"Стресс CPU", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, 20, 20, 100, 25, hwnd, (HMENU)1, nullptr, nullptr); hwndMem = CreateWindow(L"BUTTON", L"Стресс памяти", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, 150, 20, 120, 25, hwnd, (HMENU)2, nullptr, nullptr); hwndStart = CreateWindow(L"BUTTON", L"Старт", WS_VISIBLE | WS_CHILD, 40, 70, 80, 30, hwnd, (HMENU)3, nullptr, nullptr); hwndStop = CreateWindow(L"BUTTON", L"Стоп", WS_VISIBLE | WS_CHILD | WS_DISABLED, 160, 70, 80, 30, hwnd, (HMENU)4, nullptr, nullptr); SendMessage(hwndCpu, BM_SETCHECK, BST_CHECKED, 0); stressCpu = true; stressMem = false; break; case WM_COMMAND: switch (LOWORD(wParam)) { case 1: // CPU selected stressCpu = true; stressMem = false; SendMessage(hwndCpu, BM_SETCHECK, BST_CHECKED, 0); SendMessage(hwndMem, BM_SETCHECK, BST_UNCHECKED, 0); break; case 2: // Memory selected stressCpu = false; stressMem = true; SendMessage(hwndCpu, BM_SETCHECK, BST_UNCHECKED, 0); SendMessage(hwndMem, BM_SETCHECK, BST_CHECKED, 0); break; case 3: // Start if (!running.load()) { StartStress(); EnableWindow(hwndStart, FALSE); EnableWindow(hwndStop, TRUE); EnableWindow(hwndCpu, FALSE); EnableWindow(hwndMem, FALSE); } break; case 4: // Stop if (running.load()) { StopStress(); EnableWindow(hwndStart, TRUE); EnableWindow(hwndStop, FALSE); EnableWindow(hwndCpu, TRUE); EnableWindow(hwndMem, TRUE); } break; } break; case WM_DESTROY: StopStress(); PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int nCmdShow) { WNDCLASS wc = {}; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.lpszClassName = L"SimpleStresserClass"; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.hCursor = LoadCursor(nullptr, IDC_ARROW); if (!RegisterClass(&wc)) return 0; HWND hwnd = CreateWindow(wc.lpszClassName, L"Жёсткий стрессер", WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), CW_USEDEFAULT, CW_USEDEFAULT, 300, 180, nullptr, nullptr, hInstance, nullptr); if (!hwnd) return 0; ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg{}; while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } C #include <windows.h> #include <thread> #include <atomic> #include <vector> #include <chrono> #include <cstring> HWND hwndCpu, hwndMem, hwndStart, hwndStop; std::atomic<bool> running(false); std::atomic<bool> stressCpu(false); std::atomic<bool> stressMem(false); std::vector<std::thread> stressThreads; const int CPU_THREADS = 8; const int MEM_THREADS = 8; const size_t BLOCK_SIZE = 50 * 1024 * 1024; void CpuStressFunc() { while (running.load()) { auto start = std::chrono::high_resolution_clock::now(); while (true) { auto now = std::chrono::high_resolution_clock::now(); auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count(); if (elapsedMs >= 20) break; for (volatile int i = 0; i < 100000; ++i) {} } std::this_thread::sleep_for(std::chrono::milliseconds(0)); } } void MemStressFunc() { std::vector<char*> blocks; try { while (running.load()) { for (int i = 0; i < 100 && running.load(); ++i) { char* block = new char[BLOCK_SIZE]; memset(block, 1, BLOCK_SIZE); blocks.push_back(block); } std::this_thread::sleep_for(std::chrono::milliseconds(50)); } } catch (std::bad_alloc&) { } for (auto b : blocks) delete[] b; } void StartStress() { running.store(true); stressThreads.clear(); if (stressCpu.load()) { for (int i = 0; i < CPU_THREADS; ++i) stressThreads.emplace_back(CpuStressFunc); } if (stressMem.load()) { for (int i = 0; i < MEM_THREADS; ++i) stressThreads.emplace_back(MemStressFunc); } } void StopStress() { running.store(false); for (auto& t : stressThreads) if (t.joinable()) t.join(); stressThreads.clear(); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: hwndCpu = CreateWindow(L"BUTTON", L"Стресс CPU", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, 20, 20, 100, 25, hwnd, (HMENU)1, nullptr, nullptr); hwndMem = CreateWindow(L"BUTTON", L"Стресс памяти", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, 150, 20, 120, 25, hwnd, (HMENU)2, nullptr, nullptr); hwndStart = CreateWindow(L"BUTTON", L"Старт", WS_VISIBLE | WS_CHILD, 40, 70, 80, 30, hwnd, (HMENU)3, nullptr, nullptr); hwndStop = CreateWindow(L"BUTTON", L"Стоп", WS_VISIBLE | WS_CHILD | WS_DISABLED, 160, 70, 80, 30, hwnd, (HMENU)4, nullptr, nullptr); SendMessage(hwndCpu, BM_SETCHECK, BST_CHECKED, 0); stressCpu = true; stressMem = false; break; case WM_COMMAND: switch (LOWORD(wParam)) { case 1: // CPU selected stressCpu = true; stressMem = false; SendMessage(hwndCpu, BM_SETCHECK, BST_CHECKED, 0); SendMessage(hwndMem, BM_SETCHECK, BST_UNCHECKED, 0); break; case 2: // Memory selected stressCpu = false; stressMem = true; SendMessage(hwndCpu, BM_SETCHECK, BST_UNCHECKED, 0); SendMessage(hwndMem, BM_SETCHECK, BST_CHECKED, 0); break; case 3: // Start if (!running.load()) { StartStress(); EnableWindow(hwndStart, FALSE); EnableWindow(hwndStop, TRUE); EnableWindow(hwndCpu, FALSE); EnableWindow(hwndMem, FALSE); } break; case 4: // Stop if (running.load()) { StopStress(); EnableWindow(hwndStart, TRUE); EnableWindow(hwndStop, FALSE); EnableWindow(hwndCpu, TRUE); EnableWindow(hwndMem, TRUE); } break; } break; case WM_DESTROY: StopStress(); PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int nCmdShow) { WNDCLASS wc = {}; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.lpszClassName = L"SimpleStresserClass"; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.hCursor = LoadCursor(nullptr, IDC_ARROW); if (!RegisterClass(&wc)) return 0; HWND hwnd = CreateWindow(wc.lpszClassName, L"Жёсткий стрессер", WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), CW_USEDEFAULT, CW_USEDEFAULT, 300, 180, nullptr, nullptr, hInstance, nullptr); if (!hwnd) return 0; ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg{}; while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } типа во