Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: Karcrack en 12 Agosto 2010, 23:55 PM

Título: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Karcrack en 12 Agosto 2010, 23:55 PM
Código (vb) [Seleccionar]
'KERNEL32
Private Declare Function CreateSemaphoreW Lib "KERNEL32" (ByVal lpSemaphoreAttributes As Long, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As Long) As Long

'---------------------------------------------------------------------------------------
' Procedure : DisableMsConfig
' Author    : Karcrack
' Date      : 12/08/2010
'---------------------------------------------------------------------------------------
'
Public Function DisableMsConfig() As Boolean
   Call CreateSemaphoreW(0, 0, 1, StrPtr("MSConfigRunning"))
   DisableMsConfig = (Err.LastDllError = 0)
End Function


Bien cortito y funcional, ejecuta el codigo e intenta abrir el msconfig.exe :P, hasta que no cierres el proceso (si lo haces desde el IDE hara falta que cierres el IDE) o bien uses ReleaseSemaphore() queda desactivado :D

Ale, a divertirse! :P
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Mi4night en 13 Agosto 2010, 00:23 AM
Hey great stuff karcrack like usually!

One question what does CreateSemaphoreW  ectually do?
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: aaronduran2 en 13 Agosto 2010, 09:45 AM
Testeado en W7 Ultimate, funciona perfectamente ;-)

Como siempre códigos geniales ;)
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Karcrack en 13 Agosto 2010, 21:58 PM
Cita de: Mi4night en 13 Agosto 2010, 00:23 AM
Hey great stuff karcrack like usually!

One question what does CreateSemaphoreW  ectually do?
Works like CreateMutex moreover...
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Miseryk en 15 Agosto 2010, 05:17 AM
Cita de: Karcrack en 12 Agosto 2010, 23:55 PM
Código (vb) [Seleccionar]
'KERNEL32
Private Declare Function CreateSemaphoreW Lib "KERNEL32" (ByVal lpSemaphoreAttributes As Long, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As Long) As Long

'---------------------------------------------------------------------------------------
' Procedure : DisableMsConfig
' Author    : Karcrack
' Date      : 12/08/2010
'---------------------------------------------------------------------------------------
'
Public Function DisableMsConfig() As Boolean
   Call CreateSemaphoreW(0, 0, 1, StrPtr("MSConfigRunning"))
   DisableMsConfig = (Err.LastDllError = 0)
End Function


Bien cortito y funcional, ejecuta el codigo e intenta abrir el msconfig.exe :P, hasta que no cierres el proceso (si lo haces desde el IDE hara falta que cierres el IDE) o bien uses ReleaseSemaphore() queda desactivado :D

Ale, a divertirse! :P

Como implemento el ReleaseSemaphore()?, lo puse sin parametros y no pasa nada, tengo que cerrar el proyecto.
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Karcrack en 15 Agosto 2010, 12:42 PM
Tienes que almacenar el valor que devuelve CreateSemaphore() y mas tarde pasarselo a ReleaseMutex()
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Miseryk en 15 Agosto 2010, 13:31 PM
Código (vb) [Seleccionar]

Option Explicit

'KERNEL32
Private Declare Function CreateSemaphoreW Lib "kernel32" (ByVal lpSemaphoreAttributes As Long, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As Long) As Long
Private Declare Function ReleaseMutex Lib "kernel32" (ByVal hMutex As Long) As Long

Dim Mutex As Long

'---------------------------------------------------------------------------------------
' Procedure : DisableMsConfig
' Author    : Karcrack
' Date      : 12/08/2010
'---------------------------------------------------------------------------------------
'
Public Function DisableMsConfig() As Boolean
Mutex = CreateSemaphoreW(0, 0, 1, StrPtr("MSConfigRunning"))
DisableMsConfig = (Err.LastDllError = 0)
End Function

Private Sub Command1_Click()
Call ReleaseMutex(Mutex)
End Sub

Private Sub Form_Load()
Call DisableMsConfig
End Sub



Lo hice asi, pero no funciona :(, estoy haciendo algo mal? :(
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: wh0! en 15 Agosto 2010, 17:06 PM
Minimalista!  :laugh:
jajaja, Todo un capo.  ;-)
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Karcrack en 15 Agosto 2010, 22:48 PM
Perdon, me equivoque al escribir, la funcion es ReleaseSemaphore() , de todas formas hay que hacerlo con CloseHandle() :xD:xD :xD :xD

Aqui tienes un codigo:
Código (vb) [Seleccionar]
Option Explicit

'KERNEL32
Private Declare Function CreateSemaphoreW Lib "KERNEL32" (ByVal lpSemaphoreAttributes As Long, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As Long) As Long
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long

Public Static Function DisableMsConfig(Optional ByVal bReEnable As Boolean = False) As Boolean
    Dim hSem        As Long
   
    If bReEnable = True And hSem <> 0 Then
        DisableMsConfig = (CloseHandle(hSem) <> 0)
    Else
        hSem = CreateSemaphoreW(0, 0, 1, StrPtr("MSConfigRunning"))
        DisableMsConfig = (Err.LastDllError = 0)
    End If
End Function

Private Sub Form_Load()
    Call DisableMsConfig(False)
    MsgBox "Cuando le des a Aceptar se reactivara MsConfig.exe"
    Call DisableMsConfig(True)
    End
End Sub
Título: Re: [m][VB6][SNIPPET] DisableMsConfig - Desactiva Msconfig.exe
Publicado por: Miseryk en 16 Agosto 2010, 07:49 AM
Wow, genial, muchas gracias, ah, también lo había probado con ReleaseSemaphore(), :D  ;-) ;-)