Leaderboard
Popular Content
Showing content with the highest reputation on 05/17/2020 in all areas
-
WM_COPYDATA return
argumentum and one other reacted to Bilgus for a topic
nah you need to use SetWindowSubclass AutoItWinSetTitle(@ScriptName) $hAutoitInternal = WinGetHandle(@ScriptName) $hMsgProc = DllCallbackRegister(NewMessage, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') _WinAPI_SetWindowSubclass($hAutoitInternal, DllCallbackGetPtr($hMsgProc), $iMyID) Func NewMessage($hWnd, $iMsg, $wParam, $lParam, $iId, $pData) #forceref $iID, $pData Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Func _Exit() If $hMsgProc Then _WinAPI_RemoveWindowSubclass($hAutoitInternal, DllCallbackGetPtr($hMsgProc), $iMyID) DllCallbackFree($g_hMsgProc) EndIf2 points -
WM_COPYDATA return
argumentum and one other reacted to Danyfirex for a topic
@MrCreatoR I meant something like this: #AutoIt3Wrapper_UseX64=y #include <WindowsConstants.au3> #include <WinAPIProc.au3> #include <WinAPIMem.au3> #include <String.au3> Global Const $tagCOPYDATASTRUCT = 'ulong_ptr dwData;' & _ 'dword cbData;' & _ 'ptr lpData' Global $stStr = 0 Global $bExit = False Global $hGUI If $CmdLine[0] And $CmdLine[1] = '/Child' Then $hGUI = GUICreate('Child') GUIRegisterMsg($WM_COPYDATA, '_WM_COPYDATA') Do Sleep(10) Until $bExit Exit EndIf Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /Child') $hChild = WinWait('[CLASS:AutoIt v3 GUI;TITLE:Child]') Sleep(500) ; ...relax $hTimer = TimerInit() ; ... timer Local $sDataToSend= "A_" & _StringRepeat('Send', Random(10, 100)) & "_Y" $sRet = _Send($hChild,$sDataToSend) $hTimer = Round(TimerDiff($hTimer), 5) ; ..time it took to return MsgBox(64, 'Return - ' & $hTimer, $sRet) Func _Send($hWnd,$sDataToSend) Local $tPtr = DllStructCreate("ptr Data") ;Pointer for reading vRet Value Local $iProcessID = @AutoItPID Local $tData = DllStructCreate("Ptr pReturn;long pid;wchar Data[" & (StringLen($sDataToSend) + 1) & "]") $tData.pReturn = DllStructGetPtr($tPtr) $tData.PID = $iProcessID ;Pid for write memory $tData.Data = $sDataToSend ;Data to Send ;~ ConsoleWrite("$tData.pid: " & $tData.PID & @CRLF) ;~ ConsoleWrite("$tData.Data: " & $tData.Data & @CRLF) Local $tCopyData = DllStructCreate($tagCOPYDATASTRUCT) $tCopyData.cbData = DllStructGetSize($tData) $tCopyData.lpData = DllStructGetPtr($tData) Local $aRet = DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($tCopyData)) ;~ ConsoleWrite("$tData.pReturn: " & $tData.pReturn & @CRLF) ;~ ConsoleWrite("$tPtr.Data: " & $tPtr.Data & @CRLF) Local $tSize = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($tPtr.Data), 'long iSize') Local $stStr = _WinAPI_ReadProcessMemoryEx(WinGetProcess($hWnd), Ptr($tPtr.Data + 4), 'wchar sStr[' & $tSize.iSize & ']') Return DllStructGetData($stStr, 'sStr') EndFunc ;==>_Send Func _WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) $bExit = True Local $vRet = "A_" & _StringRepeat('Return', Random(10, 100)) & "_Y" ; Return Local $iLen = (StringLen($vRet) + 1) Local $tCopyData = DllStructCreate($tagCOPYDATASTRUCT, $lParam) Local $tData = DllStructCreate("Ptr pReturn;long PID;wchar Data[" & ($tCopyData.cbData - (@AutoItX64 ? 12 : 8)) & "]", $tCopyData.lpData) $stStr = DllStructCreate('long iSize;wchar sStr[' & $iLen & ']') DllStructSetData($stStr, 'iSize', $iLen) DllStructSetData($stStr, 'sStr', $vRet) Return _WinAPI_WriteProcessMemoryPtr($tData.PID, $tData.pReturn, DllStructGetPtr($stStr)) EndFunc ;==>_WM_COPYDATA Func _WinAPI_WriteProcessMemoryPtr($iProcessID, $pPointer, $ptPtr) Local $iSYNCHRONIZE = (0x00100000), $iSTANDARD_RIGHTS_REQUIRED = (0x000F0000) Local $iPROCESS_ALL_ACCESS = ($iSTANDARD_RIGHTS_REQUIRED + $iSYNCHRONIZE + 0xFFF) Local $hProcess, $Struct, $StructPtr, $StructSize, $iWriten $hProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS, False, $iProcessID) If @error Then Return SetError(@error, 1, $Struct) Local $Struct = DllStructCreate("ptr Data") $StructSize = DllStructGetSize($Struct) $StructPtr = DllStructGetPtr($Struct) $Struct.Data = $ptPtr Local $bWrite = _WinAPI_WriteProcessMemory($hProcess, $pPointer, $StructPtr, $StructSize, $iWriten) _WinAPI_CloseHandle($hProcess) Return SetError(@error, $iWriten, $bWrite) EndFunc ;==>_WinAPI_WriteProcessMemoryPtr Func _WinAPI_ReadProcessMemoryEx($iProcessID, $pPointer, $sStructTag) Local $iSYNCHRONIZE = (0x00100000), $iSTANDARD_RIGHTS_REQUIRED = (0x000F0000) Local $iPROCESS_ALL_ACCESS = ($iSTANDARD_RIGHTS_REQUIRED + $iSYNCHRONIZE + 0xFFF) Local $hProcess, $Struct, $StructPtr, $StructSize, $Read $hProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS, False, $iProcessID) If @error Then Return SetError(@error, 1, $Struct) $Struct = DllStructCreate($sStructTag) $StructSize = DllStructGetSize($Struct) $StructPtr = DllStructGetPtr($Struct) _WinAPI_ReadProcessMemory($hProcess, $pPointer, $StructPtr, $StructSize, $Read) _WinAPI_CloseHandle($hProcess) Return SetError(@error, $Read, $Struct) EndFunc ;==>_WinAPI_ReadProcessMemoryEx Saludos2 points -
Version 1.6.3.0
17,288 downloads
Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort1 point -
AutoIt v3.3.15.3 Beta View File 3.3.15.3 (16th May, 2020) (Beta) AutoIt: - Added #3681: Lang Variable prefix "o". - Fixed #2915: Map memory leak. - Fixed: Map errors with index < 0. UDFs: - Changed #3620: Removed "stable" from _ArraySort function header. - Added #3670: DriveGetDrive() @error doc clarification. - Added #3574: GuiCtrlCreateInput() Doc $ES_AUTOHSCROLL precision. - Fixed: Problem with _WinAPI_GetFontResourceInfo & _WinAPI_GetFontMemoryResourceInfo - Fixed #3728: Added optional parameter to force single column 2D array to 1D. - Fixed #3678: Amended Help file to show that function with no text blanks a line, not removes it. - Fixed #3757: Added note to GUICtrlListView_SetColor* pages about need to use BGR format. - Fixed #3697: _WinAPI_GetOverlappedResult() failure. Submitter Jon Submitted 05/16/2020 Category Beta1 point
-
WM_COPYDATA return
argumentum reacted to Bilgus for a topic
OH don't conflate the two, Subclassing an existing winproc is not doing your own message loop its the same idea as GUIRegister message doing your own message loop isn't near as simple1 point -
WM_COPYDATA return
argumentum reacted to Bilgus for a topic
No you just pass on what you don't want to handle to the default with _WinAPI_DefSubclassProc() The helpfile explains it pretty clearly1 point -
WM_COPYDATA return
Danyfirex reacted to argumentum for a topic
@Danyfirex, this look awesome, very cool. The _WM_COPYDATA is used as an event, to trigger the read memory. Is there a way, that is not too far out of your way, to trigger the memory read without using a GUI for it ?, as a memory write that triggers a memory read, or simple in the main loop read, that is not heavy for AutoIt ? I know this is not the OP question but, can't help to wonder since is all a memory read/write and the GUI is just for the event handler. No GUI dependency would be like, WOW. Thanks.1 point -
WM_COPYDATA return
argumentum reacted to Danyfirex for a topic
Inside _WM_COPYDATA check $tData.Data Saludos1 point -
Yes they are the same, i don't know why i didn't thought about that in the first place. Thanks. It's always good to dream! But soon everything will be better! 🍻1 point
-
Beware that Maps don't allow negative integer keys.1 point
-
I modified this script. Here is my result: #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=N ; CAPICOM is a 32-bit only component ;~ https://www.autoitscript.com/forum/topic/129720-digital-signatures-and-timestamp-with-ssl-certificates ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/signer-options ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/capicom-certificate-include-option Global Const $CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0 ; Saves all certificates in the chain with the exception of the root entity. Global Const $CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1 ; Saves the complete certificate chain. Global Const $CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2 ; Saves only the end entity certificate. _Example() Exit 0 Func _Example() Local $s_FileFullPath_ToSign If $CmdLine[0] < 1 Then $s_FileFullPath_ToSign = FileSaveDialog('Select File', @ScriptDir, "All (*.*)") Else $s_FileFullPath_ToSign = $CmdLine[1] EndIf _SignFile($s_FileFullPath_ToSign, "CERTIFICATE.pfx", 'PASSWORD', 'SOME DESCRIPTION') EndFunc ;==>_Example Func _SignFile($s_FileFullPath_ToSign, $s_FileFullPath_Certificat, $s_Password, $s_Description = '') ConsoleWrite("> Signing file with this following parameters:" & @CRLF) ConsoleWrite("> 1= " & $s_FileFullPath_ToSign & @CRLF) If Not FileExists($s_FileFullPath_ToSign) Then ConsoleWrite("! NOT EXIST" & @CRLF) Exit 1 EndIf ConsoleWrite("> 2= " & $s_FileFullPath_Certificat & @CRLF) If Not FileExists($s_FileFullPath_Certificat) Then ConsoleWrite("! NOT EXIST" & @CRLF) Exit 2 EndIf ConsoleWrite("> 3= " & StringLen($s_Password) & @CRLF) ConsoleWrite("> 4= " & $s_Description & @CRLF) Local $oError = ObjEvent("AutoIt.Error", _COM_ErrorHandler_for_Signer) ; Initialize Error Handler #forceref $oError ; Create COM objects ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/signedcode Local $oSignerCode = ObjCreate("CAPICOM.SignedCode.1") ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/signedcode-signer ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/signer Local $oSigner = ObjCreate("CAPICOM.Signer.1") ; Load certificate - Who Is Signing $oSigner.Load($s_FileFullPath_Certificat, $s_Password) ; https://docs.microsoft.com/en-us/windows/win32/seccrypto/signer-options ; $oSigner.Options = $CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT #Region - Sign it $oSignerCode.FileName = $s_FileFullPath_ToSign If $s_Description = Default Then $s_Description = InputBox("Description", "Add a Description.. EX.. My Project Name v.01") If Not $s_Description = "" Then $oSignerCode.Description = $s_Description $oSignerCode.Sign($oSigner) ; TimeStampIt $oSignerCode.Timestamp("http://timestamp.verisign.com/scripts/timestamp.dll") #EndRegion - Sign it ; CleanUp - Clear Memory $oSignerCode = "" $oSigner = "" EndFunc ;==>_SignFile Func _COM_ErrorHandler_for_Signer(ByRef $oError) Local $HexNumber = Hex($oError.number, 8) ConsoleWrite("! " & "Signer intercept COM Error" & @CRLF) ConsoleWrite("! " & " $oError.description is: " & @TAB & $oError.description & @CRLF) ConsoleWrite("! " & " $oError.windescription:" & @TAB & $oError.windescription & @CRLF) ConsoleWrite("! " & " $oError.number is: " & @TAB & $HexNumber & @CRLF) ConsoleWrite("! " & " $oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF) ConsoleWrite("! " & " $oError.scriptline is: " & @TAB & $oError.scriptline & @CRLF) ConsoleWrite("! " & " $oError.source is: " & @TAB & $oError.source & @CRLF) ConsoleWrite("! " & " $oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF) ConsoleWrite("! " & " $oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF) Exit 20 EndFunc ;==>_COM_ErrorHandler_for_Signer EDIT 1: I just tried this on second computer (latop), and I get into trouble. So I also read: https://docs.microsoft.com/en-us/windows/win32/seccrypto/getting-ready-to-use-capicom And if you get (just like I on my laptop) or: To fix this you should download: Platform SDK Redistributable: CAPICOM https://www.microsoft.com/en-us/download/details.aspx?id=25281 And register: regsvr32 "c:\Program Files (x86)\Microsoft CAPICOM 2.1.0.2 SDK\Lib\X86\capicom.dll" EDIT 2: according to: https://docs.microsoft.com/en-us/windows/win32/seccrypto/getting-ready-to-use-capicom so the script must use 32Bit AutoIt so I added: #AutoIt3Wrapper_UseX64=N1 point