MSDOS Memory Viewer: mview

Ai făcut un program și vrei să ne arați și nouă? Vrei să te lauzi cu priceperea ta în programare? Vrei să îți dăm un feedback sau unele sugestii în legătură cu aplicația ta? Haide, arată-ne şi noi te vom ajuta să-ți finisezi creațiile.

MSDOS Memory Viewer: mview

Postby emi » 01 May 2010, 21:39

Program facut in momentul in care invatam sa controlez Pascal si assembler, pe un sistem MS-DOS.
(functioneaza si sub Win XP, dar memoria afisata nu e cea reala)

MVIEW.PAS
  1. {$A+,B-,D-,E-,F-,G-,I+,L-,N-,O-,P-,Q-,R-,S+,T-,V-,X-}
  2. {$M $800,0,0 }
  3.  
  4. uses dos;
  5. type
  6.   dword=record l,h:word end;
  7.  
  8. var
  9.   VideoSeg,P,I:WORD;
  10.   str:string;
  11.   again:boolean;
  12.   firstMCB:boolean;
  13.   urmMCB,CurrentIP,DataSeg:word;
  14.   KbdIntVec:Procedure;
  15.   sav_x,sav_y,scr_attr:byte;
  16.   scr_full_mode:boolean;
  17.   Active:boolean;
  18.  
  19.  
  20. {$I   VIDEO.INC}
  21. {$I   CUSOR.INC}
  22. {$I     KEY.INC}
  23. {$I    SCAN.INC}
  24. {$I  Memory.INC}
  25.  
  26.  
  27. procedure init;
  28. begin
  29.   FirstMCB:=true;
  30.   str:='';
  31.   P:=0;
  32.   scr_full_mode:=false;
  33.   clrscr;
  34.   VideoSeg:=GetVideoSeg;
  35.   scr_attr:=mem[VideoSeg:1];
  36.   Active:=false;
  37.   asm
  38.     call @1
  39.     @1:
  40.     pop ax
  41.     mov cx,4
  42.     shr ax,cl
  43.     mov bx,cs
  44.     add ax,bx
  45.     mov CurrentIP,ax
  46.  
  47.     mov dx,$1234            { Allready installed ? }
  48.     int $09
  49.     cmp dx,$4321
  50.     jne @NotActive
  51.     mov al,true
  52.     mov Active,al
  53.     @NotActive:
  54.   end;
  55. end;
  56.  
  57. procedure run;
  58. var
  59.   ExtKey,Key:byte;
  60.   step:word;
  61. BEGIN
  62.   gotoxy(12,0);
  63.   REPEAT
  64.     WritePage;
  65.     extendedkey(ExtKey,Key);
  66.     again:=false;
  67.     if scr_full_mode then begin
  68.       case key of
  69.       27:exit;
  70.       0 :case extkey of
  71.          80: p:=p+5;                           { DN }
  72.          72: p:=p-5;                           { UP }
  73.          73: p:=p-125;                         { PgUp }
  74.          81: p:=p+125;                         { PgDn }
  75.          end;
  76.       32:scr_full_mode:=false;
  77.       end;
  78.     end else begin
  79.     CASE Key OF
  80.       27: EXIT;
  81.       0 : CASE ExtKey OF
  82.         80 : INC(P);                            { DN }
  83.         72 : DEC(P);                            { UP }
  84.         77 : right;
  85.         75 : left;
  86.         71 : P:=0;                              { HOME  }
  87.         79 : P:=$FFE7;                          { End   }
  88.         73 : P:=P-$19;                          { PgUp  }
  89.         81 : P:=P+$19;                          { PgDn  }
  90.         132: P:=P-$190;                         { ^PgUp }
  91.         118: P:=P+$190;                         { ^PgDn }
  92.         68 : if active then begin               { F10   }
  93.                clrscr;
  94.                setintvec($09,Addr(KbdIntVec));
  95.                halt;
  96.              end;
  97.       END;
  98.       48..57,65..70,97..102:
  99.         if key<58 then P:=(key-48)*$1000
  100.         else P:=((key and $DF)-55)*$1000;
  101.       83,115: scan;                             { S     }
  102.       71,103: begin again:=true; scan; end;     { G     }
  103.       23    : writemsg;                         { ^W    }
  104.       09    : tab;
  105.       73,105: Interrupts;
  106.       77,109: Mcb;
  107.       84,116: DTA;
  108.       32    : scr_full_mode:=true;
  109.       36    : asm mov ax,sp; shr ax,1; shr ax,1; shr ax,1; shr ax,1;
  110.                   mov bx,ss; add ax,bx; mov p,ax
  111.               end;
  112.       64    : P:=CurrentIP;
  113.       35    : P:=DataSeg;
  114.       END;
  115.     end;
  116.   UNTIL FALSE;
  117. END;
  118.  
  119. procedure done;
  120. begin
  121.   clrscr;
  122.   gotoxy(21,12);
  123.   WriteLn('Memory View 1.7 (c) 93,98 by EmiSoft');
  124. end;
  125.  
  126. {$F+}
  127. procedure Activate; interrupt;
  128. var flags:word;
  129. begin
  130.   asm
  131.     pushf
  132.     pop ax
  133.     mov flags,ax
  134.   end;
  135.  
  136.   inline ($9C); { PUSHF }
  137.   KbdIntVec;
  138.   asm
  139.     mov dx,[BP+10]             { Self test }
  140.     cmp dx,$1234
  141.     jne @1
  142.     mov dx,$4321
  143.     mov [BP+10],dx
  144.     @1:
  145.   end;
  146.   if Active then exit;
  147.   if (flags and $30) <> 0 then exit;
  148.  
  149.   if (mem[0:$417] and $03) <> $03       { not (Left and Right Shift) ? }
  150.   then exit;
  151.  
  152.   {init}
  153.     Active:=true;
  154.     asm
  155.       mov ax,[BP+18]
  156.       mov cx,4
  157.       shr ax,cl
  158.       add ax,[BP+20]
  159.       mov CurrentIP,ax
  160.       mov ax,[BP+4]
  161.       mov DataSeg,ax
  162.     end;
  163.     sav_x:=wherex; sav_y:=wherey;
  164.     MovScreen( ptr(VideoSeg+$0700,0), ptr(VideoSeg,0) );
  165.  
  166.     VideoSeg:=VideoSeg+$0600;
  167.     scr_Fill($20,scr_attr);
  168.     WritePage;
  169.     VideoSeg:=VideoSeg-$0600;
  170.  
  171.     scr_RigthScroll(VideoSeg,VideoSeg+$0600);
  172.   {end init}
  173.  
  174.   run;
  175.   gotoxy(sav_x,sav_y);
  176.   scr_LeftScroll(VideoSeg,VideoSeg+$0700);
  177.   Active:=false;
  178. end;
  179. {$F-}
  180.  
  181. BEGIN
  182.   init;
  183.   if not Active and (paramstr(1)='tsr') then begin
  184.     GetIntVec($9,@KbdIntVec);
  185.     SetIntVec($9,Addr(Activate));
  186.     Keep(0); { Terminate, stay resident }
  187.   end;
  188.   run;
  189.   done;
  190. END.


VIDEO.INC
  1. function GetVideoMode:byte;assembler;
  2. asm
  3.   mov ah,$0f
  4.   int $10
  5. end;
  6.  
  7. function GetVideoSeg:word;
  8. var
  9.   mode: shortint;
  10. begin
  11.   asm
  12.     mov ah,$0f
  13.     int $10
  14.     mov byte ptr mode,al
  15.   end;
  16.   case mode of
  17.     1..6,8..9 : getvideoseg := $b800;
  18.     -2,7,10   : getvideoseg := $b000;
  19.   else getvideoseg := $a000;
  20.   end;
  21. end;
  22.  
  23. procedure clrscr;assembler;
  24. asm
  25.   mov ah,15
  26.   int 10h
  27.   mov ah,0
  28.   int 10h
  29. end;
  30.  
  31. procedure scr_write(x,y:byte; var s:string);assembler;
  32. asm
  33.   mov ax,VideoSeg
  34.   mov es,ax
  35.   xor ax,ax
  36.   mov al,160
  37.   mul y
  38.   xor bx,bx
  39.   mov bl,x
  40.   shl bx,1
  41.   add ax,bx
  42.   mov di,ax
  43.   cld
  44.   push ds
  45.   lds si,s
  46.   xor ax,ax
  47.   lodsb
  48.   mov cx,ax
  49. @1:
  50.   movsb
  51.   inc di
  52.   loop @1
  53.   pop ds
  54. end;
  55.  
  56. procedure MovScreen(Dest,Source:pointer);assembler;
  57. asm
  58.   push ds
  59.   mov cx,2000
  60.   cld
  61.   lds si,Source
  62.   les di,Dest
  63.   rep movsw
  64.   pop ds
  65. end;
  66.  
  67. procedure scr_Fill(fill,attr:byte);assembler;
  68. asm
  69.   mov cx,2000
  70.   mov ax,VideoSeg
  71.   mov es,ax
  72.   xor di,di
  73.   mov al,fill
  74.   mov ah,attr
  75.   cld
  76.   rep stosw
  77. end;
  78.  
  79. procedure scr_CopyCol(scr1,scr2,col1,col2:word);assembler;
  80. asm
  81.   { load segment of screen1 (destination) }
  82.   mov ax,scr1
  83.   mov es,ax
  84.   { load offset }
  85.   mov di,col1
  86.   shl di,1
  87.   { load segment of screen2 (source) }
  88.   mov ax,scr2
  89.   push ds
  90.   mov ds,ax
  91.   { load offset }
  92.   mov si,col2
  93.   shl si,1
  94.   { go copy }
  95.   mov cx,25
  96.   cld
  97. @1:
  98.   movsw
  99.   add si,160-2
  100.   add di,160-2
  101.   loop @1
  102.   pop ds
  103. end;
  104.  
  105. procedure scr_asmLeftScroll(scr:word);assembler;
  106. asm
  107.   push ds
  108.   mov ax,scr
  109.   mov ds,ax
  110.   mov es,ax
  111.   xor di,di
  112.   mov si,2
  113.   mov cx,25*80-1
  114.   cld
  115.   rep
  116.   movsw
  117.   pop ds
  118. end;
  119.  
  120. procedure scr_asmRigthScroll(scr:word);assembler;
  121. asm
  122.   push ds
  123.   mov ax,scr
  124.   mov ds,ax
  125.   mov es,ax
  126.   mov di,25*160
  127.   mov si,25*160-2
  128.   mov cx,26*80-1
  129.   std
  130.   rep movsw
  131.   pop ds
  132. end;
  133.  
  134. procedure Delay(ms:word);
  135. var x:longint;
  136. begin
  137.   { de fapt 55*ms milisecunde }
  138.   x:=meml[0:$46c] + ms;
  139.   repeat until (x <= meml[0:$46c]);
  140. end;
  141.  
  142. procedure scr_LeftScroll(scr1,scr2:word);
  143. var i,j:word;
  144. begin
  145.   for i:=0 to 80-1 do begin
  146.     scr_asmLeftScroll(scr1);
  147.     scr_CopyCol(scr1,scr2,79,i);
  148.     {Delay(1);{}
  149.   end;
  150. end;
  151.  
  152. procedure scr_RigthScroll(scr1,scr2:word);
  153. var i:word;
  154. begin
  155.   for i:=80-1 downto 0 do begin
  156.     scr_asmRigthScroll(scr1);
  157.     scr_CopyCol(scr1,scr2,0,i);
  158.   end;
  159. end;


CUSOR.INC
  1. function wherex:byte;assembler;
  2. asm
  3.     push    ds
  4.     xor ax,ax
  5.     mov ds,ax
  6.     mov si,462h
  7.     lodsb
  8.     mov si,450h
  9.     shl ax,1
  10.     add si,ax
  11.     lodsb
  12.     pop ds
  13. end;
  14.  
  15. function wherey:byte;assembler;
  16. asm
  17.     push    ds
  18.     xor ax,ax
  19.     mov ds,ax
  20.     mov si,462h
  21.     lodsb
  22.     mov si,450h
  23.     shl ax,1
  24.     inc ax
  25.     add si,ax
  26.     lodsb
  27.     pop ds
  28. end;
  29.  
  30. procedure gotoxy(x,y:byte);assembler;
  31. asm
  32.     push    ds
  33.     xor ax,ax
  34.     mov ds,ax
  35.     mov bh,[462h]
  36.     mov dl,[bp+6]
  37.     mov dh,[bp+4]
  38.     mov ah,2
  39.     int 10h
  40.     pop ds
  41. end;


KEY.INC
  1. procedure waitkey;assembler;
  2. asm
  3.   push ds
  4.   xor ax,ax
  5.   mov ds,ax
  6.   mov al,[$041a]
  7.   mov [$041c],al
  8.   pop ds
  9.   int $16
  10. end;
  11.  
  12. function keypressed:boolean;assembler;
  13. asm
  14.   push ds
  15.   xor ax,ax
  16.   mov ds,ax
  17.   mov al,[41ah]
  18.   cmp al,[41ch]
  19.   jz @0
  20.   mov al,1
  21.   jmp @1
  22. @0:
  23.   mov al,0
  24. @1:
  25.   pop ds
  26. end;
  27.  
  28. function readkey:char;assembler;
  29. asm
  30.   mov ah,0
  31.   int 16h
  32. end;
  33.  
  34. procedure extendedkey(var e,k:byte);assembler;
  35. asm
  36.   mov ah,0
  37.   int 16h
  38.   les di,[bp+4]
  39.   stosb
  40.   les di,[bp+8]
  41.   mov al,ah
  42.   stosb
  43. end;
  44.  
  45. procedure ZipSound(zip,final:word);assembler;
  46. asm
  47.     IN  AL,61h
  48.     OR  AL,0003
  49.     OUT 61h,AL
  50.     MOV AL,0090h
  51.     OUT 43h,AL
  52.     MOV AX,0002
  53. @1: OUT 42h,AL
  54.     MOV CX,zip       {0210h}
  55.     SUB CX,AX
  56. @2: loop    @2
  57.     ADD AL,02
  58.     JNZ @1
  59.     SUB AL,04
  60. @3: OUT 42h,AL
  61.     MOV CX,final     {0114h}
  62. @4: loop    @4
  63.     SUB AL,4
  64.     JNZ @3
  65.     IN  AL,61h
  66.     AND AL,0FCh
  67.     OUT 61h,AL
  68. end;


SCAN.INC
  1. function scan_str(segment:word; var str:string; var offs_match:word):boolean;assembler;
  2. var
  3.   lungime:byte;
  4.   ofs_str:word;
  5.   sav_si :word;
  6. asm
  7.   push ds
  8.   les di,str
  9.   mov al,es:[di]
  10.   mov lungime,al
  11.   xor dx,dx
  12.   mov dl,al
  13.   inc di
  14.   mov ofs_str,di
  15.   mov ax,segment
  16.   mov ds,ax
  17.   xor si,si
  18.   cld
  19.   mov cx,$FFF0
  20. @restore:
  21.   mov bl,es:[di]
  22.   inc di
  23.   dec dl
  24.   xor bl,$55
  25.   and bl,$DF
  26. @continua:
  27.   lodsb
  28.   and al,$DF
  29.   cmp al,bl
  30.   jz @found
  31.   loop @continua
  32. @out:
  33.   xor ax,ax
  34.   jmp @end
  35. @found:
  36.   mov sav_si,si
  37.   or dl,dl
  38.   jz @match
  39.   mov bl,es:[di]
  40.   xor bl,$55
  41.   and bl,$DF
  42.   inc di
  43.   dec dx
  44.   lodsb
  45.   and al,$DF
  46.   cmp al,bl
  47.   jz @found
  48.   mov di,ofs_str
  49.   mov si,sav_si
  50.   xor dx,dx
  51.   mov dl,lungime
  52.   jmp @restore
  53. @match:
  54.   mov ax,si
  55.   sub al,lungime
  56.   sbb ah,0
  57.   les di,offs_match
  58.   stosw
  59. @end:
  60.   pop ds
  61. end;
  62.  
  63. procedure XorStr(var str:string);assembler;
  64. asm
  65.   push ds
  66.   lds si,str
  67.   les di,str
  68.   cld
  69.   lodsb
  70.   inc di
  71.   xor cx,cx
  72.   mov cl,al
  73. @1:
  74.   lodsb
  75.   xor al,$55
  76.   stosb
  77.   loop @1
  78.   pop ds
  79. end;
  80.  
  81. procedure SecureReadStr(var str:string);
  82. var
  83.   count:byte;
  84.   key:char;
  85. begin
  86.   for count:=0 to 255 do str[count]:=#0;
  87.   count:=0;
  88.   repeat
  89.     key:=readkey;
  90.     if key=#27 then begin str:=''; exit; end;
  91.     if (key in [#32..#126]) and (count<20)
  92.     then begin
  93.       inc(count);
  94.       str[0]:=char(count);
  95.       str[count]:=key;
  96.       write(key);
  97.     end else if (key=#8) and (count>0) then begin
  98.       dec(count);
  99.       str[0]:=char(count);
  100.       write(#8,'ů',#8);
  101.     end else if key<>#13 then write(#7);
  102.   until key=#13;
  103.   XorStr(str);
  104. end;
  105.  
  106. procedure add_dw_w(var x:dword; source:word);assembler;
  107. asm
  108.   mov ax,source
  109.   les di,x
  110.   add es:[di],ax
  111.   jnc @exit
  112.   inc word ptr es:[di+2]
  113. @exit:
  114. end;
  115.  
  116. procedure scan;
  117. var x,y,z:byte;
  118.     b:dword;
  119.     ofs:word;
  120.     s:string[22];
  121. begin
  122.   b.h:=0;
  123.   x:=wherex; y:=wherey;
  124.   b.l:=p+1;
  125.   if not again then begin
  126.     b.l:=p;                                  { incepe cu paragraful curent }
  127.     scr_fill(176,scr_attr);
  128.     s:='Enter a string:'; scr_write(28,10,s);
  129.     s:='[ůůůůůůůůůůůůůůůůůůůů]'; scr_write(28,12,s);
  130.  
  131.     gotoxy(29,12);
  132.     SecureReadStr(str);
  133.   end;
  134.   if str<>'' then begin
  135.     scr_fill($20,scr_attr);
  136.     s:='Searching...'; scr_write(33,12,s);
  137.     while b.h=0 do begin
  138.       if scan_str(b.l,str,ofs) then begin
  139.         p := b.l + ofs div 16;
  140.         x :=  64 + ofs mod 16;
  141.         ZipSound($210,$114);
  142.         gotoxy(x,0); exit;
  143.       end;
  144.       add_dw_w(b,$ff0);
  145.     end;
  146.     gotoxy(33,12); write('NOT FOUND ! '); waitkey;
  147.   end;
  148.   gotoxy(x,y);
  149. end;


MEMORY.INC
  1. procedure WritePara(source,dest:pointer);assembler;
  2. asm
  3.   cld
  4.   push ds
  5.   lds  si,source
  6.   mov  dx,ds
  7.   mov  bx,si
  8.   les  di,dest
  9.   mov  ax,es
  10.   mov  al,'['
  11.   stosb
  12.   inc  di
  13.   shl  bx,1
  14.   shl  bx,1
  15.   shl  bx,1
  16.   shl  bx,1
  17.   add  dx,bx
  18.   mov  al,'0'
  19.   stosb
  20.   inc  di
  21.   stosb
  22.   inc  di
  23.   stosb
  24.   inc  di
  25.   mov  al,dh
  26.   call @store
  27.   mov  al,dl
  28.   call @store
  29.   mov  al,'0'
  30.   stosb
  31.   inc  di
  32.   mov  al,']'
  33.   stosb
  34.   inc  di
  35.   mov  cx,$0010
  36. @hexpara:
  37.   mov  dx,cx
  38.   mov  al,' '
  39.   stosb
  40.   inc  di
  41.   shr  dx,1
  42.   jc   @unspatiu
  43.   shr  dx,1
  44.   jc   @unspatiu
  45.   stosb
  46.   inc  di
  47. @unspatiu:
  48.   lodsb
  49.   call @store
  50.   loop @hexpara
  51.   mov  al,' '
  52.   stosb
  53.   inc  di
  54.   stosb
  55.   inc  di
  56.   sub  si,$10
  57.   mov  cx,$0010
  58. @asciipara:
  59.   movsb
  60.   inc  di
  61.   loop @asciipara
  62.   jmp  @return
  63. @store:
  64.   mov  ah,al
  65.   shr  al,1
  66.   shr  al,1
  67.   shr  al,1
  68.   shr  al,1
  69.   call @qbit
  70.   mov  al,ah
  71.   and  al,$0f
  72. @qbit:
  73.   add  al,'0'
  74.   cmp  al,'9'
  75.   jbe  @cifra
  76.   add  al,$07
  77. @cifra:
  78.   stosb
  79.   inc  di
  80.   ret
  81. @return:
  82.   pop ds
  83. end;
  84.  
  85. procedure asmWriteFull(source:word);assembler;
  86. asm
  87.   mov ax,VideoSeg
  88.   mov es,ax
  89.   xor di,di
  90.   push ds
  91.   mov ax,source
  92.   mov ds,ax
  93.   xor si,si
  94.   mov cx,80*25
  95.   cld
  96. @1:
  97.   movsb
  98.   inc di
  99.   loop @1
  100.   pop ds
  101. end;
  102.  
  103. procedure WritePage;
  104. var i:word;
  105. begin
  106.   if not scr_full_mode
  107.   then begin
  108.     for i:=0 to 24 do
  109.     WritePara( Ptr(P+I,0), Ptr(VideoSeg,I*160) );
  110.   end
  111.   else asmWriteFull(P);
  112. end;
  113.  
  114. procedure Mcb;
  115. var x:word;
  116.     id:char;
  117. begin
  118.   if (firstMCB) or (urmMCB=0) then begin
  119.     firstMCB:=false;
  120.     asm
  121.       mov ah,$52
  122.       int $21
  123.       mov ax,es:[bx-2];
  124.       mov x,ax
  125.     end;
  126.     P:=x;
  127.     asm
  128.       mov ax,x
  129.       mov es,ax
  130.       mov ax,es:[$0003]
  131.       mov x,ax
  132.     end;
  133.     urmMCB:=P+x+1;
  134.     exit;
  135.   end;
  136.   P:=urmMCB;
  137.   x:=urmMCB;
  138.   asm
  139.     push ds
  140.     mov ax,x
  141.     mov ds,ax
  142.     mov ax,[$0003]
  143.     add x,ax
  144.     mov al,[$0000]
  145.     mov id,al
  146.     pop ds
  147.   end;
  148.   urmMCB:=x+1;
  149.   if upcase(id)='Z' then urmMCB:=0;
  150. end;
  151.  
  152. procedure DTA;
  153. var x:word;
  154. begin
  155.   asm
  156.     mov ah,$2f
  157.     int $21
  158.     shr bx,1
  159.     shr bx,1
  160.     shr bx,1
  161.     shr bx,1
  162.     mov ax,es
  163.     add ax,bx
  164.     mov x,ax
  165.   end;
  166.   P:=x;
  167. end;
  168.  
  169. procedure writeInt(x,y:byte;i:word);
  170. const h:array[0..15] of char = '0123456789ABCDEF';
  171. var v,w:word;
  172. begin
  173.   gotoxy(x,y);
  174.   write('Int',h[i shr 4],h[i and $0f],' ');
  175.   v:=memw[$0:i*4];
  176.   w:=memw[$0:i*4+2];
  177.   write(h[hi(w) shr 4],h[hi(w) and $0f],
  178.         h[lo(w) shr 4],h[lo(w) and $0f],':',
  179.         h[hi(v) shr 4],h[hi(v) and $0f],
  180.         h[lo(v) shr 4],h[lo(v) and $0f]);
  181.   writeln;
  182. end;
  183.  
  184. procedure Interrupts;
  185. var i:word;
  186.     x,y:byte;
  187.     p:word;
  188. begin
  189.   x:=0; y:=0;
  190.   scr_Fill($20,scr_attr);
  191.   gotoxy(0,0);
  192.   write('Intreruperi suspecte:');
  193.   for i:=0 to $90 do begin
  194.     p:=memw[0:i*4+2];
  195.     p:=p + memw[0:i*4] div 16;
  196.     if (p>0) and ((p<$0052) or (p>$8000)) and (p<$C800)
  197.     then begin
  198.       inc(y);
  199.       if y>22 then begin x:=x+17; y:=1; end;
  200.       writeInt(x,y,i);
  201.     end;
  202.   end;
  203.   gotoxy(70,0); write('Ram ',memw[0:$413],'K');
  204.   gotoxy(0,23); write('Press any key to continue...'); waitkey;
  205.   gotoxy(12,0);
  206. end;
  207.  
  208. procedure left;
  209. var x:byte;
  210. begin
  211.   x:=wherex;
  212.   if x>12 then
  213.   if x>64 then gotoxy(wherex-1,0)
  214.   else begin
  215.     if ((x+1) mod 13)=0
  216.     then gotoxy(x-3,0)
  217.     else if (((x+1) mod 13) mod 3)=0
  218.          then gotoxy(x-2,0)
  219.          else gotoxy(x-1,0)
  220.   end;
  221. end;
  222.  
  223. procedure right;
  224. var x:byte;
  225. begin
  226.   x:=wherex;
  227.   if x<79 then
  228.   if x>63 then gotoxy(wherex+1,0)
  229.   else begin
  230.     if ((x-9) mod 13)=0
  231.     then gotoxy(x+3,0)
  232.     else if ((((x-9) mod 13)-1) mod 3)=0
  233.      then gotoxy(x+2,0)
  234.      else gotoxy(x+1,0)
  235.   end;
  236. end;
  237.  
  238. procedure tab;
  239. var x:byte;
  240. begin
  241.   x:=wherex;
  242.   if x<64 then begin
  243.     x:=64+4*((x-12) div 13)+((x-12) mod 13) div 3;
  244.   end else begin
  245.     x:=12+((x-64) div 4)*13+((x-64) mod 4)*3;
  246.   end;
  247.   gotoxy(x,0);
  248. end;
  249.  
  250. procedure writetoram(c:byte);
  251. var x,d,i,j:byte; ofs:word;
  252. begin
  253.   x:=wherex;
  254.   if x<64 then begin
  255.     if ((c>=48) and (c<=57)) or
  256.        ((c>=65) and (c<=70)) or
  257.        ((c>=97) and (c<=102)) then begin
  258.     if c<58 then i:=c-48 else i:=(c and $DF)-55;
  259.     ofs:=4*((x-12) div 13)+((x-12) mod 13) div 3;
  260.     d:=((x-12) mod 13) mod 3;
  261.     j:=byte(ptr(p,ofs)^);
  262.     if d=0
  263.     then byte(ptr(p,ofs)^):=(j or $F0) and ((i shl 4) or $0F)
  264.     else byte(ptr(p,ofs)^):=(j or $0F) and (i or $F0);
  265.     if j<>byte(ptr(p,ofs)^) then
  266.     if x=61 then begin
  267.       inc(p); gotoxy(12,0);
  268.     end else right;
  269.   end
  270.   end else begin
  271.   byte(ptr(p,x-64)^):=c;
  272.   if byte(ptr(p,x-64)^)=c then
  273.   if x=79 then begin
  274.     inc(p); gotoxy(64,0);
  275.   end else right;
  276.   end;
  277. end;
  278.  
  279. procedure writemsg;
  280. var x,y:byte;
  281.     write_mode:boolean;
  282. begin
  283.   x:=wherex; y:=wherey;
  284.   scr_Fill($20,scr_attr);
  285.   gotoxy(30,12); write('I LIKE HACKING !'); WaitKey;
  286.   gotoxy(x,y);
  287.   write_mode:=true;
  288.   repeat
  289.     WritePage;
  290.     extendedkey(x,y);
  291.     case y OF
  292.       27: write_mode:=false;
  293.       09: tab;
  294.       00: case x of
  295.         80 : INC(P);       {DN}
  296.         72 : DEC(P);       {UP}
  297.         77 : right;
  298.         75 : left;
  299.         73 : P:=P-$19;     {PgUp}
  300.         81 : P:=P+$19;     {PgDn}
  301.         132: P:=P-$190;    {^PgUp}
  302.         118: P:=P+$190;    {^PgDn}
  303.       end;
  304.       else writetoram(y);
  305.     end;
  306.   until not write_mode;
  307.   x:=wherex; y:=wherey;
  308.   scr_Fill($20,scr_attr);
  309.   gotoxy(28,12); write('Back to read only mode'); waitkey;
  310.   gotoxy(x,y);
  311. end;
  312.  
  313. procedure MemoryMap;
  314. begin
  315.   scr_Fill($20,scr_attr);
  316.  
  317.   waitkey;
  318. end;


MVIEW.DOC
Memory Viewer version 1.7
(c) by EmiSoft


Deplasare cusor: Left,Right,Tab

Deplasare la adesa:
Up, PgUp,Home,^PgUp - o linie, o pagina, adresa 0, mai repede in sus.
Down,PgDn,End, ^PgDn - o linie, o pagina, ultima adresa, mai repede.
0,1,..,9,A,B,..,F - deplasare la adresa x0000

SpaceBar = FULL Page

Esc = EXIT !


Special:
--------
I = Interrupts ( de obicei virusii se incarca la 9Fxx:xxxx )
S = Search string
G = Search aGain
^W = Write mode
M = Memory Control Block
T = Current Disk Transfer Address
$ = Current Stack Zone
# = DS
@ = CS:IP


Rezident:
---------
Comanda: MVIEW tsr

Activare = Shift LEFT + Shift RIGHT


VIRUS.DOC
Am scris acest program special pentru a detecta mai usor virusii din memorie.

Reguli important de retinut !
-----------------------------

1. Un virus se activeaza DOAR ATUNCI cind este EXECUTAT (cu mai mult sau mai
putina voie a dvs.!!!) adica:
- executie MBR infectat ( MBR contine cod executabil )
- BOOT infectat
- fisier infectat

2. Un virus nu poate fi activ in memorie decit daca are cel putin o
intrerupere redirectata spre el.

Intreruperile frecvent "mincate" sunt:
08 - IRQ0 = System Timer (se apeleaza automat la fiecare 55ms)
09 - IRQ1 = Keyboard (se apeleaza la fiecare actionare a vreunei taste)
13 - Disk (BIOS)
1C - User Timer Tick (la fiecare 55ms)
21 - DOS Functions
25 - Absolute Disk Read
26 - Absolute Disk Write

Bineinteles ca mai pot fi si altele.

In continuare voi folosi adresa fizica memoriei.
Este o adresa pe 20 de biti si se calculeaza astfel:

AdrFizica = Segment*16 + Offset.


Locul de incarcare al unui virus (Adresa fizica) :

00200..00400 Chiar in vectorii de inreruperi !!!
Exepmlu: Tiny178

9F000..A0000 Marea majoritate se copiaza aici.

A0000..C8000 Pot fi si aici, daca nu i-am intilnit nu inseamna ca nu exista.

Chestiuni picante
------------------
Dark Avenger
SCANEAZA BIOS-ul !!! (de la C8000 in colo) si gaseste adresa pentru int13.
Bineinteles ca are nevoie totusi de o intrerupere ca sa se activeze.
Foloseste int21

AI
Se copiaza tot la 9Fxxx dar pacaleste cautatorul neexperimentat
pentru ca redirecteaza intreruperile mai intii la
004F0..004FF zona BIOS pentru programe utilizator.


Cum se scapa de virusi
----------------------

Intotdeauna trebuie o discheta (CURATA) de salvare! Altfel ...
Care sa contina:
1. Sistemul de operare
2. FORMAT
3. SYS
4. FDISK
5. Un antivirus

Ce trebuie facut ?
------------------
1. Porniti sistemul de pe discheta.
Si NU executati nimic de pe hard!
2. FDISK /MBR - elimina virusii care se instaleaza in MBR
3. SYS c: - elimina virusii din BOOT
4. Lansati antivirusul sa caute executabile infectate.
5. Ultima solutie: FORMAT c: /s - distruge tot.

ATENTIE!
NU formatati hard-ul aiurea!
Doar cu FORMAT nu se elimina toti virusii.


Sursele si executabilul le gasiti in atasament.

P.S.: Acest program a fost publicat si pe alt site.
5p / 1 votes
Attachments
EmiSoft mview1.7.zip
(13.62 KiB) Downloaded 31 times
User avatar
emi
Byte
 
Joined: 10 Apr 2010
Status: 18

Return to Programe facute de noi

Who is online

Users browsing this forum: No registered users and 0 guests