valinet / sws

sws (Simple Window Switcher) is an Alt-Tab replacement for Windows
GNU General Public License v2.0
67 stars 9 forks source link

Whatever for does, it returns 1 #2

Open aeagean opened 2 years ago

aeagean commented 2 years ago

https://github.com/valinet/sws/blob/2f67abc2315d3cc15911294e45765fa23f2f56f3/SimpleWindowSwitcher/sws_WindowHelpers.c#L433

source code

Finally, 1 will be returned

for (i = v5; ; i = v16)
{
  v15 = GetWindow(i, 4u);
  v16 = v15;
  if (!v15)
      break;

  v14 = GetWindowLongPtrW(v15, -20);
  if ((v14 & 0x40000i64) == 0 && ((v14 & 0x80u) != 0 || (v14 & 0x8000000) != 0))
      break;

  if (!IsWindowVisible(v16) || _sws_GhostWindowFromHungWindow(v16))
      break;

  v5 = v16;
}

return 1; // is BUG?
valinet commented 2 years ago

It’s taken directly from the disassembly of some system file (AltTab.dll from Windows 7 if I remember correctly). Might not be optimally written, but it is probably optimized away anyway and it seems to work. What’s the actual problem?

aeagean commented 2 years ago

Invalid behavior in the for loop。There is a problem with the code logic。