Jump to content

j0kky

Active Members
  • Posts

    349
  • Joined

  • Last visited

  • Days Won

    2

j0kky last won the day on November 30 2016

j0kky had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

j0kky's Achievements

  1. Hi folks, Last morning I needed to know programmatically which were my DNS(s) for the current connection, and I searched for an API which fitted my needs... I just tried dnsqueryconfig, which shows the DNS(s) used, if you have manually selected them in the past. The API is little tricky (or maybe I'm little rusty), so I decided to write a small UDF function to avoid a waste of time in the future... here you are. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DnsQueryConfig ; Description ...: Retrieves the currently used DNS servers, if they were selected by user ; Syntax.........: _WinAPI_DnsQueryConfig() ; Return values .: On success it returns an array with the list of currently used DNS servers ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - DllCall error ; |2 - Generic error, DNS could be generated automatically ; Author ........: j0kky ; Modified ......: 1.0.0 14/11/2018 ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/windns/nf-windns-dnsqueryconfig ; =============================================================================================================================== Func _WinAPI_DnsQueryConfig() Local Const $DnsConfigDnsServerList = 6 Local $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", Null, "dword*", 0) If @error Then Return SetError(1, 0, 0) if $aRet[6] <= 4 Then Return SetError(2, 0, 0) Local $tagBuffer = "" For $i = 1 To ($aRet[6] / 4) $tagBuffer &= "dword;" Next Local $tBuffer = DllStructCreate($tagBuffer) $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", DllStructGetPtr($tBuffer), "dword*", $aRet[6]) Local $aDNS[($aRet[6] / 4) - 1] For $i = 2 to (UBound($aDNS) + 1) $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "dword", DllStructGetData($tBuffer, $i)) if @error Then Return SetError(1, 0, 0) $aDNS[$i - 2] = $aRet[0] Next Return SetError(0, 0, $aDNS) EndFunc
  2. Which domain?
  3. No, it is not. But you can develope a console application which interacts with a browser window that enable the user to login and set the right permission to your app. You can try tons of material on the FB Dev Network, you are interested in Graph API part, avoid the SDKs one. From https://developers.facebook.com/docs/sharing/web:
  4. You could concatenate strings through &= operator, add the final @CRLF and then write to a file with FileWrite...
  5. Read in my signature
  6. That's really strange... Try this switching between the two keyboard setup without closing the application (and mantaining it on the top level). #include <WinAPI.au3> Global Const $WM_INPUTLANGCHANGE = 0x0051 $hGUI = GUICreate("My GUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "_WM_INPUTLANGCHANGE") GUISetState(@SW_SHOW) HotKeySet("{ESC}", _Exit) WinActivate($hGUI) While 1 Sleep(100) WEnd Func _WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) Local $aRet = DllCall("user32.dll", "HANDLE", "GetKeyboardLayout", "DWORD", 0) If @error Then ConsoleWrite("ERROR!" & @CRLF) Return EndIf ConsoleWrite("Handle: " & $aRet[0] & @CRLF & _ "Language Identifier: " & Hex(_WinAPI_LoWord($aRet[0]), 4) & @CRLF & _ "Device Identifier: " & Hex(_WinAPI_HiWord($aRet[0]), 4) & @CRLF & _ "wParam: " & $wParam & @CRLF & _ "lParam: " & $lParam & @CRLF & @CRLF) Return 'GUI_RUNDEFMSG' EndFunc Func _Exit() Exit EndFunc Then post here full console output.
  7. I didn't run your script and I don't know which protocol this particular procedure uses, but if you want to receive binary data, TCPRecv should have $flag = 1... Anyway what is your problem? What do you get instead of the wanted meta-data?
  8. $sString = _WinAPI_WideCharToMultiByte($sString,65001,True) Why do you add this line? Have you tried to remove it?
  9. Doing a quick check, I saw this: Local $bString = StringToBinary($sString,2) ;compress function $sString = BinaryToString(DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $pUncompressedBuffer), 1),4) ;uncompress function You should use the same UNICODE character set.
  10. Don't you like GetKeyboardLayout? #include <WinAPI.au3> HotKeySet("{SPACE}", _GetKeyboardLayout) HotKeySet("{ESC}", _Exit) While 1 Sleep(100) WEnd Func _GetKeyboardLayout() Local $aRet = DllCall("user32.dll", "HANDLE", "GetKeyboardLayout", "DWORD", 0) If @error Then ConsoleWrite("ERROR!" & @CRLF) Return EndIf ConsoleWrite("Language Identifier: " & Hex(_WinAPI_LoWord($aRet[0]), 4) & @CRLF & _ "Device Identifier: " & Hex(_WinAPI_HiWord($aRet[0]), 4) & @CRLF & @CRLF) EndFunc Func _Exit() Exit EndFunc
  11. No, but you can register an AdLibRegister function which can start automatically, and when it ends, your script continues its job. EDIT: also, there is another interesting function that uses callback: _Timer_SetTimer
  12. I think @kblayout macro calls GetKeyboardLayout API, but it retrieves only low order byte, so it gets only the language identifier, you need the device identifier (also known as device handle or physical layout) too that's contained in high order bytes. EDIT: On second thought, @kblayout macro calls GetKeyboardLayoutName function, which retrieves by default only language ID.
  13. Hi, I recently used _WinAPI_GetProcessFileName, I noticed it uses GetModuleFileNameEx function to retrieve the path, and it requires PROCESS_QUERY_INFORMATION and PROCESS_VM_READ. Well, from Vista there is another function, QueryFullProcessImageName, which requires only PROCESS_QUERY_LIMITED_INFORMATION access rights, and it allows to retrieve some process which GetModuleFileNameEx can't get because of its requirements. Here is an example which shows the issue: #include <WinAPIProc.au3> $array = ProcessList() For $i = 1 To $array[0][0] If $array[$i][1] Then $output1 = _WinAPI_GetProcessFileName2($array[$i][1]) $output2 = _WinAPI_GetProcessFileName($array[$i][1]) If @error Then $output2 = -1 If Not ($output1 = $output2) Then If Not ($output1 = -1) Then ConsoleWrite($output1 & "--> _WinAPI_GetProcessFileName2" & @CRLF) If Not ($output2 = -1) Then ConsoleWrite($output2 & "--> _WinAPI_GetProcessFileName" & @CRLF) EndIf EndIf Next Func _WinAPI_GetProcessFileName2($iPID) Local $dwDesiredAccess = __Iif($__WINVER < 0x0600, 0x0410, 0x1000), $sPath = "" Local $aRet = DllCall("Kernel32.dll", "HANDLE", "OpenProcess", "DWORD", $dwDesiredAccess, "BOOL", False, "DWORD", $iPID) If @error Or $aRet[0] = Null Or $aRet[0] = 0 Or $aRet[0] = Ptr(0) Then Return SetError(-1, 0, -1) Local $hProcess = $aRet[0] If $dwDesiredAccess = 0x0410 Then $aRet = DllCall(@SystemDir & "\psapi.dll", "DWORD", "GetModuleFileNameExW", "HANDLE", $hProcess, "HANDLE", 0, "wstr", "", "DWORD", 65535) Else $aRet = DllCall("Kernel32.dll", "BOOL", "QueryFullProcessImageNameW", "HANDLE", $hProcess, "DWORD", 0, "wstr", "", "dword*", 65535) EndIf If Not (@error Or $aRet[0] = 0) Then $sPath = $aRet[3] DllCall("Kernel32.dll", "BOOL", "CloseHandle", "HANDLE", $hProcess) Return $sPath = "" ? SetError(-1, 0, -1) : $sPath EndFunc ;==>_GetProcessPath
  14. Copy&Paste here the console output of this script, so we can have an idea about the program which is interfering. $array = ProcessList() For $i = 1 to $array[0][0] $output = _PidGetPath($array[$i][1]) If Not ($output = "0") Then ConsoleWrite($output & @CRLF) Next Func _PidGetPath($pid = "", $strComputer = 'localhost') If $pid = "" Then $pid = WinGetProcess(WinGetTitle("")) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath Next EndIf EndFunc ;==>_PidGetPath
×
×
  • Create New...