string?StoreValue_CorDebug(DnEval dnEval, List <CorValue> createdValues, CorAppDomain appDomain, DnThread dnThread, CorValue targetValue, DmdType targetType, CorValue sourceValue, DmdType sourceType) { if (targetType.IsByRef) { return(CordbgErrorHelper.InternalError); } int hr; if (!targetType.IsValueType) { if (!targetValue.IsReference) { return(CordbgErrorHelper.InternalError); } if (!sourceValue.IsReference) { var boxedSourceValue = BoxIfNeeded(dnEval, appDomain, createdValues, sourceValue, targetType, sourceType); if (!boxedSourceValue.IsReference) { return(CordbgErrorHelper.InternalError); } sourceValue = boxedSourceValue; } if (!sourceValue.IsNull && sourceType.IsValueType) { var sourceDerefVal = sourceValue.GetDereferencedValue(out hr); if (sourceDerefVal is null) { return(CordbgErrorHelper.GetErrorMessage(hr)); } if (!sourceDerefVal.IsBox) { return(CordbgErrorHelper.InternalError); } } hr = targetValue.SetReferenceAddress(sourceValue.ReferenceAddress); if (hr != 0) { return(CordbgErrorHelper.GetErrorMessage(hr)); } return(null); } else { if (!sourceType.IsValueType) { return(CordbgErrorHelper.InternalError); } if (targetValue.IsReference) { if (!(targetValue.GetDereferencedValue(out hr) is CorValue derefValue)) { return(CordbgErrorHelper.GetErrorMessage(hr)); } targetValue = derefValue; } if (targetValue.IsBox) { return(CordbgErrorHelper.InternalError); } if (sourceValue.IsReference) { if (!(sourceValue.GetDereferencedValue(out hr) is CorValue derefValue)) { return(CordbgErrorHelper.GetErrorMessage(hr)); } sourceValue = derefValue; } if (sourceValue.IsBox) { if (!(sourceValue.GetBoxedValue(out hr) is CorValue unboxedValue)) { return(CordbgErrorHelper.GetErrorMessage(hr)); } sourceValue = unboxedValue; } if (!targetValue.IsGeneric || !sourceValue.IsGeneric) { return(CordbgErrorHelper.InternalError); } if (targetValue.Size != sourceValue.Size) { return(CordbgErrorHelper.InternalError); } hr = targetValue.WriteGenericValue(sourceValue.ReadGenericValue(), dnThread.Process.CorProcess); if (hr < 0) { return(CordbgErrorHelper.GetErrorMessage(hr)); } return(null); } }
public CorValue Box(CorValue value) { Debug.Assert(value != null && value.IsGeneric && !value.IsBox && !value.IsHeap && value.ExactType.IsValueType); if (value == null || !value.IsGeneric || value.IsBox || value.IsHeap || !value.ExactType.IsValueType) return value; var res = WaitForResult(eval.NewParameterizedObjectNoConstructor(value.ExactType.Class, value.ExactType.TypeParameters.ToArray())); if (res == null || res.Value.WasException) return null; var newObj = res.Value.ResultOrException; var r = newObj.NeuterCheckDereferencedValue; var vb = r == null ? null : r.BoxedValue; if (vb == null) return null; int hr = vb.WriteGenericValue(value.ReadGenericValue()); if (hr < 0) return null; return newObj; }
public byte[] Read() { return(debugger.Dispatcher.UI(() => value.ReadGenericValue())); }