Tells me that an ACTION_TO_TYPE structure contains an m_8 member which is a DWORD.
If we suppose a2 is an array and that this loop is used to access m_8 in the different elements of the array (that's a lot of ifs), this means that the size of an ACTION_TO_TYPE structure is 3 times the size of a DWORD (padding bytes included).
Yes but if it is an array with 12 bytes size, why the pointer is initaliazed firstly with m_8 (NOTE I use m_8 just for looking good actually it must be *((BYTE*)a2+8))? And why then are accessed members above the array (*(BYTE*)(v3-2))? Any more suggestions?
Clearly this code has been written by a sadist without any care for readability or maintainability.
One example: for(v3 = &a2->m_8; v3; v3+=3). If &a2->m_8 is not NULL, this loop may never end.
The only thing that can stop the loop is this condition if(*(BYTE*)(v3-2)) which may read uninitialized memory.
As for *(BYTE*)(v3-2), I guess that the first byte of a valid ACTION_TO_TYPE structure must always be 0.
It's hard to say more.
OH I realize a Big Mistake while decompiling this code (yeah the "sadist without any care for readability or maintainability" is me! :O). Actually this need to be the actually code:
Anyway this actually doesn't make the things clear for me :(. And this code was decompiled so actually I'm wondering for some sort of like behavior of code written not by a sadist (with the rules of C++).
This looks like the construction of some sort of linked list.
If I had to guess, I'd say a1 is a linked list, a2 an array of elements to add, and a0 some kind of list of authorized values to add to the a1.
Line 7 looks like it checks to see if *v3 is registered in a0, and if that's the case it returns a pointer v4 somehow linked to it.
It then creates a new node using *(v3-1) and v4 and adds it to a1.
Line 14 the fact the only the first byte is checked could be explained by the fact that the first member of a ACTION_TO_TYPE structure is in fact a boolean.
A compiler will generally add padding bytes after a boolean to align the memory address of the next member properly, which could explain why 4 bytes are taken but only 1 is used.
With that hypothesis, I can suggest the following structures: