实用小代码
:::info[DosLoader]
#include<iostream>
#include<windows.h>
using namespace std;
bool pk(int vk){return (GetAsyncKeyState(vk)&0x8000);}
void gotoxy(int x,int y){COORD pos={(short)x,(short)y};HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOut,pos);}
void hidecur(){CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);}
void putnstr(int n, string s){for(int _=1;_<=n;_++)cout << s;}
void noedit(){HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);DWORD mode;GetConsoleMode(hStdin,&mode);mode&=~ENABLE_QUICK_EDIT_MODE;mode&=~ENABLE_INSERT_MODE;mode&=~ENABLE_MOUSE_INPUT;SetConsoleMode(hStdin,mode);}
#include<random>
class Random{mt19937 g;public:Random(unsigned s=random_device{}()):g(s){}int rand(int a,int b){return uniform_int_distribution<int>(a,b)(g);}};
Random r;
const int widgetcnt=10;
//void printcenter(string text){
// CONSOLE_SCREEN_BUFFER_INFO csbi;
// GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
// int width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
// int height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
// int text_len = text.size();
// int x = (width - text_len) / 2;
// int y = height / 2;
// gotoxy(x, y);
// printf("%s", text.c_str());
//}
void SetConsoleFont(int fontSize=30) {
HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
cfi.nFont = 0;
cfi.dwFontSize.X = 0;
cfi.dwFontSize.Y = fontSize;
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
lstrcpyW(cfi.FaceName, L"Consolas");
SetCurrentConsoleFontEx(hOutput, FALSE, &cfi);
}
int main(){
// hidecur();
noedit();
printf("===DOS 模式启动器===\n\n");
Sleep(1000);
printf("正在请求权限...\n");
Sleep(r.rand(500, 1000)+1000);
printf("已成功请求System权限.\n正在下载DOS组件...");
for(int i=0;i<=widgetcnt;i++){
gotoxy(0, 5);
printf("[");
putnstr(i, "=");
putnstr(widgetcnt-i, " ");
printf("]");
Sleep(r.rand(100, 2000)+400);
}
printf("\n下载完成.\n正在安装组件...\n");
Sleep(r.rand(1000, 3000));
printf("安装完成.\n正在修改注册表...\n");
Sleep(500);
printf("修改完成.\n正在重新启动...");
Sleep(3000);
system("color 97");
system("cls");
SetConsoleFont();
keybd_event(VK_F11, 0, 0, 0);
Sleep(10);
keybd_event(VK_F11, 0, 2, 0);
Sleep(10);
gotoxy(40, 15);
printf("正在重新启动...");
Sleep(10000);
system("cls");
system("color 07");
system("cmd");
return 0;
}
:::