NO

Author Topic: Windows XP apps  (Read 5032 times)

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Windows XP apps
« on: August 20, 2024, 01:03:05 AM »
Hey guys,

When I create a new 32bit dialog project and immediately compile the application (zero changes to project settings or code), the app runs fine on Windows Vista+, but when I attempt to run on Windows XP Pro I get "... is not a valid win32 application".

Is there a compiler flag that passes support for this? Is there something else I need to do?

Thank you,
cheers

Offline John Z

  • Member
  • *
  • Posts: 865
Re: Windows XP apps
« Reply #1 on: August 20, 2024, 03:35:01 AM »
Hi WiilF23,

I don't think there is anything 'special' as long as the project has been set to 32 bit in the Source files window.  Any DLL's in use ? if so are they 32 bit as well?

Attached is a small single exe 32 bit program for testing - see if it runs on the XP Pro.

John Z

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2122
Re: Windows XP apps
« Reply #2 on: August 20, 2024, 07:34:33 AM »
try polink options
Code: [Select]
/SUBSYSTEM:CONSOLE,5.01 /OSVERSION:5.1
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 870
    • http://www.vortex.masmcode.com
Re: Windows XP apps
« Reply #3 on: August 20, 2024, 07:42:36 AM »
Timo's suggestion should do the job. Specifiying the pragma expression in the code :

Code: [Select]
pragma comment(linker,"/subsystem:console,5.1")
Code it... That's all...

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: Windows XP apps
« Reply #4 on: August 20, 2024, 08:44:30 PM »
Thanks guys, I appreciate the input a lot.

@John Z, what is interesting is that exe wont run on Windows 10 unless I turn compatibility mode on for "Windows XP SP3", then it launches fine. I will fire up VirtualBox and try along with the linker flags.

Will report back!

EDIT: not working in native XP mode

« Last Edit: August 20, 2024, 09:08:37 PM by WiiLF23 »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Windows XP apps
« Reply #5 on: August 20, 2024, 08:53:21 PM »
what is interesting is that exe wont run on Windows 10 unless I turn compatibility mode on for "Windows XP SP3", then it launches fine.
Which service pack is installed on your XP-pro system?
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: Windows XP apps
« Reply #6 on: August 20, 2024, 09:11:11 PM »
what is interesting is that exe wont run on Windows 10 unless I turn compatibility mode on for "Windows XP SP3", then it launches fine.
Which service pack is installed on your XP-pro system?

Service Pack 3, Professional 32bit build 2600

Current link flags (Windows 10, Pelles C):

Code: [Select]
-machine:x86 -subsystem:windows /MANIFEST:EMBED kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib delayimp.lib wininet.lib shell32.lib shlwapi.lib ole32.lib ws2_32.lib crypt32.lib libcurl.lib curl_dll.lib version.lib msimg32.lib

Passing
Code: [Select]
/OSVERSION:5.1 doesnt have any effect. Same error message.
« Last Edit: August 20, 2024, 09:24:50 PM by WiiLF23 »

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: Windows XP apps
« Reply #7 on: August 20, 2024, 09:41:34 PM »
I got it. Compiling a new project, and adding:

Code: [Select]
-machine:x86 -subsystem:windows,5.1 -safeseh kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib delayimp.lib /OSVERSION:5.1
This successfully launched a basic dialog app in Windows XP Pro SP3.

« Last Edit: August 20, 2024, 09:44:01 PM by WiiLF23 »

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: Windows XP apps
« Reply #8 on: August 20, 2024, 11:24:44 PM »
The first problem is OpenSSL (notably, libcrypto-3.dll) calls for "api-ms-win-crt-stdio-l1-1-0.dll", which is a problem. This is provided by the VC 2017 runtime installer, which did not fix it. The APIs are not present to locate the entry point in this runtime file provided by Microsoft on Windows XP.

Reviewing my libraries authors webpage under "Compatibility and Support Matrix" I see XP is red (Incompatible / Unsupported).

So we can shoot that out of the park.

I am still testing libcurl, and so far it I am having no luck.

It would be nice to support XP+ as my GUI and API calls are all purposely compatible by best efforts from Windows 2000 and onward. Very strange.

Would someone recommend a old version of OpenSSL lib? This sounds like a terrible idea, but for the sake of legacy support on this platform.

EDIT: Solved.

https://msfn.org/board/topic/176299-latest-version-of-software-running-on-xp/page/36/
https://slproweb.com/products/Win32OpenSSL.html (Install 32bit, extract libcrypt-3.dll)

Required on a fresh XP install:

- VC_redist.x86.exe (14.28.29213.0)
- Win32OpenSSL-3_3_1.exe -> libcrypto-3.dll (Program Files\OpenSSL-Win32\libcrypto-3.dll)

---

Full blown app is running on Windows XP! Winsock, OpenSSL, cURL, everything. Very nice. Also the exact same copy from XP is running in Windows 10 just fine. So, this will be my 32bit project settings going forward and will make no assumption it is XP, but all 32bit versions of Windows. The compatibility I was looking for.

The DLLs will do the talking, I can test anything on VirtualBox.

Winsock Compatibility

For Winsock on XP for compatibility you must consider too

Windows Vista+
Code: [Select]
inet_ntop(AF_INET, &(clientAddr.sin_addr), ip, INET_ADDRSTRLEN);
port = ntohs(clientAddr.sin_port);

Windows XP+
Code: [Select]
char *ip = inet_ntoa(clientAddr.sin_addr);
port = ntohs(clientAddr.sin_port);
if (ip != NULL) {
    // use ip, port
}

https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop
https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-inet_ntoa

Otherwise this will break the compatibility and throw a Winsock API error dialog.
« Last Edit: August 21, 2024, 02:10:10 AM by WiiLF23 »