Professional Documents
Culture Documents
Summary
In this lab, students are expected to understand and build a C++ programme that will infect
Windows Registry to start every time the machine starts and make the mouse go crazy.
I left some errors and/or bugs on purpose to encourage students to find fixes and solutions
themselves. This is essential to teach them debugging and for developing their assignment
later. Below, you’ll find the corrections that you can share with students after they give up.
Please encourage them to find solutions themselves.
Activities
This is the correct code. The errors were related to data types that are passed to
RegSetValueEx function. Students should read and understand that function from
winreg.h online page.
Please don’t share the solution until at least 30 minutes of the lab session is passed.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
HKEY RunKey;
LPCTSTR valueP = TEXT("CO1508");
LPCTSTR data = TEXT("C:\\WINDOWS\\system32\\mspaint.exe");
if (RegOpenKey(HKEY_CURRENT_USER,
TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\RUN"), &RunKey) !=
ERROR_SUCCESS)
{
cout << "Unable to open registry key. Exit.\n";
return 0;
}
Here, students should start thinking about how to use the knowledge here for their
assignment. They should start working on these tasks to use in their assignment. Please
remind them that they should understand every line of code they’re writing.
h script solution