(08-02-2013, 01:24 AM)aeonhack Wrote: I think this is what you are looking for, just add the code and call BlockAccess().
Code:
<DllImport("advapi32.dll")> _
Private Function GetKernelObjectSecurity( _
ByVal handle As IntPtr, _
ByVal requestedInformation As Integer, _
ByVal data As Byte(), _
ByVal dataLength As Integer, _
ByRef size As Integer) As Boolean
End Function
<DllImport("advapi32.dll")> _
Private Function SetKernelObjectSecurity( _
ByVal handle As IntPtr, _
ByVal securityInformation As Integer, _
ByVal data As Byte()) As Boolean
End Function
Function BlockAccess() As Boolean
Dim Handle As IntPtr = Process.GetCurrentProcess().Handle
Dim Size As Integer
GetKernelObjectSecurity(Handle, 4, Nothing, 0, Size)
If Not Size > 0 Then Return False
Dim Data As Byte() = New Byte(Size - 1) {}
If Not GetKernelObjectSecurity(Handle, 4, Data, Data.Length, Size) Then Return False
Dim SD As New RawSecurityDescriptor(Data, 0)
Dim SI As New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing)
Dim Ace As New CommonAce(AceFlags.None, AceQualifier.AccessDenied, 2035711, SI, False, Nothing)
SD.DiscretionaryAcl.InsertAce(0, Ace)
Data = New Byte(SD.BinaryLength - 1) {}
SD.GetBinaryForm(Data, 0)
If Not SetKernelObjectSecurity(Handle, 4, Data) Then Return False
Return True
End Function
Perfect!!
Fianlly!
That was exactly what I was searching for !
No BSOD, But working! Thank you very much, and some +Rep for you!