|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
![]() |
#1 |
Junior Member
Join Date: Nov 2017
Posts: 1
|
ws2_32::ntohs returns mistake after WIN10 1709
Greeting everybody,
In my installer, I need to check port if listen or not, so I use the code "Ports.nsh" in NSIS wiki. http://nsis.sourceforge.net/Check_open_ports It works perfect until I update Windows 10 Fall Creators Update (ver 1709) Tracking code and debug for a while, I found the error reason is ws2_32::ntohs returns mistake value. For example, in this code code: If input ir4 is 14357(0x3815), ws2_32::ntohs should return 5432(0x1538) to i.r4, but in error case, $4 is 3675448(0x381538). I have no idea why ws2_32::ntohs retruns mistake value, so I modify my script to avoid ws2_32::ntohs. code: just reverse high-low byte of port value. Full code will post below, wish it can help someone. ![]() code: |
![]() |
![]() |
![]() |
#2 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,701
|
This is not a bug in Windows, the function is documented as returning a 16-bit value and the upper part of EAX should be ignored. Unfortunately the System plug-in does not have a 16-bit return type but you can use this workaround:
Quote:
This seems to affect others as well so it might get "fixed" in the next Windows release. IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#3 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,701
|
Win 10 FCU left shifts the 16-bit parameter (in ECX) and ORs it with EAX (the bottom right shifted bits) at the end.
Win 8 has the registers swapped and EAX is ANDed with 0xff before it is left shifted. The source code has probably not changed, the compiler has swapped things around and removed one 10 byte instruction. IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|