📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

Blogs >> zen's Blog

Created: Thursday, February 2 2006 20:34.01 CST Modified: Thursday, February 2 2006 20:36.03 CST
Printer Friendly ...
Some old code I recently saw again
Author: zen # Views: 614

Here is some code I wrote tht may be interesting to some of you. I was trying to work out how random-dot stereograms worked and decided to write some code to test some methods.

It's ugly code. ;] But it kinda works, and i think it shows how to do them. Oh yeah....it's all text.

to compile it, save it as stereo.c and then

$ cc -o stereo stereo.c -lm
$ ./stereo > stereo.txt

You may have to mess around a little to get the sizes you want.


#define HEIGHT 50
#define WIDTH 55

unsigned char screen[HEIGHT][WIDTH];
unsigned char map[HEIGHT][WIDTH];
unsigned char fill[11];

char f[]="!@#$%^&*()_+1234567890";


mkfill(char *s)
{
int i;
for(i=0;i<sizeof(fill);s[i]?i++:i)
{
  s[i]=rand()%90 + ' ';
}
}


int fn(int x,int y)
{
double a,b,c;
int ret;
a=(WIDTH/2)-x;
b=(HEIGHT/2)-y;
c=(sqrt(a*a/4 + b*b)/4);
ret=c>4?0:8-c;
if(a>0)ret=-ret;
return (sizeof(fill)+ret)%sizeof(fill);
}

main(int argc,char *argv[])
{
int h,w;
srand(time(0)^getpid());
for(h=0;h<HEIGHT;h++)
{
  for(w=0;w<WIDTH;w++)
  {
   map[h][w]=fn(w,h);
  }
}


if(argc<2)
for(h=0;h<HEIGHT;h++)
{
  int o;
  mkfill(fill);
  for(w=0;w<WIDTH;w++)
  {
   o = map[h][w];
   screen[h][w]=fill[(o+w)%sizeof(fill)];
  }
  printf("\t");
  printf("%s%s",fill,fill);
  printf("%s%s",fill,fill);
  for(w=0;w<WIDTH;w++)
  {
   printf("%c",screen[h][w]);
  }
  printf("%s%s",fill,fill);
  printf("%s%s",fill,fill);
  printf("\n");
}
else
{
  for(h=0;h<HEIGHT;h++)
  {
   printf("\t");
   for(w=0;w<WIDTH;w++)
   {
    printf("%c",map[h][w]+'0');
   }
   printf("\n");
  }
}
}


Coming soon (maybe)... animated ascii random dot stereograms.
(not sure yet if the maybe is the 'soon' or the 'coming' part.




Add New Comment
Comment:









There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit