Subversion Repositories Kolibri OS

Rev

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

Rev 8593 Rev 8671
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 8593 $
8
$Revision: 8671 $
Line 9... Line 9...
9
 
9
 
Line 879... Line 879...
879
        dec     ecx
879
        dec     ecx
880
        rep movsb
880
        rep movsb
881
        mov     byte [edi], 0
881
        mov     byte [edi], 0
882
.check_tls_header:
882
.check_tls_header:
883
        cmp     word [6], '02'
883
        cmp     word [6], '02'
884
        jne     .cleanup
884
        jne     .try_load_dll ;.cleanup
885
        call    init_heap
885
        call    init_heap
886
        stdcall user_alloc, 4096
886
        stdcall user_alloc, 4096
887
        mov     edx, [current_slot]
887
        mov     edx, [current_slot]
888
        mov     [edx+APPDATA.tls_base], eax
888
        mov     [edx+APPDATA.tls_base], eax
889
        mov     [tls_data_l+2], ax
889
        mov     [tls_data_l+2], ax
890
        shr     eax, 16
890
        shr     eax, 16
891
        mov     [tls_data_l+4], al
891
        mov     [tls_data_l+4], al
892
        mov     [tls_data_l+7], ah
892
        mov     [tls_data_l+7], ah
893
        mov     dx, app_tls
893
        mov     dx, app_tls
894
        mov     fs, dx
894
        mov     fs, dx       
-
 
895
; { Patch by Coldy, For DLL autoload 
-
 
896
;   if APP_HEADER.version = 2 => lib/load dll.obj & change eip to APP_START_THUNK)
-
 
897
.try_load_dll:
-
 
898
; TODO: It;s app, not thread?
-
 
899
           
-
 
900
; Test app header version (
-
 
901
        mov     ecx, dword[ebp+APP_HDR.img_base]
-
 
902
        ;DEBUGF 1, "K : ecx = %d\n", [ecx+8]
-
 
903
        cmp     dword[ecx+8], 2
-
 
904
        jne     .cleanup
-
 
905
        DEBUGF 1, 'K : App header version 2\n'
-
 
906
        ;DEBUGF 1, "K : DLL.OBJ path: %s\n", dll_lib_path
-
 
907
        stdcall load_library, dll_lib_path, 0
-
 
908
        ;DEBUGF 1, "K : DLL.OBJ exp ptr: %x\n", eax
-
 
909
        
-
 
910
        ;test eax, eax
-
 
911
        ;jnz @f
-
 
912
        cmp     eax, 0
-
 
913
        jne     @f
-
 
914
; Something went wrong 
-
 
915
        stdcall free_kernel_space, [ebp+APP_HDR.img_base]
-
 
916
        stdcall kernel_free, ebp
-
 
917
        DEBUGF 1, 'K : DLL.OBJ not found! Terminate application!'
-
 
918
        mov     ebx, dll_error_msg
-
 
919
        mov     ebp, notifyapp
-
 
920
        call    fs_execute_from_sysdir_param
-
 
921
; Terminate process 
-
 
922
        call    sys_end
-
 
923
        
-
 
924
@@:       
-
 
925
        ; Find base of DLL.OBJ
-
 
926
        ;mov     ebx, eax
-
 
927
        ;cdq
-
 
928
        ;mov     ecx, 0x00000400
-
 
929
        ;div     ecx
-
 
930
        ;sub     ebx, edx
-
 
931
        sub     eax, 4
-
 
932
        mov     eax, [eax]   
-
 
933
        ;DEBUGF 1, "K : DLL.OBJ base ptr: %x\n", eax
-
 
934
        
-
 
935
; load_library don't map coff header,
-
 
936
; so we may change entry point for app APP_START_THUNK
-
 
937
; to base of DLL.OBJ
-
 
938
        
-
 
939
;.change_eip:
-
 
940
        mov     ecx, [current_slot]
-
 
941
        mov     ecx, [ecx+APPDATA.pl0_stack]
-
 
942
        ;DEBUGF 1, "K : EIP = %x\n", ebx
-
 
943
        mov     [ecx+REG_EIP], eax
-
 
944
        
-
 
945
; } End patch by Coldy, For DLL autoload
895
.cleanup:
946
.cleanup:
896
        stdcall free_kernel_space, [ebp+APP_HDR.img_base]
947
        stdcall free_kernel_space, [ebp+APP_HDR.img_base]
897
        stdcall kernel_free, ebp
948
        stdcall kernel_free, ebp
898
        mov     ebx, [current_slot]
949
        mov     ebx, [current_slot]
899
        cmp     [ebx+APPDATA.debugger_slot], 0
950
        cmp     [ebx+APPDATA.debugger_slot], 0