Subversion Repositories Kolibri OS

Rev

Rev 3038 | Rev 7134 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. ;-----------------------------------------------------------------------------
  2. proc dll.Load, import_table:dword
  3.         mov     esi, [import_table]
  4.   .next_lib:
  5.         mov     edx, [esi]
  6.         or      edx, edx
  7.         jz      .exit
  8.         push    esi
  9.         mov     esi, [esi + 4]
  10.         mov     edi, s_libdir.fname
  11.     @@:
  12.         lodsb
  13.         stosb
  14.         or      al, al
  15.         jnz     @b
  16.         mcall   68, 19, s_libdir
  17.         or      eax, eax
  18.         jz      .fail
  19.         stdcall dll.Link, eax, edx
  20.         push    eax
  21.         mov     eax, [eax]
  22.         cmp     dword[eax], 'lib_'
  23.         pop     eax
  24.         jnz     @f
  25.         stdcall dll.Init, [eax + 4]
  26.     @@:
  27.         pop     esi
  28.         add     esi, 8
  29.         jmp     .next_lib
  30.   .exit:
  31.         xor     eax, eax
  32.         ret
  33.   .fail:
  34.         add     esp, 4
  35.         xor     eax, eax
  36.         inc     eax
  37.         ret
  38. endp
  39. ;-----------------------------------------------------------------------------
  40. proc dll.Link, exp:dword, imp:dword
  41.         push    eax
  42.         mov     esi, [imp]
  43.         test    esi, esi
  44.         jz      .done
  45.   .next:
  46.         lodsd
  47.         test    eax, eax
  48.         jz      .done
  49.         stdcall dll.GetProcAddress, [exp], eax
  50.         or      eax, eax
  51.         jz      @f
  52.         mov     [esi - 4], eax
  53.         jmp     .next
  54.     @@:
  55.         mov     dword[esp], 0
  56.   .done:
  57.         pop     eax
  58.         ret
  59. endp
  60. ;-----------------------------------------------------------------------------
  61. proc dll.Init, dllentry:dword
  62.         pushad
  63.         mov     eax, mem.Alloc
  64.         mov     ebx, mem.Free
  65.         mov     ecx, mem.ReAlloc
  66.         mov     edx, dll.Load
  67.         stdcall [dllentry]
  68.         popad
  69.         ret
  70. endp
  71. ;-----------------------------------------------------------------------------
  72. proc dll.GetProcAddress, exp:dword, sz_name:dword
  73.         mov     edx, [exp]
  74.         xor     eax, eax
  75.   .next:
  76.         or      edx, edx
  77.         jz      .end
  78.         cmp     dword[edx], 0
  79.         jz      .end
  80.         stdcall strcmp, [edx], [sz_name]
  81.         test    eax, eax
  82.         jz      .ok
  83.         add     edx, 8
  84.         jmp     .next
  85.   .ok:
  86.         mov     eax, [edx + 4]
  87.   .end:
  88.         ret
  89. endp
  90. ;-----------------------------------------------------------------------------
  91. proc strcmp, str1:dword, str2:dword
  92.         push    esi edi
  93.         mov     esi, [str1]
  94.         mov     edi, [str2]
  95.         xor     eax, eax
  96.     @@:
  97.         lodsb
  98.         scasb
  99.         jne     .fail
  100.         or      al, al
  101.         jnz     @b
  102.         jmp     .ok
  103.   .fail:
  104.         or      eax, -1
  105.   .ok:
  106.         pop     edi esi
  107.         ret
  108. endp
  109. ;-----------------------------------------------------------------------------
  110. s_libdir:
  111.   db '/sys/lib/'
  112.   .fname rb 32
  113. ;-----------------------------------------------------------------------------
  114. proc mem.Alloc, size
  115.         push    ebx ecx
  116.         mov     ecx, [size]
  117.         mcall   68, 12
  118.         pop     ecx ebx
  119.         ret
  120. endp
  121. ;-----------------------------------------------------------------------------
  122. proc mem.ReAlloc, mptr, size
  123.         push    ebx ecx edx
  124.         mov     ecx, [size]
  125.         mov     edx, [mptr]
  126.         mcall   68, 20
  127.         pop     edx ecx ebx
  128.         ret
  129. endp
  130. ;-----------------------------------------------------------------------------
  131. proc mem.Free, mptr
  132.         push    ebx ecx
  133.         mov     ecx,[mptr]
  134.         mcall   68, 13
  135.         pop     ecx ebx
  136.         ret
  137. endp
  138. ;-----------------------------------------------------------------------------
  139.