home *** CD-ROM | disk | FTP | other *** search
- /* æÑαó¿ß¡δÑ Σπ¡¬µ¿¿ ñ½∩ »α«óÑન ºáΘ¿Γ,
- ¿¡¿µ¿á½¿ºáµ¿¿ ßΓαπ¬Γπα ñá¡¡δσ TRACER, ¡Ñ
- »αÑñ¡áº¡áτÑ¡á ñ½∩ ¿ß»«½∞º«óá¡¿∩ «Γñѽ∞¡«
- «Γ TRACER */
-
- #include"ftrace.h"
- #include"cpu.h"
- #include"intr.h"
- #include<alloc.h>
- #include<process.h>
- #include<stdio.h>
-
- fidt oldidt,newidt={0xffff,0l};
- void * it=0;
- unsigned char test,testc,EnIDT;
- unsigned char bufc[4],bufc1[4],far * oldcommand,far * oldcommand1;
- unsigned char far * fstack=0l;
-
- static unsigned char far * c;
-
- #ifdef DEBUG
- void DEBstep(void) /*No enter!!!*/
- {
- void interrupt (* DEB)(void);
- if(EnIDT)
- {
- DEB=getvect(1);
- setvect(1,ftrace);
- step();
- setvect(1,DEB);
- }else{
- _lidt(&newidt);
- step();
- _lidt(&oldidt);
- }
- }
- #endif
-
- void texit(cod)
- int cod;
- {
- if(!EnIDT)
- {
- _lidt(&oldidt);
- }
- exit(cod);
- }
-
- steptest()
- {
- topb[4]|=1;
-
- #ifdef DEBUG1
- printf("IP=%x\tCS=%x\n",last_command);
- #endif
-
- {
- int i=4;
- while(i-- > 0)bufc[i]=c[i];
- oldcommand=c;
- if(!testc)oldcommand1=oldcommand;
- }
-
- if(test)
- {
- if(last_command[-1] == 0x9c)
- {
- topb[6]&=0xfe;
- test=0;
- }
- }
-
- for(c=last_command;;)
- if(ispref(*c)){c++;continue;}
- else if(isatrece(*c)){
- if(havepost(*(c++))){c += sizedata(*c) + 1;}
- continue;
- }else break;
- if((*c)==0x9c)
- {
- test = 1;
- }
- if((*c)==0xcd){return(2);}
- if((*c)==0xcf){return(1);}
-
- #ifdef DEBUG
- DEBstep(); /*No enter! Pres F8 if you used TorboDebuger!*/
- #else
- step();
- #endif
- {
- int i;
- if(testc)
- {
- i=4;
- while(i-- > 0)
- {
- oldcommand1[i]=bufc1[i];
- }
- testc=0;
- }else{
- i=4;
- while((i-- > 0) && !(testc = (oldcommand[i] != bufc[i])));
- }
- if(testc)
- {
- i=4;
- while(i-- > 0)
- {
- #ifdef DEBUG1
- printf("Buffer IP=%x\tCS=%x\n",oldcommand1);
- #endif
- bufc1[i]=oldcommand1[i];
- oldcommand1[i]=bufc[i];
- }
- }
- }
- return 0;
- }
-
- void inittrace(funct t)
- {
- fstack=save_stat.stack.stack = (void far *) farmalloc(256);
- topstack->CS_IP.point = t;
- topstack->flags = 0x100;
- if(!(EnIDT=CpuTest())) /*Zero - enable using idt*/
- {
- _sidt(&oldidt);
- if((it = malloc(1024)) == 0)
- {
- EnIDT = 5;
- puts("Warning:Out of memory for new interrupt table");
- }else{
- newidt.table = mkidt(it);
- #ifndef DEBUG
- _lidt(&newidt);
- #endif
- }
- }
- if(EnIDT)
- {
- #ifndef DEBUG
- setvect(1,ftrace);
- #endif
- }else{
- ((long*)it)[1] = (long)ftrace;
- }
- }