home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / caway349.zip / BIN / CROAK3.C < prev    next >
C/C++ Source or Header  |  1996-06-17  |  936b  |  38 lines

  1. // croak3.c
  2. // C source example #3 on using UserDump API function
  3. #include <stdio.h>
  4. #include <i86.h>
  5.  
  6. char buffer[128];
  7. char *oldstring="This is going away, so it can say anything it wants";
  8. char *newstring="What I really wanted to say is this: Moo!";
  9.  
  10. void main(void)
  11. {
  12.     int i;
  13.     union REGS regs;
  14.     struct SREGS sregs;
  15.  
  16.     strcpy(buffer,oldstring);
  17.     segread(&sregs);
  18.     sregs.es=sregs.ds;
  19.     regs.x.edi=(int)buffer;
  20.     regs.w.cx=128;
  21.     regs.h.bl='A';  // ASCII dump
  22.     regs.h.bh=1;    // preset dump bytes
  23.     regs.w.dx='-X'; // -X fill buffer
  24.     regs.w.ax=0xff2f;
  25.     int386x(0x31,®s,®s,&sregs);
  26.     strcpy(buffer,newstring);
  27.     croaker();
  28. }
  29.  
  30. void croaker(void)
  31. {
  32.     int i,peekaboo=0x12345678;
  33.  
  34.     printf("%d ",*(int *)peekaboo);     // if this one doesn't GPF,
  35.     peekaboo=0x87654321;                // then
  36.     printf("%d\n",*(int *)peekaboo);    // this one will
  37. }
  38.