Subversion Repositories Kolibri OS

Rev

Rev 158 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. format ELF
  2. include "public_stdcall.inc"
  3. section '.text' executable
  4. public_stdcall _msys_read_file,20
  5. ;arg1 - file name
  6. ;arg2 - file offset
  7. ;arg3 - size to read
  8. ;arg4 - data
  9. ;arg5 - file size
  10.   push  ebp
  11.   mov   ebp,esp
  12.   xor   eax,eax
  13.   mov   [file_struct.operation],eax
  14.   mov   eax,[ebp+12]
  15.   mov   [file_struct.offset],eax
  16.   mov   eax,[ebp+16]
  17.   mov   [file_struct.size],eax
  18.   mov   eax,[ebp+20]
  19.   mov   [file_struct.data],eax
  20.   mov   [file_struct.temp_buffer],temp_buffer
  21.   mov   edx,[ebp+8]
  22.   call  copy_file_name
  23.   push  ebx
  24.   mov   ebx,file_struct
  25.   mov   eax,58
  26.   int   0x40
  27.   mov   ecx,[ebp+24]
  28.   test  ecx,ecx
  29.   jz    .no_file_size
  30.   mov   [ecx],ebx
  31. .no_file_size:
  32.   pop   ebx
  33.   pop   ebp
  34.   ret   20
  35.  
  36. copy_file_name:
  37.   push  esi edi
  38.   cld
  39.   mov   edi,edx
  40.   xor   eax,eax
  41.   xor   ecx,ecx
  42.   dec   ecx
  43.   repnz scasb
  44.   not   ecx
  45.   mov   edi,file_struct.path
  46.   mov   esi,edx
  47.   rep   movsb
  48.   pop   edi esi
  49.   ret
  50.  
  51. public_stdcall _msys_write_file,12
  52. ;arg1 - file name
  53. ;arg2 - size
  54. ;arg3 - data
  55.   push  ebp
  56.   mov   ebp,esp
  57.   xor   eax,eax
  58.   mov   [file_struct.offset],eax
  59.   inc   eax
  60.   mov   [file_struct.operation],eax
  61.   mov   eax,[ebp+12]
  62.   mov   [file_struct.size],eax
  63.   mov   eax,[ebp+16]
  64.   mov   [file_struct.data],eax
  65.   mov   [file_struct.temp_buffer],temp_buffer
  66.   mov   edx,[ebp+8]
  67.   call  copy_file_name
  68.   push  ebx
  69.   mov   eax,58
  70.   mov   ebx,file_struct
  71.   int   0x40
  72.   pop   ebx
  73.   pop   ebp
  74.   ret   12
  75.  
  76. public_stdcall _msys_run_program,8
  77. ;arg1 - program name
  78. ;arg2 - parameters
  79.   push  ebp
  80.   mov   ebp,esp
  81.   mov   [file_struct.operation],16
  82.   xor   eax,eax
  83.   mov   [file_struct.offset],eax
  84.   mov   [file_struct.data],eax
  85.   mov   eax,[ebp+12]
  86.   mov   [file_struct.param],eax
  87.   mov   [file_struct.temp_buffer],temp_buffer;
  88.   mov   edx,[ebp+8]
  89.   call  copy_file_name
  90.   push  ebx
  91.   mov   eax,58
  92.   mov   ebx,file_struct
  93.   int   0x40
  94.   pop   ebx
  95.   pop   ebp
  96.   ret   8
  97. section '.bss' writeable
  98. file_struct:
  99. .operation   rd 1
  100. .offset      rd 1
  101. .param:
  102. .size        rd 1
  103. .data        rd 1
  104. .temp_buffer rd 1
  105. .path        rb 1024
  106.   temp_buffer rb 4096
  107.  
  108.  
  109.