Ward Posted October 9, 2010 Author Share Posted October 9, 2010 Finally I got a 64-bit windows. I recompiled the old CRC16/32 code and now it should work on both AutoItX32 and AutoItX64. It works for me, how about you? Other code is pending...... expandcollapse popup; ------------------------------------------------------------------ ; CRC Checksum UDF ; Purpose: Provide Fast CRC32/CRC16 Algorithm In AutoIt ; Author: Ward ; ------------------------------------------------------------------ #Include <Memory.au3> Func _CRC32($Data, $Initial = -1, $Polynomial = 0xEDB88320) If @AutoItX64 Then Local $Opcode = '0x554889E54881EC2004000048894D10488955184489452044894D28C745F800000000EB468B45F88945ECC745FC08000000EB1E8B45EC83E00184C0740D8B45ECD1E83345288945ECEB03D16DEC836DFC01837DFC007FDC8B45F848988B55EC899485E0FBFFFF8345F801817DF8FF0000007EB1488B4510488945F0C745F800000000EB318B452089C2C1EA088B45F84898480345F00FB6000FB6C033452025FF00000089C08B8485E0FBFFFF31D08945208345F8018B45F84898483B451872C48B4520F7D0C9C3' Else Local $Opcode = '0xC8000400538B5514B9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000' EndIf Local $CodeBufferMemory = _MemVirtualAlloc(0, BinaryLen($Opcode), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]", $CodeBufferMemory) DllStructSetData($CodeBuffer, 1, $Opcode) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) Local $Ret = DllCall("user32.dll", "uint", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "uint", $Initial, _ "int", $Polynomial) $Input = 0 $CodeBuffer = 0 _MemVirtualFree($CodeBufferMemory, 0, $MEM_RELEASE) Return $Ret[0] EndFunc Func _CRC16($Data, $Initial = 0, $Polynomial = 0xA001) If @AutoItX64 Then Local $Opcode = '0x554889E54881EC2002000048894D10488955184489C24489C86689552066894528C745F800000000EB4F8B45F8668945EEC745FC08000000EB240FB745EE83E00184C074110FB745EE66D1E866334528668945EEEB0466D16DEE836DFC01837DFC007FD68B45F848980FB755EE66899445E0FDFFFF8345F801817DF8FF0000007EA8488B4510488945F0C745F800000000EB380FB7452089C166C1E9080FB755208B45F84898480345F00FB6000FB6C031D025FF00000048980FB78445E0FDFFFF31C8668945208345F8018B45F84898483B451872BD0FB74520C9C3' Else Local $Opcode = '0xC800020053668B5514B9000100006689C86648516A085966D1E873036631D0E2F6596689844DFEFDFFFFE2E28B5D088B4D0C668B451085DB7418E3168A1330C20FB6D266C1E8086633845500FEFFFF43E2EA5BC9C21000' EndIf Local $CodeBufferMemory = _MemVirtualAlloc(0, BinaryLen($Opcode), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]", $CodeBufferMemory) DllStructSetData($CodeBuffer, 1, $Opcode) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) Local $Ret = DllCall("user32.dll", "word", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "word", $Initial, _ "word", $Polynomial) $Input = 0 $CodeBuffer = 0 _MemVirtualFree($CodeBufferMemory, 0, $MEM_RELEASE) Return $Ret[0] EndFunc CRC.ZIP 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
wraithdu Posted October 9, 2010 Share Posted October 9, 2010 Nice Looking forward to the MD* and SHA* algos. Good to see you're still around too Link to comment Share on other sites More sharing options...
KaFu Posted October 10, 2010 Share Posted October 10, 2010 (edited) Nice to see the x64 version . But something seems to be wrong. I tested the old x86 crc32 Opcode against the crc32 values created by Winzip, they are identical (and thus I assume them to be correct )... but now the new x86 Opcode is different ? Old x86 crc32 Opcode '0xC800040053BA2083B8EDB9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000' New x86 crc32 Opcode '0xC8000400538B5514B9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000' Also if I test you example CRCFileTest.au3 against the same file, I get different results on x86 and x64. Additionally the results change when I change the $BufferSize. Additionally I noticed the $Polynomial value for crc32 to be 0 in the old code (which I assume to be correct), now it is 0xEDB88320 by default. I'm not sure what to make of this one ... I would also recommend to initialize the $CodeBufferMemory & $CodeBuffer one time globally at the top of the Include crc.au3 and not every time the function is called. The memory should be released automatically on exit, to be clean _MemVirtualFree() and $CodeBuffer=0 called in a function registered with OnAutoItExitRegister() should do. Edited October 10, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Ward Posted October 11, 2010 Author Share Posted October 11, 2010 I rewrite the crc32 code to support different polynomial. Old code always use 0xEDB88320, and new code just use it as default. You can find out other polynomial at http://en.wikipedia.org/wiki/Cyclic_redundancy_check. If x86 and x64 version generate different result, I think x86 version is correct. I not yet test x64 version very well until now, because I loss my new computer...... I can't compile x64 code now About innitialize $CodeBuffer as global variable. It should be, I just forget. But I think Static is better. (I hope Static will be the formal keyword in the furture) 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
KaFu Posted October 23, 2010 Share Posted October 23, 2010 (edited) Retested CRC32 and it seems to work good on x86 and x64 ... looking forward to the md5 and sha1 x64 implementation , hope your x64 machine is back soon ... Here's a proposed change to speed up repetitive calls to the crc32 function: #include <Memory.au3> If @AutoItX64 Then Global $_CRC32Opcode = '0x554889E54881EC2004000048894D10488955184489452044894D28C745F800000000EB468B45F88945ECC745FC08000000EB1E8B45EC83E00184C0740D8B45ECD1E83345288945ECEB03D16DEC836DFC01837DFC007FDC8B45F848988B55EC899485E0FBFFFF8345F801817DF8FF0000007EB1488B4510488945F0C745F800000000EB318B452089C2C1EA088B45F84898480345F00FB6000FB6C033452025FF00000089C08B8485E0FBFFFF31D08945208345F8018B45F84898483B451872C48B4520F7D0C9C3' Else Global $_CRC32Opcode = '0xC8000400538B5514B9000100008D41FF516A0859D1E8730231D0E2F85989848DFCFBFFFFE2E78B5D088B4D0C8B451085DB7416E3148A1330C20FB6D2C1E80833849500FCFFFF43E2ECF7D05BC9C21000' EndIf Global $_CRC32CodeBufferMemory = _MemVirtualAlloc(0, BinaryLen($_CRC32Opcode), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Global $_CRC32CodeBuffer = DllStructCreate("byte[" & BinaryLen($_CRC32Opcode) & "]", $_CRC32CodeBufferMemory) DllStructSetData($_CRC32CodeBuffer, 1, $_CRC32Opcode) OnAutoItExitRegister("_CRC32_Exit") Func _CRC32($Data, $Initial = -1, $Polynomial = 0xEDB88320) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) Local $Ret = DllCall("user32.dll", "uint", "CallWindowProc", "ptr", DllStructGetPtr($_CRC32CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "uint", $Initial, _ "int", $Polynomial) $Input = 0 Return $Ret[0] EndFunc ;==>_CRC32 Func _CRC32_Exit() $_CRC32CodeBuffer = 0 _MemVirtualFree($_CRC32CodeBufferMemory, 0, $MEM_RELEASE) EndFunc ;==>_CRC32_Exit ; Example $sFile = @WindowsDir & "\explorer.exe" For $i = 1 To 10 ConsoleWrite("CRC32 for " & $sFile & @TAB & "0x" & Hex(_CRC32(FileRead($sFile), 8)) & @CRLF) Next Edited October 24, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
hench Posted February 8, 2011 Share Posted February 8, 2011 thank you Ward, this has brought Auto It a step forward!!! Link to comment Share on other sites More sharing options...
MvGulik Posted February 8, 2011 Share Posted February 8, 2011 (edited) Your post is empty Edited February 12, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
o0o Posted April 2, 2011 Share Posted April 2, 2011 Problem with windows server 2008 Link to comment Share on other sites More sharing options...
BrewManNH Posted April 2, 2011 Share Posted April 2, 2011 Problem with windows server 2008How is that helpful? Think you might need to say what the problem is rather than just saying "it's broke, don't work"? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
o0o Posted April 3, 2011 Share Posted April 3, 2011 Don't work Link to comment Share on other sites More sharing options...
guinness Posted April 3, 2011 Share Posted April 3, 2011 I'm missing the joke? Perhaps posting an Example over in the General Support section will Help you, but only if you stop continuing to post uninformative details! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
z3r0c00l12 Posted June 26, 2011 Share Posted June 26, 2011 I tried the Base64 in Windows Server 2008 and it didn't work. When the function is called, windows reports the application has crashed. I don't have AutoIt on the server, but if you need some information on the error, let me know what you need and I could install AutoIt and provide the output. The same script works fine in Windows 7, so i'm not too sure what is going wrong. Maybe it's the dll being called causing the error. If you have an example script I can use that will output some debugging information that would be useful. Thank you. Link to comment Share on other sites More sharing options...
KaFu Posted June 26, 2011 Share Posted June 26, 2011 Maybe the Server 2008 runs under x64? For x64 versions check out Wards newer UDF AutoIt Machine Code Algorithm Collection - Checksum, Compression, Encoding and Hash, Both X86/X64 Supported which also supports Bas64 encoding. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
z3r0c00l12 Posted June 26, 2011 Share Posted June 26, 2011 You are correct, in both cases. Windows Server 2008 is only 64-bit, whereas Windows 7 has both versions, this UDF still works on Windows 7 x64 though. I tried the new UDF you mentioned and it worked perfectly. Thank you for the quick reply. Link to comment Share on other sites More sharing options...
Unsigned Posted September 30, 2011 Share Posted September 30, 2011 (edited) I have a sneaking suspicion this will not work if the target machine has DEP (NX bit) on OptOut (or AlwaysOn). I'm running WinXP in a VM right now, but I'll try to test it and confirm when I get to a Windows box. Edited September 30, 2011 by Unsigned . Link to comment Share on other sites More sharing options...
KaFu Posted September 30, 2011 Share Posted September 30, 2011 (edited) You'll have to reserve the address space with _MemVirtualAlloc(), then it works with activated DEP (look some posts up for an example). Nevertheless I would recommend to switch to Wards newer UDF AutoIt Machine Code Algorithm Collection - Checksum, Compression, Encoding and Hash, Both X86/X64 Supported. Edited September 30, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
rodent1 Posted October 27, 2011 Share Posted October 27, 2011 Well, I downloaded the code from http://www.autoitscript.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=22412, and tried both SHA1Test and MD5Test. Both caused an error and autoit to crash. Here is the log for MD5Test:>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\X\SHA1_MD5_RC4_BASE64_CRC32_XXTEA\MD5Test.au3" !>16:46:16 AutoIT3.exe ended.rc:-1073741819>Exit code: -1073741819 Time: 3.023My OS is windows 2008 R1. Is something escaping me?Thanks! Link to comment Share on other sites More sharing options...
KaFu Posted October 27, 2011 Share Posted October 27, 2011 Maybe the Server 2008 runs under x64? For x64 versions check out Wards newer UDF AutoIt Machine Code Algorithm Collection - Checksum, Compression, Encoding and Hash, Both X86/X64 Supported which also supports Bas64 encoding.You'll have to reserve the address space with _MemVirtualAlloc(), then it works with activated DEP (look some posts up for an example). Nevertheless I would recommend to switch to Wards newer UDF AutoIt Machine Code Algorithm Collection - Checksum, Compression, Encoding and Hash, Both X86/X64 Supported. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
rodent1 Posted October 27, 2011 Share Posted October 27, 2011 OK, I downloaded that one and tried HashesFileTest.au3. It finds that there is a missing function, _Checksum_Init() in the include fie CHECKSum.au3. The error: >Running AU3Check (1.54.19.0) from:C:\Program Files (x86)\AutoIt3 C:\X\AutoIt Machine Code Algorithm Collection\Hash\CHECKSUM.au3(104,64) : ERROR: _CHECKSUM_Init(): undefined function. If Not IsDllStruct($_CHECKSUM_CodeBuffer) Then _CHECKSUM_Init() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\X\AutoIt Machine Code Algorithm Collection\Hash\HASHESFileTest.au3 - 1 error(s), 0 warning(s) !>17:22:31 AU3Check ended.rc:2 Link to comment Share on other sites More sharing options...
KaFu Posted October 27, 2011 Share Posted October 27, 2011 I'll post there... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now