A reversing problem at structure restore

Hi,

I have issue in my recently works

for example, I copy snippets, in this snippet, it’s calculate index firstly, and then add a fixed offset to set value.

__int64 __fastcall RegisterCallbackHandler(
        unsigned int cmdCode,
        void (*handler)(void *context, ...),
        __int16 a3,
        void *context)
{
  __int16 v4; // w8
  __int64 v5; // x9

  if ( cmdCode <= 0xC7 )
  {
    v4 = 0;
    v5 = (__int64)&g_context + 0x1A * (unsigned __int16)cmdCode;
    *(_QWORD *)(v5 + 0x5D8) = handler;
    *(_WORD *)(v5 + 0x5E0) = a3;
    *(_QWORD *)(v5 + 0x5D0) = context;
  }
  else
  {
    return (unsigned int)0xE6F9;
  }
  return (unsigned int)v4;
}

I defined 2 structure:

#pragma pack(push, 1)
struct CallbackEntry /*0x1A*/ {
    void *context;
    void (*handler)(void *, ...);
    __int16 a3;
    char padding[8];
};
#pragma pack(pop)

struct GlobalContext {
    char gap0[0x5D0];
    struct CallbackEntry callbacks[200];
};

and set g_context type as GlobalContext,

but it’s seems not work for Hex-Ray decompiler, how can I solve this issue?

Try to set the global variable structure with DeclareStructVar (Edit / Struct var) in IDA-View.