Пример #1
0
static inline void rot_entry_delete(struct rot_entry *rot_entry)
{
    if (rot_entry->cookie)
    {
        InterfaceData *object = NULL;
        InterfaceData *moniker = NULL;
        __TRY
        {
            IrotRevoke(get_irot_handle(), rot_entry->cookie,
                       &rot_entry->ctxt_handle, &object, &moniker);
        }
        __EXCEPT(rpc_filter)
        {
        }
        __ENDTRY
        MIDL_user_free(object);
        if (moniker)
        {
            IStream *stream;
            HRESULT hr;
            hr = create_stream_on_mip_ro(moniker, &stream);
            if (hr == S_OK)
            {
                CoReleaseMarshalData(stream);
                IUnknown_Release(stream);
            }
        }
        MIDL_user_free(moniker);
    }
Пример #2
0
void kull_m_rpc_drsr_free_DRS_MSG_CRACKREPLY_data(DWORD nameCrackOutVersion, DRS_MSG_CRACKREPLY * reply)
{
	DWORD i;
	if(reply)
	{
		switch (nameCrackOutVersion)
		{
		case 1:
			if(reply->V1.pResult)
			{
				for(i = 0; i < reply->V1.pResult->cItems; i++)
				{
					if(reply->V1.pResult->rItems[i].pDomain)
						MIDL_user_free(reply->V1.pResult->rItems[i].pDomain);
					if(reply->V1.pResult->rItems[i].pName)
						MIDL_user_free(reply->V1.pResult->rItems[i].pName);
				}
				if(reply->V1.pResult->rItems)
					MIDL_user_free(reply->V1.pResult->rItems);
				MIDL_user_free(reply->V1.pResult);
			}
			break;
		default:
			PRINT_ERROR(L"nameCrackOutVersion not valid (0x%08x - %u)\n", nameCrackOutVersion, nameCrackOutVersion);
			break;
		}
	}
}
Пример #3
0
static void
free_pyramid_doub_carr(doub_carr_t *dc)
{
  int i;
  for (i = 0; i < dc->n; ++i)
    MIDL_user_free(dc->a[i]);
  MIDL_user_free(dc);
}
Пример #4
0
static void free_list(LPWSTR *list, DWORD count)
{
    LONG i;

    for (i = 0; i < count; i++)
        MIDL_user_free(list[i]);

    MIDL_user_free(list);
}
Пример #5
0
VOID
NTAPI
SamIFree_SAMPR_SR_SECURITY_DESCRIPTOR(PSAMPR_SR_SECURITY_DESCRIPTOR Ptr)
{
    if (Ptr != NULL)
    {
        if (Ptr->SecurityDescriptor != NULL)
            MIDL_user_free(Ptr->SecurityDescriptor);

        MIDL_user_free(Ptr);
    }
}
Пример #6
0
VOID
NTAPI
SamIFree_SAMPR_GET_GROUPS_BUFFER(PSAMPR_GET_GROUPS_BUFFER Ptr)
{
    if (Ptr != NULL)
    {
        if (Ptr->Groups != NULL)
            MIDL_user_free(Ptr->Groups);

        MIDL_user_free(Ptr);
    }
}
Пример #7
0
VOID
LsapMmFreeLastEntry(
    IN PLSAP_MM_FREE_LIST FreeList
    )

/*++

Routine Description:

    This function frees the last buffer appeended to the Free List.

Arguments:

    FreeList - Pointer to Free List.

--*/

{
    ULONG LastIndex = FreeList->UsedCount - 1;

    if (FreeList->Buffers[LastIndex].Options & LSAP_MM_MIDL) {

        MIDL_user_free( FreeList->Buffers[LastIndex].Buffer );

    } else {

        LsapFreeLsaHeap( FreeList->Buffers[LastIndex].Buffer );
    }

    FreeList->Buffers[LastIndex].Buffer = NULL;
    FreeList->UsedCount--;
}
Пример #8
0
/*
 * @implemented
 */
NTSTATUS
WINAPI
LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
                          IN POLICY_INFORMATION_CLASS InformationClass,
                          OUT PVOID *Buffer)
{
    PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
    NTSTATUS Status;

    TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);

    RpcTryExcept
    {
        Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
                                            InformationClass,
                                            &PolicyInformation);
        *Buffer = PolicyInformation;
    }
    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
    {
        if (PolicyInformation != NULL)
            MIDL_user_free(PolicyInformation);

        Status = I_RpcMapWin32Status(RpcExceptionCode());
    }
    RpcEndExcept;

    TRACE("Done (Status: 0x%08x)\n", Status);

    return Status;
}
Пример #9
0
/*
 * @implemented
 */
NTSTATUS
WINAPI
LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
                       IN PLUID Value,
                       OUT PUNICODE_STRING *Name)
{
    PRPC_UNICODE_STRING NameBuffer = NULL;
    NTSTATUS Status;

    TRACE("(%p,%p,%p)\n", PolicyHandle, Value, Name);

    RpcTryExcept
    {
        Status = LsarLookupPrivilegeName(PolicyHandle,
                                         Value,
                                         &NameBuffer);

        *Name = (PUNICODE_STRING)NameBuffer;
    }
    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
    {
        if (NameBuffer != NULL)
            MIDL_user_free(NameBuffer);

        Status = I_RpcMapWin32Status(RpcExceptionCode());
    }
    RpcEndExcept;

    return Status;
}
Пример #10
0
NTSTATUS
LsarQueryModification(PLSA_DB_OBJECT PolicyObject,
                      PLSAPR_POLICY_INFORMATION *PolicyInformation)
{
    PPOLICY_MODIFICATION_INFO Info = NULL;
    ULONG AttributeSize;
    NTSTATUS Status;

    *PolicyInformation = NULL;

    AttributeSize = sizeof(POLICY_MODIFICATION_INFO);
    Info = MIDL_user_allocate(AttributeSize);
    if (Info == NULL)
        return STATUS_INSUFFICIENT_RESOURCES;

    Status = LsapGetObjectAttribute(PolicyObject,
                                    L"PolMod",
                                    Info,
                                    &AttributeSize);
    if (!NT_SUCCESS(Status))
    {
        MIDL_user_free(Info);
    }
    else
    {
        *PolicyInformation = (PLSAPR_POLICY_INFORMATION)Info;
    }

    return Status;
}
Пример #11
0
  /* routine that frees graph for struct _LSAPR_UNICODE_STRING */
void _fgs__LSAPR_UNICODE_STRING (LSAPR_UNICODE_STRING  * _source)
  {
  if (_source->Buffer !=0)
    {
    MIDL_user_free((void  *)(_source->Buffer));
    }
  }
Пример #12
0
  /* routine that frees graph for struct _LSAPR_ACCOUNT_INFORMATION */
void _fgs__LSAPR_ACCOUNT_INFORMATION (LSAPR_ACCOUNT_INFORMATION  * _source)
  {
  if (_source->Sid !=0)
    {
    MIDL_user_free((void  *)(_source->Sid));
    }
  }
Пример #13
0
/* routine that frees graph for struct _STRING */
void _fgs__STRING (STRING  * _source)
  {
  if (_source->Buffer !=0)
    {
    MIDL_user_free((void  *)(_source->Buffer));
    }
  }
Пример #14
0
  /* routine that frees graph for struct _LSAPR_POLICY_AUDIT_EVENTS_INFO */
void _fgs__LSAPR_POLICY_AUDIT_EVENTS_INFO (LSAPR_POLICY_AUDIT_EVENTS_INFO  * _source)
  {
  if (_source->EventAuditingOptions !=0)
    {
    MIDL_user_free((void  *)(_source->EventAuditingOptions));
    }
  }
Пример #15
0
  /* routine that frees graph for struct _LSAPR_TRANSLATED_SIDS */
void _fgs__LSAPR_TRANSLATED_SIDS (LSAPR_TRANSLATED_SIDS  * _source)
  {
  if (_source->Sids !=0)
    {
    MIDL_user_free((void  *)(_source->Sids));
    }
  }
Пример #16
0
  /* routine that frees graph for struct _LSAPR_CR_CIPHER_VALUE */
void _fgs__LSAPR_CR_CIPHER_VALUE (LSAPR_CR_CIPHER_VALUE  * _source)
  {
  if (_source->Buffer !=0)
    {
    MIDL_user_free((void  *)(_source->Buffer));
    }
  }
Пример #17
0
  /* routine that frees graph for struct _LSAPR_SR_SECURITY_DESCRIPTOR */
void _fgs__LSAPR_SR_SECURITY_DESCRIPTOR (LSAPR_SR_SECURITY_DESCRIPTOR  * _source)
  {
  if (_source->SecurityDescriptor !=0)
    {
    MIDL_user_free((void  *)(_source->SecurityDescriptor));
    }
  }
Пример #18
0
NTSTATUS
LsarQueryAuditFull(PLSA_DB_OBJECT PolicyObject,
                   PLSAPR_POLICY_INFORMATION *PolicyInformation)
{
    PPOLICY_AUDIT_FULL_QUERY_INFO AuditFullInfo = NULL;
    ULONG AttributeSize;
    NTSTATUS Status;

    *PolicyInformation = NULL;

    AttributeSize = sizeof(POLICY_AUDIT_FULL_QUERY_INFO);
    AuditFullInfo = MIDL_user_allocate(AttributeSize);
    if (AuditFullInfo == NULL)
        return STATUS_INSUFFICIENT_RESOURCES;

    Status = LsapGetObjectAttribute(PolicyObject,
                                    L"PolAdtFl",
                                    AuditFullInfo,
                                    &AttributeSize);
    if (!NT_SUCCESS(Status))
    {
        MIDL_user_free(AuditFullInfo);
    }
    else
    {
        *PolicyInformation = (PLSAPR_POLICY_INFORMATION)AuditFullInfo;
    }

    return Status;
}
Пример #19
0
NTSTATUS
LsarSetAuditFull(PLSA_DB_OBJECT PolicyObject,
                 PPOLICY_AUDIT_FULL_QUERY_INFO Info)
{
    PPOLICY_AUDIT_FULL_QUERY_INFO AuditFullInfo = NULL;
    ULONG AttributeSize;
    NTSTATUS Status;

    TRACE("(%p %p)\n", PolicyObject, Info);

    AttributeSize = sizeof(POLICY_AUDIT_FULL_QUERY_INFO);
    AuditFullInfo = MIDL_user_allocate(AttributeSize);
    if (AuditFullInfo == NULL)
        return STATUS_INSUFFICIENT_RESOURCES;

    Status = LsapGetObjectAttribute(PolicyObject,
                                    L"PolAdtFl",
                                    AuditFullInfo,
                                    &AttributeSize);
    if (!NT_SUCCESS(Status))
        goto done;

    AuditFullInfo->ShutDownOnFull = Info->ShutDownOnFull;

    Status = LsapSetObjectAttribute(PolicyObject,
                                    L"PolAdtFl",
                                    AuditFullInfo,
                                    AttributeSize);

done:
    if (AuditFullInfo != NULL)
        MIDL_user_free(AuditFullInfo);

    return Status;
}
Пример #20
0
NTSTATUS
LsarQueryDefaultQuota(PLSA_DB_OBJECT PolicyObject,
                      PLSAPR_POLICY_INFORMATION *PolicyInformation)
{
    PPOLICY_DEFAULT_QUOTA_INFO QuotaInfo = NULL;
    ULONG AttributeSize;
    NTSTATUS Status;

    *PolicyInformation = NULL;

    AttributeSize = sizeof(POLICY_DEFAULT_QUOTA_INFO);
    QuotaInfo = MIDL_user_allocate(AttributeSize);
    if (QuotaInfo == NULL)
        return STATUS_INSUFFICIENT_RESOURCES;

    Status = LsapGetObjectAttribute(PolicyObject,
                                    L"DefQuota",
                                    QuotaInfo,
                                    &AttributeSize);
    if (!NT_SUCCESS(Status))
    {
        MIDL_user_free(QuotaInfo);
    }
    else
    {
        *PolicyInformation = (PLSAPR_POLICY_INFORMATION)QuotaInfo;
    }

    return Status;
}
Пример #21
0
BOOL kull_m_rpc_drsr_getDCBind(RPC_BINDING_HANDLE *hBinding, GUID *NtdsDsaObjectGuid, DRS_HANDLE *hDrs)
{
	BOOL status = FALSE;
	ULONG drsStatus;
	DRS_EXTENSIONS_INT DrsExtensionsInt;// = {0};
	DRS_EXTENSIONS *pDrsExtensionsOutput = NULL;

	DrsExtensionsInt.cb = sizeof(DRS_EXTENSIONS_INT) - sizeof(DWORD);
	DrsExtensionsInt.dwFlags = DRS_EXT_GETCHGREPLY_V6 | DRS_EXT_STRONG_ENCRYPTION;

	RpcTryExcept
	{
		drsStatus = IDL_DRSBind(*hBinding, NtdsDsaObjectGuid, (DRS_EXTENSIONS *) &DrsExtensionsInt, &pDrsExtensionsOutput, hDrs); // to free ?
		if(drsStatus == 0)
		{
			if(pDrsExtensionsOutput)
			{
				if(((DRS_EXTENSIONS_INT *) pDrsExtensionsOutput)->dwFlags & (DRS_EXT_GETCHGREQ_V8 | DRS_EXT_STRONG_ENCRYPTION))
					status = TRUE;
				else PRINT_ERROR(L"Incorrect DRS Extensions Output (%08x)\n", ((DRS_EXTENSIONS_INT *) pDrsExtensionsOutput)->dwFlags);
				MIDL_user_free(pDrsExtensionsOutput);
			}
			else PRINT_ERROR(L"No DRS Extensions Output\n");
		
			if(!status)
				IDL_DRSUnbind(hDrs);
		}
		else PRINT_ERROR(L"IDL_DRSBind: %u\n", drsStatus);
	}
	RpcExcept(DRS_EXCEPTION)
		PRINT_ERROR(L"RPC Exception 0x%08x (%u)\n", RpcExceptionCode(), RpcExceptionCode());
	RpcEndExcept
		return status;
}
Пример #22
0
BOOL kull_m_rpc_bkrp_generic(LPCWSTR NetworkAddr, const GUID * pGuid, PVOID DataIn, DWORD dwDataIn, PVOID *pDataOut, DWORD *pdwDataOut)
{
	BOOL status = FALSE;
	RPC_BINDING_HANDLE hBinding;
	NET_API_STATUS netStatus;
	PBYTE out = NULL;
	*pDataOut = NULL;
	*pdwDataOut = 0;
	if(kull_m_rpc_bkrp_createBinding(NetworkAddr, &hBinding))
	{
		RpcTryExcept
		{
			netStatus = BackuprKey(hBinding, (GUID *) pGuid, (PBYTE) DataIn, dwDataIn, &out, pdwDataOut, 0);
			if(status = (netStatus == 0))
			{
				if(*pDataOut = LocalAlloc(LPTR, *pdwDataOut))
					RtlCopyMemory(*pDataOut, out, *pdwDataOut);
				MIDL_user_free(out);
			}
			else PRINT_ERROR(L"BackuprKey: 0x%08x (%u)\n", netStatus, netStatus);
		}
		RpcExcept(RPC_EXCEPTION)
			PRINT_ERROR(L"RPC Exception: 0x%08x (%u)\n", RpcExceptionCode(), RpcExceptionCode());
		RpcEndExcept
			kull_m_rpc_deleteBinding(&hBinding);
	}
Пример #23
0
NTSTATUS
LsapLookupAccountRightName(ULONG RightValue,
                           PRPC_UNICODE_STRING *Name)
{
    PRPC_UNICODE_STRING NameBuffer;
    ULONG i;

    for (i = 0; i < ARRAYSIZE(WellKnownRights); i++)
    {
        if (WellKnownRights[i].Flag == RightValue)
        {
            NameBuffer = MIDL_user_allocate(sizeof(RPC_UNICODE_STRING));
            if (NameBuffer == NULL)
                return STATUS_NO_MEMORY;

            NameBuffer->Length = wcslen(WellKnownRights[i].Name) * sizeof(WCHAR);
            NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR);

            NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength);
            if (NameBuffer->Buffer == NULL)
            {
                MIDL_user_free(NameBuffer);
                return STATUS_INSUFFICIENT_RESOURCES;
            }

            wcscpy(NameBuffer->Buffer, WellKnownRights[i].Name);

            *Name = NameBuffer;

            return STATUS_SUCCESS;
        }
    }

    return STATUS_NO_SUCH_PRIVILEGE;
}
Пример #24
0
NTSTATUS
LsarpLookupPrivilegeDisplayName(PRPC_UNICODE_STRING Name,
                                USHORT ClientLanguage,
                                USHORT ClientSystemDefaultLanguage,
                                PRPC_UNICODE_STRING *DisplayName,
                                USHORT *LanguageReturned)
{
    PRPC_UNICODE_STRING DisplayNameBuffer;
    UNIMPLEMENTED;

    /* For now, description is equal to privilege name */

    DisplayNameBuffer = MIDL_user_allocate(sizeof(RPC_UNICODE_STRING));
    if (DisplayNameBuffer == NULL)
    {
        return STATUS_NO_MEMORY;
    }
    DisplayNameBuffer->Length = Name->Length;
    DisplayNameBuffer->MaximumLength = Name->MaximumLength;

    DisplayNameBuffer->Buffer = MIDL_user_allocate(DisplayNameBuffer->MaximumLength);
    if (DisplayNameBuffer->Buffer == NULL)
    {
        MIDL_user_free(DisplayNameBuffer);
        return STATUS_NO_MEMORY;
    }

    wcscpy(DisplayNameBuffer->Buffer, Name->Buffer);

    *DisplayName = DisplayNameBuffer;

    return STATUS_SUCCESS;
}
Пример #25
0
HRESULT __cdecl IrotRevoke(
    IrotHandle h,
    IrotCookie cookie,
    IrotContextHandle *ctxt_handle,
    PInterfaceData *obj,
    PInterfaceData *mk)
{
    struct rot_entry *rot_entry;

    WINE_TRACE("%d\n", cookie);

    EnterCriticalSection(&csRunningObjectTable);
    LIST_FOR_EACH_ENTRY(rot_entry, &RunningObjectTable, struct rot_entry, entry)
    {
        if (rot_entry->cookie == cookie)
        {
            HRESULT hr = S_OK;

            list_remove(&rot_entry->entry);
            LeaveCriticalSection(&csRunningObjectTable);

            *obj = MIDL_user_allocate(FIELD_OFFSET(InterfaceData, abData[rot_entry->object->ulCntData]));
            *mk = MIDL_user_allocate(FIELD_OFFSET(InterfaceData, abData[rot_entry->moniker->ulCntData]));
            if (*obj && *mk)
            {
                (*obj)->ulCntData = rot_entry->object->ulCntData;
                memcpy((*obj)->abData, rot_entry->object->abData, (*obj)->ulCntData);
                (*mk)->ulCntData = rot_entry->moniker->ulCntData;
                memcpy((*mk)->abData, rot_entry->moniker->abData, (*mk)->ulCntData);
            }
            else
            {
                MIDL_user_free(*obj);
                MIDL_user_free(*mk);
                hr = E_OUTOFMEMORY;
            }

            rot_entry_release(rot_entry);
            *ctxt_handle = NULL;
            return hr;
        }
    }
    LeaveCriticalSection(&csRunningObjectTable);

    return E_INVALIDARG;
}
Пример #26
0
  /* routine that frees graph for struct _LSAPR_TRUST_INFORMATION */
void _fgs__LSAPR_TRUST_INFORMATION (LSAPR_TRUST_INFORMATION  * _source)
  {
  _fgs__LSAPR_UNICODE_STRING ((LSAPR_UNICODE_STRING *)&_source->Name);
  if (_source->Sid !=0)
    {
    MIDL_user_free((void  *)(_source->Sid));
    }
  }
Пример #27
0
  /* routine that frees graph for struct _LSAPR_POLICY_ACCOUNT_DOM_INFO */
void _fgs__LSAPR_POLICY_ACCOUNT_DOM_INFO (LSAPR_POLICY_ACCOUNT_DOM_INFO  * _source)
  {
  _fgs__LSAPR_UNICODE_STRING ((LSAPR_UNICODE_STRING *)&_source->DomainName);
  if (_source->DomainSid !=0)
    {
    MIDL_user_free((void  *)(_source->DomainSid));
    }
  }
Пример #28
0
  /* routine that frees graph for struct _LSAPR_POLICY_PRIMARY_DOM_INFO */
void _fgs__LSAPR_POLICY_PRIMARY_DOM_INFO (LSAPR_POLICY_PRIMARY_DOM_INFO  * _source)
  {
  _fgs__LSAPR_UNICODE_STRING ((LSAPR_UNICODE_STRING *)&_source->Name);
  if (_source->Sid !=0)
    {
    MIDL_user_free((void  *)(_source->Sid));
    }
  }
Пример #29
0
  /* routine that frees graph for struct _LSAPR_SECURITY_DESCRIPTOR */
void _fgs__LSAPR_SECURITY_DESCRIPTOR (LSAPR_SECURITY_DESCRIPTOR  * _source)
  {
  if (_source->Owner !=0)
    {
    MIDL_user_free((void  *)(_source->Owner));
    }
  if (_source->Group !=0)
    {
    MIDL_user_free((void  *)(_source->Group));
    }
  if (_source->Sacl !=0)
    {
    MIDL_user_free((void  *)(_source->Sacl));
    }
  if (_source->Dacl !=0)
    {
    MIDL_user_free((void  *)(_source->Dacl));
    }
  }
Пример #30
0
int wmain(int argc, wchar_t * argv[])
{
	RPC_BINDING_HANDLE hBinding;
	wchar_t dataIn[] = L"a cleartext message!";
	PVOID pDataOut, pDataOut2;
	DWORD dwDataOut, dwDataOut2;

	if(argc > 1)
	{
		wprintf(L"Will use \'%s\' for DC name...\n", argv[1]);
		if(kull_m_rpc_createBinding(L"ncacn_np", argv[1], L"\\pipe\\protected_storage", L"ProtectedStorage", RPC_C_IMP_LEVEL_IMPERSONATE, &hBinding, NULL))
		{
			wprintf(L"\n* Retrieve RSA Public Key\n");
			if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_RETRIEVE_BACKUP_KEY_GUID, (PVOID) 0xbadc00fe, 0, &pDataOut, &dwDataOut)) // don't ask me why dummy data is needed here (not used).
			{
				wprintf(L"  > pDataOut @ 0x%p (%u)\n", pDataOut, dwDataOut);
				//printHex(pDataOut, dwDataOut);
				MIDL_user_free(pDataOut);
			}

			wprintf(L"\n* Backup a secret (%s)\n", dataIn);
			if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_BACKUP_GUID, &dataIn, sizeof(dataIn), &pDataOut, &dwDataOut))
			{
				wprintf(L"  > pDataOut @ 0x%p (%u)\n", pDataOut, dwDataOut);
				printHex(pDataOut, dwDataOut);

				wprintf(L"\n* Restore a secret\n");
				if(kull_m_rpc_bkrp_generic(&hBinding, &BACKUPKEY_RESTORE_GUID, pDataOut, dwDataOut, &pDataOut2, &dwDataOut2))
				{
					wprintf(L"  > pDataOut2 @ 0x%p (%u)\n", pDataOut, dwDataOut);
					wprintf(L"  > Secret : %s\n", pDataOut2);
					MIDL_user_free(pDataOut2);
				}
				MIDL_user_free(pDataOut);
			}

			kull_m_rpc_deleteBinding(&hBinding);
		}
	}
	else wprintf(L"[ERROR] A DC name is needed in argument\n");
	return ERROR_SUCCESS;
}