private void switchToCustomStorage() {
		try {
			VariableStorage returnStorage = returnInfo.getStorage();
			DataType returnType = returnInfo.getDataType();
			if (returnStorage.isForcedIndirect() && returnStorage.isVoidStorage()) {
				returnType = VoidDataType.dataType;
			}
			returnInfo.setFormalDataType(returnType);
			returnInfo.setStorage(returnStorage.clone(getProgram()));

			autoParamCount = 0;
			for (ParamInfo paramInfo : parameters) {
				DataType dt = paramInfo.getDataType();
				VariableStorage storage = paramInfo.getStorage();
				paramInfo.setFormalDataType(dt);
				paramInfo.setStorage(storage.clone(getProgram()));
			}
		}
		catch (InvalidInputException e) {
			throw new AssertException(e); // unexpected
		}
	}
Switch to custom storage and perform required transformations
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionData.java