Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/03/2021 in all areas

  1. ptrex

    Hex Editor COM Control

    HEX Editor COM Control You can find the HEX Editor GUI example based on this ActiveX control https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control It was a challenge to make it all work, but due the Lars his bright solution the final piece of the puzzle was in place. See here where all the magic is happening ! I made 2 slight optimizations : 1. No need for an external VBScript 2. No need to register the OCX control on Windows PREQUISITES : 1. Download the HexEdit.ocx see attached. And put it is your script folder (No registration needed ! ) 2. Download IRunningObjectTable.au3 3. Run this script ; https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control #AutoIt3Wrapper_UseX64=N ;~ Opt("WinTitleMatchMode", 2) #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include "IRunningObjectTable.au3" #include <Array.au3> ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Global $hFileOD Global $hFile Global $hActiveX ; Load ActiveX module $hActiveX = DllOpen(@ScriptDir & "\HexEdit.ocx") ; Object identifiers Global Const $sCLSID = "{2E93307E-777D-49E4-886A-D5B04470796A}" Global Const $sIID = Default ; Create a simple GUI for our output Local $hHexEdit = GUICreate ( "Hex Editor", 1000, 580,(@DesktopWidth-1000)/2, (@DesktopHeight-580)/2 ) Local $idButton_About = GUICtrlCreateButton("About", 100, 10, 85, 25) Local $idButton_FileOpen = GUICtrlCreateButton("FileOpen", 10, 10, 85, 25) GUICtrlCreateGroup("Columns", 790, 40, 190, 90) Local $idInput = GUICtrlCreateInput("20", 800, 80, 60, 25) GUICtrlCreateUpdown($idInput) $sInput = GUICtrlRead($idInput) Local $idButton_Auto = GUICtrlCreateButton("Auto", 880, 80, 75, 25) GUICtrlCreateGroup("Address", 790, 180, 190, 90) Local $idAscii = GUICtrlCreateCheckbox("Address", 800, 180, 185, 25) Local $idAddress1 = GUICtrlCreateRadio("WORD", 800, 210, 120, 20) Local $idAddress2 = GUICtrlCreateRadio("DWORD", 800, 235, 120, 20) GUICtrlSetState($idAddress1, $GUI_CHECKED) GUICtrlCreateGroup("Data", 790, 280, 190, 90) Local $idData1 = GUICtrlCreateRadio("BYTE", 800, 300, 120, 20) Local $idData2 = GUICtrlCreateRadio("WORD", 800, 320, 120, 20) Local $idData3 = GUICtrlCreateRadio("DWORD", 800, 340, 120, 20) GUICtrlSetState($idData1, $GUI_CHECKED) Local $idAscii = GUICtrlCreateCheckbox("Show ASCII", 800, 400, 185, 25) GUICtrlSetState(-1, 1) Local $idInvert = GUICtrlCreateCheckbox("Invert Color", 800, 430, 185, 25) Local $idLabel = GUICtrlCreateLabel("Modified : ", 800, 540, 185, 25) ; Create Com Object ;~ Local $oHexEdit = ObjCreate("HEXEDIT.HexEditCtrl.1") Local $oHexEdit = ObjCreate($sCLSID, $sIID, $hActiveX) If IsObj($oHexEdit) = 0 Then MsgBox(48, "Error", "Could not create the object, Common problem ActiveX not registered.") ConsoleWrite(IsObj($oHexEdit) & @CRLF) Exit EndIf $oHexEdit.Appearance = 1 $oHexEdit.AllowChangeSize = 0 $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff $oHexEdit.Fontheight = 16 $oHexEdit.Columns = Int($sInput) $GUIActiveX = GUICtrlCreateObj ($oHexEdit, 10, 40, 750, 520) GUICtrlSetResizing ( $GUIActiveX, $GUI_DOCKAUTO) GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) ; Show GUI GUISetState () ; Loop GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) If $oHexEdit.DataModified = True Then GUICtrlSetColor($idLabel, $COLOR_RED) EndIf Case $idButton_About $oHexEdit.AboutBox() Case $idButton_Auto $oHexEdit.Columns = 0 Case $idInput $oHexEdit.Columns = GUICtrlRead($idInput) Case $idAscii If BitAND(GUICtrlRead($idAscii), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.ShowAscii = 1 Else $oHexEdit.ShowAscii = 0 EndIf Case $idInvert If BitAND(GUICtrlRead($idInvert), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.BackColor = 0xffffff $oHexEdit.ForeColor = 0x000000 Else $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff EndIf Case $idButton_FileOpen Set_Data(GetFile()) If BitAND(GUICtrlRead($idAddress1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 4 EndIf If BitAND(GUICtrlRead($idAddress2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 8 EndIf If BitAND(GUICtrlRead($idData1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 2 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 4 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 8 EndIf EndSwitch WEnd ; Function File Open Func GetFile() $hFileOD = FileOpenDialog("Select EXE File", @ScriptDir & "\", "EXE (*.exe)") $hFileOpen = FileOpen($hFileOD, 16) If $hFileOpen = -1 Then MsgBox(48, "Error", "Unable to open file, or no file selected !!") Else ; Read the contents of the file using the handle returned by FileOpen. Local $sFileRead = FileRead($hFileOpen) Return $sFileRead EndIf ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc Func Set_Data($dBinary) ; https://www.autoitscript.com/forum/topic/202618-implementing-irunningobjecttable-interface/?do=findComment&comment=1471171 Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary Local $code= 'Dim oROTobj, oHexEdit, dBinary' $code=$code & @CRLF & 'Set oROTobj = GetObject( "DictionaryData" )' $code=$code & @CRLF & 'Set oHexEdit = oROTobj( "oHexEdit" )' $code=$code & @CRLF & 'dBinary = oROTobj( "dBinary" )' $code=$code & @CRLF & 'oHexEdit.SetData dBinary, 0' Local $vbs = ObjCreate("ScriptControl") $vbs.language="vbscript" $vbs.addcode($code) ;~ ROT_Revoke($oROTobj) EndFunc ; COM Error Handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) Endfunc Enjoy !! PS : I did not implement the write back to file yet. Feel free to add this if needed. HexEdit.zip
    2 points
  2. abberration

    Software Installer

    Software Installer Version: 2.0 It's been been a long year, but I finally got some time to rework this project. I re-wrote everything from scratch because the old version was getting too complicated with so many options and sub-menus. This new version is much easier to use and I have been testing for a few days and it seems very stable. For those who are new to this software, it helps you install software silently/unattended. This new version tries to determine the silent switch automatically. You can also re-organize the order in which the software installs by dragging & dropping them in the listview. It now supports creating profiles and checks for missing software (and automatically unchecks them, so it does not attempt to install non-existent software). One feature I included was because I have seen several people on Youtube talk about disliking bright screens at night. So, now you can choose from a few color theme (half of them are dark). I dabbled a bit more into GDI+ to draw a few things and show my logo with a transparent background (hint: I'm not good at GDI+). Under the Help menu, you will find a User Guide, which goes through most of it's features. I included a new icon if you want to use when you compile the script (in the Assets > Misc folder). If you have questions, comments or suggestions, all are welcome. Hope you enjoy! Here it is in action: Software_Installer_2.0.zip
    1 point
  3. TheXman

    Ignore....

    The FIRST thing you need to do is SEARCH for answers to your questions. AutoIt and their forums have been around long enough that almost any question has been asked and answered numerous times (with examples), either directly or indirectly. All you need to do is put in the effort to find those answers and examples. If you are too lazy to do that, then don't be surprised if you get little or no help. You should not hijack or pollute this topic by posting a totally unrelated question. The title of this topic is "WinHttp Invalid Server Response". Your question has nothing to do with invalid winhttp server responses. If you have done your due diligence and still cannot find answers to your questions, then and only then should you create a new topic to get help finding answers to those questions. English obviously isn't your native language. Your posts are hard to understand and lack the necessary detail to even begin to help you. Your questions probably make perfect sense to you. But for someone who has no idea what you are trying to do, they make little or no sense at all. It might benefit you to write your questions in your native language and post the English translation. If that is what you are doing, you need to either find a better translation tool or write better questions.
    1 point
  4. You can create the ActiveX object this way without registering the file: $sIID = Default $sCLSID = "{2E93307E-777D-49E4-886A-D5B04470796A}" $hActiveX = DllOpen(@ScriptDir & "\HexEdit.ocx") $oHexEdit = ObjCreate($sCLSID, $sIID, $hActiveX) It's demonstrated by ptrex in this example. I think this technique also works even if your object is defined in a dll file. Then you can register the object in the ROT.
    1 point
  5. Replace your run statement with this one : $pid = Run(@ComSpec & " /c chcp",'',@SW_HIDE, $STDIN_CHILD+$STDERR_MERGED)
    1 point
  6. abberration

    Software Installer

    Hi, everyone! Version 1.2 is now posted with some cool new features. The first post contains a link to the full package but you also have the option to just download the script and a couple supplemental files. Hope you like it! Comments/questions are welcome. Link here: Special thanks to bundyal for alerting me to some issues with the previous version and a couple new ideas, which improved this version.
    1 point
  7. Hi Lars, I made some slight modifications in this version you don't need the external vbscript. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "IRunningObjectTable.au3" Example() Func Example() ; Create GUI GUICreate( "Hex Editor", 420, 420 ) ; Create COM error handler Local $oMyError = ObjEvent( "AutoIt.Error", "MyErrFunc" ) ; Create Com object Local $oHexEdit = ObjCreate( "HEXEDIT.HexEditCtrl.1" ) If Not IsObj( $oHexEdit ) Then Return ConsoleWrite( "$oHexEdit ERR" & @CRLF ) ConsoleWrite( "$oHexEdit OK" & @CRLF ) ; Create ActiveX control GUICtrlCreateObj( $oHexEdit, 10, 10, 400, 400 ) ; Show GUI GUISetState() ; Load HexEditDlg.exe into ActiveX control Local $hFile = FileOpen( "HexEditDlg.exe", 16 ), $dBinary = FileRead( $hFile ), $i = FileClose( $hFile ) ; 16 = $FO_BINARY Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary Local $code= 'Dim oROTobj, oHexEdit, dBinary' $code=$code & @CRLF & 'Set oROTobj = GetObject( "DictionaryData" )' $code=$code & @CRLF & 'Set oHexEdit = oROTobj( "oHexEdit" )' $code=$code & @CRLF & 'dBinary = oROTobj( "dBinary" )' $code=$code & @CRLF & 'oHexEdit.SetData dBinary, 0' ;~ ConsoleWrite($code & @CRLF & @CRLF) Local $vbs = ObjCreate("ScriptControl") $vbs.language="vbscript" $vbs.addcode($code) ROT_Revoke($oROTobj) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #forceref $oMyError, $i EndFunc Func MyErrFunc( $oError ) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc Thanks again for the bright solution ! ptrex
    1 point
  8. Next time try: $sDll = @SystemDir & "\ImageMagickObject.dll" ; or just name DllCall($sDll, "long", "DllRegisterServer") That's how it should be done. You don't need Run, ShellExecute or RegSvr32 or @ComSpec.
    1 point
×
×
  • Create New...