sws icon indicating copy to clipboard operation
sws copied to clipboard

Whatever for does, it returns 1

Open aeagean opened this issue 3 years ago • 2 comments

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?

aeagean avatar Jan 07 '22 01:01 aeagean

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?

valinet avatar Jan 07 '22 03:01 valinet

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

aeagean avatar Jan 14 '22 01:01 aeagean