Jump to content

Terenz

Active Members
  • Posts

    568
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    Terenz got a reaction from KaFu in New _Singleton() need opinion   
    Hello,
    _Singleton is a controversy function, for unknow reason not work for everybody. The first version was using semaphore, the actual mutex. There is another alternative, CreateEvent.
    If _SingletonEx("Global\MyApp", 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") Func _SingletonEx($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local $hStartEvent = DllCall("kernel32.dll", "handle", "CreateEventW", "struct*", 0, "bool", False, "bool", False, "wstr", $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonEx On my system work fine also without the $tSecurityAttributes for the Global\ since the switch between my two user recognize the old instance running, test also on your enviroment.
    Please be gentle, i'm not so expert in structure and DllCall. If i have loose time and the actual _Singleton() is better then mine isn't a problem for me, I won't be offended
    P.S. In thoery we need a CloseHandle for CreateEvent when the script has only 1 instance at exit. Since the original _Singleton() don't close the handle for the Mutex in the same situation and leave to do by Autoit at exit, i have do it the same.
    Another one, with FileMapping
    If _SingletonMap("Global\MyApp", 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") Func _SingletonMap($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local $tInt64 = DllStructCreate('int64') Local $tQWord = DllStructCreate('dword;dword', DllStructGetPtr($tInt64)) DllStructSetData($tInt64, 1, 1) Local $iSize_HiDWord = DllStructGetData($tQWord, 2), $iSize_LoDWord = DllStructGetData($tQWord, 1) Local $hStartEvent = DllCall('kernel32.dll', 'handle', 'CreateFileMappingW', 'handle', -1, 'struct*', 0, 'dword', 0x0004, 'dword', $iSize_HiDWord, 'dword', $iSize_LoDWord, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc With CreateWaitableTimer
    If _SingletonWT("Global\MyApp", 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") Func _SingletonWT($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 $hStartEvent = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonEx With Semaphore, like the original Valik function but improved with CloseHandle and error checking.
    If _SingletonSemaphore("Global\MyApp", 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") Func _SingletonSemaphore($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 $hStartEvent = DllCall('kernel32.dll', 'handle', 'CreateSemaphoreW', 'struct*', 0, 'long', 0, 'long', 1, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonEx This was made just for fun from C# code:
    Global $iListenSingleton If _SingletonTCP(12345, 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") OnAutoItExitRegister("_SingletonExit") Func _SingletonTCP($iOccurrence, $iFlag = 0) If Not IsNumber($iOccurrence) Then Return SetError(1, 0, 0) Local Const $WSAEADDRINUSE = 10048 TCPStartup() $iListenSingleton = TCPListen("127.0.0.1", $iOccurrence) If @error = $WSAEADDRINUSE Then If BitAND($iFlag, 1) Then Return 0 Else Exit -1 EndIf EndIf Return 1 EndFunc ;==>_SingletonTCP Func _SingletonExit() TCPCloseSocket($iListenSingleton) TCPShutdown() EndFunc ;==>_SingletonExit All version work globally on multi user enviroment.
  2. Like
    Terenz got a reaction from Asifmute in Detect an UEFI Windows and GPT Disk type   
    ConsoleWrite(_GetDrivePartitionStyle() & @CRLF) ConsoleWrite(_WinAPI_GetFirmwareEnvironmentVariable() & @CRLF) Func _GetDrivePartitionStyle($sDrive = "C") Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _ 'dword PartitionCount;' & _ 'byte union[40];' & _ 'byte PartitionEntry[8192]') Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _ "wstr", "\\.\" & $sDrive & ":", _ "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ "ptr", 0) If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDrive[0], _ "dword", 0x00070050, _ "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tDriveLayout), _ "dword", DllStructGetSize($tDriveLayout), _ "dword*", 0, _ "ptr", 0) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0]) Switch DllStructGetData($tDriveLayout, "PartitionStyle") Case 0 Return "MBR" Case 1 Return "GPT" Case 2 Return "RAW" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_GetDrivePartitionStyle Func _WinAPI_GetFirmwareEnvironmentVariable() DllCall("kernel32.dll", "dword", _ "GetFirmwareEnvironmentVariableW", "wstr", "", _ "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", "", "dword", 4096) Local $iError = DllCall("kernel32.dll", "dword", "GetLastError") Switch $iError[0] Case 1 Return "LEGACY" Case 998 Return "UEFI" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_WinAPI_GetFirmwareEnvironmentVariable  
  3. Like
    Terenz reacted to Nine in Regex get month and year   
    Maybe this ?
    #include <Constants.au3> #include <Array.au3> Local $aTxt = ["my_business_03_2020", "03 my business 2020"] For $sTxt in $aTxt $arr = StringRegExp ($sTxt, "\D?(\d{2}|\d{4})(?=\D|$)", 3) _ArrayDisplay ($arr) Next  
  4. Like
    Terenz reacted to ahmet in Regex get month and year   
    Can this help
    $sTestString="my_business_032020" $btest=StringRegExp($sTestString,".*\d\d.*\d\d\d\d") MsgBox(0,"Test",($btest ? "There is" : "There is not") & " date") You can look at regex101.com for explanation
  5. Like
    Terenz reacted to careca in Unsigned decimal conversion?   
    #include <WinAPIConv.au3> Local $iValue = 59904 ConsoleWrite(_WinAPI_WordToShort($iValue) & @CRLF) Local $iValue = -5632 ConsoleWrite(_WinAPI_ShortToWord($iValue) & @CRLF)  
  6. Like
    Terenz reacted to UEZ in [GDI+] Bitmap from memory alpha   
    You made some mistakes. Try this:
    #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $myImage = "https://www.autoitscript.com/forum/uploads/profile/photo-thumb-29844.png" Global $hBMPMem = _GDIPlus_BitmapCreateFromMemory(InetRead($myImage)) ;use GDI+ bitmap format!!! Global $hAttribute_Transparent_BMP = _GDIPlus_AttributeCreateTransparentBitmap($hBMPMem, 0.66666) Global $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hAttribute_Transparent_BMP, 0xFFFFFFFF) Global $hGUI = GUICreate("", 300, 300, -1, -1) GUICtrlCreateTab(0,0,300,300) GUICtrlCreateTabItem("Test") Global $iPic = GUICtrlCreatePic("", 50, 50) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, 0, $hGDIBitmap)) ; $STM_SETIMAGE ;~ _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, 0, $hBMPMem)) ; $STM_SETIMAGE GUICtrlCreateTabItem(""); end tabitem definition GUICtrlCreateTabItem("Test2") GUICtrlCreateTabItem(""); end tabitem definition GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hBMPMem) _GDIPlus_ImageDispose($hAttribute_Transparent_BMP) _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Func _GDIPlus_AttributeCreateTransparentBitmap($hImage, $fTransparency = 0.25) Local Const $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() ;~ $fTransparency = $fTransparency > 1 ? 1 : $fTransparency < 0 ? 0 : $fTransparency Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, $fTransparency * -1) Local Const $pColorMatrix = DllStructGetPtr($tColorMatrix) _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, $pColorMatrix) Local $aDim = _GDIPlus_ImageGetDimension($hImage) Local Const $aBitmap = _GDIPlus_BitmapCreateFromScan0($aDim[0], $aDim[1]) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($aBitmap) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hImage, 0, 0, $aDim[0], $aDim[1], 0, 0, $aDim[0], $aDim[1], $hAttribute_Alpha) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageAttributesDispose($hAttribute_Alpha) Return $aBitmap EndFunc  
  7. Like
    Terenz reacted to UEZ in [GDI+] Bitmap from memory alpha   
    I understand your first question not really. What do you mean with "set alpha channel"? You want to set a color to transparent?
     
    regarding your second question:
    #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $myImage = "https://p5.focus.de/img/fotos/crop3196039/3194875996-cv21_9-w630-h270-oc-q75-p5/Preise-Die-Jahresinflationsrate-in-den-USA-war-weniger-als-von-den-meisten-Experten-erwartet.jpg" Global $hBMPMem = _GDIPlus_BitmapCreateFromMemory(InetRead($myImage)) ;GDI+ bitmap Global $hGfx = _GDIPlus_ImageGetGraphicsContext($hBMPMem) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 4) Global $hBrush = _GDIPlus_BrushCreateSolid(0x80000000) _GDIPlus_GraphicsFillRect($hGfx, 100, 50, 300, 150, $hBrush) Global $hFormat = _GDIPlus_StringFormatCreate() Global $hFamily = _GDIPlus_FontFamilyCreate("Impact") Global $hFont = _GDIPlus_FontCreate($hFamily, 24) _GDIPlus_BrushSetSolidColor($hBrush, 0xF0FFFFFF) Global $tLayout = _GDIPlus_RectFCreate(150, 100, 300, 50) _GDIPlus_GraphicsDrawStringEx($hGfx, "Hello world", $hFont, $tLayout, $hFormat, $hBrush) Global $hBMPMemGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMPMem) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BrushDispose($hBrush) _GDIPlus_ImageDispose($hBMPMem) Global $hGUI = GUICreate("", 800, 800, -1, -1) GUICtrlCreateTab(0,0,800,700) GUICtrlCreateTabItem("Test") Global $iPic = GUICtrlCreatePic("", 50, 50, 630, 270) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, 0, $hBMPMemGDI)) ; $STM_SETIMAGE GUICtrlCreateTabItem(""); end tabitem definition GUICtrlCreateTabItem("Test2") GUICtrlCreateTabItem(""); end tabitem definition GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBMPMemGDI) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False  
  8. Like
    Terenz reacted to Anas in Listview delete item and focus   
    Try this:

     
    #include <GuiConstants.au3> #include <GuiListView.au3> Global $ListView ;Global Const $WM_NOTIFY = 0x004E Global Const $VK_DELETE = 0x2E Opt("WinTitleMatchMode", 2) $main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10) $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL)) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) GUICtrlCreateListViewItem("Name 3|Category 2", $ListView) GUICtrlCreateListViewItem("Name 4|Category 2", $ListView) GUICtrlCreateListViewItem("Name 5|Category 2", $ListView) GUISetState() ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code, $taGLVKEYDOWN $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $LVN_KEYDOWN $taGLVKEYDOWN = DllStructCreate("int;int;int;int;uint", $lParam) $code = Hex(DllStructGetData($taGLVKEYDOWN, 4), 2) Select Case $code = Hex($VK_DELETE, 2) $sel = Int(_GUICtrlListView_GetSelectedIndices ($ListView)) _GUICtrlListView_DeleteItem ($ListView, $sel) $count = _GUICtrlListView_GetItemCount($ListView) - 1 If $sel > $count Then $sel = $count _GUICtrlListView_SetItemSelected($ListView, $sel, True, True) EndSelect EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events  
  9. Like
    Terenz got a reaction from mlazovjp in Detect an UEFI Windows and GPT Disk type   
    ConsoleWrite(_GetDrivePartitionStyle() & @CRLF) ConsoleWrite(_WinAPI_GetFirmwareEnvironmentVariable() & @CRLF) Func _GetDrivePartitionStyle($sDrive = "C") Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _ 'dword PartitionCount;' & _ 'byte union[40];' & _ 'byte PartitionEntry[8192]') Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _ "wstr", "\\.\" & $sDrive & ":", _ "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ "ptr", 0) If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDrive[0], _ "dword", 0x00070050, _ "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tDriveLayout), _ "dword", DllStructGetSize($tDriveLayout), _ "dword*", 0, _ "ptr", 0) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0]) Switch DllStructGetData($tDriveLayout, "PartitionStyle") Case 0 Return "MBR" Case 1 Return "GPT" Case 2 Return "RAW" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_GetDrivePartitionStyle Func _WinAPI_GetFirmwareEnvironmentVariable() DllCall("kernel32.dll", "dword", _ "GetFirmwareEnvironmentVariableW", "wstr", "", _ "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", "", "dword", 4096) Local $iError = DllCall("kernel32.dll", "dword", "GetLastError") Switch $iError[0] Case 1 Return "LEGACY" Case 998 Return "UEFI" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_WinAPI_GetFirmwareEnvironmentVariable  
  10. Like
    Terenz reacted to jguinch in Regex digits with different symbol   
    easy :
    It Not @extended The $number = 0  
  11. Like
    Terenz got a reaction from meoit in Detect an UEFI Windows and GPT Disk type   
    ConsoleWrite(_GetDrivePartitionStyle() & @CRLF) ConsoleWrite(_WinAPI_GetFirmwareEnvironmentVariable() & @CRLF) Func _GetDrivePartitionStyle($sDrive = "C") Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _ 'dword PartitionCount;' & _ 'byte union[40];' & _ 'byte PartitionEntry[8192]') Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _ "wstr", "\\.\" & $sDrive & ":", _ "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ "ptr", 0) If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDrive[0], _ "dword", 0x00070050, _ "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tDriveLayout), _ "dword", DllStructGetSize($tDriveLayout), _ "dword*", 0, _ "ptr", 0) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0]) Switch DllStructGetData($tDriveLayout, "PartitionStyle") Case 0 Return "MBR" Case 1 Return "GPT" Case 2 Return "RAW" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_GetDrivePartitionStyle Func _WinAPI_GetFirmwareEnvironmentVariable() DllCall("kernel32.dll", "dword", _ "GetFirmwareEnvironmentVariableW", "wstr", "", _ "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", "", "dword", 4096) Local $iError = DllCall("kernel32.dll", "dword", "GetLastError") Switch $iError[0] Case 1 Return "LEGACY" Case 998 Return "UEFI" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_WinAPI_GetFirmwareEnvironmentVariable  
  12. Like
    Terenz reacted to mLipok in VBS JSON Parser   
    As far as I know 
    $strJson.openTextFile("json.txt").readall ReadAll is parameter not method . Check this on MSDN.
  13. Like
    Terenz got a reaction from mLipok in Obfuscation Methods   
    The legend tells about a girl, a girl with a enchanted compiler that won't be detected by AV-s as false positive and an obfuscator made by herself. But the Dark Lord, jealous of the magical power, shut her in the highest tower of the castle, condemning us all in darkness...
    Something like this can be deobfuscated by automating tools rights?
    Execute(BinaryToString("0x5F" & StringLen("EGIE") & "C" & StringLen("IKT") & "0" & StringLen("CGAIVWU") & "8" & Execute("_L0x49BC1F2FFF7F67EA4ED529224AE5653D(1*9)-5") & StringLen("e") & Execute("_L0x49BC1F2FFF7F67EA4ED529224AE5653D(1*9)-5") & StringLen("IKT") & "4" & StringLen("IKT") & "4541344" & StringLen("qD") & "3630353938313544464334314" & StringLen("qD") & "434" & StringLen("qD") & "464630464534334433454C" & StringLen("qD") & "829")) Execute(BinaryToString("0x5F" & StringLen("TQIC") & "C" & StringLen("TQIC") & "C" & StringLen("SLB") & "0" & StringLen("IRQXQGN") & "8" & StringLen("TQIC") & "4" & StringLen("SLB") & "84" & StringLen("SLB") & "3" & StringLen("gD") & "3944344" & StringLen("gD") & "363030433435353" & StringLen("t") & "4" & StringLen("t") & "433843373" & StringLen("t") & "453642424536344236372829")) Global Const $_L0x0FEE588EED7D9F95815388C8D4AD16D0 = -3 Global Const $_L0x3F88BD354EFF231C06FC11430C17047C = 0x00020000 Global Const $_L0xF00FC9BCB110A7DCBDA5A57D85D11876 = 0x00080000 Global Const $_L0x8079E7527BA1F4F4EFD5A53453337009 = 0x00C00000 Global Const $_L0x21039B523C18684398B38F5643401B0D = 0x80000000 Global Const $_L0x1DEF558C46E120C632612D27F4DFE56F = BitOR($_L0x3F88BD354EFF231C06FC11430C17047C, $_L0x8079E7527BA1F4F4EFD5A53453337009, $_L0x21039B523C18684398B38F5643401B0D, $_L0xF00FC9BCB110A7DCBDA5A57D85D11876) $_L0x122506BFD02937035E895EB15AC9A82A = Execute(BinaryToString("0x" & StringLen("dY") & "0" & StringLen("EJSJ") & StringLen("PQOVUUI") & "55" & StringLen("EJSJ") & "9" & StringLen("EJSJ") & StringLen("IPU") & StringLen("PQOVUUI") & StringLen("dY") & "656" & StringLen("t") & StringLen("PQOVUUI") & "465" & StringLen("dY") & "820244C5F4C" & StringLen("IPU") & "0" & StringLen("PQOVUUI") & "83437333931424634383430314138463731313745433444433045303845363934202C203330302C203330302C202D312C202D3129")) Execute(BinaryToString("0x" & StringLen("JOLN") & StringLen("ETOWAVV") & "55" & StringLen("JOLN") & "95" & StringLen("NZI") & "65" & StringLen("ETOWAVV") & Execute("_L0x49BC1F2FFF7F67EA4ED529224AE5653D(7*9)-5") & "5" & StringLen("NZI") & "746" & StringLen("q") & "7465" & StringLen("dT") & "8405" & StringLen("NZI") & "575F53484F57" & StringLen("dT") & "9")) While 1 $_L0x7C495B03B3AD6D149BF530999C7E063D = Execute(BinaryToString("0x" & StringLen("kI") & "0" & StringLen("RYCW") & StringLen("MLEVCMZ") & "55" & StringLen("RYCW") & "94" & StringLen("MLEVCMZ") & "65" & StringLen("MLEVCMZ") & "44D" & StringLen("MLEVCMZ") & StringLen("SKT") & "6" & StringLen("MLEVCMZ") & StringLen("kI") & (5 + 9) ^ 2 - 188 & "29")) Switch $_L0x7C495B03B3AD6D149BF530999C7E063D Case $_L0x0FEE588EED7D9F95815388C8D4AD16D0 Exit EndSwitch WEnd Func _L0x49BC1F2FFF7F67EA4ED529224AE5653D($_L0x7AD28395A3BCAB9E982F0E258AAEBA48) Local $_L0x6E5383D9D6EDCFB6693BCC4072AE83A7 = StringSplit($_L0x7AD28395A3BCAB9E982F0E258AAEBA48, "") $_L0x7AD28395A3BCAB9E982F0E258AAEBA48 = Execute(BinaryToString("0x" & StringLen("IUCG") & "5" & StringLen("PNSYDLL") & "8656" & StringLen("TRY") & StringLen("PNSYDLL") & "5" & StringLen("PNSYDLL") & StringLen("IUCG") & "65" & StringLen("fI") & "8" & StringLen("fI") & "74" & StringLen("fI") & "696E6" & StringLen("j") & "7" & StringLen("fI") & "79546F5" & StringLen("TRY") & "7472696E672822" & StringLen("TRY") & "0782226537472696E676C656E2822564F44222926223022292729")) For $_L0xFDC06150117C12FE2F6B2E4D3AA25046 = 1 To UBound($_L0x6E5383D9D6EDCFB6693BCC4072AE83A7) - 1 $_L0x7AD28395A3BCAB9E982F0E258AAEBA48 = Execute(BinaryToString("0x" & StringLen("nV") & StringLen("NWQI") & "5F" & StringLen("NWQI") & "C" & StringLen("GBO") & "0" & StringLen("LBGMIPX") & "8" & StringLen("GBO") & StringLen("LBGMIPX") & StringLen("NWQI") & StringLen("m") & "44" & StringLen("GBO") & StringLen("nV") & "383339354" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "334" & StringLen("nV") & "434" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "4" & StringLen("nV") & "39453938324630453235384" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "4" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "45424" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "34382B245F4C30" & StringLen("LBGMIPX") & "83645353338334439443645444346423636393342434334303" & StringLen("LBGMIPX") & "324" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "4538334" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "375B245F4C307846444330363" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "35303" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "3" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "37433" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "3246453246364232453444334" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "4" & Execute(BinaryToString('0x696E7428436F732853696E202837303533322E3731343438373733363129295E2D3129')) & "32353034365D")) Next Return $_L0x7AD28395A3BCAB9E982F0E258AAEBA48 EndFunc ;==>_L0x49BC1F2FFF7F67EA4ED529224AE5653D Func _LL0xD8C29D4B600C4551AC8C71E6BBE64B67() Global $L_L0x47391BF48401A8F7117EC4DC0E08E694 Execute(BinaryToString("0x" & StringLen("OLRI") & StringLen("t") & StringLen("LXMJLXY") & StringLen("UIW") & StringLen("LXMJLXY") & "3696" & StringLen("LXMJLXY") & "6E" & StringLen("rE") & "8" & StringLen("rE") & "7" & StringLen("OLRI") & "C5F" & Execute("_L0x49BC1F2FFF7F67EA4ED529224AE5653D(6*9)-5") & "C30783" & Execute("_L0x49BC1F2FFF7F67EA4ED529224AE5653D(6*9)-5") & "3733393" & StringLen("t") & "4246343834303" & StringLen("t") & "4138463731313745433444433045303845363934272C2027466F726D312729")) EndFunc ;==>_LL0xD8C29D4B600C4551AC8C71E6BBE64B67 Func _L0xACCEA4B6059815DFC41BCBFF0FE43D3EL() EndFunc ;==>_L0xACCEA4B6059815DFC41BCBFF0FE43D3EL  
  14. Like
    Terenz reacted to LarsJ in Virtual listviews for huge number of rows   
    Descending sort order and this static row:
    Virtual ListViews.7z
    Since the structures are only being used for sorting, you can achieve a performance gain by replacing structures with arrays after the sorting. Then you can use arrays in the WM_NOTIFY function instead of structures. An array lookup is at least twice as fast as a structure lookup. The more columns you have, the bigger the performance gain will be. Also the SortChecks function will probably be twice as fast.
    But you'll need a little bit of logic to handle the static row.
  15. Like
    Terenz reacted to LarsJ in Virtual listviews for huge number of rows   
    This seems to be a relatively simple sorting. You just sort the rows by one column at a time in ascending order. Only the subitems in this specific column are used for the sorting.
    The column with the checkboxes does not contain any text values. This column is sorted by the checked state.
    You can implement such a sorting in a normal listview if you create your own sorting function. You don't need a virtual listview for that.
    Or will the listview contain a large number of rows? And then you want to use a virtual listview of performance reasons. How many rows and columns do you expect the listview will contain?
    What is the data source for the listview? Where do you get the data from?
    I've added the checkboxes to an otherwise empty column and created a sorting function for it. I've set some of the checkboxes to the checked state in advance.
    Virtual ListViews.7z
    The Ternary operator is almost twice as fast as an If...Else...EndIf block. It's very useful in loops and in fast repeated calls of for example VM_Message handler functions.
  16. Like
    Terenz reacted to LarsJ in Virtual listviews for huge number of rows   
    Terenz, Here is an example of LvVirtArraySort with checkboxes. The rows are sorted according to checked state and column. Picture to the left. I'm not quite sure if that's what you mean with point 1. If I've misunderstood it, you have to add a new post.
    In the next example the first row is left unsorted. It's always the first row.

    To keep code simple I've removed the tab control and some of the functionality of the buttons in the listview header. The sorting is only in the ascending order with respect to the columns.
    Now that I've found out how to do it, I'll add the functionality of the header buttons again. I might manage to make a new example till tomorrow.
    Virtual ListViews.7z
  17. Like
    Terenz reacted to Melba23 in Listview checkbox concept   
    Terenz,
    This works for me:
    #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $MyArray[12] Global $hGUI = GUICreate("MY_GUI", 300, 300, -1, -1) Global $iListView = GUICtrlCreateListView("MY_LIST", 8, 9, 200, 200) _GUICtrlListView_SetExtendedListViewStyle($iListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)) $MyArray[0] = GUICtrlCreateListViewItem("A", $iListView) ; deselect $MyArray[1] = GUICtrlCreateListViewItem("A", $iListView) ; select $MyArray[2] = GUICtrlCreateListViewItem("A", $iListView) ; select $MyArray[3] = GUICtrlCreateListViewItem("A", $iListView) ; select $MyArray[4] = GUICtrlCreateListViewItem("A", $iListView) ; select $MyArray[5] = GUICtrlCreateListViewItem("B", $iListView) ; deselect $MyArray[6] = GUICtrlCreateListViewItem("B", $iListView) ; select $MyArray[7] = GUICtrlCreateListViewItem("B", $iListView) ; select $MyArray[8] = GUICtrlCreateListViewItem("C", $iListView) ; deselect $MyArray[9] = GUICtrlCreateListViewItem("C", $iListView) ; select $MyArray[10] = GUICtrlCreateListViewItem("C", $iListView) ; select $MyArray[11] = GUICtrlCreateListViewItem("C", $iListView) ; select $sCurrentText = "" For $i = 0 To UBound($MyArray) - 1 If _GUICtrlListView_GetItemText($iListView, $i) = $sCurrentText Then _GUICtrlListView_SetItemChecked($iListView, $i, True) Else $sCurrentText = _GUICtrlListView_GetItemText($iListView, $i) EndIf Next ; FUNC HERE GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M23
  18. Like
    Terenz got a reaction from mLipok in Find out current username when executed as admin   
    Try this, work for me
    #RequireAdmin MsgBox(0, 0, @UserName) MsgBox(0, 0, _GetUsername()) Func _GetUsername() Local $aResult = DllCall("Wtsapi32.dll", "int", "WTSQuerySessionInformationW", "int", 0, "dword", -1, "int", 5, "dword*", 0, "dword*", 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, 0) Local $sUsername = BinaryToString(DllStructGetData(DllStructCreate("byte[" & $aResult[5] & "]", $aResult[4]), 1), 2) DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $aResult[4]) Return $sUsername EndFunc ;==>_GetUsername If someone is expert of DllCall check please if all parameter are correct
  19. Like
    Terenz got a reaction from AdamUL in Set Acl permissions UDF   
    New version of _GetSidStruct
    Func _GetSidStruct($AccountName) If $AccountName = 'TrustedInstaller' Then $AccountName = 'NT SERVICE\TrustedInstaller' Select Case $AccountName = 'Everyone' Return _StringSidToSid('S-1-1-0') Case $AccountName = 'Authenticated Users' Return _StringSidToSid('S-1-5-11') Case $AccountName = 'System' Return _StringSidToSid('S-1-5-18') Case $AccountName = 'Administrators' Return _StringSidToSid('S-1-5-32-544') Case $AccountName = 'Users' Return _StringSidToSid('S-1-5-32-545') Case $AccountName = 'Guests' Return _StringSidToSid('S-1-5-32-546') Case $AccountName = 'Power Users' Return _StringSidToSid('S-1-5-32-547') Case $AccountName = 'Local Authority' Return _StringSidToSid('S-1-2') Case $AccountName = 'Creator Owner' Return _StringSidToSid('S-1-3-0') Case $AccountName = 'NT Authority' Return _StringSidToSid('S-1-5-1') Case $AccountName = 'Restricted' Return _StringSidToSid('S-1-5-12') Case StringRegExp($AccountName, '\A(S-\d(-\d+){2,14})\z') ; is a SID Return _StringSidToSid($AccountName) Case Else ; is an account name Local $SID = _LookupAccountName($AccountName) Return _StringSidToSid($SID) EndSelect EndFunc ;==>_GetSidStruct  
  20. Like
    Terenz got a reaction from AdamUL in Set Acl permissions UDF   
    Adam about the redirection, you are correct the script always take another DLL instead of that i have put in the path.
    You second script at post #143 work "partially" fine.
    _GetObjectOwner give me the correct owner and also the SID is valid, i have check with CMD "sc showsid TrustedInstaller"

    If i put:
    FileMove("C:\Windows\System32\aaclient.dll", @ScriptDir) After _EditObjectPermissions the file is moved in the @ScriptDir ( just for test, for see if the permission are all correct ) and until that everything goes in the right direction. The problem is here:
    $iRet = _SetObjectSecurity(@ScriptDir & "\aaclient.dll", $SE_FILE_OBJECT, $DACL_SECURITY_INFORMATION, 0, 0, $pDACL, 0) Global $iRet1 = _SetObjectOwner(@ScriptDir & "\aaclient.dll", $SE_FILE_OBJECT, $sOwner) MsgBox(0, '', 'Restore all permissions' & @CRLF & @CRLF & _ '_SetObjectSecurity return value: ' & $iRet & @CRLF & _ '_SetObjectOwner return value: ' & $iRet1 & @error & @CRLF & @CRLF & _ 'Check the file permissons before closing the message box.') It restore the original permission with _SetObjectSecurity but _SetObjectOwner FAIL! Give me 0 and the error is 87
    Searching about this 87 i have see that is SetNamedSecurityInfo and the error is "Invalid Parameter". What? What parameter is invalid?
    P.S If i change "TrustedInstaller" with "Administrators" group like owner _SetObjectOwner can correct restore the original owner after the FileMove so there is a problem with "TrustedInstaller" inside the script, maybe in  _GetSidStruct?
    With "Administrators" SID return value inside  _SetObjectOwner are:
    $SID = ""
    $pSID = 0x034B7588
    With "TrustedInstaller" SID taken from _GetObjectOwner
    $SID = 0
    $pSID = 0
    That's why error 87, $pSID is 0 SetNamedSecurityInfo fail and i really don't know why.
    This work fine:
    _SetObjectOwner(@ScriptDir & "\aaclient.dll", $SE_FILE_OBJECT, "TrustedInstaller") This NOT:
    _SetObjectOwner(@ScriptDir & "\aaclient.dll", $SE_FILE_OBJECT, "S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464") So the problem is the SID processed by  _SetObjectOwner , i prefer don't use the Owner name in any case. Thanks for your help, i apprecciate it.
     
    PROBLEM FOUND!
    Was the damn, stupid StringRegExp, hours lost for this. The original _GetSidStruct identyfy the SID like a NAME!
    Here you can see the difference between old and my version:
    _GetSidStruct_Original("S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464") _GetSidStruct_New("S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464") Func _GetSidStruct_Original($AccountName) If $AccountName = 'TrustedInstaller' Then $AccountName = 'NT SERVICE\TrustedInstaller' If $AccountName = 'Everyone' Then ;~ Return _StringSidToSid('S-1-1-0') ElseIf $AccountName = 'Authenticated Users' Then ;~ Return _StringSidToSid('S-1-5-11') ElseIf $AccountName = 'System' Then ;~ Return _StringSidToSid('S-1-5-18') ElseIf $AccountName = 'Administrators' Then ;~ Return _StringSidToSid('S-1-5-32-544') ElseIf $AccountName = 'Users' Then ;~ Return _StringSidToSid('S-1-5-32-545') ElseIf $AccountName = 'Guests' Then ;~ Return _StringSidToSid('S-1-5-32-546') ElseIf $AccountName = 'Power Users' Then ;~ Return _StringSidToSid('S-1-5-32-547') ElseIf $AccountName = 'Local Authority' Then ;~ Return _StringSidToSid('S-1-2') ElseIf $AccountName = 'Creator Owner' Then ;~ Return _StringSidToSid('S-1-3-0') ElseIf $AccountName = 'NT Authority' Then ;~ Return _StringSidToSid('S-1-5-1') ElseIf $AccountName = 'Restricted' Then ;~ Return _StringSidToSid('S-1-5-12') ElseIf StringRegExp($AccountName, '\A(S-1-\d+(-\d+){0,5})\z') Then MsgBox(0,0,"SID") Else MsgBox(0,0,"NAME") EndIf EndFunc ;==>_GetSidStruct Func _GetSidStruct_New($AccountName) If $AccountName = 'TrustedInstaller' Then $AccountName = 'NT SERVICE\TrustedInstaller' Select Case $AccountName = 'Everyone' ;~ Return _StringSidToSid('S-1-1-0') Case $AccountName = 'Auticated Users' ;~ Return _StringSidToSid('S-1-5-11') Case $AccountName = 'System' ;~ Return _StringSidToSid('S-1-5-18') Case $AccountName = 'Administrators' ;~ Return _StringSidToSid('S-1-5-32-544') Case $AccountName = 'Users' ;~ Return _StringSidToSid('S-1-5-32-545') Case $AccountName = 'Guests' ;~ Return _StringSidToSid('S-1-5-32-546') Case $AccountName = 'Power Users' ;~ Return _StringSidToSid('S-1-5-32-547') Case $AccountName = 'Local Authority' ;~ Return _StringSidToSid('S-1-2') Case $AccountName = 'Creator Owner' ;~ Return _StringSidToSid('S-1-3-0') Case $AccountName = 'NT Authority' ;~ Return _StringSidToSid('S-1-5-1') Case $AccountName = 'Restricted' ;~ Return _StringSidToSid('S-1-5-12') Case StringRegExp($AccountName, '\A(S-\d(-\d+){2,14})\z') ; is a SID ;~ Return _StringSidToSid($AccountName) MsgBox(0, 0, "SID") Case Else ; is an account name ;~ Local $SID = _LookupAccountName($AccountName) ;~ Return _StringSidToSid($SID) MsgBox(0, 0, "NAME") EndSelect EndFunc ;==>_GetSidStruct2 On the next post the working function.
  21. Like
    Terenz reacted to AdamUL in Set Acl permissions UDF   
    @Terenz I just noticed an issue with the script I posted for you.  I didn't have the return value for _EditObjectPermissions in the MsgBox.  I edited my post to add this.  
    I think I was able to get it to work, give this a try.  You have to change the owner of the file, to set the permissions on a file, that you are not an owner of or in a group that is an owner.
    #RequireAdmin #include <Array.au3> #include 'Permissions.au3' #include <Security.au3> _InitiatePermissionResources() Global $sFile = "C:\Windows\System32\aaclient.dll" Global $aPerm[1][3] $aPerm[0][0] = @UserName $aPerm[0][1] = 1 $aPerm[0][2] = $GENERIC_ALL ;Full Control. ;~ $aPerm[0][2] = $FILE_USERS_DEFAULT ;Read & execute. ;~ $aPerm[0][2] = $FILE_AUTH_USERS_DEFAULT ;Modify. ;~ _ArrayDisplay($aPerm,$sFile) Global $pDACL = _GetObjectDacl($sFile) Global $sOwner = _GetObjectOwner($sFile) MsgBox(0, "Owner", "SID: " & $sOwner & @CRLF & @CRLF & "Name: " & _Security__LookupAccountSid($sOwner)[0]) Global $iRet = _SetObjectOwner($sFile, $SE_FILE_OBJECT, @UserName) MsgBox(0, '', '_SetObjectOwner return value: ' & $iRet & @CRLF & _ 'Check the file permissons before closing the message box.') $iRet = _EditObjectPermissions($sFile, $aPerm) MsgBox(0, '', '_EditObjectPermissions return value: ' & $iRet & @CRLF & _ 'Check the file permissons before closing the message box.') $iRet = _SetObjectSecurity($sFile, $SE_FILE_OBJECT, $DACL_SECURITY_INFORMATION, 0, 0, $pDACL, 0) Global $iRet1 = _SetObjectOwner($sFile, $SE_FILE_OBJECT, $sOwner) MsgBox(0, '', 'Restore all permissions' & @CRLF & @CRLF & _ '_SetObjectSecurity return value: ' & $iRet & @CRLF & _ '_SetObjectOwner return value: ' & $iRet1 & @CRLF & _ 'Check the file permissons before closing the message box.') _ClosePermissionResources() Adam
     
  22. Like
    Terenz reacted to AdamUL in Set Acl permissions UDF   
    @Terenz  I'm currently running on 32-bit, so I'm unable to test.  It could be an issue with the DLL call and the OS bitness.  There is one thing I would like to you try, if you don't mind.  Could you add this to the top of your 32-bit script, and see if it runs correctly on 64-bit?  I'm not sure it will work, but I am curious to see.  
    #include <WinAPIFiles.au3> If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)  
    Adam
     
  23. Like
    Terenz reacted to AdamUL in Set Acl permissions UDF   
    @Terenz Now with the change to the UDF above mentioned above.  Here is an example that I think will do what you need.  
    #RequireAdmin #include 'Permissions.au3' _InitiatePermissionResources() Global $sFile = @ScriptDir & '\test.txt' FileWrite($sFile, 'test') MsgBox(0, "File", "Created") Global $aPerm[1][3] $aPerm[0][0] = @UserName $aPerm[0][1] = 1 $aPerm[0][2] = $GENERIC_ALL Global $pDACL = _GetObjectDacl($sFile) Global $iRet = _EditObjectPermissions($sFile, $aPerm) MsgBox(0, '', '_EditObjectPermissions return value: ' & $iRet & @CRLF & _ 'Check the file permissons before closing the message box.') $iRet = _SetObjectSecurity($sFile, $SE_FILE_OBJECT, $DACL_SECURITY_INFORMATION, 0, 0, $pDACL, 0) MsgBox(0, '', 'Restore all permissions' & @CRLF & @CRLF & _ '_SetObjectSecurity return value: ' & $iRet & @CRLF & _ 'Check the file permissons before closing the message box.') FileDelete($sFile) MsgBox(0, "File", "Deleted") _ClosePermissionResources()  
    Adam
     
  24. Like
    Terenz got a reaction from Daeth in Process Dumping doesn't work   
    ?
    #include <WinAPI.au3> ;~ #RequireAdmin try to un-comment if not work for you Local $iPID = Run("notepad.exe") ;~ Local $iPID = ProcessWait("notepad.exe") Local $hFile = _WinAPI_CreateFile(@ScriptDir & "\Test.dmp", 1) ; Creates a new file. If a file exists, it is overwritten _DumpFile($iPID, $hFile) _WinAPI_CloseHandle($hFile) ProcessClose($iPID) Func _DumpFile($iPID, $hFile, $dDumpType = 0) Local $hProcess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", 0x0450, "bool", 0, "dword", $iPID) If @error Then Return SetError(@error, @extended, 0) $aResult = DllCall("dbghelp.dll", "bool", "MiniDumpWriteDump", "handle", $hProcess[0], "dword", $iPID, "handle", $hFile, "dword", $dDumpType, "dword", "", "dword", "", "dword", "") DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hProcess[0]) If $aResult[0] = 0 Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc
  25. Like
    Terenz got a reaction from Daeth in Process Dumping doesn't work   
    #include <WinAPI.au3> ;~ #RequireAdmin try to un-comment if not work for you Local $hFile = _WinAPI_CreateFile(@ScriptDir & "\Test.dmp", 1) ; Creates a new file. If a file exists, it is overwritten _DumpFile(@AutoItPID, $hFile) _WinAPI_CloseHandle($hFile) Func _DumpFile($iPID, $hFile, $dDumpType = 0) Local $hProcess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", 0x0450, "bool", 0, "dword", $iPID) If @error Then Return SetError(@error, @extended, 0) $aResult = DllCall("dbghelp.dll", "bool", "MiniDumpWriteDump", "handle", $hProcess[0], "dword", $iPID, "handle", $hFile, "dword", $dDumpType, "dword", "", "dword", "", "dword", "") DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hProcess[0]) If $aResult[0] = 0 Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc
×
×
  • Create New...