Blob Blame History Raw
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013--2021  SysDeer Technologies, LLC */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/nt_object.h>
#include "ntapi_impl.h"

void __stdcall __ntapi_tt_sid_copy(
	__out	nt_sid *	dst,
	__in	const nt_sid *	src)
{
	int i;

	dst->revision             = src->revision;
	dst->sub_authority_count  = src->sub_authority_count;
	dst->identifier_authority = src->identifier_authority;

	for (i=0; i<src->sub_authority_count; i++)
		dst->sub_authority[i] = src->sub_authority[i];
}

int32_t __stdcall __ntapi_tt_sid_compare(
	__in	const nt_sid *	sida,
	__in	const nt_sid *	sidb)
{
	int			i;
	int32_t			a;
	int32_t			b;
	const unsigned char *	va;
	const unsigned char *	vb;

	if ((a = sida->revision) - (b = sidb->revision))
		return a-b;

	if ((a = sida->sub_authority_count) - (b = sidb->sub_authority_count))
		return a-b;

	va=sida->identifier_authority.value;
	vb=sidb->identifier_authority.value;

	for (i=0; i<6; i++)
		if ((a = va[i]) - (b = vb[i]))
			return a-b;

	for (i=0; i<sida->sub_authority_count; i++)
		if ((a = sida->sub_authority[i]) - (b = sidb->sub_authority[i]))
			return a-b;

	return 0;
}