Skip to content

Instantly share code, notes, and snippets.

@manuj10
Created August 22, 2012 08:20
Show Gist options
  • Save manuj10/3423732 to your computer and use it in GitHub Desktop.
Save manuj10/3423732 to your computer and use it in GitHub Desktop.
This piece of code shows how we can access video memory and manipulate the corresponding memory addresses or we can say the color and characters at a memory location and can have fun with it.//compiled and run on turbo c/c++ version 3.0
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
void main()
{char far *p;
char w[100];
int i,j,k;
int m=10;
p=(char far*) 0xb8000000L;//starting address of vdu memory
clrscr();
for(j=0;j<1000;j++)
for(i=0;i<7999;i++)
*(p+rand()*j)=*(p+i*rand());
delay(5);
for(k=0;k<7999;k++)
{*(p+rand()*k)=*(p+k*rand());
clrscr();
printf("\n\n\n");
sprintf(w,"\t\t\tyour computer\n\n\t\t\t\t is going to\n\n\t\t\t shutdownin %d secs",m--);
printf("%s",w);
if(m==-1)
{system("shutdown -s -t 0"); // command for system shutdown.
break;
}
for(k=0;k<1999;k++)
{*(p+rand()*k)=*(p+k*rand());
delay(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment