Search code examples
reverse-engineeringida

What does ::struct mean in this context?


I don't know how to search for this, as it seems google ignores the :: in my search.

I have the following line in pseudo code: (player in this context is defined as: Player *player)

if ( player == ::player )

I am taking this to mean, if var player, is of type player. But that doesn't make sense to me as the compiler should know what type it is.

So what does ::player mean here?


Solution

  • I don't have enough rep to comment. So turned it into a full answer.

    Typically the :: operator is used as a Scope resolution operator.

    Depending on the language, in your example because there is no prepended namespace, it would refer to the global player

    From the linked page:

    class A {
    public:
        static int i; // scope of A
    };
    
    namespace B {
        int j = 2;
    }  // namespace B
    
    int A::i = 4;  // scope operator refers to the integer i declared in the class A
    int x = B::j;  // scope operator refers to the integer j declared in the namespace B
    

    In the context of IDA, it could be it's own way of referencing a global player object.

    So in your example:

    if ( player == ::player )
    

    The developer is explicitly forcing the local player object / variable to be compared to the player object/variable that is in the global namespace.

    Here is a a simple online demo that might help. The avar primitive variable could be a more complex object, class or function instead of an int.