Leaderboard
Popular Content
Showing content with the highest reputation on 08/13/2021 in all areas
-
Have you looked into using _WinAPI_GetKeyboardState?2 points
-
The Microsoft Windows Task Scheduler offers a lot of features. The two existing UDFs are a bit "complex" to use and miss help files and examples for each function. Based on a discussion on the german forum we would like to create a new UDF based on the existing "template" UDFs. Which functions do you miss in the existing UDFs? Should there be more examples? Should there be a help file? Should there be a wiki entry explaining the concepts? Which functions should be made easier to use? What else? Basic conditions Only Task Scheduler 2.0 will be supported (>= Windows Vista, Windows Server 2008). The UDF will use COM; neither AT.exe nor SCHTASKS.exe will be used. It will support as many of the objects and parameters as sensible. The UDF should be useable for everyone (beginners and experts) to suit their needs. Completed functions (fully documented including examples) - last changed: 2019-12-03 Planned functions (functions we are working on) - last changed: 2019-10-25 Suggested functions (we need to discuss if they schould be implemented) - last changed: 2019-11-03 Postponed functions (we will discuss this functions when the need arises) - last changed: 2019-09-301 point
-
First, If you want my help, DO NOT REFER TO ME AS BRO! Second, you need to do a much better job explaining exactly what it is you want help with. If you are not good with English than you need to get good with a language translation tool like Google Translate. The reason the result is not the same is because the IV is different. The AES-CBC IV used for the generic _CryptoNG_EncryptData() function is 0x000102030405060708090A0B0C0D0E0F. So either change the IV on Cryptii to match the generic IV or use the _CryptoNG_AES_CBC_EncryptData() function and specify whatever IV you would like. Example using your data, with your IV: #include <Constants.au3> #include <CryptoNG.au3> aes_cbc_encrypt_decrypt_example() Func aes_cbc_encrypt_decrypt_example() Const $ALG_ID = $CNG_BCRYPT_AES_ALGORITHM, _ $MESSAGE = "Nam@225225", _ $KEY = Binary("0xBA82B18BB98A1B7367B44A3930545633"), _ $IV = Binary("0x00000000000000000000000000000000") Local $sDecryptedMessage = "" Local $vEncryptKey = "" Local $xEncryptedMessage = "" write_to_log("", True) ;Clear log ;Encrypt plain text message $xEncryptedMessage = _CryptoNG_AES_CBC_EncryptData($MESSAGE, $KEY, $IV) If @error Then write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Exit 1 EndIf ;Decrypt encrypted message $sDecryptedMessage = _CryptoNG_AES_CBC_DecryptData($xEncryptedMessage, $KEY, $IV) If @error Then write_to_log("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Exit 1 EndIf ;Display results write_to_log(@CRLF) write_to_log("CryptoNG AES Data Encryption/Decryption Example" & @CRLF) write_to_log(@CRLF) write_to_log(StringFormat("%s Plain text message = %s", $ALG_ID, $MESSAGE) & @CRLF) write_to_log(StringFormat("%s Plain text message = %s", $ALG_ID, Binary($MESSAGE)) & @CRLF) write_to_log(@CRLF) write_to_log(StringFormat("%s Encrypt Key = %s", $ALG_ID, $KEY) & @CRLF) write_to_log(StringFormat("%s Encrypt Key (Base64) = %s", $ALG_ID, _CryptoNG_CryptBinaryToString($KEY, $CNG_CRYPT_STRING_BASE64 + $CNG_CRYPT_STRING_NOCRLF)) & @CRLF) write_to_log(@CRLF) write_to_log(StringFormat("%s Initialization Vector (IV) = %s", $ALG_ID, $IV) & @CRLF) write_to_log(@CRLF) write_to_log(StringFormat("%s Encrypted Message = %s", $ALG_ID, $xEncryptedMessage) & @CRLF) write_to_log(StringFormat("%s Encrypted Message (Base64) = %s", $ALG_ID, _CryptoNG_CryptBinaryToString($xEncryptedMessage, $CNG_CRYPT_STRING_BASE64 + $CNG_CRYPT_STRING_NOCRLF)) & @CRLF) write_to_log(@CRLF) write_to_log(StringFormat("%s Decrypted Message = %s", $ALG_ID, $sDecryptedMessage) & @CRLF) EndFunc Func write_to_log($sMsg = "", $bClear = False) Const $TITLE_NOTEPAD = "[RegExpTitle:(?i)untitled - notepad]" Static $hWndNotepad = -1 ;If we don't have a handle to notepad yet If $hWndNotepad = -1 Then ;If there isn't an existing instance of notepad running, launch one If Not WinExists($TITLE_NOTEPAD) Then Run("Notepad.exe") ;Get handle to notepad window $hWndNotepad = WinWait($TITLE_NOTEPAD, "", 3) If Not $hWndNotepad Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to find Notepad window.") EndIf ;Paste msg to notepad text If WinExists($hWndNotepad) Then If $bClear Then ControlSetText($hWndNotepad, "", "Edit1", "") ControlCommand($hWndNotepad, "", "Edit1", "EditPaste", $sMsg) EndIf EndFunc Output: CryptoNG AES Data Encryption/Decryption Example AES Plain text message = Nam@225225 AES Plain text message = 0x4E616D40323235323235 AES Encrypt Key = 0xBA82B18BB98A1B7367B44A3930545633 AES Encrypt Key (Base64) = uoKxi7mKG3NntEo5MFRWMw== AES Initialization Vector (IV) = 0x00000000000000000000000000000000 AES Encrypted Message = 0xEE243AD9A45DC7FF7177BE2483634A65 AES Encrypted Message (Base64) = 7iQ62aRdx/9xd74kg2NKZQ== AES Decrypted Message = Nam@2252251 point
-
_SendMessage return value
KaFu reacted to 636C65616E for a topic
I've done some tests with Lazarus, but i'm not familiar enought with Pascal, anyway i guess you need to override something like that (Delphi): procedure TWindow.WndProc(var Msg: TMessage); begin // do your stuff Inherited WndProc(Msg); end; Short example in pure AutoIt: One programm to create a window with a custom WindowProc handling a custom 0x401 msg : #cs FROM MSDN: Application-Defined Messages An application can create messages to be used by its own windows or to communicate with windows in other processes. If an application creates its own messages, the window procedure that receives them must interpret the messages and provide appropriate processing. Message-identifier values are used as follows: - The system reserves message-identifier values in the range 0x0000 through 0x03FF (the value of WM_USER – 1) for system-defined messages. Applications cannot use these values for private messages. - Values in the range 0x0400 (the value of WM_USER) through 0x7FFF are available for message identifiers for private window classes. - If your application is marked version 4.0, you can use message-identifier values in the range 0x8000 (WM_APP) through 0xBFFF for private messages. - The system returns a message identifier in the range 0xC000 through 0xFFFF when an application calls the RegisterWindowMessage function to register a message. The message identifier returned by this function is guaranteed to be unique throughout the system. Use of this function prevents conflicts that can arise if other applications use the same message identifier for different purposes. #ce #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> $form = GUICreate('TestWnd', 174, 102, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) $label = GUICtrlCreateLabel('received: ', 32, 24, 108, 49, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUISetState(@SW_SHOW) ; to handle native AutoIt stuff $oldproc = _WinAPI_GetWindowLong($form, $GWL_WNDPROC) func WndProc($hwnd, $uMsg, $wParam, $lParam) static $count = 0 switch $uMsg case 0x401 $count += 1 GUICtrlSetData($label, 'received: ' & $count) return 0x452 endswitch ; ConsoleWrite('msg = ' & ptr($uMsg) & @CRLF) ; return _WinAPI_DefWindowProc($hwnd, $uMsg, $wParam, $lParam) local $res = DllCallAddress('LRESULT', $oldproc, 'HWND', $hwnd, 'UINT', $uMsg, 'WPARAM', $wParam, 'LPARAM', $lParam) if @ERROR <> 0 then ConsoleWrite('ERROR: ' & @ERROR & @CRLF) return 0 endif return $res[0] endfunc $WndProc = DllCallbackRegister(WndProc, 'LRESULT', 'HWND;UINT;WPARAM;LPARAM;') _WinAPI_SetWindowLong($form, $GWL_WNDPROC, DllCallbackGetPtr($WndProc)) while 1 switch GUIGetMsg() case $GUI_EVENT_CLOSE ExitLoop endswitch wend GUIDelete($form) DllCallbackFree($WndProc) One program to interact with it (notice that sending 0x10 will close the 1st one as it is the WM_CLOSE), here the custom msg is 0x401: #include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $hwnd = WinWait('TestWnd', '', 1) if ($hwnd = 0) then MsgBox(0x10, 'Error', 'Cant find the TestWnd') Exit endif $form = GUICreate('SENDER', 196, 128, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) $send = GUICtrlCreateButton('SEND', 16, 46, 161, 33) $input = GUICtrlCreateInput('0x401', 50, 17, 126, 21) $disp = GUICtrlCreateLabel('-', 18, 94, 157, 17, $SS_CENTERIMAGE) GUICtrlCreateLabel("Msg:", 17, 16, 35, 22, $SS_CENTERIMAGE) GUISetBkColor(0xB9D1EA) GUISetState(@SW_SHOW) while 1 switch GUIGetMsg() case $GUI_EVENT_CLOSE Exit case $send local $msg = Number(GUICtrlRead($input),1) local $res = _SendMessage($hwnd, $msg) GUICtrlSetData($disp, '[0x' & hex($msg,4) & '] ' & ptr($res)) endswitch wend For some obscure reason selecting the window also post a WM_USER message, that's why I use 0x401 instead of simply 0x4001 point -
1 point
-
1 point
-
1 point