elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [16] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ... 60 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 534,500 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #150 en: 5 Junio 2013, 17:05 pm »

Recorre todos los controles de "X" tipo en un container.

Código
  1. #Region " Disable Controls "
  2.  
  3.    ' [ Disable Controls ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    '
  9.    ' Disable_Controls(Of CheckBox)(Me.Controls, False)
  10.    ' Disable_Controls(Of Button)(GroupBox1.Controls, False)
  11.  
  12.    Public Sub Disable_Controls(Of T As Control)(ByVal Container As Object, ByVal Enabled As Boolean)
  13.        For Each control As T In Container : control.Enabled = Enabled : Next
  14.    End Sub
  15.  
  16. #End Region





Pequeño ejemplo de como saber el tipo de objeto:

Código
  1. MsgBox(TypeName(Me))      ' Result: Form1
  2. MsgBox(TypeName(Me.Text)) ' Result: String
  3. MsgBox(TypeName(Panel1))  ' Result: Panel


« Última modificación: 5 Junio 2013, 17:07 pm por EleKtro H@cker » En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #151 en: 5 Junio 2013, 17:38 pm »

Hide-Restore Process

Para ocultar o reestablecer la visibilidad de un proceso,
Esto solo oculta la ventana del proceso, no lo oculta del administrador de tareas,
la función "Restore" no está muy pulida, para perfeccionarlo habría que guardar cada handle de los procesos escondidos en un tipo de diccionario si se quiere usar con más de un proceso simultáneamente, ya que cuando ocultas una ventana, el handle se vuelve "0".

EDITO: Código mejorado:

Código
  1. #Region " Hide-Restore Process "
  2.  
  3.    ' [ Hide-Restore Process Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' Hide_Process(Process.GetCurrentProcess().MainModule.ModuleName, False)
  10.    ' Hide_Process("notepad.exe", False)
  11.    ' Hide_Process("notepad", True)
  12.    '
  13.    ' Restore_Process(Process.GetCurrentProcess().MainModule.ModuleName, False)
  14.    ' Restore_Process("notepad.exe", False)
  15.    ' Restore_Process("notepad", True)
  16.  
  17.    Dim Process_Handle_Dictionary As New Dictionary(Of String, IntPtr)
  18.  
  19.    <System.Runtime.InteropServices.DllImport("User32")> Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Int32
  20.    End Function
  21.  
  22.    Private Sub Hide_Process(ByVal Process_Name As String, Optional ByVal Recursive As Boolean = False)
  23.  
  24.        If Process_Name.ToLower.EndsWith(".exe") Then Process_Name = Process_Name.Substring(0, Process_Name.Length - 4)
  25.  
  26.        Dim proc() As Process = Process.GetProcessesByName(Process_Name)
  27.  
  28.        If Recursive Then
  29.            For proc_num As Integer = 0 To proc.Length - 1
  30.                Try
  31.                    Process_Handle_Dictionary.Add(Process_Name & ";" & proc(proc_num).Handle.ToString, proc(proc_num).MainWindowHandle)
  32.                    ShowWindow(proc(proc_num).MainWindowHandle, 0)
  33.                Catch ex As Exception
  34.                    ' MsgBox(ex.Message) ' The handle already exist in the Dictionary
  35.                End Try
  36.                Application.DoEvents()
  37.            Next
  38.        Else
  39.            If Not proc.Length = 0 AndAlso Not proc(0).MainWindowHandle = 0 Then
  40.                Process_Handle_Dictionary.Add(Process_Name & ";" & proc(0).Handle.ToString, proc(0).MainWindowHandle)
  41.                ShowWindow(proc(0).MainWindowHandle, 0)
  42.            End If
  43.        End If
  44.  
  45.    End Sub
  46.  
  47.    Private Sub Restore_Process(ByVal Process_Name As String, Optional ByVal Recursive As Boolean = False)
  48.  
  49.        If Process_Name.ToLower.EndsWith(".exe") Then Process_Name = Process_Name.Substring(0, Process_Name.Length - 4)
  50.  
  51.        Dim Temp_Dictionary As New Dictionary(Of String, IntPtr) ' Replic of the "Process_Handle_Dictionary" dictionary
  52.        For Each Process In Process_Handle_Dictionary : Temp_Dictionary.Add(Process.Key, Process.Value) : Next
  53.  
  54.        If Recursive Then
  55.            For Each Process In Temp_Dictionary
  56.                If Process.Key.ToLower.Contains(Process_Name.ToLower) Then
  57.                    ShowWindow(Process.Value, 9)
  58.                    Process_Handle_Dictionary.Remove(Process.Key)
  59.                End If
  60.                Application.DoEvents()
  61.            Next
  62.        Else
  63.            For Each Process In Temp_Dictionary
  64.                If Process.Key.ToLower.Contains(Process_Name.ToLower) Then
  65.                    ShowWindow(Process.Value, 9)
  66.                    Process_Handle_Dictionary.Remove(Process.Key)
  67.                    Exit For
  68.                End If
  69.                Application.DoEvents()
  70.            Next
  71.        End If
  72.  
  73.    End Sub
  74.  
  75. #End Region


« Última modificación: 5 Junio 2013, 18:39 pm por EleKtro H@cker » En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #152 en: 6 Junio 2013, 02:19 am »

Un panel extendido con varias propiedades nuevas e interesantes...

Código
  1. '
  2. '  /*               *\
  3. ' |#* Panel Elektro *#|
  4. '  \*               */
  5. '
  6. ' // By Elektro H@cker
  7. '
  8. '   Properties:
  9. '   ...........
  10. ' · Disable_Flickering
  11. ' · Double_Buffer
  12. ' · Opaccity
  13. ' · Scroll_Loop
  14.  
  15. Public Class Panel_Elektro
  16.    Inherits Panel
  17.  
  18.    Private _Opaccity As Int16 = 100
  19.    Private _Diable_Flickering As Boolean = True
  20.    Private _Scroll_Loop As Boolean = False
  21.  
  22.    Dim Scroll_Range As Int64 = 0
  23.  
  24.    Public Sub New()
  25.        Me.Name = "Panel_Elektro"
  26.        ' Me.AutoScroll = True
  27.        ' ResumeLayout(False)
  28.    End Sub
  29.  
  30. #Region " Properties "
  31.  
  32.    ''' <summary>
  33.    ''' Enable/Disable any flickering effect on the panel.
  34.    ''' </summary>
  35.    Protected Overrides ReadOnly Property CreateParams() As CreateParams
  36.        Get
  37.            If _Diable_Flickering Then
  38.                Dim cp As CreateParams = MyBase.CreateParams
  39.                cp.ExStyle = cp.ExStyle Or &H2000000
  40.                Return cp
  41.            Else
  42.                Return MyBase.CreateParams
  43.            End If
  44.        End Get
  45.    End Property
  46.  
  47.    ''' <summary>
  48.    ''' Set the Double Buffer.
  49.    ''' </summary>
  50.    Public Property Double_Buffer() As Boolean
  51.        Get
  52.            Return Me.DoubleBuffered
  53.        End Get
  54.        Set(ByVal Value As Boolean)
  55.            Me.DoubleBuffered = Value
  56.        End Set
  57.    End Property
  58.  
  59.    ''' <summary>
  60.    ''' Set the transparency for this panel.
  61.    ''' </summary>
  62.    Public Property Opaccity() As Short
  63.        Get
  64.            Return _Opaccity
  65.        End Get
  66.        Set(ByVal Value As Short)
  67.            If Value > 100 Then Throw New Exception("Opaccity range is from 0 to 100")
  68.            If Value < 0 Then Throw New Exception("Opaccity range is from 0 to 100")
  69.            Me._Opaccity = Value
  70.            Make_Opaccity(Value, Me.BackColor)
  71.        End Set
  72.    End Property
  73.  
  74.    ''' <summary>
  75.    ''' Enable/Disable the flickering effects on this panel.
  76.    '''
  77.    ''' This property turns off any Flicker effect on the panel
  78.    ''' ...but also reduces the performance (speed) of the panel about 30% slower.
  79.    ''' This don't affect to the performance of the application itself, only to the performance of this control.
  80.    ''' </summary>
  81.    Public Property Diable_Flickering() As Boolean
  82.        Get
  83.            Return _Diable_Flickering
  84.        End Get
  85.        Set(ByVal Value As Boolean)
  86.            Me._Diable_Flickering = Value
  87.        End Set
  88.    End Property
  89.  
  90.    ''' <summary>
  91.    ''' Enable/Disable the scroll loop effect.
  92.    ''' Only when AutoScroll option is set to "True".
  93.    ''' </summary>
  94.    Public Property Scroll_Loop() As Boolean
  95.        Get
  96.            Return _Scroll_Loop
  97.        End Get
  98.        Set(ByVal Value As Boolean)
  99.            Me._Scroll_Loop = Value
  100.        End Set
  101.    End Property
  102.  
  103. #End Region
  104.  
  105. #Region " Event handlers "
  106.  
  107.    ' Scroll
  108.    Private Sub Infinite_Scroll_Button(sender As Object, e As ScrollEventArgs) Handles Me.Scroll
  109.  
  110.        If _Scroll_Loop AndAlso Me.AutoScroll Then
  111.  
  112.            Set_Scroll_Range()
  113.  
  114.            If Me.VerticalScroll.Value >= Scroll_Range - 4 Then ' Button Down
  115.                Me.VerticalScroll.Value = 1
  116.            ElseIf Me.VerticalScroll.Value <= 0 Then ' Button Up
  117.                Me.VerticalScroll.Value = Scroll_Range
  118.            End If
  119.  
  120.        End If
  121.  
  122.    End Sub
  123.  
  124.    ' MouseWheel (Scroll)
  125.    Private Sub Infinite_Scroll_MouseWheel(sender As Object, e As MouseEventArgs) Handles Me.MouseWheel
  126.  
  127.        If _Scroll_Loop AndAlso Me.AutoScroll Then
  128.  
  129.            Set_Scroll_Range()
  130.  
  131.            If e.Delta < 0 AndAlso Me.VerticalScroll.Value >= Scroll_Range - 4 Then ' MouseWheel Down
  132.                Me.VerticalScroll.Value = 1
  133.            ElseIf e.Delta > 0 AndAlso Me.VerticalScroll.Value <= 0 Then ' MouseWheel Up
  134.                Me.VerticalScroll.Value = Scroll_Range
  135.            End If
  136.  
  137.        End If
  138.  
  139.    End Sub
  140.  
  141. #End Region
  142.  
  143. #Region " Methods / Functions "
  144.  
  145.    ''' <summary>
  146.    ''' Changes the transparency of this panel.
  147.    ''' </summary>
  148.    Private Sub Make_Opaccity(ByVal Percent As Short, ByVal colour As Color)
  149.        Me.BackColor = Color.FromArgb(Percent * 255 / 100, colour.R, colour.G, colour.B)
  150.    End Sub
  151.  
  152.    ''' <summary>
  153.    ''' Set the VerticalScrollBar Range.
  154.    ''' </summary>
  155.    Private Sub Set_Scroll_Range()
  156.        Scroll_Range = Me.VerticalScroll.Maximum - Me.VerticalScroll.LargeChange + Me.VerticalScroll.SmallChange
  157.    End Sub
  158.  
  159. #End Region
  160.  
  161. End Class
En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #153 en: 6 Junio 2013, 10:23 am »

· Ocultar uno o varios procesos en el Task Manager (Si, en el administrador de tareas!)

(Este código es originálmente de un anónimo (La class "TMListViewDelete", no sé ni me voy a molestar en buscar el nombre del autor), modificado por Kub0x, y vuelto a modificar por mí.)

-> http://foro.elhacker.net/net/aporte_ocultar_aplicacion_en_administrador_de_tareas-t359259.0.html

· Añadida compatibilidad para Windows en el lenguaje Inglés y Alemán, y con posibilidad de añadir fácilmente más soporte para otros lenguajes.

· Ahora se puede ocultar varios procesos al mismo tiempo.

· Añadida opción para poder especificar el/los proceso(s) que queremos ocultar.

· Añadida opción para controlar el intervalo de tiempo en el que se procesa la lista del TaskManager (Por defecto 3 ms, para evitar efectos visuales sospechosos en el TaskManager).

· Reorganización de la estructura del código original (Contenía demasiadas regiones para mi gusto y me dificultaba la lectura).

NOTAS: Si se ocultan varios procesos al mismo tiempo, aunque se use 1 ms para el intervalo del timer puede dar esos efectos visuales extraños en la lista del task manager, así que no excederse si se requiere perfección xD.

Lo he testeado en:
Código:
WinXP x86 Inglés
WinXP x86 Español
Win7 x86 Inglés
Win7 x64 Español
Win7 x64 Inglés
Win7 x64 Español

En Windows 8 No funciona.
A menos que se utilice el replacamiento NO oficial del TaskManager por el TaskManager de Windows 7 (como hago yo) porque el TaskManager de windows 8 no me gusta)


Ejemplos de uso:

Código
  1. Hide_Process_From_TaskManager.Processes_Names = _
  2. {Process.GetCurrentProcess.ProcessName, "cmd", "notepad.exe"} ' Processes to hide.
  3.  
  4. Hide_Process_From_TaskManager.Task_Manager_Window_Titles = _
  5. {"Administrador de tareas de Windows", "Windows Task Manager"} ' Support for unknown TaskManager Window Titles.
  6.  
  7. Hide_Process_From_TaskManager.Hide_Interval = 3 ' Hidding Interval.
  8.  
  9. Hide_Process_From_TaskManager.Running = True ' Start hidding processes.
  10.  
  11. Hide_Process_From_TaskManager.Running = False ' Stop hidding processes.

Los créditos son por orden para el creador de la Class TMListViewDelete que ronda por internet,
luego para las modificaciones de Kub0x y por tener la generosidad de haber compartido el código,
y por último para mis modificaciones y compartirlo con vosotros.    :)


Aquí tienen:

Código
  1. #Region " Hide Process From TaskManager "
  2.  
  3. ' [ Hide Process From TaskManager ]
  4. '
  5. ' // By Elektro H@cker
  6. '
  7. ' Examples :
  8. '
  9. ' Hide_Process_From_TaskManager.Processes_Names = {Process.GetCurrentProcess.ProcessName, "cmd", "notepad.exe"} ' Processes to hide.
  10. ' Hide_Process_From_TaskManager.Task_Manager_Window_Titles = {"Administrador de tareas de Windows", "Windows Task Manager"} ' Support for unknown TaskManager Window Titles.
  11. ' Hide_Process_From_TaskManager.Hide_Interval = 3 ' Hidding Interval.
  12. ' Hide_Process_From_TaskManager.Running = True ' Start hidding processes.
  13. ' Hide_Process_From_TaskManager.Running = False ' Stop hidding processes.
  14.  
  15. #Region " Hide Process From TaskManager Class "
  16.  
  17. Imports Microsoft.Win32.SafeHandles
  18. Imports System.Runtime.InteropServices
  19. Imports System.Text
  20. Imports System.ComponentModel
  21.  
  22. Module Hide_Process_From_TaskManager
  23.  
  24. #Region " API's "
  25.  
  26.    Private Delegate Function EnumDelegate(ByVal lngHwnd As IntPtr, ByVal lngLParam As Integer) As Integer
  27.    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
  28.    Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumDelegate, ByVal lParam As Integer) As Integer
  29.    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
  30.    Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As IntPtr) As Integer
  31.    Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
  32.  
  33.    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
  34.    Private Sub GetClassName(ByVal hWnd As System.IntPtr, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)
  35.    End Sub
  36.  
  37. #End Region
  38.  
  39. #Region " Variables "
  40.  
  41.    ''' <summary>
  42.    ''' The processses to hide from TaskManager.
  43.    ''' Caution: The process name is Case-Sensitive.
  44.    ''' </summary>
  45.    Public Processes_Names() As String = {Process.GetCurrentProcess.ProcessName} ' The current process.
  46.  
  47.    ''' <summary>
  48.    ''' The interval time in ms to hide the process from TaskManager.
  49.    ''' Values greater than "5" can cause bad visual effects in TaskManager processes list.
  50.    ''' </summary>
  51.    Public Hide_Interval As Int32 = 3 ' ms
  52.  
  53.    ''' <summary>
  54.    ''' The known Window Titles for Task Manager process.
  55.    ''' This is necessary to work properly in all languages.
  56.    ''' Add here your own Task Manager Window Tittle if is not inside.
  57.    ''' Default support: Spanish, English, Deutsch
  58.    ''' </summary>
  59.    Public Task_Manager_Window_Titles() As String = { _
  60.        "Administrador de tareas de Windows", _
  61.        "Windows Task Manager", _
  62.        "Windows Task-Manager", _
  63.    }
  64.  
  65.    ''' <summary>
  66.    ''' Gets the next process in the Processes_Names array to hide it.
  67.    ''' Don't touch this.
  68.    ''' </summary>
  69.    Public MyProc As String
  70.  
  71.    Dim t As New Timer
  72.    Dim hwnd As IntPtr
  73.    Dim controls As String
  74.    Dim ProcLV As IntPtr = IntPtr.Zero
  75.  
  76.    Private Const LVM_FIRST = &H1000
  77.    Private Const LVM_DELETECOLUMN = LVM_FIRST + 28
  78.    Private Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
  79.    Private Const LVM_SORTITEMS = (LVM_FIRST + 48)
  80.    Private Const LVM_DELETEITEM = (LVM_FIRST + 8)
  81.    Private Const LVM_GETNEXTITEM = (LVM_FIRST + 12)
  82.    Private Const LVM_GETITEM = (LVM_FIRST + 75)
  83.  
  84. #End Region
  85.  
  86. #Region " Properties "
  87.  
  88.    ''' <summary>
  89.    ''' Turns ON/OFF the process hiding.
  90.    ''' </summary>
  91.    Public Property Running() As Boolean
  92.        Get
  93.            If t.Enabled = True Then
  94.                Return True
  95.            Else
  96.                Return False
  97.            End If
  98.        End Get
  99.        Set(ByVal value As Boolean)
  100.            If value = True Then
  101.  
  102.                If Processes_Names.Length = 0 Then Throw New Exception("Processes_Names Array is empty.")
  103.                If Hide_Interval <= 0 Then Throw New Exception("Hide_Interval value is too low, minimum value: 1")
  104.  
  105.                MyProc = Processes_Names(0)
  106.                If Not t.Interval = Hide_Interval Then
  107.                    With t
  108.                        AddHandler t.Tick, AddressOf t_Tick
  109.                        .Interval = Hide_Interval
  110.                        .Enabled = True
  111.                        .Start()
  112.                    End With
  113.                Else
  114.                    t.Enabled = True
  115.                    t.Start()
  116.                End If
  117.            Else
  118.                t.Enabled = False
  119.                t.Stop()
  120.                ProcLV = IntPtr.Zero
  121.            End If
  122.        End Set
  123.    End Property
  124.  
  125. #End Region
  126.  
  127. #Region " Timer Tick event "
  128.  
  129.    Private Sub t_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  130.        If ProcLV = IntPtr.Zero Then
  131.  
  132.            For Each Title In Task_Manager_Window_Titles
  133.                hwnd = FindWindow(vbNullString, Title)
  134.                If hwnd <> 0 Then
  135.                    EnumChildWindows(hwnd, New EnumDelegate(AddressOf Hide_Process_From_TaskManager.EnumChildWindows), 0)
  136.                End If
  137.            Next
  138.  
  139.        Else
  140.            GetListView(hwnd, ProcLV)
  141.        End If
  142.    End Sub
  143.  
  144. #End Region
  145.  
  146. #Region " Functions "
  147.  
  148.    ' EnumChildWindows
  149.    Private Function EnumChildWindows(ByVal lngHwnd As IntPtr, ByVal lngLParam As Integer) As Integer
  150.        Dim strClassName As String = ObtenerClase(lngHwnd)
  151.        Dim strText As String = ObtenerTextoVentana(lngHwnd)
  152.        If InStr(strClassName, "SysListView32") Then
  153.            GetListView(hwnd, lngHwnd)
  154.            If InStr(strText, "Procesos") Then
  155.                ProcLV = lngHwnd
  156.            End If
  157.        End If
  158.        Dim Classes As String = lngHwnd.ToString & ", " & strClassName & ", " & strText
  159.        Return 1
  160.    End Function
  161.  
  162.    ' ObtenerClase
  163.    Private Function ObtenerClase(ByVal handle As IntPtr) As String
  164.        Dim strClassName As New System.Text.StringBuilder()
  165.        strClassName.Length = 255
  166.        GetClassName(handle, strClassName, strClassName.Length)
  167.        Return strClassName.ToString
  168.    End Function
  169.  
  170.    ' ObtenerTextoVentana
  171.    Private Function ObtenerTextoVentana(ByVal handle As IntPtr) As String
  172.        Dim titleText As New System.Text.StringBuilder()
  173.        titleText.Length = GetWindowTextLength(handle) + 1
  174.        GetWindowText(handle, titleText, titleText.Length)
  175.        Return titleText.ToString
  176.    End Function
  177.  
  178. #End Region
  179.  
  180. End Module
  181.  
  182. Module GetItems
  183.  
  184. #Region " API's "
  185.  
  186.    ' OpenProcess
  187.    <DllImport(kernel32, SetLastError:=True)> _
  188.    Private Function OpenProcess(ByVal dwDesiredAccess As UInteger, ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As SafeProcessHandle
  189.    End Function
  190.  
  191.    ' ReadProcessMemoryW
  192.    <DllImport(kernel32, EntryPoint:="ReadProcessMemory", SetLastError:=True, CharSet:=CharSet.Unicode)> _
  193.    Private Function ReadProcessMemoryW(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As StringBuilder, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  194.    End Function
  195.  
  196.    ' ReadProcessMemory
  197.    <DllImport(kernel32, SetLastError:=True, CharSet:=CharSet.Ansi)> _
  198.    Private Function ReadProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As StringBuilder, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  199.    End Function
  200.  
  201.    ' ReadProcessMemory
  202.    <DllImport(kernel32, SetLastError:=True)> _
  203.    Private Function ReadProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As LV_ITEM, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  204.    End Function
  205.  
  206.    ' ReadProcessMemory
  207.    <DllImport(kernel32, SetLastError:=True)> _
  208.    Private Function ReadProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As HDITEM, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  209.    End Function
  210.  
  211.    ' ReadProcessMemory
  212.    <DllImport(kernel32, SetLastError:=True)> _
  213.    Private Function ReadProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As IntPtr, ByVal nSize As Integer, ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  214.    End Function
  215.  
  216.    ' SendMessage
  217.    <DllImport(user32, SetLastError:=True)> _
  218.    Private Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
  219.    End Function
  220.  
  221.    ' GetHeaderSendMessage
  222.    <DllImport(user32, SetLastError:=True, EntryPoint:="SendMessageA")> _
  223.    Private Function GetHeaderSendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
  224.    End Function
  225.  
  226.    ' SendMessage
  227.    <DllImport(user32, SetLastError:=True)> _
  228.    Private Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
  229.    End Function
  230.  
  231.    ' SendMessage
  232.    <DllImport(user32, SetLastError:=True)> _
  233.    Private Function SendMessage(ByVal hWnd As IntPtr, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
  234.    End Function
  235.  
  236.    ' VirtualAllocEx
  237.    <DllImport(kernel32, SetLastError:=True)> _
  238.    Private Function VirtualAllocEx(ByVal hProcess As SafeProcessHandle, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flAllocationType As UInteger, ByVal flProtect As UInteger) As IntPtr
  239.    End Function
  240.  
  241.    ' VirtualFreeEx
  242.    <DllImport(kernel32, SetLastError:=True)> _
  243.    Private Function VirtualFreeEx(ByVal hProcess As SafeProcessHandle, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal dwFreeType As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
  244.    End Function
  245.  
  246.    ' WriteProcessMemory
  247.    <DllImport(kernel32, SetLastError:=True)> _
  248.    Private Function WriteProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As LV_ITEM, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  249.    End Function
  250.  
  251.    ' WriteProcessMemory
  252.    <DllImport(kernel32, SetLastError:=True)> _
  253.    Private Function WriteProcessMemory(ByVal hProcess As SafeProcessHandle, ByVal lpBaseAddress As IntPtr, ByRef lpBuffer As HDITEM, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  254.    End Function
  255.  
  256. #End Region
  257.  
  258. #Region " Variables "
  259.  
  260.    Dim listViewHandle As IntPtr
  261.  
  262.    Public Const LVM_FIRST As UInteger = &H1000
  263.    Public Const LVM_DELETEITEM As UInteger = (LVM_FIRST + 8)
  264.    Public Const kernel32 As String = "kernel32"
  265.    Public Const user32 As String = "user32"
  266.    Public Const LVM_GETITEMCOUNT As UInteger = &H1004
  267.    Public Const LVM_GETITEMTEXT As UInteger = &H102D
  268.    Public Const LVM_GETHEADER As UInteger = &H101F
  269.    Public Const HDM_GETIEMA As UInteger = &H1203
  270.    Public Const HDM_GETITEMW As UInteger = &H120B
  271.    Public Const HDM_GETITEMCOUNT As UInteger = &H1200
  272.    Public Const HDM_GETUNICODEFORMAT As UInteger = &H2006
  273.    Public Const HDI_TEXT As UInteger = 2
  274.    Public Const MEM_COMMIT As UInteger = &H1000
  275.    Public Const MEM_RELEASE As UInteger = &H8000
  276.    Public Const PAGE_READWRITE As UInteger = 4
  277.    Public Const PROCESS_VM_READ As UInteger = &H10
  278.    Public Const PROCESS_VM_WRITE As UInteger = &H20
  279.    Public Const PROCESS_VM_OPERATION As UInteger = &H8
  280.    Public Const WM_GETTEXT As UInteger = &HD
  281.    Public Const WM_GETTEXTLENGTH As UInteger = &HE
  282.  
  283. #End Region
  284.  
  285. #Region " Structures "
  286.  
  287.    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
  288.    Public Structure LV_ITEM
  289.        Public mask As UInteger
  290.        Public iItem As Integer
  291.        Public iSubItem As Integer
  292.        Public state As UInteger
  293.        Public stateMask As UInteger
  294.        Public pszText As IntPtr
  295.        Public cchTextMax As Integer
  296.        Public iImage As Integer
  297.        Public lParam As IntPtr
  298.        Public iIndent As Integer
  299.        Public iGroupId As Integer
  300.        Public cColumns As Integer
  301.        Public puColumns As IntPtr
  302.        Public piColFmt As IntPtr
  303.        Public iGroup As Integer
  304.        Public Function Size() As Integer
  305.            Return Marshal.SizeOf(Me)
  306.        End Function
  307.    End Structure
  308.  
  309.    <StructLayout(LayoutKind.Sequential)> _
  310.    Public Structure HDITEM
  311.        Public mask As UInteger
  312.        Public cxy As Integer
  313.        Public pszText As IntPtr
  314.        Public hbm As IntPtr
  315.        Public cchTextMax As Integer
  316.        Public fmt As Integer
  317.        Public lParam As IntPtr
  318.        Public iImage As Integer
  319.        Public iOrder As Integer
  320.        Public Function Size() As Integer
  321.            Return Marshal.SizeOf(Me)
  322.        End Function
  323.    End Structure
  324.  
  325. #End Region
  326.  
  327. #Region " Functions "
  328.  
  329.    Public Function GetListView(ByVal handle As IntPtr, ByVal lvhandle As IntPtr) As Boolean
  330.        listViewHandle = lvhandle
  331.        Dim hParent As IntPtr = handle
  332.  
  333.        Dim id As Integer = -1
  334.        Try
  335.            For Each p In Process.GetProcessesByName("taskmgr")
  336.                id = p.Id
  337.            Next
  338.            If id = -1 Then
  339.                Throw New ArgumentException("Can't find process", "processName")
  340.            End If
  341.        Catch : Return False : End Try
  342.  
  343.        Dim hprocess As SafeProcessHandle = Nothing
  344.        Try
  345.            hprocess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, id)
  346.  
  347.            If hprocess Is Nothing Then
  348.                If Marshal.GetLastWin32Error = 0 Then
  349.                    Throw New System.ComponentModel.Win32Exception
  350.                End If
  351.            End If
  352.  
  353.            Dim itemCount As Integer = SendMessage(listViewHandle, LVM_GETITEMCOUNT, IntPtr.Zero, IntPtr.Zero)
  354.  
  355.            For row As Integer = 0 To itemCount - 1
  356.  
  357.                Dim lvi As New ListViewItem(GetItem(row, 0, hprocess))
  358.  
  359.                For Each processname In Processes_Names
  360.                    MyProc = processname
  361.                    If lvi.Text.Contains(Hide_Process_From_TaskManager.MyProc) Then SendMessage(listViewHandle, LVM_DELETEITEM, row, IntPtr.Zero)
  362.                Next
  363.  
  364.            Next
  365.        Catch : Return False
  366.        Finally
  367.            If hprocess IsNot Nothing Then
  368.                hprocess.Close()
  369.                hprocess.Dispose()
  370.            End If
  371.  
  372.        End Try
  373.        Return True
  374.    End Function
  375.  
  376.    Public Function GetItem(ByVal row As Integer, ByVal subitem As Integer, _
  377.                                ByVal hProcess As SafeProcessHandle) As String
  378.  
  379.        Dim lvitem As New LV_ITEM
  380.        lvitem.cchTextMax = 260
  381.        lvitem.mask = 1
  382.        lvitem.iItem = row
  383.        lvitem.iSubItem = subitem
  384.        Dim pString As IntPtr
  385.        Dim s As New StringBuilder(260)
  386.  
  387.        Try
  388.  
  389.            pString = VirtualAllocEx(hProcess, IntPtr.Zero, 260, MEM_COMMIT, PAGE_READWRITE)
  390.            lvitem.pszText = pString
  391.            Dim pLvItem As IntPtr
  392.            Try
  393.                pLvItem = VirtualAllocEx(hProcess, IntPtr.Zero, lvitem.Size, MEM_COMMIT, PAGE_READWRITE)
  394.                Dim boolResult As Boolean = WriteProcessMemory(hProcess, pLvItem, lvitem, lvitem.Size, 0)
  395.                If boolResult = False Then Throw New Win32Exception
  396.  
  397.                SendMessage(listViewHandle, LVM_GETITEMTEXT, row, pLvItem)
  398.                boolResult = ReadProcessMemory(hProcess, pString, s, 260, 0)
  399.                If boolResult = False Then Throw New Win32Exception
  400.                boolResult = ReadProcessMemory(hProcess, pLvItem, lvitem, Marshal.SizeOf(lvitem), 0)
  401.                If boolResult = False Then Throw New Win32Exception
  402.            Finally
  403.                If pLvItem.Equals(IntPtr.Zero) = False Then
  404.                    Dim freeResult As Boolean = VirtualFreeEx(hProcess, pLvItem, 0, MEM_RELEASE)
  405.                    If freeResult = False Then Throw New Win32Exception
  406.                End If
  407.            End Try
  408.        Finally
  409.            If pString.Equals(IntPtr.Zero) = False Then
  410.                Dim freeResult As Boolean = VirtualFreeEx(hProcess, pString, 0, MEM_RELEASE)
  411.                If freeResult = False Then Throw New Win32Exception
  412.            End If
  413.        End Try
  414.  
  415.        Return s.ToString
  416.  
  417.    End Function
  418.  
  419.    Friend NotInheritable Class SafeProcessHandle : Inherits SafeHandleZeroOrMinusOneIsInvalid
  420.  
  421.        Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal hObject As IntPtr) As Boolean
  422.  
  423.        Public Sub New()
  424.            MyBase.New(True)
  425.        End Sub
  426.  
  427.        Public Sub New(ByVal handle As IntPtr)
  428.            MyBase.New(True)
  429.            MyBase.SetHandle(handle)
  430.        End Sub
  431.  
  432.        Protected Overrides Function ReleaseHandle() As Boolean
  433.            Return CloseHandle(MyBase.handle)
  434.        End Function
  435.  
  436.    End Class
  437.  
  438. #End Region
  439.  
  440. End Module
  441.  
  442. #End Region
  443.  
  444. #End Region
  445.  
« Última modificación: 6 Junio 2013, 10:29 am por EleKtro H@cker » En línea



z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #154 en: 6 Junio 2013, 11:02 am »

Y porque el autor es anónimo? :x
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #155 en: 6 Junio 2013, 11:08 am »

Y porque el autor es anónimo? :x

Es anónimo xq me da la gana xD, vi el code del TMListViewDelete posteado por un "guiri" hace mucho tiempo (código que solo funcionaba en XP), lo cierto es que ví la Class en varios sitios buscando una manera de ocultar procesos en el TaskManager, pero no recuerdo el autor, y Kub0x no lo nombra en su code tampoco, así que... anonymous!
En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #156 en: 7 Junio 2013, 05:23 am »

Formatear un número:

Código
  1. #Region " Format Number "
  2.  
  3.    ' [ Format Number Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Format_Number(50000))     ' Result: 50.000
  9.    ' MsgBox(Format_Number(-12345.33)) ' Result: -12.345,33
  10.  
  11.    Private Function Format_Number(ByVal Number As Object) As String
  12.  
  13.        Select Case Number.GetType()
  14.            Case GetType(Int16), GetType(Int32), GetType(Int64)
  15.                Return FormatNumber(Number, TriState.False)
  16.            Case Else
  17.                Return FormatNumber(Number, , TriState.False)
  18.        End Select
  19.  
  20.    End Function
  21.  
  22. #End Region





Crear un textbox con una máscara de asteriscos (para introducir passwords):

Código
  1.        TextBox1.Text = "Elektro" ' Set a random text.
  2.        TextBox1.PasswordChar = "*" ' The character to use in the mask.
  3.        TextBox1.MaxLength = 8 ' The maximum length of characters inside the textbox.
  4.        MsgBox(TextBox1.Text) ' Result: Elektro





Genera todas las combinaciones posibles de una serie de caracteres:

(Este código es ORO por su sencillez y eficacia):

Código
  1. #Region " Permute all combinations of characters"
  2.  
  3.    ' [ Permute Characters Function ]
  4.    '
  5.    ' Examples :
  6.    ' Dim Permutations As IEnumerable = Permute_Characters("abc", 2)
  7.    ' For Each Permutation As IEnumerable(Of Char) In Permutations : RichTextBox1.Text &= vbNewLine & Permutation.ToArray : Next
  8.  
  9.    Private Shared Function Permute_Characters(Of T)(list As IEnumerable(Of T), length As Integer) As IEnumerable(Of IEnumerable(Of T))
  10.  
  11.        If length = 1 Then
  12.            Return list.[Select](Function(x) New T() {x})
  13.        Else
  14.            Return Permute_Characters(list, length - 1).SelectMany(Function(x) list, Function(t1, t2) t1.Concat(New T() {t2}))
  15.        End If
  16.  
  17.    End Function
  18.  
  19. #End Region

Resultado:
Código:
aa
ab
ac
ba
bb
bc
ca
cb
cc
En línea



z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #157 en: 7 Junio 2013, 07:39 am »

Ostia, ese es el code en el que te he ayudado;-)
No verdad, es el siguiente no?
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #158 en: 7 Junio 2013, 09:56 am »

Ostia, ese es el code en el que te he ayudado?  ;-)
No verdad, es el siguiente no?

¿En que parte del código ves algo elevado al cuadrado? xD

Me ayudaste a resolver un problema de una operación matemática en una aplicación donde yo usaba un code, el code o la aplicación es irelevante, pero si, te refieres al code de las combinaciones xD

Salu2
En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.885



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #159 en: 7 Junio 2013, 21:01 pm »

Modifica el modo de renderizado de IExplorer sobre una aplicación, es decir, el modo de renderizado para un "WebBrowser control"

Código
  1. #Region " Set IExplorer Rendering Mode "
  2.  
  3.    ' [ Set IExplorer Rendering Mode ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Set_IExplorer_Rendering_Mode(IExplorer_Renders.IE10)
  9.    ' Set_IExplorer_Rendering_Mode(IExplorer_Renders.IE10_DOCTYPE, "Application.exe")
  10.  
  11.    Public Enum IExplorer_Renders As Int16
  12.        IE10 = 10001         ' Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
  13.        IE10_DOCTYPE = 10000 ' Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
  14.        IE9 = 9999           ' Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
  15.        IE9_DOCTYPE = 9000   ' Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
  16.        IE8 = 8888           ' Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
  17.        IE8_DOCTYPE = 8000   ' Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
  18.        IE7 = 7000           ' Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
  19.    End Enum
  20.  
  21.    Private Sub Set_IExplorer_Rendering_Mode(ByVal IExplorer_Render As IExplorer_Renders, _
  22.                                             Optional ByVal Application_Name As String = Nothing)
  23.  
  24.        If Application_Name Is Nothing Then Application_Name = Process.GetCurrentProcess().ProcessName & ".exe"
  25.  
  26.        Try
  27.            My.Computer.Registry.SetValue( _
  28.            "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _
  29.            Application_Name, IExplorer_Render, Microsoft.Win32.RegistryValueKind.DWord)
  30.        Catch ex As Exception
  31.            MsgBox(ex.Message)
  32.        End Try
  33.  
  34.    End Sub
  35.  
  36. #End Region





Bloquear popups en un webbrowser

Código
  1.        Private Sub WebBrowser_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _
  2.        Handles WebBrowser1.NewWindow
  3.           e.Cancel = True
  4.       End Sub





Bloquear iFrames en un webbrowser

Código
  1.    Private Sub WebBrowser_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) _
  2.    Handles WebBrowser1.DocumentCompleted
  3.  
  4.        For Each element As HtmlElement In CType(sender, WebBrowser).Document.GetElementsByTagName("iframe")
  5.            element.OuterHtml = String.Empty
  6.            Application.DoEvents()
  7.        Next
  8.  
  9.    End Sub
En línea



Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [16] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ... 60 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines