Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiating between object reference and class reference #72

Open
Kein opened this issue Feb 6, 2022 · 4 comments
Open

Differentiating between object reference and class reference #72

Kein opened this issue Feb 6, 2022 · 4 comments

Comments

@Kein
Copy link

Kein commented Feb 6, 2022

So I have this dump from UD:

struct AMyGameMode : AGameModeBase {
	struct TArray<struct AMyCharacterBase*> ListOfPlayables; // 0x320(0x10)

which, if you try to inherit the data, would be

UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<AMyCharacterBase*> ListOfPlayables;

However, in actuality it is

TArray<TSubclassOf<AMyCharacterBase>>

These are completely different things. Is it impossible to differentiate this type runtime when dumping?

@guttir14
Copy link
Owner

guttir14 commented Feb 9, 2022

So, in example you provided there is array of UClass pointers? Could you give me game name, class and field name where this bug occurs, so I can find a way to differentiate them.

@Kein
Copy link
Author

Kein commented Feb 9, 2022

So, in example you provided there is array of UClass pointers?

No, it is a type. For example, In UE editor in Blueprints, when you create a variable to a reference type UObject like Actor or PlayerController it offers 2 choices:

image

Object Reference and Class Reference (soft-references just some weak-pointer wrappers)

On C++ side it is respectively:
TArray<AMyCharacterBase*> for an array of references/pointer of the objects of said class
and
TArray<TSubclassOf<AMyCharacterBase>> is an array of class types

Could you give me game name, class and field name where this bug occurs, so I can find a way to differentiate them.

I can but I believe you dont need to know specific game, it is nothing unique and this is just how UDumper seems to handle things in general (?).

If you desire so I can make repro test project on UE 4.26.2, it is very simple, just define basic class with 2 types of said members and then package and dump. The only way I managed to figure this out is because they have used it in a blueprint that inherited custom C++ class and in BP they have populated inherited field which was serialized later with BP body. Obviously you cant do that with pointers.

@Kein
Copy link
Author

Kein commented Feb 9, 2022

Test project:

https://www.dropbox.com/s/u8soy5cjtu9cph4/WindowsNoEditor.7z?dl=1

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class MYPROJECT_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<AMyActor*> ObjectReference;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<TSubclassOf<AMyActor>> TypeReference;

};

Dumped as:

// Class MyProject.MyActor
// Size: 0x240 (Inherited: 0x220)
struct AMyActor : AActor {
	struct TArray<struct AMyActor*> ObjectReference; // 0x220(0x10)
	struct TArray<struct AMyActor*> TypeReference; // 0x230(0x10)
};

@WhiteHair-Chen
Copy link

So, is this problem solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants