Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
.text:00430364 __fastcall KiZeroPages(x, x) proc near ; CODE XREF: MiZeroWorkerPages(x,x)+10Dp
.text:00430364 ; KiXMMIZeroPages(x,x)+B5j ...
.text:00430364 push edi
.text:00430365 xor eax, eax
.text:00430367 mov edi, ecx
.text:00430369 mov ecx, edx
.text:0043036B shr ecx, 2
.text:0043036E rep stosd
.text:00430370 pop edi
.text:00430371 retn
.text:00430371 __fastcall KiZeroPages(x, x) endp
.text:00430288 __fastcall KiXMMIZeroPagesNoSave(x, x) proc near
.text:00430288 ; CODE XREF: KiXMMIZeroPages(x,x)+84p
.text:00430288 ; DATA XREF: KiInitMachineDependent()+1F0o
.text:00430288
.text:00430288 var_4 = dword ptr -4
.text:00430288
.text:00430288 xorps xmm0, xmm0
.text:0043028B shr edx, 6
.text:0043028E
.text:0043028E loc_43028E: ; CODE XREF: KiXMMIZeroPagesNoSave(x,x)+19j
.text:0043028E movntps xmmword ptr [ecx], xmm0
.text:00430291 movntps xmmword ptr [ecx+10h], xmm0
.text:00430295 movntps xmmword ptr [ecx+20h], xmm0
.text:00430299 movntps xmmword ptr [ecx+30h], xmm0
.text:0043029D add ecx, 40h
.text:004302A0 dec edx
.text:004302A1 jnz short loc_43028E
.text:004302A3 sfence
.text:004302A6 xchg edx, [esp+var_4]
.text:004302AA retn
.text:004302AA __fastcall KiXMMIZeroPagesNoSave(x, x) endp
//
// The following code sets the current thread's base priority to zero
// and then sets its current priority to zero. This ensures that the
// thread always runs at a priority of zero.
//
KeSetPriorityZeroPageThread (0);
// TEMPLATE FUNCTION fill
template< class _FwdIt, class _Ty >
inline void _Fill(_FwdIt _First, _FwdIt _Last, const _Ty& _Val)
{ // copy _Val through [_First, _Last)
for (; _First != _Last; ++_First)
*_First = _Val;
}
inline void _Fill(char *_First, char *_Last, int _Val)
{ // copy char _Val through [_First, _Last)
_CSTD memset(_First, _Val, _Last - _First);
}
inline void _Fill(signed char *_First, signed char *_Last, int _Val)
{ // copy signed char _Val through [_First, _Last)
_CSTD memset(_First, _Val, _Last - _First);
}
inline void _Fill(unsigned char *_First, unsigned char *_Last, int _Val)
{ // copy unsigned char _Val through [_First, _Last)
_CSTD memset(_First, _Val, _Last - _First);
}
; 8 : if (mode == 1)
00031 83 ff 01 cmp edi, 1
00034 75 16 jne SHORT $LN5@main
$LN32@main:
; 9 : std::memset(buf, 0, n * sizeof(*buf));
00036 68 00 00 00 40 push 1073741824 ; 40000000H
; 15 : std::fill(buf, buf + n, '\0');
0003b 6a 00 push 0
0003d 56 push esi
0003e e8 00 00 00 00 call _memset
; 16 : return buf[0];
00043 0f be 06 movsx eax, BYTE PTR [esi]
00046 83 c4 0c add esp, 12 ; 0000000cH
00049 5f pop edi
0004a 5e pop esi
; 17 : }
0004b c3 ret 0
$LN5@main:
; 10 : // else if (mode == 2)
; 11 : // bzero(buf, n * sizeof(*buf));
; 12 : else if (mode == 3)
0004c 83 ff 03 cmp edi, 3
; 13 : std::fill(buf, buf + n, 0);
0004f 74 e5 je SHORT $LN32@main
; 14 : else if (mode == 4)
00051 83 ff 04 cmp edi, 4
00054 75 18 jne SHORT $LN26@main
; 15 : std::fill(buf, buf + n, '\0');
00056 8d 86 00 00 00
40 lea eax, DWORD PTR [esi+1073741824]
0005c 3b f0 cmp esi, eax
0005e 74 0e je SHORT $LN26@main
00060 2b c6 sub eax, esi
00062 50 push eax
00063 6a 00 push 0
00065 56 push esi
00066 e8 00 00 00 00 call _memset
0006b 83 c4 0c add esp, 12 ; 0000000cH
$LN26@main:
; 16 : return buf[0];
0006e 0f be 06 movsx eax, BYTE PTR [esi]
00071 5f pop edi
00072 5e pop esi
for( auto p = buf; p != buf + n; ++p )
*p = '\0';
00DA107D lea eax,[esi+40000000h]
00DA1083 cmp esi,eax
00DA1085 je f+95h (0DA1095h)
00DA1087 sub eax,esi
00DA1089 push eax
00DA108A push 0
00DA108C push esi
00DA108D call memset (0DA1D64h)
00DA1092 add esp,0Ch
Кто быстрее: memset, bzero или std::fill