}
    ExitOnWin32Error(er, hr, "Failed to enumerate registry value");

LExit:
    return hr;
}


/********************************************************************
 RegReadBinary - reads a registry key binary value.
 NOTE: caller is responsible for freeing *ppbBuffer
*********************************************************************/
HRESULT DAPI RegReadBinary(
    __in HKEY hk,
    __in_z_opt LPCWSTR wzName,
    __deref_out_bcount_opt(*pcbBuffer) BYTE** ppbBuffer,
    __out SIZE_T *pcbBuffer
     )
{
    HRESULT hr = S_OK;
    LPBYTE pbBuffer = NULL;
    DWORD er = ERROR_SUCCESS;
    DWORD cb = 0;
    DWORD dwType = 0;

    er = vpfnRegQueryValueExW(hk, wzName, NULL, &dwType, NULL, &cb);
    ExitOnWin32Error(er, hr, "Failed to get size of registry value.");

    // Zero-length binary values can exist
    if (0 < cb)
    {
Exemple #2
0
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include "efx.h"
#include "efx_impl.h"

#if EFSYS_OPT_VPD

#if EFSYS_OPT_SIENA

static	__checkReturn			efx_rc_t
siena_vpd_get_static(
	__in				efx_nic_t *enp,
	__in				uint32_t partn,
	__deref_out_bcount_opt(*sizep)	caddr_t *svpdp,
	__out				size_t *sizep)
{
	siena_mc_static_config_hdr_t *scfg;
	caddr_t svpd;
	size_t size;
	uint8_t cksum;
	unsigned int vpd_offset;
	unsigned int vpd_length;
	unsigned int hdr_length;
	unsigned int pos;
	unsigned int region;
	efx_rc_t rc;

	EFSYS_ASSERT(partn == MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 ||
		    partn == MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1);