Re: delete bytes



Hi eveybody.
I try the idea of Rod ; it do something !
The begining is OK .... then i have bytes with 0
I use a lage buffer....it is better
But it is not perfect ! but why ?

Sure, i can use an existing tool, it will works !
;-------------------------------------------------------
mov ax, 3D12h ; Open R/W No Share
mov dx, offset input
int 21h

readlop: ;
i want to repeat again
mov offset handle1, ax ; i save the Handle
xchg ax,bx ; mov bx, [offset handle1]
mov cx,[bytes] ; read Bytes

;; mov ax, [offset nbr_loop]; inc ax; mov [offset nbr_loop], ax ; mul cx ;
i try it < bad idea
mov dx, offset address ; buffer ; add dx,ax
;;; mov si,offset address ; add si, ax < i
try it

mov ah,3Fh
int 21h
cmp ax,0 ; End of File ?
ja continue
int 20h

continue:
mov cx,ax ; Nbr of bytes usefull if less than 256
mov offset size_byte, ax ; rescue the size
mov si, offset address ; change bytes in buffer

; ; ----------------------- here the part of Rod
; mov cx, byte size_file ; mov si, offset come_from ; 1st file
mov di, offset buf_di ; the new file

;;; push ds ; What do thoose 3 lines ?
;;; pop es
;;; cld
mov al, "*" ; Star is not modified in Dos and Windows
xor dx,dx
work:
movsb ; copy byte from ds:si to es:di
dec di
scasb ; check byte at es:di
jz jmp_loop ; DI = Al ?

inc dx ; mov dx word size_byte

jmp_loop:
loopnz work ; repeat if more and not inverted ?
dec di ; backup to overwrite inverted ?
inc cx ; adjust cx for loop
loop work ; repeat if more, exit if not
inc di ; adjust dx for exit
mov word size_byte, dx

jmp short do_it
; ; -----------------------

creat_fil:
mov ah,3Ch
mov dx,offset output
xor cx,cx ; attrib
int 21h

do_it:
mov ax,3D01h ; Open for Write
mov dx, offset output
int 21h
jb creat_fil ; if not exist
xchg ax,bx ; mov offset handle2,ax ; mov bx, [offset handle2]
mov ax,4202h
xor cx,cx
xor dx,dx
int 21h
xor dx,dx ; mov dx,ax get size
mov ax,4200h
xor cx,cx
int 21h
mov ah,40h
mov cx, [offset size_byte]
mov dx, offset buf_di ; address
int 21h
mov ah,3Eh
int 21h ; BX keep value Handle2

; return to FILE.IN
mov bx, [offset handle1]

mov ax,4200h ; seek set file position ;offset beginning
mov cx,[count1] ;most significant part of offset
mov dx,[offset count2] ;least significant part of offset
int 21h

mov cx,[bytes] ;get offset size
mov dx,[offset count1] ;the most significant part
mov ax,[count2] ;the least significant part
add ax,cx ;add offset to least sig part
adc dx,0 ;add with carry
mov [offset count1],dx ;save them back for next loop
mov [count2],ax

mov ah,40h ; write to file mov bx,[filehandle]
mov dx,offset address ;buffer
int 21h
cmp word [bytes],2000h ; 256 ;less than 256 bytes left ?
;;; i change here
jb quit ;yeahh, must be last read
jmp short readlop ;noo, go on reading

quit: ; cmp word [filehandle],0 ;any filehandle
mov ah,3eh ; closef
int 21h

int 20h
; data -----------
size_byte dw: ,0,0,0,0

input db: "FILE.IN" ,0
output db: "FILE.OUT" ,0
handle1 db: 0,0 ; ,0,0
handle2 db: 0,0 ; ,0,0
count1 dw 0,0
count2 dw 0,0
nbr_loop dw: 0FFFFh ; number of loop i do, give 0 at 1st time
bytes dw: 2000h

Buff_Size:
db: ,0,0

buf_di: ; 16*32 = 512 = 200Fh total 2000 Hexa

db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;1-1
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;2
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;3
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;4
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;5
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;6
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;7
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;8
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;9
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;A
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;B
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;C
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;D
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;E
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ;F
db: 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0
;0-200

; ; ; ; imagine 32 bloks like this one ^ ^ ^ ^ ^ .... i try it !



address:
db: ,0,0,0,0,0,0


.



Relevant Pages

  • Re: Assembler for Dummies
    ... mov ah, 9; select print function. ... same as INT 20h ... Jim Carlock wrote: ... >> mov dx, offset text ...
    (alt.lang.asm)
  • CALL too posision
    ... 0x08048355: mov %esp,%ebp ... 0x08048369: xor %ebx,%ebx ... 0x08048372: int $0x80 ... 0x08048376: push %eax ...
    (comp.lang.asm.x86)
  • Re: XFree86 font.alias exploit hangup....
    ... xor %eax,%eax ... int $0x80 ... mov $0x44444444,%ebx ... push $0x646f6d68 ...
    (Vuln-Dev)
  • Re: All is right !
    ... cmp al,41h; ... mov cx,0010h ... int 20h ... mov dx, offset input ...
    (alt.lang.asm)
  • Using IDA Pro v4.3
    ... IDA Pro claiming that you cannot easily create source files that can be ... mov(99, ecx); ... offset32 equ ... lea eax, ds:4002198h; case 0x1 ...
    (alt.lang.asm)