如题,小弟菜菜,高手指导~

解决方案 »

  1.   

    在DDK的ntdef.h中InitializeObjectAttributes()只是一个宏 static VOID InitializeObjectAttributes ( OUT POBJECT_ATTRIBUTES InitializedAttributes, 
                                             IN PUNICODE_STRING ObjectName, 
                                             IN ULONG Attributes, 
                                             IN HANDLE RootDirectory, 
                                             IN PSECURITY_DESCRIPTOR SecurityDescriptor 
                                           ) 

        InitializedAttributes->Length                   = sizeof( OBJECT_ATTRIBUTES ); 
        InitializedAttributes->RootDirectory            = RootDirectory; 
        InitializedAttributes->Attributes               = Attributes; 
        InitializedAttributes->ObjectName               = ObjectName; 
        InitializedAttributes->SecurityDescriptor       = SecurityDescriptor; 
        InitializedAttributes->SecurityQualityOfService = NULL; 
        return; 
    }  /* end of InitializeObjectAttributes */ 
      

  2.   

    Delphi下定义为:type
      PUNICODE_STRING = ^UNICODE_STRING;
      _UNICODE_STRING = record
        Length: word;
        MaximumLength: word;
        Buffer: PWideChar;
      end;
      POBJECT_ATTRIBUTES = ^TOBJECT_ATTRIBUTES;
      TOBJECT_ATTRIBUTES = record
        Length: Cardinal;
        RootDirectory: HANDLE;
        ObjectName: PUNICODE_STRING;
        Attributes: Dword;
        SecurityDescriptor: pointer;       // Points to type SECURITY_DESCRIPTOR
        SecurityQualityOfService: pointer; // Points to type SECURITY_QUALITY_OF_SERVICE
      end;
    procedure InitializeObjectAttributes(pAttributes: POBJECT_ATTRIBUTES; n: PUNICODE_STRING;
      a: Cardinal; r: HANDLE; s: pointer);
    begin
      pAttributes^.Length := SizeOf(TOBJECT_ATTRIBUTES);
      pAttributes^.RootDirectory := r;
      pAttributes^.Attributes := a;
      pAttributes^.ObjectName := n;
      pAttributes^.SecurityDescriptor := s;
      pAttributes^.SecurityQualityOfService := nil;
    end;