本帖最后由 pusofalse 于 2011-4-15 07:48 编辑
#include <lsasecur.au3>
Local $sText1 = "Text1"
Local $sText2 = "Text2"
Local $iTimerInit = TimerInit()
For $i = 1 to 500
_CompareStringD($sText1, $sText2)
Next
MsgBox(0, TimerDiff($iTimerInit) / 1000, "")
Func _CompareStringD($sText1, $sText2)
Local $tText1, $tText2, $iLen1, $iLen2, $iMaxLen, $iMinLen, $tResult
$iLen1 = StringLen($sText1)
$iLen2 = StringLen($sText2)
If $iLen1 > $iLen2 Then
$iMaxLen = $iLen1
Else
$iMaxLen = $iLen2
EndIf
$iMinLen = ($iLen1 + $iLen2 - $iMaxLen) * 8 / 8 + 8
$tText1 = DllStructCreate("char Text[" & $iLen1 + 1 & "]")
$tText2 = DllStructCreate("char Text[" & $iLen2 + 1 & "]")
DllStructSetData($tText1, "Text", $sText1)
DllStructSetData($tText2, "Text", $sText2)
$tResult = DllStructCreate("ubyte BitFlags[" & Ceiling($iMaxLen / 4) & "]")
DllCall("User32.dll", "none", "CallWindowProcA", _
"ptr", _MMX_CompareStringD(), _
"ptr", DllStructGetPtr($tText1), _
"ptr", DllStructGetPtr($tText2), _
"dword", $iMinLen, _
"ptr", DllStructGetPtr($tResult))
Return DllStructGetData($tResult, "BitFlags")
EndFunc ;==>_CompareStringD
Func _MMX_CompareStringD()
Local Static $pStartAddr, $bCode, $tBuffer
If IsDllStruct($tBuffer) Then Return SetError(0, DllStructGetSize($tBuffer), $pStartAddr)
$pStartAddr = __SeVirtualAlloc(1024)
$bCode = "0x" & _
"55" & _ ; push ebp
"8BEC" & _ ; mov ebp, esp
"8B4D10" & _ ; mov ecx, dword ptr [ebp+10]
"C1E903" & _ ; shr ecx, 3
"E32F" & _ ; jecxz $+2f
"56" & _ ; push esi
"8B7508" & _ ; mov esi, dword ptr [ebp+8]
"57" & _ ; push edi
"8B7D0C" & _ ; mov edi, dword ptr [ebp+c]
"53" & _ ; push ebx
"8B5D14" & _ ; mov ebx, dword ptr [ebp+14]
"0F6F44CEF8" & _ ; movq mm0, qword ptr [esi+ecx*8-8]
"0F7644CFF8" & _ ; pcmpeqd mm0, qword ptr [edi+ecx*8-8]
"0F7EC2" & _ ; movd edx, mm0
"88544BFE" & _ ; mov byte ptr [ebx+ecx*2-2], dl
"0F73D020" & _ ; psrlq mm0, 20
"0F7EC2" & _ ; movd edx, mm0
"88544BFF" & _ ; mov byte ptr [ebx+ecx*2-1], dl
"E2E2" & _ ; loopd $-1e
"0F77" & _ ; emms
"5B" & _ ; pop ebx
"5F" & _ ; pop edi
"5E" & _ ; pop esi
"5D" & _ ; pop ebp
"C21000" & _ ; ret 10
"CCCC"
$tBuffer = DllStructCreate("ubyte Code[64]", $pStartAddr)
DllStructSetData($tBuffer, "Code", Binary($bCode))
Return SetError(0, DllStructGetSize($tBuffer), $pStartAddr)
EndFunc ;==>_MMX_CompareStringD
|