What does HRESULT 0x8004006C (DV_E_DVTARGETDEVICE_SIZE) mean?

 
Previous Next
DV_E_DVASPECT DV_E_NOIVIEWOBJECT

DV_E_DVTARGETDEVICE_SIZE

tdSize parameter of the DVTARGETDEVICE structure is invalid

DV_E_DVTARGETDEVICE_SIZE is the failure HRESULT 2147745900 (0x8004006C, signed -2147221396) from winerror.h. AllStat defines it as “tdSize parameter of the DVTARGETDEVICE structure is invalid”. In practical terms, DVTARGETDEVICE::tdSize does not describe a valid complete target-device buffer. Interpret it in the context of validating FORMATETC::ptd before device-specific data rendering or transfer.

The high bit in 0x8004006C is set, so this is a failure rather than a success or informational result. Its facility field is 4 (FACILITY_ITF) and its low 16-bit code is 108 (0x006C). Those bit fields classify the value, but they do not identify the failing object by themselves; the native method, object identity, and first producer of DV_E_DVTARGETDEVICE_SIZE remain essential.

Contract boundary

Understanding DV_E_DVTARGETDEVICE_SIZE requires this subsystem context: COM data-transfer structures are compound contracts: a field can be numerically well formed yet invalid for the provider, object generation, requested aspect, or ownership rules. For DV_E_DVTARGETDEVICE_SIZE, diagnosis therefore has to preserve the complete descriptor and the exact method that consumed it.

  • Associate DV_E_DVTARGETDEVICE_SIZE with one exact operation in IDataObject, FORMATETC/STGMEDIUM negotiation, data advisory enumeration, or OLE rendering.
  • Confirm that DV_E_DVTARGETDEVICE_SIZE came from validating FORMATETC::ptd before device-specific data rendering or transfer, rather than from cleanup or a wrapper that ran afterward.
  • Preserve any IErrorInfo, underlying Win32 result, provider message, or callback failure that preceded DV_E_DVTARGETDEVICE_SIZE; the HRESULT alone should not erase a more specific cause.

Likely cause branches

  • DV_E_DVTARGETDEVICE_SIZE can result when tdSize is smaller than the fixed header.
  • DV_E_DVTARGETDEVICE_SIZE can result when tdSize exceeds the allocated buffer or wraps during arithmetic.
  • DV_E_DVTARGETDEVICE_SIZE can result when driver, device, port, or DEVMODE offsets point outside tdSize even though the total size appears plausible.

Evidence to preserve

A useful DV_E_DVTARGETDEVICE_SIZE incident records the IDataObject identity, method, clipboard format, aspect, lindex, tymed mask, target-device size, advisory cookie, and ownership of every returned interface or medium. For DV_E_DVTARGETDEVICE_SIZE, also retain the application and component build, architecture, process and thread IDs, COM apartment, operation correlation ID, elapsed time, and the first state-changing event before the failure. When logging DV_E_DVTARGETDEVICE_SIZE, redact content and credentials while preserving types, lengths, hashes, opaque identities, and lifecycle generations needed to reproduce its contract.

  • For DV_E_DVTARGETDEVICE_SIZE, capture tdSize, allocation length, and all four offsets.
  • For DV_E_DVTARGETDEVICE_SIZE, validate every offset and terminating string inside the same buffer.
  • For DV_E_DVTARGETDEVICE_SIZE, check 32/64-bit marshalling and packed-structure assumptions at process boundaries.

Diagnostic sequence

  1. Capture DV_E_DVTARGETDEVICE_SIZE at the first native return before a wrapper maps it to a generic exception.
  2. Identify the exact object, method, and lifecycle phase involved in validating FORMATETC::ptd before device-specific data rendering or transfer.
  3. Capture tdSize, allocation length, and all four offsets.
  4. Validate every offset and terminating string inside the same buffer.
  5. Check 32/64-bit marshalling and packed-structure assumptions at process boundaries.
  6. Reproduce DV_E_DVTARGETDEVICE_SIZE with one controlled input or state change, and verify that the correction changes the decisive evidence rather than merely hiding the result.

Recovery and retry

Correction. For DV_E_DVTARGETDEVICE_SIZE, rebuild the variable-length DVTARGETDEVICE buffer from validated strings and DEVMODE data, then set tdSize to the exact byte count. Retry boundary. Retry only with a newly constructed buffer; changing tdSize alone can expose out-of-bounds fields. Before repeating the DV_E_DVTARGETDEVICE_SIZE operation, release every returned STGMEDIUM according to pUnkForRelease, retain advisory cookies only after successful DAdvise, and discard enumerated formats after the data object is replaced.

Practical scenario

A print-oriented data object receives a structure copied with sizeof(DVTARGETDEVICE), omitting the appended device strings; allocating the complete variable-length record resolves the failure. This isolates DV_E_DVTARGETDEVICE_SIZE within COM data transfer and advisory connections and provides a regression test for the stated correction.

Difference from related HRESULTs

DV_E_DVTARGETDEVICE can cover broader descriptor defects; DV_E_DVTARGETDEVICE_SIZE specifically points to tdSize and the extent it claims. For DV_E_DVTARGETDEVICE_SIZE, keep those outcomes separate in exception mappings, telemetry dimensions, user messages, and automated retry policy.

Developer and administrator guidance

For DV_E_DVTARGETDEVICE_SIZE, copy complete FORMATETC and DVTARGETDEVICE structures, preserve signed lindex values, intersect tymed masks before requesting data, and encode STGMEDIUM ownership explicitly. Regression coverage for DV_E_DVTARGETDEVICE_SIZE should include provider-advertised versus caller-invented formats, supported and unsupported DVASPECT/tymed combinations, sentinel lindex values, malformed target-device sizes, and replacement during advisory callbacks.

Operational repair for DV_E_DVTARGETDEVICE_SIZE must target the evidence-backed owner: compare the data provider, consumer, and registered handler versions; repair a handler only when traces identify that provider as missing or incompatible. Retain before-and-after traces for DV_E_DVTARGETDEVICE_SIZE so the change can be attributed and reversed.

References


Looking for a different code? Search another status or error code.