Hola!

Dejo este source para setear algun proceso como proceso de sistema

Al cerrar el proceso dará un BSOD :)

Modulo:
[spoiler][code2=vbnet]Option Explicit

Private Const ANYSIZE_ARRAY = 1
Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8
Private Const SE_PRIVILEGE_ENABLED = &H2

Private Type LUID
LowPart As Long
HighPart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type

Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLUID As LUID) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long

Public Const SE_DEBUG_NAME As String = "SeDebugPrivilege"

Public Declare Function RtlSetProcessIsCritical Lib "ntdll.dll" (ByVal NewValue As Boolean, ByVal OldValue As Boolean, ByVal WinLogon As Boolean)

Public Function ObtenerPrivilegios(ByVal privilegio As String) As Long

Dim lpLUID As LUID
Dim lpToken As TOKEN_PRIVILEGES
Dim lpAntToken As TOKEN_PRIVILEGES
Dim hToken As Long
Dim hProcess As Long
Dim res As Long

hProcess = GetCurrentProcess()
res = OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken)
If res = 0 Then
Exit Function
End If
res = LookupPrivilegeValue(vbNullString, privilegio, lpLUID)
If res = 0 Then
Exit Function
End If
With lpToken
.PrivilegeCount = 1
.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
.Privileges(0).pLuid = lpLUID
End With

res = AdjustTokenPrivileges(hToken, False, lpToken, Len(lpToken), lpAntToken, Len(lpAntToken))
If res = 0 Then
Exit Function
End If
ObtenerPrivilegios = res
End Function[/code2][/spoiler]


Para setear el proceso:
[spoiler][code2=vbnet]ObtenerPrivilegios SE_DEBUG_NAME
Call RtlSetProcessIsCritical(0, 0, 1)[/code2][/spoiler]


Lo he probado y funciona perfectamente (Requiere permisos de administrador)

Saludos!
Blau escribió:Si no me equivoco, iniciando el taskmgr como administardor se puede cerrar el proceso tranquilamente.
Pero te da un BSOD tranquilamente
Ninfrock escribió:
Blau escribió:Si no me equivoco, iniciando el taskmgr como administardor se puede cerrar el proceso tranquilamente.
Pero te da un BSOD tranquilamente
Con el code que probé hace tiempo no resultaba en BSOD si se cerraba con UAC. Quizá fue una mala implementación o un bug a la hora de codear.
Blau escribió:
Ninfrock escribió:
Blau escribió:Si no me equivoco, iniciando el taskmgr como administardor se puede cerrar el proceso tranquilamente.
Pero te da un BSOD tranquilamente
Con el code que probé hace tiempo no resultaba en BSOD si se cerraba con UAC. Quizá fue una mala implementación o un bug a la hora de codear.
Estas cerrando un proceso de sistema, lo cierres con la X o lo cierres con un driver ring0 va a dar BSOD igual

pd: andas on fire, eh? de los 10 mensajes nuevos 9 son de Blau
Responder

Volver a “Fuentes”