Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/07/2018 in all areas

  1. RdRand is Intel's on-chip hardware random number generator using entropy. This is just a quick response to this query; a faster solution would be to integrate some inline assembly (maybe using fasm?) The dll source is written by Stephen Higgins (blog here); there are several alternative codes available on GitHub as well. Usage for encryption is controversial (there are rumours of an NSA backdoor), but it may provide the closest approach to TRNG using PRNG. This is the 32-bit unsigned version, producing an integer in range: 0 to (4GB-1). Example: ; for dll source, see: https://github.com/viathefalcon/rdrand_msvc_2010 ; NB only some Intel CPUs support this feature $RdRandsupported=_RdRandInit() MsgBox(0,"Is RdRand supported on this CPU?",$RdRandsupported) if $RdRandsupported=False then Exit Global $lowerbound=0 ; NB: negative values are returned as 4GB - value (unsigned int) Global $upperbound=1000 ConsoleWrite("RdRand lower bound: " & $lowerbound & @CRLF) ConsoleWrite("RdRand upper bound: " & $upperbound & @CRLF & @CRLF) For $rc=1 To 100 ConsoleWrite("RdRand: " & @TAB & _RdRand($lowerbound, $upperbound) & @CRLF) Next _RdRandCleanUp() ;################################################################################## Func _RdRandInit() Global $DllHandleRdRand = DllOpen(".\RdRandlib.dll") If @error Then Return SetError(1,0,False) $result=DllCall($DllHandleRdRand, "bool", "rdrand_supported" ) If @error Then Return SetError(1,0,False) Return ($result[0]=1) EndFunc Func _RdRandCleanUp() If IsDeclared($DllHandleRdRand) Then DllClose($DllHandleRdRand) EndFunc Func _RdRand($lower, $upper) $result=DllCall($DllHandleRdRand, "uint", "rdrand_uniform_ex", "uint", $lower, "uint", $upper ) if @error then Return SetError(@error,@extended,False) Return $result[0] EndFunc RdRand.7z
    1 point
  2. Okay, let me quickly try to address the confusion (from a fidgety hotel WiFi in faraway lands, with a weird foreign keyboard, so I have to be brief). RdRand is not about speed (I think a call typically takes 420-460 cycles), it's about approximating TRNG through DRNG, rather than PRNG. PRNG comprises all regular randomiser functions you're used to (such as AutoIt's Mersenne twister). Read Intel's doc here. PRNGs produce a very very very long sequence of totally predictable numbers that for a sufficiently small sample look (and can be used as it they were truly) random. RdRand is different because it uses the (truly unpredictable) entropy of on-chip hardware (3GHz thermal noise) to produce a bitstream. So in theory the sequence of values produced by RdRand never repeats itself. Now in truth there are caveats to this (e.g., the refresh cycle itself), but in theory, if you need true randomness, then DRNG should approximate this significantly better than PRNGs as produced by any and all possible software implementations. And I didn't use a dll for speed, it was just faster to implement that way than to debug a fasm implementation from scratch. All clear? About to be automatically disconnected, so I better post this now...
    1 point
  3. Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Moderation Team
    1 point
  4. Hi, There have been far too many occasions recently where the Mod team have been trying to determine whether a particular thread is legal and a member has posted offering help to the OP. If the Mods are concerned about a thread, please refrain from posting within it - and certainly do not offer anything at all useful - until the all-clear has been given. After this announcement has been posted, we will regard any future instances as unfriendly acts and the poster can expect to be sanctioned - you have been warned. M23
    1 point
  5. It seems the message has still not got through - the 2 eager beavers who posted in this thread got a week off: And a word to the wise - the next one gets a month. M23
    1 point
  6. Then try this: #include <GDIPlus.au3> _GDIPlus_Startup() Global $handle = WinGetHandle("[CLASS:Notepad]") Global $hBitmap = Capture_Window($handle, _WinAPI_GetWindowWidth($handle), _WinAPI_GetWindowHeight($handle)) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\test.jpg") _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\test.jpg") Func Capture_Window($hWnd, $w, $h) If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) If Int($w) < 1 Then Return SetError(2, 0, 0) If Int($h) < 1 Then Return SetError(3, 0, 0) Local Const $hDC_Capture = _WinAPI_GetDC(HWnd($hWnd)) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $w, $h) Local Const $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) DllCall("gdi32.dll", "int", "SetStretchBltMode", "hwnd", $hDC_Capture, "uint", 4) DllCall("user32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) _WinAPI_DeleteDC($hMemDC) _WinAPI_SelectObject($hMemDC, $hObjectOld) _WinAPI_ReleaseDC($hWnd, $hDC_Capture) Local Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hFullScreen) Local Const $c1 = $aFullScreen[2] - @DesktopWidth, $c2 = $aFullScreen[3] - @DesktopHeight Local Const $wc1 = $w - $c1, $hc2 = $h - $c2 If (($wc1 > 1 And $wc1 < $w) Or ($w - @DesktopWidth > 1) Or ($hc2 > 7 And $hc2 < $h) Or ($h - @DesktopHeight > 1)) And (BitAND(WinGetState(HWnd($hWnd)), 32) = 32) Then Local $hBmp_t = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) $hBmp = _GDIPlus_BitmapCloneArea($hBmp_t, 8, 8, $w - 16, $h - 16) _GDIPlus_BitmapDispose($hBmp_t) Else $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) EndIf _WinAPI_DeleteObject($hHBitmap) Return $hBmp EndFunc ;==>Capture_Window The captured window might be looking different than the original window. This is a problem with the PrintWindow function! Br, UEZ
    1 point
  7. Edit: SOLVED, see below. I'm trying to run my automation from a server which has some additional security policy and it blocks Chrome Unpacked extensions. I found a way to get around that by disabling the Automation Extension: Chromium Bug 1749 per that link: You can set the "useAutomationExtension" capability to false. ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("useAutomationExtension", false); WebDriver driver = new ChromeDriver(options); This capability will help to not load Chrome Automation extension. Due to which, "Failed to load extension" popup would not appear. But please note you will not be able to perform any window resizing/positioning operations without the Chrome automation extension. But I can't figure out how to use that .setExperimentalOption() feature. I tried $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}{"setExperimentalOption":{"useAutomationExtension": false}}}}' but that didn't work. Found the correct way, not using the experimental and just setting it as a normal option. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "useAutomationExtension": false, "args":["start-maximized", "disable-infobars"] }}}}'
    0 points
×
×
  • Create New...