Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: RodrigoCastro en 1 Noviembre 2016, 21:09 pm



Título: ¿Como usar GetInheritanceSource en VB6?
Publicado por: RodrigoCastro en 1 Noviembre 2016, 21:09 pm
Un saludo a todos, soy nuevo en el foro, pero tengo varios años de experiencia en VB6, PHP, administración de redes y configuración de servidores. Espero ser bien acogido por ustedes los mas antiguos y poder ayudarles cuando sea pertinente. Históricamente siempre he trabajado solo y resuelto por mi mismo las dudas y problemas obviamente con mucho esfuerzo, sufrimiento y satisfacción a través de la teoría y también pruebas y error en variadas infraestructuras.

Por supuesto ya he buscado una respuesta en la WEB y he hecho una búsqueda en el foro, tampoco he podido obtener una solución traduciendo algún código encontrado de C++, ni mucho menos desde VB.net. También alterando las llamadas a diferentes aproximaciones posibles pero no he podido pasar mas allá del error de sistema 87 "A parameter is not valid" devuelto por la función.

Puedo obtener correctamente las ACEs explicitas en Win7 y WinXP SP2 y mi intención es obtener información acerca de las ACEs heredadas.

Código:
'Intentar implementar para encontrar ACLs heredadas.
'Probando
Type GENERIC_MAPPING
   'The GENERIC_MAPPING structure defines the mapping of generic access
   'rights to specific and standard access rights for an object. When a
   'client application requests generic access to an object, that request
   'is mapped to the access rights defined in this structure.
   GenericRead As Long
   'Specifies an access mask defining read access to an object.
   GenericWrite As Long
   'Specifies an access mask defining write access to an object.
   GenericExecute  As Long
   'Specifies an access mask defining execute access to an object.
   GenericAll As Long
   'Specifies an access mask defining all possible types of access to an
   'object.
   
   'Requirements
   'Minimum supported client  Windows XP [desktop apps only]
   'Minimum supported server  Windows Server 2003 [desktop apps only]
   'Header                    Winnt.h (include Windows.h)
End Type

Private Type GUID
   'GUIDs identify objects such as interfaces, manager entry-point vectors
   '(EPVs), and class objects. A GUID is a 128-bit value consisting of one
   'group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal
   'digits each, followed by one group of 12 hexadecimal digits. The
   'following example GUID shows the groupings of hexadecimal digits in a
   'GUID: 6B29FC40-CA47-1067-B31D-00DD010662DA
   
   'The GUID structure stores a GUID.
   Data1 As Long
   Data2 As Integer
   Data3 As Integer
   Data4(0 To 7) As Byte
End Type

Public Declare Function GetInheritanceSource Lib "advapi32.dll" Alias "GetInheritanceSourceW" _
                (ByVal pObjectName As String, _
                 ByVal ObjectType As enmSE_OBJECT_TYPE, _
                 ByVal SecurityInfo As Long, _
                 ByVal Container As Long, _
                 ByRef ObjectTypeGuid As Long, _
                 ByVal GuidCount As Long, _
                 ByRef pAcl As Long, _
                 ByVal pfnArray As Long, _
                 ByRef pGenericMapping As GENERIC_MAPPING, _
                 ByRef pInheritArray As Long) As Long

'The GetInheritanceSource function returns information about the source of
'inherited access control entries (ACEs) in an access control list (ACL).

'Si la función se ejecuta correctamente debería devolver un array de:
Type INHERITED_FROM
   GenerationGap As Long
   'Number of levels, or generations, between the object and the ancestor.
   'Set this to zero for an explicit ACE. If the ancestor cannot be determined
   'for the inherited ACE, set this member to –1.
   AncestorName As String
   'Name of the ancestor from which the ACE was inherited. For an explicit ACE,
   'set this to NULL.
   
   'Requirements
   'Minimum supported client  Windows XP [desktop apps only]
   'Minimum supported server  Windows Server 2003 [desktop apps only]
   'Header                    AccCtrl.h
   'Unicode and ANSI names    INHERITED_FROMW (Unicode) And INHERITED_FROMA(ANSI)
End Type
'apuntado por el parámetro pInheritArray

Estaría muy agradecido si alguien pudiera ayudarme a salir del estancamiento.
Desde ya muchas gracias.