Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling convention fixes for better consistency #2050

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kphlib/include/kphdyndata.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <kphdyn.h>

_Must_inspect_result_
NTSTATUS KphDynDataGetConfiguration(
NTSTATUS NTAPI KphDynDataGetConfiguration(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the Kph functions are exported or external.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, should not be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd party projects which use the kphlib may link against un exported functions, and if they by default use a different calling convention then __stdcall a fix like this is required.

_In_ PKPH_DYNDATA DynData,
_In_ ULONG DynDataLength,
_In_ USHORT MajorVersion,
Expand Down
4 changes: 2 additions & 2 deletions kphlib/include/kphmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ C_ASSERT(KPH_MESSAGE_MIN_SIZE == FIELD_OFFSET(KPH_MESSAGE, _Dyn.Buffer));

EXTERN_C_START

VOID KphMsgInit(
VOID NTAPI KphMsgInit(
_Out_writes_bytes_(KPH_MESSAGE_MIN_SIZE) PKPH_MESSAGE Message,
_In_ KPH_MESSAGE_ID MessageId
);

_Must_inspect_result_
NTSTATUS KphMsgValidate(
NTSTATUS NTAPI KphMsgValidate(
_In_ PCKPH_MESSAGE Message
);

Expand Down
22 changes: 11 additions & 11 deletions kphlib/include/kphmsgdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,65 @@ typedef struct _KPHM_SIZED_BUFFER
PBYTE Buffer;
} KPHM_SIZED_BUFFER, *PKPHM_SIZED_BUFFER;

VOID KphMsgDynClear(
VOID NTAPI KphMsgDynClear(
_Inout_ PKPH_MESSAGE Message
);

VOID KphMsgDynClearLast(
VOID NTAPI KphMsgDynClearLast(
_Inout_ PKPH_MESSAGE Message
);

USHORT KphMsgDynRemaining(
USHORT NTAPI KphMsgDynRemaining(
_In_ PCKPH_MESSAGE Message
);

_Must_inspect_result_
NTSTATUS KphMsgDynAddUnicodeString(
NTSTATUS NTAPI KphMsgDynAddUnicodeString(
_Inout_ PKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_In_ PCUNICODE_STRING String
);

NTSTATUS KphMsgDynGetUnicodeString(
NTSTATUS NTAPI KphMsgDynGetUnicodeString(
_In_ PCKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_Out_ PUNICODE_STRING String
);

_Must_inspect_result_
NTSTATUS KphMsgDynAddAnsiString(
NTSTATUS NTAPI KphMsgDynAddAnsiString(
_Inout_ PKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_In_ PCANSI_STRING String
);

NTSTATUS KphMsgDynGetAnsiString(
NTSTATUS NTAPI KphMsgDynGetAnsiString(
_In_ PCKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_Out_ PANSI_STRING String
);

_Must_inspect_result_
NTSTATUS KphMsgDynAddStackTrace(
NTSTATUS NTAPI KphMsgDynAddStackTrace(
_Inout_ PKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_In_ PKPHM_STACK_TRACE StackTrace
);

NTSTATUS KphMsgDynGetStackTrace(
NTSTATUS NTAPI KphMsgDynGetStackTrace(
_In_ PCKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_Out_ PKPHM_STACK_TRACE StackTrace
);

_Must_inspect_result_
NTSTATUS KphMsgDynAddSizedBuffer(
NTSTATUS NTAPI KphMsgDynAddSizedBuffer(
_Inout_ PKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_In_ PKPHM_SIZED_BUFFER SizedBuffer
);

NTSTATUS KphMsgDynGetSizedBuffer(
NTSTATUS NTAPI KphMsgDynGetSizedBuffer(
_In_ PCKPH_MESSAGE Message,
_In_ KPH_MESSAGE_FIELD_ID FieldId,
_Out_ PKPHM_SIZED_BUFFER SizedBuffer
Expand Down
2 changes: 1 addition & 1 deletion phlib/include/apiimport.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ typedef VOID (WINAPI* _UnsubscribeServiceChangeNotifications)(
_In_ PSC_NOTIFICATION_REGISTRATION pSubscription
);

#define PH_DECLARE_IMPORT(Name) _##Name Name##_Import(VOID)
#define PH_DECLARE_IMPORT(Name) _##Name NTAPI Name##_Import(VOID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types don't have calling conventions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well my VS2022 begs to differ without that fix i can not build a x86 version of Task Explorer


PH_DECLARE_IMPORT(NtQueryInformationEnlistment);
PH_DECLARE_IMPORT(NtQueryInformationResourceManager);
Expand Down
38 changes: 19 additions & 19 deletions phlib/include/appresolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@

EXTERN_C_START

HRESULT PhAppResolverGetAppIdForProcess(
HRESULT NTAPI PhAppResolverGetAppIdForProcess(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AppResolver functions are not external or exported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd party projects which use the kphlib may link against un exported functions, and if they by default use a different calling convention then __stdcall a fix like this is required.

_In_ HANDLE ProcessId,
_Out_ PPH_STRING *ApplicationUserModelId
);

HRESULT PhAppResolverGetAppIdForWindow(
HRESULT NTAPI PhAppResolverGetAppIdForWindow(
_In_ HWND WindowHandle,
_Out_ PPH_STRING *ApplicationUserModelId
);

HRESULT PhAppResolverActivateAppId(
HRESULT NTAPI PhAppResolverActivateAppId(
_In_ PPH_STRING ApplicationUserModelId,
_In_opt_ PWSTR CommandLine,
_Out_opt_ HANDLE *ProcessId
);

HRESULT PhAppResolverPackageTerminateProcess(
HRESULT NTAPI PhAppResolverPackageTerminateProcess(
_In_ PPH_STRING PackageFullName
);

Expand All @@ -40,36 +40,36 @@ typedef struct _PH_PACKAGE_TASK_ENTRY
GUID TaskGuid;
} PH_PACKAGE_TASK_ENTRY, *PPH_PACKAGE_TASK_ENTRY;

PPH_LIST PhAppResolverEnumeratePackageBackgroundTasks(
PPH_LIST NTAPI PhAppResolverEnumeratePackageBackgroundTasks(
_In_ PPH_STRING PackageFullName
);

HRESULT PhAppResolverPackageStopSessionRedirection(
HRESULT NTAPI PhAppResolverPackageStopSessionRedirection(
_In_ PPH_STRING PackageFullName
);

PPH_STRING PhGetAppContainerName(
PPH_STRING NTAPI PhGetAppContainerName(
_In_ PSID AppContainerSid
);

PPH_STRING PhGetAppContainerSidFromName(
PPH_STRING NTAPI PhGetAppContainerSidFromName(
_In_ PWSTR AppContainerName
);

PPH_STRING PhGetAppContainerPackageName(
PPH_STRING NTAPI PhGetAppContainerPackageName(
_In_ PSID Sid
);

BOOLEAN PhIsPackageCapabilitySid(
BOOLEAN NTAPI PhIsPackageCapabilitySid(
_In_ PSID AppContainerSid,
_In_ PSID Sid
);

PPH_STRING PhGetPackagePath(
PPH_STRING NTAPI PhGetPackagePath(
_In_ PPH_STRING PackageFullName
);

PPH_LIST PhGetPackageAssetsFromResourceFile(
PPH_LIST NTAPI PhGetPackageAssetsFromResourceFile(
_In_ PWSTR FilePath
);

Expand All @@ -85,18 +85,18 @@ typedef struct _PH_APPUSERMODELID_ENUM_ENTRY
PPH_STRING SmallLogoPath;
} PH_APPUSERMODELID_ENUM_ENTRY, *PPH_APPUSERMODELID_ENUM_ENTRY;

PPH_LIST PhEnumApplicationUserModelIds(
PPH_LIST NTAPI PhEnumApplicationUserModelIds(
VOID
);

HRESULT PhAppResolverGetPackageResourceFilePath(
HRESULT NTAPI PhAppResolverGetPackageResourceFilePath(
_In_ PCWSTR PackageFullName,
_In_ PCWSTR Key,
_Out_ PWSTR* FilePath
);

_Success_(return)
BOOLEAN PhAppResolverGetPackageIcon(
BOOLEAN NTAPI PhAppResolverGetPackageIcon(
_In_ HANDLE ProcessId,
_In_ PPH_STRING PackageFullName,
_Out_opt_ HICON* IconLarge,
Expand All @@ -106,23 +106,23 @@ BOOLEAN PhAppResolverGetPackageIcon(

// Immersive PLM task support

HRESULT PhAppResolverBeginCrashDumpTask(
HRESULT NTAPI PhAppResolverBeginCrashDumpTask(
_In_ HANDLE ProcessId,
_Out_ HANDLE* TaskHandle
);

HRESULT PhAppResolverBeginCrashDumpTaskByHandle(
HRESULT NTAPI PhAppResolverBeginCrashDumpTaskByHandle(
_In_ HANDLE ProcessHandle,
_Out_ HANDLE* TaskHandle
);

HRESULT PhAppResolverEndCrashDumpTask(
HRESULT NTAPI PhAppResolverEndCrashDumpTask(
_In_ HANDLE TaskHandle
);

// Desktop Bridge

HRESULT PhCreateProcessDesktopPackage(
HRESULT NTAPI PhCreateProcessDesktopPackage(
_In_ PWSTR ApplicationUserModelId,
_In_ PWSTR Executable,
_In_ PWSTR Arguments,
Expand Down
12 changes: 6 additions & 6 deletions phlib/include/kphcomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <kphmsg.h>

NTSTATUS KphFilterLoadUnload(
NTSTATUS NTAPI KphFilterLoadUnload(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are not exported or external.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd party projects which use the kphlib may link against un exported functions, and if they by default use a different calling convention then __stdcall a fix like this is required.

_In_ PPH_STRINGREF ServiceName,
_In_ BOOLEAN LoadDriver
);
Expand All @@ -40,26 +40,26 @@ BOOLEAN (NTAPI *PKPH_COMMS_CALLBACK)(
);

_Must_inspect_result_
NTSTATUS KphCommsStart(
NTSTATUS NTAPI KphCommsStart(
_In_ PPH_STRINGREF PortName,
_In_opt_ PKPH_COMMS_CALLBACK Callback
);

VOID KphCommsStop(
VOID NTAPI KphCommsStop(
VOID
);

BOOLEAN KphCommsIsConnected(
BOOLEAN NTAPI KphCommsIsConnected(
VOID
);

NTSTATUS KphCommsReplyMessage(
NTSTATUS NTAPI KphCommsReplyMessage(
_In_ ULONG_PTR ReplyToken,
_In_ PKPH_MESSAGE Message
);

_Must_inspect_result_
NTSTATUS KphCommsSendMessage(
NTSTATUS NTAPI KphCommsSendMessage(
_Inout_ PKPH_MESSAGE Message
);

Expand Down
1 change: 1 addition & 0 deletions phlib/include/phutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,7 @@ PhHungWindowFromGhostWindow(

PHLIBAPI
NTSTATUS
NTAPI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

PhGetFileData(
_In_ HANDLE FileHandle,
_Out_ PVOID* Buffer,
Expand Down
5 changes: 4 additions & 1 deletion phlib/include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct _PH_SETTING

PHLIBAPI
VOID
NTAPI
PhSettingsInitialization(
VOID
);
Expand Down Expand Up @@ -376,7 +377,9 @@ VOID PhResetSettings(
// begin_phapppub
// High-level settings creation

VOID PhAddSetting(
VOID
NTAPI
PhAddSetting(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

_In_ PH_SETTING_TYPE Type,
_In_ PPH_STRINGREF Name,
_In_ PPH_STRINGREF DefaultValue
Expand Down
Loading