Subversion Repositories Kolibri OS

Rev

Rev 135 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 135 Rev 193
Line 1... Line 1...
1
; project name:   SYSTREE FILE COPIER
1
; project name:   SYSTREE FILE COPIER
-
 
2
; version:        1.2
-
 
3
; Mario79 23/10/06
-
 
4
;
2
; version:        1.1b
5
; version:        1.1b
3
; last update:    18/07/2004
6
; last update:    18/07/2004
4
; compiler:       FASM 1.52
7
; compiler:       FASM 1.52
5
; written by:     Ivan Poddubny
8
; written by:     Ivan Poddubny
6
; e-mail:         ivan-yar@bk.ru
9
; e-mail:         ivan-yar@bk.ru
7
; copying-policy: GPL
10
; copying-policy: GPL
Line 8... Line 11...
8
 
11
 
-
 
12
; History:
9
; History:
13
; 23/10/06 application use function 70
10
; 18/07/2004 strings using "lsz" macro + french language (not 100%!)
14
; 18/07/2004 strings using "lsz" macro + french language (not 100%!)
11
; 04/06/2004 Bugfix for memory - thanks to Ville
15
; 04/06/2004 Bugfix for memory - thanks to Ville
Line 12... Line 16...
12
; ...
16
; ...
Line 16... Line 20...
16
 
20
 
17
    db      'MENUET01'     ; 8 byte id
21
    db      'MENUET01'     ; 8 byte id
18
    dd      0x01           ; header version
22
    dd      0x01           ; header version
19
    dd      START          ; start of code
23
    dd      START          ; start of code
20
    dd      I_END          ; size of image
24
    dd      I_END          ; size of image
21
    dd      0x20201        ; memory for app
25
    dd      0x10000        ; memory for app
22
    dd      0x10000        ; esp
26
    dd      0x10000        ; esp
Line 23... Line 27...
23
    dd      0x0 , 0x0      ; I_Param , I_Icon
27
    dd      0x0 , 0x0      ; I_Param , I_Icon
24
 
28
 
Line 67... Line 71...
67
    jz   dstbtn
71
    jz   dstbtn
68
    cmp  ah,4       ; user pressed src button ?
72
    cmp  ah,4       ; user pressed src button ?
69
    jnz  still
73
    jnz  still
Line 70... Line 74...
70
 
74
 
71
  srcbtn:
75
  srcbtn:
72
    mov  [addr],dword source
76
    mov  [addr],dword source_info.name  ;source
73
    mov  [ya],dword 36
77
    mov  [ya],dword 36
74
    jmp  rk
78
    jmp  rk
75
  dstbtn:
79
  dstbtn:
76
    mov  [addr],dword destination
80
    mov  [addr],dword dest_info.name  ;destination
Line 77... Line 81...
77
    mov  [ya],dword 36+16
81
    mov  [ya],dword 36+16
78
 
82
 
79
  rk:
83
  rk:
Line 148... Line 152...
148
;   It's NOT a function! It's reached by direct jump
152
;   It's NOT a function! It's reached by direct jump
149
;   from the button handler.
153
;   from the button handler.
150
;====================================================
154
;====================================================
151
copy_file:
155
copy_file:
152
    ; at first we must get the size of the source file
156
    ; at first we must get the size of the source file
153
    mov  [source_info.blocks],1 ; load only 512 bytes
-
 
154
    mov  eax,58
-
 
155
    mov  ebx,source_info
157
    mcall 70, get_param_info
156
    int  0x40
-
 
Line 157... Line 158...
157
 
158
 
158
    ; now eax contains error code
-
 
159
    ; and ebx contains file size in bytes
159
    ; now eax contains error code
160
    test eax,eax      ; check if eax is equal to zero (success)
-
 
161
    je   .ok_getsize  ;   eax = 0 => continue
-
 
162
    cmp  eax,6
-
 
163
    jna  @f
-
 
164
    mov  eax,7        ; if error code is above 6, it will be 7
-
 
165
  @@:
-
 
166
    cmp  eax,5        ; file might be copied successfully altrough
-
 
167
                      ; the system reports an error 5
160
    test eax,eax      ; check if eax is equal to zero (success)
168
    jne  copy_error   ; print error code now
-
 
Line 169... Line 161...
169
  .ok_getsize:
161
    jne  copy_error   ; print error code now
170
 
-
 
171
    ; allocate memory
162
 
172
    push ebx         ; save file size
163
    ; allocate memory
173
    mov  ecx,ebx
164
    mov  ecx,[param_info+32]   ;ebx
174
    add  ecx,0x20000 ; size of memory needed = 0x20000+filesize
165
    add  ecx,0x10000 ; size of memory needed = 0x10000+filesize
175
    mov  eax,64      ; func 64
166
    mov  eax,64      ; func 64
176
    mov  ebx,1       ; resize application memory
-
 
Line 177... Line 167...
177
    int  0x40
167
    mov  ebx,1       ; resize application memory
178
    pop  ebx         ; restore filesize
168
    int  0x40
179
 
169
 
180
    ; check if alloc function failed
170
    ; check if alloc function failed
181
    test eax,eax     ; non-zero value means error
171
    test eax,eax     ; non-zero value means error
182
    je   .ok_memory
172
    je   .ok_memory
Line 183... Line 173...
183
    mov  eax,5       ; error 5 - out of memory
173
    mov  eax,5       ; error 5 - out of memory
184
    jmp  copy_error  ; print error code now
174
    jmp  copy_error  ; print error code now
185
  .ok_memory:
175
  .ok_memory:
186
 
176
 
-
 
177
    ; save size to source_info
187
    ; save number of blocks to source_info
178
    mov  ebx,[param_info+32]
-
 
179
    mov  [source_info.size],ebx    ; read the source file
188
    add  ebx,511
180
    mcall 70,source_info
-
 
181
 
189
    shr  ebx,9       ; round up to 512 boundary
182
    ; now eax contains error code
190
    mov  [source_info.blocks],ebx
183
    test eax,eax      ; check if eax is equal to zero (success)
Line 191... Line -...
191
    ; read the source file
-
 
192
    mov  eax,58
184
    jne  copy_error   ; print error code now
193
    mov  ebx,source_info
-
 
194
    int  0x40
-
 
195
 
185
 
196
    ; ebx = file size
-
 
Line 197... Line 186...
197
    ; save loaded file
186
    ; file size in bytes
198
    mov  [dest_info.bytes2write],ebx ; file size in bytes
187
    mov   [dest_info.size],ebx
199
    mov  eax,58
-
 
200
    mov  ebx,dest_info
-
 
201
    int  0x40
-
 
202
 
188
 
203
    ; check if 58 function failed
-
 
204
    test eax,eax
-
 
205
    je   .ok_write
-
 
Line 206... Line 189...
206
    add  eax,7        ; error number += 7
189
    ; save loaded file
207
    cmp  eax,6+7
190
    mcall 70,dest_info
208
    jna  copy_error
191
 
209
    mov  eax,7+7
192
    ; now eax contains error code
210
    jmp  copy_error
193
    test eax,eax
Line 211... Line 194...
211
  .ok_write:
194
    jne  copy_error
Line 295... Line 278...
295
    mov  ecx, 49*65536+12
278
    mov  ecx, 49*65536+12
296
    mov  edx, 5
279
    mov  edx, 5
297
    mov  esi, 0xEBEBEB
280
    mov  esi, 0xEBEBEB
298
    int  0x40
281
    int  0x40
Line 299... Line 282...
299
 
282
 
300
    mov  esi, source
283
    mov  esi, source_info.name  ;source
301
    mov  edi, text+14
284
    mov  edi, text+14
302
    mov  ecx, STRLEN
285
    mov  ecx, STRLEN
Line 303... Line 286...
303
    rep  movsb
286
    rep  movsb
304
 
287
 
305
    mov  esi, destination
288
    mov  esi, dest_info.name  ;destination
306
    mov  edi, text+STRLEN+59-45+14
289
    mov  edi, text+STRLEN+59-45+14
Line 307... Line 290...
307
    mov  ecx, STRLEN
290
    mov  ecx, STRLEN
Line 325... Line 308...
325
 
308
 
Line 326... Line 309...
326
    ret
309
    ret
-
 
310
 
-
 
311
 
-
 
312
; DATA AREA
-
 
313
get_param_info:
-
 
314
 .subfunction	 dd   5 	      ; 5 - get parameters of file
-
 
315
 .start        dd   0        ; rezerved
327
 
316
 .size_high    dd   0 	      ; rezerved
-
 
317
 .size         dd   0	      ; rezerved
-
 
318
 .return	      dd   param_info
-
 
319
 .name:
328
 
320
     db  0
329
; DATA AREA
321
     dd  source_info.name
330
align 4
322
 
331
source_info:                 ; SOURCE FILEINFO
323
source_info:                 ; SOURCE FILEINFO
332
  .mode            dd 0      ; read file
324
 .subfunction	 dd   0 	      ; 0=READ
333
  .start_block     dd 0x0    ; block to read
325
 .start        dd   0        
-
 
326
 .size_high    dd   0 	     
334
  .blocks          dd 0x700  ; num of blocks
327
 .size         dd   0	      
335
  .address         dd 0x20000
328
 .return	      dd   0x10000
Line 336... Line 329...
336
  .workarea        dd 0x10000
329
 .name:
337
  source           db '/HD/1/KERNEL/KERNEL.MNT',0
330
     db   '/hd0/1/kernel/kernel.mnt',0   ; ASCIIZ dir & filename
338
    times (STRLEN-23) db 0
331
     times (STRLEN-24) db 0
339
 
332
 
340
dest_info:                   ; DESTINATION FILEINFO
333
dest_info:                   ; DESTINATION FILEINFO
341
  .mode            dd 1      ; write
334
 .subfunction	 dd   2 	      ; 0=WRITE
-
 
335
 .start        dd   0        
342
  .notused         dd 0x0    ; not used
336
 .size_high    dd   0 	     
343
  .bytes2write     dd 0      ; bytes to write
337
 .size         dd   0	      
Line -... Line 338...
-
 
338
 .return	      dd   0x10000
-
 
339
 .name:
-
 
340
     db   '/rd/1/kernel.mnt',0   ; ASCIIZ dir & filename
-
 
341
    times (STRLEN-16) db 0
-
 
342
 
-
 
343
param_info:
-
 
344
     rb 40
-
 
345
 
-
 
346
 
-
 
347
;align 4
-
 
348
;source_info:                 ; SOURCE FILEINFO
-
 
349
;  .mode            dd 0      ; read file
-
 
350
;  .start_block     dd 0x0    ; block to read
-
 
351
;  .blocks          dd 0x700  ; num of blocks
-
 
352
;  .address         dd 0x20000
-
 
353
;  .workarea        dd 0x10000
-
 
354
;  source           db '/HD/1/KERNEL/KERNEL.MNT',0
-
 
355
;    times (STRLEN-23) db 0
-
 
356
;
-
 
357
;dest_info:                   ; DESTINATION FILEINFO
-
 
358
;  .mode            dd 1      ; write
-
 
359
;  .notused         dd 0x0    ; not used
-
 
360
;  .bytes2write     dd 0      ; bytes to write
344
  .address         dd 0x20000
361
;  .address         dd 0x20000
345
  .workarea        dd 0x10000
362
;  .workarea        dd 0x10000
346
  destination      db '/RD/1/KERNEL.MNT',0
363
;  destination      db '/RD/1/KERNEL.MNT',0
347
    times (STRLEN-16) db 0
364
;    times (STRLEN-16) db 0