; 效果不如意
;[MCode function]
;GitHub - joedf/MCode4GCC: MCode4GCC is an MCode generator using the GCC Compiler.
;https://github.com/joedf/MCode4GCC
; q:: ;string compare case-insensitive Unicode get position
;VarSetCapacity(x, 20100100*2+2)
;Loop, 20100100
; x .= "a"
x := StrReplace(Format("{:20100100}", ""), " ", "a")
y := x
x .= "A"
y .= "a"
;NumPut(Ord("z"), &x, 10000000, "UShort")
vSize := StrLen(x)*2
; MsgBox, % "准备好变量"
;区分大小写的比较
vTickCount := A_TickCount
vRet := DllCall("ntdll\RtlCompareMemory", "Ptr",&x, "Ptr",&y, "UPtr",vSize, "UPtr")
MsgBox, % vRet "`n是否一致:" (vRet = vSize) "`n耗时:" (A_TickCount - vTickCount)
;不区分大小写的比较
vTickCount := A_TickCount
StringLower, x, % x ; 转换字符串为小写
StringLower, y, % y
vRet := DllCall("ntdll\RtlCompareMemory", "Ptr",&x, "Ptr",&y, "UPtr",vSize, "UPtr")
MsgBox, % vRet "`n是否一致:" (vRet = vSize) "`n耗时:" (A_TickCount - vTickCount)
;不敏感比较
pFuncToWUpper := DllCall("kernel32\GetProcAddress", "Ptr",DllCall("kernel32\GetModuleHandle", "Str","msvcrt", "Ptr"), "AStr","towupper", "Ptr")
pFunc := MCode("2,x86:VVdWU4PsHItEJDiLbCQ0i1wkPIXAdDMx/+sOkI10JgCDxwE5fCQ4dCGLRCQwD7cEeIkEJP/TicYPt0R9AIkEJP/TOcZ02ol8JDiLRCQ4g8QcW15fXcM=,x64:QVZBVUFUVVdWU0iD7CBFhcBJicxJidVFicZMic50MkGNaP8x20iDxQHrDg8fRAAASIPDAUg53XQYQQ+3DFz/1kEPt0xdAInH/9Y5x3TiQYneRInwSIPEIFteX11BXEFdQV7D")
vTickCount := A_TickCount
vRet := DllCall(pFunc, "Ptr",&x, "Ptr",&y, "UInt",vSize/2, "Ptr",pFuncToWUpper, "Cdecl")
MsgBox, % vRet "`n是否一致:" (vRet = vSize/2) "`n耗时:" (A_TickCount - vTickCount)
return
;e.g. results
;15 203 780
;31 203 780
;15 202 764
return
/*
unsigned int customstrcmpi(unsigned short* str1, unsigned short* str2, unsigned int count, int _cdecl(*MyFunction)(int))
{
for (unsigned int i = 0; i < count; ++i)
{
//if (str1[i] != str2[i])
if ((*MyFunction)(str1[i]) != (*MyFunction)(str2[i]))
{
count = i;
break;
}
}
return count;
}
*/
MCode(mcode) {
static e := {1:4, 2:1}, c := (A_PtrSize=8) ? "x64" : "x86"
if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m))
return
if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0))
return
p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr")
if (c="x64")
DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op)
if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0))
return p
DllCall("GlobalFree", "ptr", p)
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。

评论(0)