reko icon indicating copy to clipboard operation
reko copied to clipboard

TypeAnalysis/ComplexExpressionRewiter do incorrect rewriting of fields of LARGE_INTEGER union

Open ptomin opened this issue 3 years ago • 0 comments

See https://github.com/ptomin/reko/blob/6fae491935dce345542de2be03aebbf278cc83a9/subjects/PE/x86/pySample/shingledPySample.reko/pySample_text.c#L444

The type of tLoc14 is LARGE_INTEGER union.

typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } DUMMYSTRUCTNAME;
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } u;
  LONGLONG QuadPart;
} LARGE_INTEGER;

The result should be

ui32 esi_n = esi_n ^ (tLoc14.HighPart ^ tLoc14.LowPart);

But was

ui32 esi_n = esi_n ^ (tLoc14.dw0004 ^ tLoc14);

It looks like later phase (TypeAnalysis/ComplexExpressionRewiter) can't transform correctly accesses to such unions.

ptomin avatar Feb 21 '22 16:02 ptomin