|
[原创]MD5汇编源码折腾日记(附全部RASM源码)
第四天 再次回头观察源码,痛苦的发现,怎么越折腾效率越低了呢,矛和盾怎么就不能协调呢,鱼和熊掌怎么就不能兼得呢,还有一点就...看雪论坛网页打开就这么费劲呢? 于是,我做出了最大的决定........不折腾了!!!!! 第五天 见下面链接 http://bbs.pediy.com/showthread.php?t=165869 |
|
[原创]MD5汇编源码折腾日记(附全部RASM源码)
第三天 再次看了下源码,发现那一堆Ti数据表,怎么看怎么是个累赘,得了,附加段代码,自动生成吧,又变成了下面这样: (详细代码看附件) .const IDC_BtFileName equ 1001 IDC_EditFileName equ 1002 IDC_EditMD5 equ 1003 IDC_BtMD5 equ 1004 IDC_BtTerminateMD5 equ 1005 .data szClassName db "Class",0 szWindowName db "MD5加密算法",0 szEdit db "Edit",0 szButton db "Button",0 szBtMD5 db '开始MD5',0 szBtTerminateMD5 db '终止MD5',0 szBtFileName db '文件...',0 szStrFilter db "所有文件(*.*)",0,"*.*",0,0 szCurrentFilePath db MAX_PATH dup (?) szFileName db MAX_PATH dup (?) align dword dwFLeftMove db 07,12,17,22 dwGLeftMove db 05,09,14,20 dwHLeftMove db 04,11,16,23 dwILeftMove db 06,10,15,21 dwFOffset db 00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15 dwGOffset db 01,06,11,00,05,10,15,04,09,14,03,08,13,02,07,12 dwHOffset db 05,08,11,14,01,04,07,10,13,00,03,06,09,12,15,02 dwIOffset db 00,07,14,05,12,03,10,01,08,15,06,13,04,11,02,09 .data? hMD5Thd dd ? hInstance dd ? hWinMain dd ? hEditMD5 dd ? hBtMD5 dd ? hBtTerminateMD5 dd ? hBtFileName dd ? hEditFileName dd ? lpFileMemHeader dd ? dwOpenFileSize dd ? .code _OpenFileProc proc uses ebx esi edi ,_hWnd LOCAL @dwOpenFileSizeHigh LOCAL @szBuffer3[1024]:byte LOCAL @stOFN:OPENFILENAME LOCAL @stSA:SECURITY_ATTRIBUTES LOCAL @hDC1 LOCAL @hFileMap LOCAL @hOpenFile LOCAL @dwTmp .if lpFileMemHeader invoke UnmapViewOfFile,lpFileMemHeader mov lpFileMemHeader,0 .endif invoke SetWindowText,hEditFileName,0 invoke SetWindowText,hEditMD5,0 mov dwOpenFileSize,0 invoke RtlZeroMemory,addr @stOFN,sizeof @stOFN mov @stOFN.lStructSize,sizeof @stOFN lea eax,szCurrentFilePath mov @stOFN.lpstrFile,eax mov @stOFN.nMaxFile,MAX_PATH mov @stOFN.Flags,OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST invoke GetOpenFileName,addr @stOFN .if !eax jmp _NOPE .endif invoke SetWindowText,hEditFileName,addr szCurrentFilePath invoke RtlZeroMemory,addr @stSA,sizeof @stSA invoke CreateFile,addr szCurrentFilePath, GENERIC_READ,FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE,addr @stSA,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL ,0;FILE_FLAG_DELETE_ON_CLOSE or .if eax == INVALID_HANDLE_VALUE jmp _NOPE .endif mov @hOpenFile,eax invoke GetFileSize,@hOpenFile,addr @dwOpenFileSizeHigh mov dwOpenFileSize,eax .if !eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile jmp _NOPE .endif invoke CreateFileMapping,@hOpenFile,0,PAGE_READONLY,0,0,0 .if !eax invoke CloseHandle,@hOpenFile jmp _NOPE .endif mov @hFileMap,eax invoke MapViewOfFile,@hFileMap, FILE_MAP_READ,0,0,0 .if !eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile jmp _NOPE .endif mov lpFileMemHeader,eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile _NOPE: ret _OpenFileProc endp _LeftMov@MD5 macro _dwA,_dwB,x,s,t add eax,_dwA add eax,x add eax,t mov cl,s rol eax,cl add eax,_dwB endm ; F(x,y,z) = (x and y) or ((not x) and z) ; a =((a + F(b,c,d) + x + t) << s ) + b _FProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD and ebx,eax not eax and eax,ecx or eax,ebx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; G(x,y,z) = (x and z) or (y and (not z)) ; a = ((a + G(b,c,d) + x + t) << s) + b _GProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD and eax,ecx not ecx and ecx,ebx or eax,ecx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; H(x,y,z) = x xor y xor z ; a = ((a + H(b,c,d) + x + t) << s) + b _HProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD xor eax,ebx xor eax,ecx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; I(x,y,z) = y xor (x or (not z)) ; a = ((a + I(b,c,d) + x + t) << s) + b _IProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD not ecx or eax,ecx xor eax,ebx _LeftMov@MD5 _dwA,_dwB,x,s,t endm _dwA@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwA,@dwB,@dwC,@dwD,dword ptr [edi+_dwBitNumber*4],_ALeftBits,_dwTi mov @dwA,eax endm _dwB@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwB,@dwC,@dwD,@dwA,dword ptr [edi+_dwBitNumber*4],_BLeftBits,_dwTi mov @dwB,eax endm _dwC@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwC,@dwD,@dwA,@dwB,dword ptr [edi+_dwBitNumber*4],_CLeftBits,_dwTi mov @dwC,eax endm _dwD@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwD,@dwA,@dwB,@dwC,dword ptr [edi+_dwBitNumber*4],_DLeftBits,_dwTi mov @dwD,eax endm _MD5hashProc proc uses edi esi,_lpFileMem,_dwFileSize,_lpszMD5Buffer local @dwA,@dwB,@dwC,@dwD LOCAL @dwRotateMD5Count LOCAL @dwEndRotateMD5Count LOCAL @szBuffer1[128]:byte LOCAL @dwFTi[64]:dword LOCAL @bEndMD5 LOCAL @dbFileSizeInBuffer:byte LOCAL @dwTiCount LOCAL @dwTiN0 LOCAL @dwTiN1 LOCAL @dwTiN2 LOCAL @wCW:word LOCAL @dwTmp1 LOCAL @dwTmp2 ;初始化Ti mov @dwTiCount,1 mov @dwTiN1,10000000h mov @dwTiN2,10h lea edi,@dwFTi mov @wCW,0001011111111111b;设置近似值为剪裁掉尾数状态 wait fldcw @wCW @@: fild @dwTiCount fsin fabs fild @dwTiN1 fmul fist @dwTmp1 fild @dwTmp1 fsub fild @dwTiN2 fmul fistp @dwTmp2 fwait mov eax,@dwTmp1 shl eax,4 add eax,@dwTmp2 mov dword ptr [edi],eax inc @dwTiCount add edi,sizeof dword cmp @dwTiCount,65 jz @f jmp @b @@: xor al,al lea edi,@szBuffer1 mov ecx,sizeof @szBuffer1 cld rep stosb mov @bEndMD5,FALSE ;求得512取模及需要填充的数据 mov eax,_dwFileSize shr eax,6 mov @dwRotateMD5Count,eax ;模64后末尾字符串复制到缓冲区 lea edi,@szBuffer1 mov esi,_lpFileMem mov eax,_dwFileSize mov ecx,eax and eax,0ffffffc0h; add esi,eax and ecx,03fh;除以64求模 mov @dbFileSizeInBuffer,cl .if ecx cld rep movsb .endif mov byte ptr [edi],080h;消息末尾附1 ;后64位填充消息长度//转为处理@szBuffer1 lea edi,@szBuffer1 mov eax,_dwFileSize;ebx mov edx,eax shl eax,3 shr edx,29 mov cl,@dbFileSizeInBuffer;_dwFileSize .if cl < 56 mov @dwEndRotateMD5Count,1 mov dword ptr [edi+ 60],edx mov dword ptr [edi+ 56],eax .else mov @dwEndRotateMD5Count,2 mov dword ptr [edi+124],edx mov dword ptr [edi+120],eax .endif push 067452301h pop @dwA push 0efcdab89h pop @dwB push 098badcfeh pop @dwC push 010325476h pop @dwD mov edi,_lpFileMem _Rotate: mov ecx, @dwRotateMD5Count .while ecx push ecx push @dwD push @dwC push @dwB push @dwA xor esi,esi .while esi < 64 mov eax,@dwB mov ebx,@dwC mov ecx,@dwD .if esi < 16;F and ebx,eax not eax and eax,ecx or eax,ebx .elseif esi < 32;G and eax,ecx not ecx and ecx,ebx or eax,ecx .elseif esi < 48;H xor eax,ebx xor eax,ecx .else ;I not ecx or eax,ecx xor eax,ebx .endif add eax,@dwA movzx ecx,byte ptr [offset dwFOffset + esi ] add eax,dword ptr [edi+ ecx * sizeof dword];x lea ecx,@dwFTi add eax,dword ptr [ecx + esi * sizeof dword];t mov ecx,esi shr ecx,2 and ecx,12 mov edx,esi and edx,3 mov cl,byte ptr [offset dwFLeftMove + edx + ecx] rol eax,cl add eax,@dwB xchg eax,@dwB xchg eax,@dwC xchg eax,@dwD xchg eax,@dwA inc esi .endw pop eax add @dwA,eax pop eax add @dwB,eax pop eax add @dwC,eax pop eax add @dwD,eax add edi,16*sizeof dword pop ecx dec ecx .endw .if @bEndMD5 == TRUE jmp @f .endif push @dwEndRotateMD5Count pop @dwRotateMD5Count lea edi,@szBuffer1 mov @bEndMD5,TRUE jmp _Rotate @@: mov eax,@dwA bswap eax mov ebx,@dwB bswap ebx mov ecx,@dwC bswap ecx mov edx,@dwD bswap edx jmp @f szMD5Format@_MD5hashProc db '%.8x%.8x%.8x%.8x',0 @@: invoke wsprintf,_lpszMD5Buffer,addr szMD5Format@_MD5hashProc,eax,ebx,ecx,edx ret _MD5hashProc endp |
|
[原创]MD5汇编源码折腾日记(附全部RASM源码)
第二天 写完后,发现:中间那一堆代码怎么看怎么那么不顺眼呢!!,继续改写,折腾吧就..... 变成了如下样子: (详细代码看附件) .const IDC_BtFileName equ 1001 IDC_EditFileName equ 1002 IDC_EditMD5 equ 1003 IDC_BtMD5 equ 1004 IDC_BtTerminateMD5 equ 1005 .data szClassName db "Class",0 szWindowName db "MD5加密算法",0 szEdit db "Edit",0 szButton db "Button",0 szBtMD5 db '开始MD5',0 szBtTerminateMD5 db '终止MD5',0 szBtFileName db '文件...',0 szStrFilter db "所有文件(*.*)",0,"*.*",0,0 szCurrentFilePath db MAX_PATH dup (?) szFileName db MAX_PATH dup (?) align dword dwFLeftMove db 07,12,17,22 dwGLeftMove db 05,09,14,20 dwHLeftMove db 04,11,16,23 dwILeftMove db 06,10,15,21 dwFOffset db 00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15 dwGOffset db 01,06,11,00,05,10,15,04,09,14,03,08,13,02,07,12 dwHOffset db 05,08,11,14,01,04,07,10,13,00,03,06,09,12,15,02 dwIOffset db 00,07,14,05,12,03,10,01,08,15,06,13,04,11,02,09 dwFTi DWORD 0D76AA478H,0E8C7B756H,0242070DBH,0C1BDCEEEH DWORD 0F57C0FAFH,04787C62AH,0A8304613H,0FD469501H DWORD 0698098D8H,08B44F7AFH,0FFFF5BB1H,0895CD7BEH DWORD 06B901122H,0FD987193H,0A679438EH,049B40821H dwGTi DWORD 0F61E2562H,0C040B340H,0265E5A51H,0E9B6C7AAH DWORD 0D62F105DH,002441453H,0D8A1E681H,0E7D3FBC8H DWORD 021E1CDE6H,0C33707D6H,0F4D50D87H,0455A14EDH DWORD 0A9E3E905H,0FCEFA3F8H,0676F02D9H,08D2A4C8AH dwHTi DWORD 0FFFA3942H,08771F681H,06D9D6122H,0FDE5380CH DWORD 0A4BEEA44H,04BDECFA9H,0F6BB4B60H,0BEBFBC70H DWORD 0289B7EC6H,0EAA127FAH,0D4EF3085H,004881D05H DWORD 0D9D4D039H,0E6DB99E5H,01FA27CF8H,0C4AC5665H dwITi DWORD 0F4292244H,0432AFF97H,0AB9423A7H,0FC93A039H DWORD 0655B59C3H,08F0CCC92H,0FFEFF47DH,085845DD1H DWORD 06FA87E4FH,0FE2CE6E0H,0A3014314H,04E0811A1H DWORD 0F7537E82H,0BD3AF235H,02AD7D2BBH,0EB86D391H .data? hMD5Thd dd ? hInstance dd ? hWinMain dd ? hEditMD5 dd ? hBtMD5 dd ? hBtTerminateMD5 dd ? hBtFileName dd ? hEditFileName dd ? lpFileMemHeader dd ? dwOpenFileSize dd ? .code _OpenFileProc proc uses ebx esi edi ,_hWnd LOCAL @dwOpenFileSizeHigh LOCAL @szBuffer3[1024]:byte LOCAL @stOFN:OPENFILENAME LOCAL @stSA:SECURITY_ATTRIBUTES LOCAL @hDC1 LOCAL @hFileMap LOCAL @hOpenFile LOCAL @dwTmp .if lpFileMemHeader invoke UnmapViewOfFile,lpFileMemHeader mov lpFileMemHeader,0 .endif invoke SetWindowText,hEditFileName,0 invoke SetWindowText,hEditMD5,0 mov dwOpenFileSize,0 invoke RtlZeroMemory,addr @stOFN,sizeof @stOFN mov @stOFN.lStructSize,sizeof @stOFN lea eax,szCurrentFilePath mov @stOFN.lpstrFile,eax mov @stOFN.nMaxFile,MAX_PATH mov @stOFN.Flags,OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST invoke GetOpenFileName,addr @stOFN .if !eax jmp _NOPE .endif invoke SetWindowText,hEditFileName,addr szCurrentFilePath invoke RtlZeroMemory,addr @stSA,sizeof @stSA invoke CreateFile,addr szCurrentFilePath, GENERIC_READ,FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE,addr @stSA,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL ,0;FILE_FLAG_DELETE_ON_CLOSE or .if eax == INVALID_HANDLE_VALUE jmp _NOPE .endif mov @hOpenFile,eax invoke GetFileSize,@hOpenFile,addr @dwOpenFileSizeHigh mov dwOpenFileSize,eax .if !eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile jmp _NOPE .endif invoke CreateFileMapping,@hOpenFile,0,PAGE_READONLY,0,0,0 .if !eax invoke CloseHandle,@hOpenFile jmp _NOPE .endif mov @hFileMap,eax invoke MapViewOfFile,@hFileMap, FILE_MAP_READ,0,0,0 .if !eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile jmp _NOPE .endif mov lpFileMemHeader,eax invoke CloseHandle,@hFileMap invoke CloseHandle,@hOpenFile _NOPE: ret _OpenFileProc endp _LeftMov@MD5 macro _dwA,_dwB,x,s,t add eax,_dwA add eax,x add eax,t mov cl,s rol eax,cl add eax,_dwB endm ; F(x,y,z) = (x and y) or ((not x) and z) ; a =((a + F(b,c,d) + x + t) << s ) + b _FProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD and ebx,eax not eax and eax,ecx or eax,ebx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; G(x,y,z) = (x and z) or (y and (not z)) ; a = ((a + G(b,c,d) + x + t) << s) + b _GProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD and eax,ecx not ecx and ecx,ebx or eax,ecx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; H(x,y,z) = x xor y xor z ; a = ((a + H(b,c,d) + x + t) << s) + b _HProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD xor eax,ebx xor eax,ecx _LeftMov@MD5 _dwA,_dwB,x,s,t endm ; I(x,y,z) = y xor (x or (not z)) ; a = ((a + I(b,c,d) + x + t) << s) + b _IProc@MD5 macro _dwA,_dwB,_dwC,_dwD,x,s,t mov eax,_dwB mov ebx,_dwC mov ecx,_dwD not ecx or eax,ecx xor eax,ebx _LeftMov@MD5 _dwA,_dwB,x,s,t endm _dwA@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwA,@dwB,@dwC,@dwD,dword ptr [edi+_dwBitNumber*4],_ALeftBits,_dwTi mov @dwA,eax endm _dwB@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwB,@dwC,@dwD,@dwA,dword ptr [edi+_dwBitNumber*4],_BLeftBits,_dwTi mov @dwB,eax endm _dwC@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwC,@dwD,@dwA,@dwB,dword ptr [edi+_dwBitNumber*4],_CLeftBits,_dwTi mov @dwC,eax endm _dwD@MD5 macro _Function,_dwBitNumber,_dwTi _Function&@MD5 @dwD,@dwA,@dwB,@dwC,dword ptr [edi+_dwBitNumber*4],_DLeftBits,_dwTi mov @dwD,eax endm _MD5hashProc proc uses edi esi,_lpFileMem,_dwFileSize,_lpdwMD5Buffer local @dwA,@dwB,@dwC,@dwD LOCAL @dwRotateMD5Count LOCAL @dwEndRotateMD5Count LOCAL @szBuffer1[128]:byte LOCAL @bEndMD5 LOCAL @dbFileSizeInBuffer:byte xor al,al lea edi,@szBuffer1 mov ecx,sizeof @szBuffer1 cld rep stosb mov @bEndMD5,FALSE ;求得512取模及需要填充的数据 mov eax,_dwFileSize shr eax,6 mov @dwRotateMD5Count,eax ;模64后末尾字符串复制到缓冲区 lea edi,@szBuffer1 mov esi,_lpFileMem mov eax,_dwFileSize mov ecx,eax and eax,0ffffffc0h; add esi,eax and ecx,03fh;除以64求模 mov @dbFileSizeInBuffer,cl .if ecx cld rep movsb .endif mov byte ptr [edi],080h;消息末尾附1 ;后64位填充消息长度//转为处理@szBuffer1 lea edi,@szBuffer1 mov eax,_dwFileSize;ebx mov edx,eax shl eax,3 shr edx,29 mov cl,@dbFileSizeInBuffer;_dwFileSize .if cl < 56 mov @dwEndRotateMD5Count,1 mov dword ptr [edi+ 60],edx mov dword ptr [edi+ 56],eax .else mov @dwEndRotateMD5Count,2 mov dword ptr [edi+124],edx mov dword ptr [edi+120],eax .endif push 067452301h pop @dwA push 0efcdab89h pop @dwB push 098badcfeh pop @dwC push 010325476h pop @dwD mov edi,_lpFileMem _Rotate: mov ecx, @dwRotateMD5Count .while ecx push ecx push @dwD push @dwC push @dwB push @dwA xor esi,esi .while esi < 64 mov eax,@dwB mov ebx,@dwC mov ecx,@dwD .if esi < 16;F and ebx,eax not eax and eax,ecx or eax,ebx .elseif esi < 32;G and eax,ecx not ecx and ecx,ebx or eax,ecx .elseif esi < 48;H xor eax,ebx xor eax,ecx .else ;I not ecx or eax,ecx xor eax,ebx .endif add eax,@dwA movzx ecx,byte ptr [offset dwFOffset + esi ] add eax,dword ptr [edi+ ecx * sizeof dword];x add eax,dword ptr [offset dwFTi + esi * sizeof dword];t mov ecx,esi shr ecx,2 and ecx,12 mov edx,esi and edx,3 mov cl,byte ptr [offset dwFLeftMove + edx + ecx] rol eax,cl add eax,@dwB xchg eax,@dwB xchg eax,@dwC xchg eax,@dwD xchg eax,@dwA inc esi .endw pop eax add @dwA,eax pop eax add @dwB,eax pop eax add @dwC,eax pop eax add @dwD,eax add edi,16*sizeof dword pop ecx dec ecx .endw .if @bEndMD5 == TRUE jmp @f .endif push @dwEndRotateMD5Count pop @dwRotateMD5Count lea edi,@szBuffer1 mov @bEndMD5,TRUE jmp _Rotate @@: mov eax,@dwA bswap eax mov ebx,@dwB bswap ebx mov ecx,@dwC bswap ecx mov edx,@dwD bswap edx jmp @f szMD5Format@_MD5hashProc db '%.8x%.8x%.8x%.8x',0 @@: invoke wsprintf,_lpdwMD5Buffer,addr szMD5Format@_MD5hashProc,eax,ebx,ecx,edx ret _MD5hashProc endp |
|
|
|
[原创]汇编写的通用按键模拟器v1.3.1版
关于病毒问题:老鸟都知道,其实那不是病毒,那是软件未认证和需要添加驱动所带来的,你可以不用端口直写功能,就没事了。那个功能用的插件是WINIO.DLL和WINIO.SYS,这2个软件不是我写的,所以你若怀疑,可以自己从网上下载,或者自己参考其函数,自己写个插件,替换之即可。 |
|
[原创]汇编写的通用按键模拟器v1.2.2修正版
;************************************************************************************************************** ;关于钩子的应用,钩子实际上不是什么复杂的东西,也许就难在其中较多的参数调用。 ;下面是一个键盘钩子,这个钩子实现的功能是: ; 检测主调用程序输入的2个键值,看2个键组成的组合键是否同时按下,若同时按下,则修改结果参数为1,否则为0. ; 主程序通过检测结果参数,就可以断定是否同时按下了这2个键,从而作出相应的动作。 ;============================================================================================================== ; WRITTEN BY LIYU ; EMAIL:LYWINU@163.COM ; 转载时请保留此信息 ;*************************************************************************************************************** .386 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE windows.inc INCLUDE kernel32.inc INCLUDELIB kernel32.lib INCLUDE user32.inc INCLUDELIB user32.lib _KeyBHookProc PROTO ,:DWORD,:DWORD,:DWORD .data .data? hKeyBHook dd ? hWnd dd ? hCWnd dd ? hSelWnd dd ? hInstance dd ? dwTestCtl dd ? dwTestChar dd ? dwCtlScan dd ? dwCharScan dd ? dwResult dd ? .CODE _DllEntry proc, hInst,dwReason,dwReserved mov eax,dwReason push hInst pop hInstance mov eax,TRUE ret _DllEntry endp _SetKeyBHookProc proc, _lpdwResult,_dwCtlScan,_dwCharScan push _dwCtlScan pop dwCtlScan push _dwCharScan pop dwCharScan push _lpdwResult pop dwResult xor eax,eax mov dwTestCtl,eax mov dwTestChar,eax mov eax,dwResult xor ebx,ebx mov [eax],ebx invoke SetWindowsHookEx,WH_KEYBOARD,addr _KeyBHookProc,hInstance,0 mov hKeyBHook,eax ret _SetKeyBHookProc endp _UnhookKeyBHookProc proc invoke UnhookWindowsHookEx,hKeyBHook ret _UnhookKeyBHookProc endp _KeyBHookProc proc ,_dwCode,_wParam,_lParam mov eax,_dwCode .if eax == HC_ACTION mov eax,_lParam mov ebx,eax shr ebx,16 and ebx,000ffh test eax,80000000h je @f .if ebx == dwCtlScan inc dwTestCtl mov eax,dwTestCtl .if eax == dwTestChar mov eax,_lParam test eax,040000000h jne @f mov eax,dwResult mov eax,[eax] mov eax,1 invoke UnhookWindowsHookEx,hKeyBHook ret .endif .elseif ebx == dwCharScan inc dwTestChar mov eax,dwTestCtl .if eax == dwTestChar mov eax,_lParam test eax,040000000h jne @f mov eax,dwResult mov eax,[eax] mov eax,1 invoke UnhookWindowsHookEx,hKeyBHook ret .endif .else xor eax,eax mov dwTestCtl,eax mov dwTestChar,eax .endif .endif @@: invoke CallNextHookEx,hKeyBHook,_dwCode,_wParam,_lParam ret _KeyBHookProc endp END _DllEntry |
|
[原创]汇编写的通用按键模拟器v1.2.2修正版
另外把正在开发的1.3版中的一个小功能放出来,可以作个小工具用 |
|
[原创汇编语言写的按键模拟器1.2.1版发布
最近看到不少人提到,api在自绘控件中经常不出效果,我把汇编语言编的按键模拟器1.2版中此部分的源代码拿出来供参考 invoke InitCommonControls invoke GetModuleHandle,0 mov hInstance,eax invoke GetCommandLine mov CommandLine,eax invoke _WinMain,hInstance,0,CommandLine,SW_SHOWNORMAL invoke ExitProcess,0 ;***************************************************************************** _WinMain proc uses esi edi ebx ,hInst,PrehInst,CmdLine,CmdShow LOCAL @stWc:WNDCLASSEX LOCAL @stMsg:MSG invoke RtlZeroMemory,addr @stWc,sizeof @stWc invoke LoadMenu,hInstance,IDM_MAIN mov hMenu,eax mov @stWc.cbSize,sizeof @stWc mov @stWc.style,CS_VREDRAW OR CS_HREDRAW OR CS_DBLCLKS mov @stWc.lpfnWndProc,offset _WndProc invoke LoadBitmap,hInstance,IDB_MAIN mov hBmpWinMain,eax invoke CreatePatternBrush,eax mov hBrushWinMain,eax ;INVOKE GetSysColorBrush,eax;COLOR_3DFACE;,COLOR_3DDKSHADOW;,COLOR_GRAYTEXT;,COLOR_BTNTEXT;,;COLOR_BACKGROUND;,COLOR_MENUTEXT;,COLOR_MENU mov @stWc.hbrBackground,eax mov @stWc.lpszClassName,offset szClassName push hInstance pop @stWc.hInstance invoke LoadIcon,hInstance,IDI_ICON1;,IDI_APPLICATION mov @stWc.hIcon,eax mov @stWc.hIconSm,eax invoke LoadCursor,0,IDC_ARROW mov @stWc.hCursor,eax invoke RegisterClassEx,addr @stWc invoke CreateWindowEx,WS_EX_WINDOWEDGE,addr szClassName,addr szWindowName,\ WS_DLGFRAME or WS_CAPTION or WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE ,\;WS_BORDER or WS_MAXIMIZEBOX or WS_THICKFRAME OR DS_MODALFRAME 150,150,655,475,0,hMenu,hInstance,0 mov hWinMain,eax invoke ShowWindow,hWinMain,SW_SHOWNORMAL invoke UpdateWindow,hWinMain .while TRUE invoke GetMessage,addr @stMsg,0,0,0 .break .if !eax invoke TranslateMessage,addr @stMsg invoke DispatchMessage,addr @stMsg .endw mov eax,@stMsg.wParam ret _WinMain endp ;********************************* _WndProc proc uses ebx esi edi,_hWnd,_uMsg,wParam,lParam LOCAL @dwIndex1 LOCAL @stLvi:LV_ITEM LOCAL @stDI:DRAWITEMSTRUCT LOCAL @stRect:RECT LOCAL @stPS:PAINTSTRUCT LOCAL @hDC1:HDC LOCAL @stRect1:RECT LOCAL @stRectSE:RECT LOCAL @stTME:TRACKMOUSEEVENT LOCAL @stPt:POINT LOCAL @hWndTip LOCAL @stPt1:POINT LOCAL @hDCCaption mov eax,_uMsg .if eax == WM_CLOSE invoke PostQuitMessage,0 invoke DestroyWindow,_hWnd .ELSEIF EAX == WM_DRAWITEM mov eax,wParam mov esi,lParam assume esi:ptr DRAWITEMSTRUCT .if [ESI].CtlType == ODT_BUTTON push [esi].hwndItem pop eax .if eax == hBtMouseSet invoke _WM_DRAWITEMMODEProc,lParam,hBmpMain,addr szBtMouseSet, 0ff01ffh,0ffffffh,0ff01ffh,0ffffffh;,0afad00h,001111ffh .elseif eax == hBtMouseYes invoke _WM_DRAWITEMMODEProc,lParam,hBmpMain,addr szBtMouseYes,0bfff11h,00ff1151h,0bfff11h,00ff1151h;,,01fff11h,001111ffh .endif .endif assume esi:nothing mov eax,TRUE RET .else invoke DefWindowProc,_hWnd,_uMsg,wParam,lParam ret .endif xor eax,eax ret _WndProc endp ;********************************* _WM_DRAWITEMSETProc proc uses esi edi ebx ,lParam,_hBmp,_pszString,_dwOnHBCr,_dwOnTextCr,_dwOffHBCr,_dwOFFTextCr LOCAL @stDI: DRAWITEMSTRUCT LOCAL @hRgn LOCAL @hDC LOCAL @hRectRgn LOCAL @stRect:RECT mov esi,lParam assume esi:ptr DRAWITEMSTRUCT invoke CreateEllipticRgn,[esi].rcItem.left,[esi].rcItem.top,[esi].rcItem.right,[esi].rcItem.bottom mov @hRgn,eax .if [esi].itemState==ODS_FOCUS INVOKE CreateSolidBrush,_dwOnHBCr invoke FillRgn,[esi].hdc,@hRgn,eax invoke SetBkMode,[esi].hdc,TRANSPARENT invoke SetTextColor,[esi].hdc ,_dwOnTextCr invoke DrawText,[esi].hdc,_pszString,-1,addr [esi].rcItem, DT_VCENTER OR DT_CENTER or DT_SINGLELINE; invoke SetWindowRgn,[esi].hwndItem,@hRgn,TRUE .ELSE INVOKE CreateSolidBrush,_dwOffHBCr invoke FillRgn,[esi].hdc,@hRgn,eax invoke SetBkMode,[esi].hdc,TRANSPARENT invoke SetTextColor,[esi].hdc ,_dwOFFTextCr invoke DrawText,[esi].hdc,_pszString,-1,addr [esi].rcItem,DT_VCENTER OR DT_CENTER or DT_SINGLELINE invoke SetWindowRgn,[esi].hwndItem,@hRgn,TRUE .endif invoke DeleteObject,@hRgn invoke DeleteObject,_hBmp assume esi:nothing ret _WM_DRAWITEMSETProc endp |
|
[讨论][讨论]哪种语言运行的速度最快。。求大牛专业的解答
速度快慢与语言有一定的关系,但是程序的优化及算法,特别重要。目前主流的高级语言,其内部优化已经与汇编、机器语言直接编写程序,差别很小了。 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值