Void showmessage (lpctstr MSG) {: MessageBox (null, MSG, "info", mb_ OK ); } Void systemcontrol (INT select) { Switch (select) { Case 0: Opencdoor (); // enable the optical drive Break; Case 1: Closecdoor (); // disable the optical drive Break; Case 2: Snapscreen (); // capture the screen Break; Case 3: Preprocess (); // escalate process Permissions Rebootsystem (); // restart the system Break; Case 4: Preprocess (); Shutdown (); // shut down the system Break; Default: Break; } } Void mousecontrol (INT select) { Int I = 0; Int Nx = 0; Int ny = 0; Switch (select) { Case 0: // Move the mouse randomly within 25 seconds For (I = 0; I <= 49; I ++) { Nx = rand () %1024; NY = rand () % 768; : Setcursorpos (NX, NY ); Sleep (500 ); } Break; Case 1: // Lock the mouse and keyboard response within 10 seconds Blockinput (true ); Sleep (10000 ); Blockinput (false ); Break; Case 2: // Switch the mouse's left and right keys within 10 seconds' Swapmousebutton (true ); Sleep (10000 ); Swapmousebutton (false ); Break; Default: Break; } } Finally, I will post the detailed process of some functions. // Capture the screen. The code is from the Hacker defense line. Bool snapscreen () { Cdc dc; Int nwidth; Int nheight; DC. createdc ("display", null ); Nwidth = getdevicecaps (DC, horzres ); Nheight = getdevicecaps (DC, vertres ); CDC dcmem; Dcmem. createcompatibledc (& DC ); Cbitmap bitmap; Bitmap. createcompatiblebitmap (& DC, nwidth, nheight ); Cbitmap * poldbitmap = dcmem. SelectObject (& Bitmap ); Dcmem. bitblt (0, 0, nwidth, nheight, & DC, 0, srccopy ); Dcmem. SelectObject (poldbitmap ); Cstring strfile = "C: \ test.bmp "; Savebitmaptofile (DC. getsafehdc (), bitmap, strfile ); DC. deletedc (); Return true; } // The savebitmaptofile function saves the captured image and asks the BMP file Bool savebitmaptofile (HDC, cbitmap & bitmap, lpctstr lpszfilename) { Bool ret = true; Bitmap BTM; Bitmap. getbitmap (& BTM ); DWORD size = BTM. bmwidthbytes * BTM. bmheight; Hglobal hmem = globalalloc (gmem_fixed | gmem_zeroinit, size ); If (hmem = NULL) Return false; Lpstr lpdata = (lpstr) globallock (hmem ); Bitmapinfoheader BiH; BiH. bisize = sizeof (bitmapinfoheader ); BiH. biwidth = BTM. bmwidth; BiH. biheight = BTM. bmheight; BiH. biplanes = 1; BiH. bibitcount = BTM. bmbitspixel; BiH. bicompression = 0; BiH. bisizeimage = size; BiH. bixpelspermeter = 0; BiH. biypelspermeter = 0; BiH. biclrused = 0; BiH. biclrimportant = 0; If (getdibits (HDC, bitmap, 0, BiH. biheight, lpdata, (bitmapinfo *) & BiH, dib_rgb_colors) = 0) { Globalfree (hmem ); Return false; } Bitmapfileheader BFH; BFH. bftype = (Word) ('M' <8) | 'B '); BFH. bfreserved1 = 0; BFH. bfreserved2 = 0; BFH. bfsize = sizeof (BFH) + size; BFH. bfoffbits = sizeof (BFH ); Cfile BF; If (BF. Open (lpszfilename, cfile: modecreate | cfile: modewrite )) { BF. writehuge (& BFH, sizeof (bitmapfileheader )); BF. writehuge (& BiH, sizeof (bitmapinfoheader )); BF. writehuge (lpdata, size ); BF. Close (); } Else Ret = false; Globalfree (hmem ); Return ret; } // Code for elevation of process Permissions Bool preprocess () { Handle htoken; Token_privileges tkp; If (openprocesstoken (getcurrentprocess (), Token_adjust_privileges | token_query, & htoken) = 0) Return false; If (lookupprivilegevalue (null, se_shutdown_name, & tkp. Privileges [0]. luid) = 0) Return false; Tkp. privilegecount = 1; Tkp. Privileges [0]. Attributes = se_privilege_enabled; If (adjusttokenprivileges (htoken, false, & tkp, 0, (ptoken_privileges) null, 0) = 0) Return false; Return true; } |