Needed for Minecraft Legends.
-- v2: apisetschema: Add api-ms-win-core-psm-appnotify-l1-1-0. twinapi.appcore: Add UnregisterAppStateChangeNotification stub. twinapi.appcore: Add RegisterAppStateChangeNotification stub. twinapi.appcore: Add stub DLL. include: Add appnotify.h file.
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/appnotify.h | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 include/appnotify.h
diff --git a/include/Makefile.in b/include/Makefile.in index 7a6e5d62763..c957fed884c 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -19,6 +19,7 @@ SOURCES = \ appcompatapi.h \ appmgmt.h \ appmodel.h \ + appnotify.h \ asferr.h \ asptlb.idl \ asyncinfo.idl \ diff --git a/include/appnotify.h b/include/appnotify.h new file mode 100644 index 00000000000..1a364df89f8 --- /dev/null +++ b/include/appnotify.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WINE_APISET_PSMAPPNOTIFY_H_ +#define _WINE_APISET_PSMAPPNOTIFY_H_ + +#include <windows.h> + +#ifdef _CONTRACT_GEN +#define PSM_APP_API_HOST +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(PSM_APP_API_HOST) +#define APICONTRACT +#else +#define APICONTRACT DECLSPEC_IMPORT +#endif + +typedef void (__stdcall *PAPPSTATE_CHANGE_ROUTINE)(BOOLEAN quiesced, void *context); + +typedef struct _APPSTATE_REGISTRATION *PAPPSTATE_REGISTRATION; + +APICONTRACT ULONG NTAPI RegisterAppStateChangeNotification(PAPPSTATE_CHANGE_ROUTINE,void *,PAPPSTATE_REGISTRATION *); +APICONTRACT void NTAPI UnregisterAppStateChangeNotification(PAPPSTATE_REGISTRATION); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINE_APISET_PSMAPPNOTIFY_H_ */
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed for Minecraft Legends. --- configure.ac | 1 + dlls/twinapi.appcore/Makefile.in | 1 + dlls/twinapi.appcore/twinapi.appcore.spec | 127 ++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 dlls/twinapi.appcore/Makefile.in create mode 100644 dlls/twinapi.appcore/twinapi.appcore.spec
diff --git a/configure.ac b/configure.ac index fde3f29c770..479bf5d06af 100644 --- a/configure.ac +++ b/configure.ac @@ -3038,6 +3038,7 @@ WINE_CONFIG_MAKEFILE(dlls/traffic) WINE_CONFIG_MAKEFILE(dlls/twain.dll16,enable_win16) WINE_CONFIG_MAKEFILE(dlls/twain_32) WINE_CONFIG_MAKEFILE(dlls/twain_32/tests) +WINE_CONFIG_MAKEFILE(dlls/twinapi.appcore) WINE_CONFIG_MAKEFILE(dlls/typelib.dll16,enable_win16) WINE_CONFIG_MAKEFILE(dlls/tzres) WINE_CONFIG_MAKEFILE(dlls/ucrtbase) diff --git a/dlls/twinapi.appcore/Makefile.in b/dlls/twinapi.appcore/Makefile.in new file mode 100644 index 00000000000..b8bb385c024 --- /dev/null +++ b/dlls/twinapi.appcore/Makefile.in @@ -0,0 +1 @@ +MODULE = twinapi.appcore.dll diff --git a/dlls/twinapi.appcore/twinapi.appcore.spec b/dlls/twinapi.appcore/twinapi.appcore.spec new file mode 100644 index 00000000000..cda1c38103f --- /dev/null +++ b/dlls/twinapi.appcore/twinapi.appcore.spec @@ -0,0 +1,127 @@ +@ stub ValidateSystemShutdown +@ stub BiActivateWorkItemForUser +@ stub BiChangeApplicationStateForPackageName +@ stub BiChangeApplicationStateForPackageNameForUser +@ stub BiChangeApplicationStateForPsmKey +@ stub BiChangeApplicationStateForPsmKeyForUser +@ stub BiChangeSessionState +@ stub BiChangeUserState +@ stub BiEnumerateWorkItemsForPackageNameAndUser +@ stub BiGetActiveBackgroundTasksEvent +@ stub BiGetActiveBackgroundTasksEventForUser +@ stub BiGetCancellationTimeoutInMs +@ stub BiIsApplicationTerminateSensitive +@ stub BiIsApplicationTerminateSensitiveForUser +@ stub BiNotifyNewSession +@ stub BiNotifyNewSessionComplete +@ stub BiNotifyNewUser +@ stub BiPlmFreeMemory +@ stub BiPtActivateDeferredWorkItem +@ stub BiPtActivateInBackground +@ stub BiPtActivateInBackgroundEx +@ stub BiPtActivateWorkItem +@ stub BiPtAssociateActivationProxy +@ stub BiPtAssociateApplicationEntryPoint +@ stub BiPtAssociateApplicationExtensionClass +@ stub BiPtCancelWorkItem +@ stub BiPtCancelWorkItemEx +@ stub BiPtCreateEvent +@ stub BiPtCreateEventForApp +@ stub BiPtCreateEventForPackageName +@ stub BiPtDeleteEvent +@ stub BiPtDisableWorkItem +@ stub BiPtDisassociateWorkItem +@ stub BiPtDisassociateWorkItemEx +@ stub BiPtEnableWorkItem +@ stub BiPtEnumerateBrokeredEvents +@ stub BiPtEnumerateBrokeredEventsEx +@ stub BiPtEnumerateWorkItemsForPackageName +@ stub BiPtEnumerateWorkItemsForPackageNameEx +@ stub BiPtFreeMemory +@ stub BiPtGetStatusStateNameFromBrokerEventId +@ stub BiPtQueryBrokerEventId +@ stub BiPtQueryBrokeredEvent +@ stub BiPtQuerySystemStateBroadcastChannels +@ stub BiPtQueryWorkItem +@ stub BiPtQueryWorkItemEx +@ stub BiPtQueryWorkItemStatusStateName +@ stub BiPtSignalEvent +@ stub BiPtSignalEventEx +@ stub BiPtSignalMultipleEvents +@ stub BiPtSignalTriggerEvent +@ stub BiPtSignalTriggerEventEx +@ stub BiQueryWorkItemForUser +@ stub BiResetActiveSessionForPackage +@ stub BiResetActiveUserForPackage +@ stub BiSetActiveSessionForPackage +@ stub BiSetActiveUserForPackage +@ stub BiTerminateApplicationHost +@ stub BiTerminateApplicationHost2 +@ stub BiTerminateApplicationHostForUser +@ stub BiUpdateBackgroundAccessApplicationsForUser +@ stub BiUpdateLockScreenApplications +@ stdcall -private DllCanUnloadNow() +@ stub DllGetActivationFactory +@ stub DllGetClassObject +@ stub PsmApplyTaskCompletion +@ stub PsmBlockAppStateChangeCompletion +@ stub PsmDisconnect +@ stub PsmGetSessionInfo +@ stub PsmInitializeExtension +@ stub PsmIsProcessInApplication +@ stub PsmIsProcessInApplication2 +@ stub PsmQueryApplicationInformation +@ stub PsmQueryApplicationInformation2 +@ stub PsmQueryApplicationInterferenceCount +@ stub PsmQueryApplicationInterferenceCount2 +@ stub PsmQueryApplicationList +@ stub PsmQueryApplicationList2 +@ stub PsmQueryApplicationProperties +@ stub PsmQueryApplicationProperties2 +@ stub PsmQueryApplicationProperties3 +@ stub PsmQueryApplicationPropertiesByUser +@ stub PsmQueryApplicationResourceUsage +@ stub PsmQueryApplicationResourceUsage2 +@ stub PsmQueryApplicationResourceUsageForTimer +@ stub PsmQueryCurrentAppState +@ stub PsmQueryMaxMemoryUsage +@ stub PsmQueryMaxMemoryUsage2 +@ stub PsmQueryMemoryUsage +@ stub PsmQueryMemoryUsage2 +@ stub PsmQueryMemoryUsageByUser +@ stub PsmQueryProcessList +@ stub PsmQueryProcessList2 +@ stub PsmQuerySharedCommitByUser +@ stub PsmQueryTaskCompletionInformation +@ stub PsmQueryTaskCompletionInformation2 +@ stub PsmRegisterAppPriorityNotification +@ stub PsmRegisterAppStateChangeNotification +@ stub PsmRegisterApplicationNotification +@ stub PsmRegisterApplicationNotification2 +@ stub PsmRegisterDynamicProcess +@ stub PsmRegisterKeyNotification +@ stub PsmRegisterManagerType +@ stub PsmResetMaxMemoryUsage +@ stub PsmResetMaxMemoryUsage2 +@ stub PsmResetMaxMemoryUsageByUser +@ stub PsmSetApplicationPriority +@ stub PsmSetApplicationPriority2 +@ stub PsmSetApplicationProperties +@ stub PsmSetApplicationProperties2 +@ stub PsmSetApplicationProperties3 +@ stub PsmSetApplicationPropertiesByUser +@ stub PsmSetApplicationState +@ stub PsmSetApplicationState2 +@ stub PsmShutdownApplication +@ stub PsmTimerCleanup +@ stub PsmTimerElapsedResourceTimeGet +@ stub PsmTimerInitialize +@ stub PsmTimerRemainingResourceTimeGet +@ stub PsmTimerStart +@ stub PsmUnblockAppStateChangeCompletion +@ stub PsmUnregisterAppStateChangeNotification +@ stub PsmWaitForAppResume +@ stub RegisterAppConstrainedChangeNotification +@ stub RegisterAppStateChangeNotification +@ stub UnregisterAppConstrainedChangeNotification +@ stub UnregisterAppStateChangeNotification
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed for Minecraft Legends. --- dlls/twinapi.appcore/Makefile.in | 3 +++ dlls/twinapi.appcore/main.c | 31 +++++++++++++++++++++++ dlls/twinapi.appcore/twinapi.appcore.spec | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 dlls/twinapi.appcore/main.c
diff --git a/dlls/twinapi.appcore/Makefile.in b/dlls/twinapi.appcore/Makefile.in index b8bb385c024..4aa120b96d4 100644 --- a/dlls/twinapi.appcore/Makefile.in +++ b/dlls/twinapi.appcore/Makefile.in @@ -1 +1,4 @@ MODULE = twinapi.appcore.dll + +C_SRCS = \ + main.c diff --git a/dlls/twinapi.appcore/main.c b/dlls/twinapi.appcore/main.c new file mode 100644 index 00000000000..55e17f4e43d --- /dev/null +++ b/dlls/twinapi.appcore/main.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "appnotify.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(twinapi); + +/*********************************************************************** + * RegisterAppStateChangeNotification (twinapi.appcore.@) + */ +APICONTRACT ULONG WINAPI RegisterAppStateChangeNotification( PAPPSTATE_CHANGE_ROUTINE routine, void *context, PAPPSTATE_REGISTRATION *reg ) +{ + FIXME( "(%p, %p, %p) - stub.\n", routine, context, reg ); + return ERROR_CALL_NOT_IMPLEMENTED; +} diff --git a/dlls/twinapi.appcore/twinapi.appcore.spec b/dlls/twinapi.appcore/twinapi.appcore.spec index cda1c38103f..9052c4e7cf5 100644 --- a/dlls/twinapi.appcore/twinapi.appcore.spec +++ b/dlls/twinapi.appcore/twinapi.appcore.spec @@ -122,6 +122,6 @@ @ stub PsmUnregisterAppStateChangeNotification @ stub PsmWaitForAppResume @ stub RegisterAppConstrainedChangeNotification -@ stub RegisterAppStateChangeNotification +@ stdcall RegisterAppStateChangeNotification(ptr ptr ptr) @ stub UnregisterAppConstrainedChangeNotification @ stub UnregisterAppStateChangeNotification
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/twinapi.appcore/main.c | 8 ++++++++ dlls/twinapi.appcore/twinapi.appcore.spec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/twinapi.appcore/main.c b/dlls/twinapi.appcore/main.c index 55e17f4e43d..f1a6af7919d 100644 --- a/dlls/twinapi.appcore/main.c +++ b/dlls/twinapi.appcore/main.c @@ -29,3 +29,11 @@ APICONTRACT ULONG WINAPI RegisterAppStateChangeNotification( PAPPSTATE_CHANGE_RO FIXME( "(%p, %p, %p) - stub.\n", routine, context, reg ); return ERROR_CALL_NOT_IMPLEMENTED; } + +/*********************************************************************** + * UnregisterAppStateChangeNotification (twinapi.appcore.@) + */ +APICONTRACT void WINAPI UnregisterAppStateChangeNotification( PAPPSTATE_REGISTRATION reg ) +{ + FIXME( "(%p) - stub.\n", reg ); +} diff --git a/dlls/twinapi.appcore/twinapi.appcore.spec b/dlls/twinapi.appcore/twinapi.appcore.spec index 9052c4e7cf5..0b2d8d2055e 100644 --- a/dlls/twinapi.appcore/twinapi.appcore.spec +++ b/dlls/twinapi.appcore/twinapi.appcore.spec @@ -124,4 +124,4 @@ @ stub RegisterAppConstrainedChangeNotification @ stdcall RegisterAppStateChangeNotification(ptr ptr ptr) @ stub UnregisterAppConstrainedChangeNotification -@ stub UnregisterAppStateChangeNotification +@ stdcall UnregisterAppStateChangeNotification(ptr)
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed for Minecraft Legends. --- dlls/apisetschema/apisetschema.spec | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/apisetschema/apisetschema.spec b/dlls/apisetschema/apisetschema.spec index 981b80c6976..122cd1209ba 100644 --- a/dlls/apisetschema/apisetschema.spec +++ b/dlls/apisetschema/apisetschema.spec @@ -99,6 +99,7 @@ apiset api-ms-win-core-psapi-ansi-l1-1-0 = kernelbase.dll apiset api-ms-win-core-psapi-l1-1-0 = kernelbase.dll apiset api-ms-win-core-psapi-obsolete-l1-1-0 = kernelbase.dll apiset api-ms-win-core-psapiansi-l1-1-0 = kernelbase.dll +apiset api-ms-win-core-psm-appnotify-l1-1-0 = twinapi.appcore.dll apiset api-ms-win-core-psm-key-l1-1-1 = kernelbase.dll apiset api-ms-win-core-quirks-l1-1-0 = kernelbase.dll apiset api-ms-win-core-realtime-l1-1-0 = kernelbase.dll
On Thu Apr 20 04:04:45 2023 +0000, Zebediah Figura wrote:
PAPPSTATE_CHANGE_ROUTINE needs a calling convention. We also probably want to guard out PSM_APP_API_HOST as it's done in the Microsoft headers, so that the DECLSPEC_IMPORT logic actually works.
The Windows SDK header does not specify a calling convention. In this case, I added __stdcall since the functions are NTAPI.
On Thu Apr 20 04:04:45 2023 +0000, Mohamad Al-Jaf wrote:
The Windows SDK header does not specify a calling convention. In this case, I added __stdcall since the functions are NTAPI.
Should it have one then?
Should it have one then?
Yes. MSVC defaults to stdcall for external functions, and gcc does not. We use -mabi-ms on x86_64, but i386 will still default to cdecl.
I suppose we could change that, but I'm not sure we want to. In the past we've always just added stdcall decorations to functions even though they're not present on Windows.
(Frankly my impression is that sysv is simply a better ABI on x86_64, but it seems that mingw-w64 gcc isn't actually capable of emitting it.)
MSVC defaults to stdcall for external functions
Huh? I thought it defaulted to `cdecl` by default, and it only defaults to `stdcall` if you pass `/Gz`. From [the relevant doc][1]:
**`/Gd`**, **the default setting** [emphasis added], specifies the **`__cdecl`** calling convention for all functions except C++ member functions and functions that are marked **`__stdcall`**, **`__fastcall`**, or **`__vectorcall`**.
[...]
**`/Gz`** specifies the **`__stdcall`** calling convention for all functions except C++ member functions, functions named `main`, and functions that are marked **`__cdecl`**, **`__fastcall`**, or **`__vectorcall`**. All **`__stdcall`** functions must have prototypes. This calling convention is only available in compilers that target x86, and is ignored by compilers that target other architectures.
[1]: https://learn.microsoft.com/en-us/cpp/build/reference/gd-gr-gv-gz-calling-co...
Edit: Oh right, you're talking about x86-64 and I'm blind. The preceding only applies to i386.
Um.
Well, I was actually trying to talk about both architectures, and potentially others. I was in fact under the impression that stdcall was the default, so I'm surprised to learn otherwise.
From some quick regex-based searches, I can't easily find an example in the Microsoft headers of a documented function that's declared without a calling convention. (There are few I could easily find that aren't documented, but that's it). I can however find plenty of cases of *callbacks* that are declared without calling conventions. I haven't tried to test any of these to see if Windows will handle cdecl and stdcall versions, but the results may not be interesting even if I do.
At least two of these examples are declared with stdcall in Wine headers (MFPERIODICCALLBACK, LPFNADDPROPSHEETPAGE). There are almost certainly others. I was aware of this discrepancy and assumed that all callbacks should have that stdcall decoration. If you're right, then these callbacks are wrong, and we should probably do a holistic check to find any other such cases.
Since gcc defaults to cdecl, we use -mabi=ms on x86_64, and I think ARM has an identical ABI across machines, I think we just want to omit the decorations, rather than explicitly writing __cdecl?
Since gcc defaults to cdecl, we use -mabi=ms on x86_64, and I think ARM has an identical ABI across machines, I think we just want to omit the decorations, rather than explicitly writing __cdecl?
No, we want explicit decorations on all functions. There's no guarantee that the Unix default is compatible with the Windows one across all platforms and architectures.
Since gcc defaults to cdecl, we use -mabi=ms on x86_64, and I think ARM has an identical ABI across machines, I think we just want to omit the decorations, rather than explicitly writing __cdecl?
No, we want explicit decorations on all functions. There's no guarantee that the Unix default is compatible with the Windows one across all platforms and architectures.
That makes sense to me, but then I'm confused, why do we use -mabi=ms in that case?
That makes sense to me, but then I'm confused, why do we use -mabi=ms in that case?
Mainly to ensure that internal functions also use msabi, because calling between msabi and sysv is expensive on x86-64.
Note also that our headers should be usable from Winelib apps that link with Unix libs, and in that case using -mabi=ms is not an option.