reactos/dll/win32/netapi32/misc.c
Hermès Bélusca-Maïto e1ef078741 Create this branch to work on loading of different Kernel-Debugger DLL providers, and see whether it is possible to move KDBG from ntoskrnl to a new DLL called, say, KDROSDBG.DLL.
The idea then would be to have the following behaviour (when specifying the following options in the kernel command line):

/DEBUGPORT=COMi --> load KDCOM.DLL and use COMi port (i == 1,2,3,4) if possible.
/DEBUGPORT=FOO  --> load KDFOO.DLL (useful for KDUSB.DLL, KD1394.DLL, KDBAZIS.DLL for VirtualKD, etc...)
/DEBUGPORT=ROSDBG:[COMi|SCREEN|FILE|GDB|...] --> load KDROSDBG.DLL which contains the ROS kernel debugger, and use COMi or SCREEN or... as output port.

svn path=/branches/kd++/; revision=58883
2013-04-28 13:26:45 +00:00

179 lines
4.3 KiB
C

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: NetAPI DLL
* FILE: reactos/dll/win32/netapi32/misc.c
* PURPOSE: Helper functions
*
* PROGRAMMERS: Eric Kohl
*/
/* INCLUDES ******************************************************************/
#include "netapi32.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
/* GLOBALS *******************************************************************/
static SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
/* FUNCTIONS *****************************************************************/
NTSTATUS
GetAccountDomainSid(IN PUNICODE_STRING ServerName,
OUT PSID *AccountDomainSid)
{
PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo = NULL;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle = NULL;
ULONG Length = 0;
NTSTATUS Status;
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
Status = LsaOpenPolicy(ServerName,
&ObjectAttributes,
POLICY_VIEW_LOCAL_INFORMATION,
&PolicyHandle);
if (!NT_SUCCESS(Status))
{
ERR("LsaOpenPolicy failed (Status %08lx)\n", Status);
return Status;
}
Status = LsaQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation,
(PVOID *)&AccountDomainInfo);
if (!NT_SUCCESS(Status))
{
ERR("LsaQueryInformationPolicy failed (Status %08lx)\n", Status);
goto done;
}
Length = RtlLengthSid(AccountDomainInfo->DomainSid);
*AccountDomainSid = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
if (*AccountDomainSid == NULL)
{
ERR("Failed to allocate SID\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
goto done;
}
memcpy(*AccountDomainSid, AccountDomainInfo->DomainSid, Length);
done:
if (AccountDomainInfo != NULL)
LsaFreeMemory(AccountDomainInfo);
LsaClose(PolicyHandle);
return Status;
}
NTSTATUS
GetBuiltinDomainSid(OUT PSID *BuiltinDomainSid)
{
PSID Sid = NULL;
PULONG Ptr;
NTSTATUS Status = STATUS_SUCCESS;
*BuiltinDomainSid = NULL;
Sid = RtlAllocateHeap(RtlGetProcessHeap(),
0,
RtlLengthRequiredSid(1));
if (Sid == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
Status = RtlInitializeSid(Sid,
&NtAuthority,
1);
if (!NT_SUCCESS(Status))
goto done;
Ptr = RtlSubAuthoritySid(Sid, 0);
*Ptr = SECURITY_BUILTIN_DOMAIN_RID;
*BuiltinDomainSid = Sid;
done:
if (!NT_SUCCESS(Status))
{
if (Sid != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, Sid);
}
return Status;
}
NTSTATUS
OpenAccountDomain(IN SAM_HANDLE ServerHandle,
IN PUNICODE_STRING ServerName,
IN ULONG DesiredAccess,
OUT PSAM_HANDLE DomainHandle)
{
PSID DomainSid = NULL;
NTSTATUS Status;
Status = GetAccountDomainSid(ServerName,
&DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);
return Status;
}
Status = SamOpenDomain(ServerHandle,
DesiredAccess,
DomainSid,
DomainHandle);
RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("SamOpenDomain failed (Status %08lx)\n", Status);
}
return Status;
}
NTSTATUS
OpenBuiltinDomain(IN SAM_HANDLE ServerHandle,
IN ULONG DesiredAccess,
OUT PSAM_HANDLE DomainHandle)
{
PSID DomainSid = NULL;
NTSTATUS Status;
Status = GetBuiltinDomainSid(&DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("GetBuiltinDomainSid failed (Status %08lx)\n", Status);
return Status;
}
Status = SamOpenDomain(ServerHandle,
DesiredAccess,
DomainSid,
DomainHandle);
RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("SamOpenDomain failed (Status %08lx)\n", Status);
}
return Status;
}
/* EOF */