helpers.cpp revision d2236df2116a3cbe8b17c567f4a9c2281733a956
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// PARTICULAR PURPOSE.
//
// Copyright (c) 2006 Microsoft Corporation. All rights reserved.
//
// Helper functions for copying parameters and packaging the buffer
// for GetSerialization.
//
// Modifications (c) 2009 Sun Microsystems, Inc.
//
#include "helpers.h"
#include <intsafe.h>
//
// Copies the field descriptor pointed to by rcpfd into a buffer allocated
// using CoTaskMemAlloc. Returns that buffer in ppcpfd.
//
)
{
if (pcpfd)
{
{
}
else
{
}
}
else
{
hr = E_OUTOFMEMORY;
}
{
}
else
{
}
return hr;
}
//
// Coppies rcpfd into the buffer pointed to by pcpfd. The caller is responsible for
// allocating pcpfd. This function uses CoTaskMemAlloc to allocate memory for
// pcpfd->pszLabel.
//
)
{
{
}
else
{
}
{
}
return hr;
}
//
// This function copies the length of pwz and the pointer pwz into the UNICODE_STRING structure
// This function is intended for serializing a credential in GetSerialization only.
// Note that this function just makes a copy of the string pointer. It DOES NOT ALLOCATE storage!
// Be very, very sure that this is what you want, because it probably isn't outside of the
// exact GetSerialization call where the sample uses it.
//
)
{
if (pwz)
{
{
{
{
{
}
else
{
}
}
}
}
}
else
{
hr = E_INVALIDARG;
}
return hr;
}
//
// The following function is intended to be used ONLY with the Kerb*Pack functions. It does
// no bounds-checking because its callers have precise requirements and are written to respect
// its limitations.
// You can read more about the UNICODE_STRING type at:
//
static void _UnicodeStringPackedUnicodeStringCopy(
const UNICODE_STRING& rus,
)
{
}
//
// WinLogon and LSA consume "packed" KERB_INTERACTIVE_LOGONs. In these, the PWSTR members of each
// UNICODE_STRING are not actually pointers but byte offsets into the overall buffer represented
// by the packed KERB_INTERACTIVE_LOGON. For example:
//
// kil.LogonDomainName.Length = 14 -> Length is in bytes, not characters
// kil.LogonDomainName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) -> LogonDomainName begins immediately
// after the KERB_... struct in the buffer
// kil.UserName.Length = 10
// kil.UserName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14 -> UNICODE_STRINGS are NOT null-terminated
//
// kil.Password.Length = 16
// kil.Password.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14 + 10
//
// THere's more information on this at:
//
const KERB_INTERACTIVE_LOGON& rkil,
)
{
// alloc space for struct plus extra for the three strings
if (pkil)
{
//
// point pbBuffer at the beginning of the extra space
//
//
// copy each string,
// fix up appropriate buffer pointer to be offset,
// advance buffer pointer over copied characters in extra space
//
_UnicodeStringPackedUnicodeStringCopy(rkil.LogonDomainName, (PWSTR)pbBuffer, &pkil->LogonDomainName);
}
else
{
hr = E_OUTOFMEMORY;
}
return hr;
}
//
// Unpack a KERB_INTERACTIVE_UNLOCK_LOGON *in place*. That is, reset the Buffers from being offsets to
// being real pointers. This means, of course, that passing the resultant struct across any sort of
// memory space boundary is not going to work -- repack it if necessary!
//
//
// Unpack a KERB_INTERACTIVE_UNLOCK_LOGON *in place*. That is, reset the Buffers from being offsets to
// being real pointers. This means, of course, that passing the resultant struct across any sort of
// memory space boundary is not going to work -- repack it if necessary!
//
)
{
: NULL;
: NULL;
: NULL;
}
//
// This function packs the string pszSourceString in pszDestinationString
// for use with LSA functions including LsaLookupAuthenticationPackage.
//
{
{
{
}
}
return hr;
}
//
// Retrieves the 'negotiate' AuthPackage from the LSA. In this case, Kerberos
// For more information on auth packages see this msdn page:
//
{
{
{
}
else
{
}
}
else
{
}
return hr;
}
/* Re-defined function for *not* having a log handle (= log file created).
For some reason this does not work in this early stage (yet). */
PRTLOGGER RTLogDefaultInit(void)
{
return NULL;
}