From a98583280d8b33605c005884854db46166afa21b Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Wed, 12 May 2021 22:06:34 +0800 Subject: more trdlist functions --- asm/rich4.asm | 122 ++------------------------------------------- asm/rich4_crt_mthread.asm | 123 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 125 insertions(+), 120 deletions(-) diff --git a/asm/rich4.asm b/asm/rich4.asm index f152319..172e033 100644 --- a/asm/rich4.asm +++ b/asm/rich4.asm @@ -183,10 +183,8 @@ extern __NTThreadFini global clib_free global fcn_0045c836 global fcn_0045e8ca -global __GetThreadData global __InitThreadData global lib_calloc -global __ReallocThreadData global ref_00488f78 global ref_00488f7c global ref_00499954 @@ -194,7 +192,11 @@ global _RWD_osbuild global _RWD_osmajor global __ThreadDataSize global __TlsIndex - +global __fatal_runtime_error +global fcn_0045c585 +global ref_0046c97c +global ref_0046c9a1 +global ref_0046c9c9 section .text db 0xcc @@ -125402,120 +125404,6 @@ loc_0045c6bc: pop ebx ret -__GetThreadData: -push ebx -xor ebx, ebx -push ebx -call __NTAddThread ; call 0x45a2cb -add esp, 4 -test eax, eax -je short loc_0045c6de ; je 0x45c6de -mov edx, dword [__TlsIndex] ; mov edx, dword [0x488f48] -push edx -call dword [cs:__imp__TlsGetValue@4] ; ucall: call dword cs:[0x46241c] -mov ebx, eax - -loc_0045c6de: -test ebx, ebx -jne short loc_0045c6f1 ; jne 0x45c6f1 -push 1 -push ref_0046c97c ; push 0x46c97c -call __fatal_runtime_error ; call 0x45c690 -add esp, 8 - -loc_0045c6f1: -mov eax, ebx -pop ebx -ret - -__ReallocThreadData: -push ebx -push esi -push edi -push ebp -call dword [ref_00488f78] ; ucall: call dword [0x488f78] -call dword [cs:__imp__GetCurrentThreadId@0] ; ucall: call dword cs:[0x46238c] -mov ebx, dword [ref_00499954] ; mov ebx, dword [0x499954] -mov ebp, eax -jmp short loc_0045c717 ; jmp 0x45c717 - -loc_0045c710: -cmp ebp, dword [ebx + 4] -je short loc_0045c71b ; je 0x45c71b -mov ebx, dword [ebx] - -loc_0045c717: -test ebx, ebx -jne short loc_0045c710 ; jne 0x45c710 - -loc_0045c71b: -cmp dword [ebx + 0xc], 0 -je short loc_0045c74b ; je 0x45c74b -mov edi, dword [__ThreadDataSize] ; mov edi, dword [0x4894b0] -push edi -mov ebp, dword [ebx + 8] -push ebp -call fcn_0045c585 ; call 0x45c585 -add esp, 8 -mov ebp, eax -test eax, eax -jne short loc_0045c799 ; jne 0x45c799 -push 1 -push ref_0046c9a1 ; push 0x46c9a1 -call __fatal_runtime_error ; call 0x45c690 -add esp, 8 -jmp short loc_0045c799 ; jmp 0x45c799 - -loc_0045c74b: -mov esi, dword [__ThreadDataSize] ; mov esi, dword [0x4894b0] -push esi -push 1 -call lib_calloc ; call 0x45c62e -add esp, 8 -mov ebp, eax -test eax, eax -jne short loc_0045c771 ; jne 0x45c771 -push 1 -push ref_0046c9c9 ; push 0x46c9c9 -call __fatal_runtime_error ; call 0x45c690 -add esp, 8 - -loc_0045c771: -mov esi, dword [ebx + 8] -mov edi, ebp -mov ecx, dword [esi + 0xf0] -push es -mov eax, ds -mov es, eax -push edi -mov eax, ecx -shr ecx, 2 -repne movsd -mov cl, al -and cl, 3 -repne movsb ; repne movsb byte es:[edi], byte ptr [esi] -pop edi -pop es -mov dword [ebx + 0xc], 1 - -loc_0045c799: -mov dword [ebx + 8], ebp -mov eax, dword [__ThreadDataSize] ; mov eax, dword [0x4894b0] -push ebp -mov dword [ebp + 0xf0], eax -mov eax, dword [__TlsIndex] ; mov eax, dword [0x488f48] -mov byte [ebp + 0x52], 1 -push eax -mov byte [ebp + 0x53], 0 -call dword [cs:__imp__TlsSetValue@8] ; ucall: call dword cs:[0x462420] -call dword [ref_00488f7c] ; ucall: call dword [0x488f7c] -mov eax, ebp -pop ebp -pop edi -pop esi -pop ebx -ret - fcn_0045c836: push ebx push esi diff --git a/asm/rich4_crt_mthread.asm b/asm/rich4_crt_mthread.asm index 26e66b7..9974ca6 100644 --- a/asm/rich4_crt_mthread.asm +++ b/asm/rich4_crt_mthread.asm @@ -10,13 +10,12 @@ extern __imp__TlsAlloc@0 extern __imp__TlsFree@4 extern __imp__TlsGetValue@4 extern __imp__TlsSetValue@8 +extern __imp__GetCurrentThreadId@0 extern clib_free extern fcn_0045c836 extern fcn_0045e8ca -extern __GetThreadData extern __InitThreadData extern lib_calloc -extern __ReallocThreadData extern ref_00488f78 extern ref_00488f7c extern ref_00499954 @@ -24,7 +23,11 @@ extern _RWD_osbuild extern _RWD_osmajor extern __ThreadDataSize extern __TlsIndex - +extern __fatal_runtime_error +extern fcn_0045c585 +extern ref_0046c97c +extern ref_0046c9a1 +extern ref_0046c9c9 section .text @@ -201,6 +204,120 @@ ret ;; trdlist.c +__GetThreadData: +push ebx +xor ebx, ebx +push ebx +call __NTAddThread ; call 0x45a2cb +add esp, 4 +test eax, eax +je short loc_0045c6de ; je 0x45c6de +mov edx, dword [__TlsIndex] ; mov edx, dword [0x488f48] +push edx +call dword [cs:__imp__TlsGetValue@4] ; ucall: call dword cs:[0x46241c] +mov ebx, eax + +loc_0045c6de: +test ebx, ebx +jne short loc_0045c6f1 ; jne 0x45c6f1 +push 1 +push ref_0046c97c ; push 0x46c97c +call __fatal_runtime_error ; call 0x45c690 +add esp, 8 + +loc_0045c6f1: +mov eax, ebx +pop ebx +ret + +__ReallocThreadData: +push ebx +push esi +push edi +push ebp +call dword [ref_00488f78] ; ucall: call dword [0x488f78] +call dword [cs:__imp__GetCurrentThreadId@0] ; ucall: call dword cs:[0x46238c] +mov ebx, dword [ref_00499954] ; mov ebx, dword [0x499954] +mov ebp, eax +jmp short loc_0045c717 ; jmp 0x45c717 + +loc_0045c710: +cmp ebp, dword [ebx + 4] +je short loc_0045c71b ; je 0x45c71b +mov ebx, dword [ebx] + +loc_0045c717: +test ebx, ebx +jne short loc_0045c710 ; jne 0x45c710 + +loc_0045c71b: +cmp dword [ebx + 0xc], 0 +je short loc_0045c74b ; je 0x45c74b +mov edi, dword [__ThreadDataSize] ; mov edi, dword [0x4894b0] +push edi +mov ebp, dword [ebx + 8] +push ebp +call fcn_0045c585 ; call 0x45c585 +add esp, 8 +mov ebp, eax +test eax, eax +jne short loc_0045c799 ; jne 0x45c799 +push 1 +push ref_0046c9a1 ; push 0x46c9a1 +call __fatal_runtime_error ; call 0x45c690 +add esp, 8 +jmp short loc_0045c799 ; jmp 0x45c799 + +loc_0045c74b: +mov esi, dword [__ThreadDataSize] ; mov esi, dword [0x4894b0] +push esi +push 1 +call lib_calloc ; call 0x45c62e +add esp, 8 +mov ebp, eax +test eax, eax +jne short loc_0045c771 ; jne 0x45c771 +push 1 +push ref_0046c9c9 ; push 0x46c9c9 +call __fatal_runtime_error ; call 0x45c690 +add esp, 8 + +loc_0045c771: +mov esi, dword [ebx + 8] +mov edi, ebp +mov ecx, dword [esi + 0xf0] +push es +mov eax, ds +mov es, eax +push edi +mov eax, ecx +shr ecx, 2 +repne movsd +mov cl, al +and cl, 3 +repne movsb ; repne movsb byte es:[edi], byte ptr [esi] +pop edi +pop es +mov dword [ebx + 0xc], 1 + +loc_0045c799: +mov dword [ebx + 8], ebp +mov eax, dword [__ThreadDataSize] ; mov eax, dword [0x4894b0] +push ebp +mov dword [ebp + 0xf0], eax +mov eax, dword [__TlsIndex] ; mov eax, dword [0x488f48] +mov byte [ebp + 0x52], 1 +push eax +mov byte [ebp + 0x53], 0 +call dword [cs:__imp__TlsSetValue@8] ; ucall: call dword cs:[0x462420] +call dword [ref_00488f7c] ; ucall: call dword [0x488f7c] +mov eax, ebp +pop ebp +pop edi +pop esi +pop ebx +ret + __AddThreadData: push ebx push esi -- cgit v1.2.3