The application I'm working on hooks psapi.dll APIs and can't cope with PE forwards. Inspection of psapi.dll in Windows shows that it doesn't contain PE forwards at all.
Since the API names are prepened with K32 it's impossible to use -import in the .spec file for automatic forwards generation.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/psapi/Makefile.in | 3 + dlls/psapi/psapi.c | 186 +++++++++++++++++++++++++++++++++++++++++ dlls/psapi/psapi.spec | 54 ++++++------ 3 files changed, 216 insertions(+), 27 deletions(-) create mode 100644 dlls/psapi/psapi.c
diff --git a/dlls/psapi/Makefile.in b/dlls/psapi/Makefile.in index f187d55f16..7a2aee44ed 100644 --- a/dlls/psapi/Makefile.in +++ b/dlls/psapi/Makefile.in @@ -2,3 +2,6 @@ MODULE = psapi.dll IMPORTLIB = psapi
RC_SRCS = version.rc + +C_SRCS = \ + psapi.c diff --git a/dlls/psapi/psapi.c b/dlls/psapi/psapi.c new file mode 100644 index 0000000000..1c0bcf453b --- /dev/null +++ b/dlls/psapi/psapi.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) the Wine project + * + * 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 <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#define PSAPI_VERSION 1 +#include "psapi.h" + +BOOL WINAPI K32EmptyWorkingSet(HANDLE process); +BOOL WINAPI EmptyWorkingSet(HANDLE process) +{ + return K32EmptyWorkingSet(process); +} + +BOOL WINAPI K32EnumDeviceDrivers(void **image_base, DWORD size, DWORD *needed); +BOOL WINAPI EnumDeviceDrivers(void **image_base, DWORD size, DWORD *needed) +{ + return K32EnumDeviceDrivers(image_base, size, needed); +} + +BOOL WINAPI K32EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA callback, LPVOID context); +BOOL WINAPI EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA callback, LPVOID context) +{ + return K32EnumPageFilesA(callback, context); +} + +BOOL WINAPI K32EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW callback, LPVOID context); +BOOL WINAPI EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW callback, LPVOID context) +{ + return K32EnumPageFilesW(callback, context); +} + +BOOL WINAPI K32EnumProcessModules(HANDLE process, HMODULE *module, DWORD size, DWORD *needed); +BOOL WINAPI EnumProcessModules(HANDLE process, HMODULE *module, DWORD size, DWORD *needed) +{ + return K32EnumProcessModules(process, module, size, needed); +} + +BOOL WINAPI K32EnumProcessModulesEx(HANDLE process, HMODULE *module, DWORD size, DWORD *needed, DWORD filter); +BOOL WINAPI EnumProcessModulesEx(HANDLE process, HMODULE *module, DWORD size, DWORD *needed, DWORD filter) +{ + return K32EnumProcessModulesEx(process, module, size, needed, filter); +} + +BOOL WINAPI K32EnumProcesses(DWORD *pid, DWORD size, DWORD *used); +BOOL WINAPI EnumProcesses(DWORD *pid, DWORD size, DWORD *used) +{ + return K32EnumProcesses(pid, size, used); +} + +DWORD WINAPI K32GetDeviceDriverBaseNameA(void *image, LPSTR name, DWORD size); +DWORD WINAPI GetDeviceDriverBaseNameA(void *image, LPSTR name, DWORD size) +{ + return K32GetDeviceDriverBaseNameA(image, name, size); +} + +DWORD WINAPI K32GetDeviceDriverBaseNameW(void *image, LPWSTR name, DWORD size); +DWORD WINAPI GetDeviceDriverBaseNameW(void *image, LPWSTR name, DWORD size) +{ + return K32GetDeviceDriverBaseNameW(image, name, size); +} + +DWORD WINAPI K32GetDeviceDriverFileNameA(void *image, LPSTR name, DWORD size); +DWORD WINAPI GetDeviceDriverFileNameA(void *image, LPSTR name, DWORD size) +{ + return K32GetDeviceDriverFileNameA(image, name, size); +} + +DWORD WINAPI K32GetDeviceDriverFileNameW(void *image, LPWSTR name, DWORD size); +DWORD WINAPI GetDeviceDriverFileNameW(void *image, LPWSTR name, DWORD size) +{ + return K32GetDeviceDriverFileNameW(image, name, size); +} + +DWORD WINAPI K32GetMappedFileNameA(HANDLE process, LPVOID lpv, LPSTR name, DWORD size); +DWORD WINAPI GetMappedFileNameA(HANDLE process, LPVOID lpv, LPSTR name, DWORD size) +{ + return K32GetMappedFileNameA(process, lpv, name, size); +} + +DWORD WINAPI K32GetMappedFileNameW(HANDLE process, LPVOID lpv, LPWSTR name, DWORD size); +DWORD WINAPI GetMappedFileNameW(HANDLE process, LPVOID lpv, LPWSTR name, DWORD size) +{ + return K32GetMappedFileNameW(process, lpv, name, size); +} + +DWORD WINAPI K32GetModuleBaseNameA(HANDLE process, HMODULE module, LPSTR name, DWORD size); +DWORD WINAPI GetModuleBaseNameA(HANDLE process, HMODULE module, LPSTR name, DWORD size) +{ + return K32GetModuleBaseNameA(process, module, name, size); +} + +DWORD WINAPI K32GetModuleBaseNameW(HANDLE process, HMODULE module, LPWSTR name, DWORD size); +DWORD WINAPI GetModuleBaseNameW(HANDLE process, HMODULE module, LPWSTR name, DWORD size) +{ + return K32GetModuleBaseNameW(process, module, name, size); +} + +DWORD WINAPI K32GetModuleFileNameExA(HANDLE process, HMODULE module, LPSTR name, DWORD size); +DWORD WINAPI GetModuleFileNameExA(HANDLE process, HMODULE module, LPSTR name, DWORD size) +{ + return K32GetModuleFileNameExA(process, module, name, size); +} + +DWORD WINAPI K32GetModuleFileNameExW(HANDLE process, HMODULE module, LPWSTR name, DWORD size); +DWORD WINAPI GetModuleFileNameExW(HANDLE process, HMODULE module, LPWSTR name, DWORD size) +{ + return K32GetModuleFileNameExW(process, module, name, size); +} + +BOOL WINAPI K32GetModuleInformation(HANDLE process, HMODULE module, MODULEINFO *info, DWORD size); +BOOL WINAPI GetModuleInformation(HANDLE process, HMODULE module, MODULEINFO *info, DWORD size) +{ + return K32GetModuleInformation(process, module, info, size); +} + +BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size); +BOOL WINAPI GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size) +{ + return K32GetPerformanceInfo(info, size); +} + +DWORD WINAPI K32GetProcessImageFileNameA(HANDLE process, LPSTR name, DWORD size); +DWORD WINAPI GetProcessImageFileNameA(HANDLE process, LPSTR name, DWORD size) +{ + return K32GetProcessImageFileNameA(process, name, size); +} + +DWORD WINAPI K32GetProcessImageFileNameW(HANDLE process, LPWSTR name, DWORD size); +DWORD WINAPI GetProcessImageFileNameW(HANDLE process, LPWSTR name, DWORD size) +{ + return K32GetProcessImageFileNameW(process, name, size); +} + +BOOL WINAPI K32GetProcessMemoryInfo(HANDLE process, PPROCESS_MEMORY_COUNTERS pmc, DWORD size); +BOOL WINAPI GetProcessMemoryInfo(HANDLE process, PPROCESS_MEMORY_COUNTERS pmc, DWORD size) +{ + return K32GetProcessMemoryInfo(process, pmc, size); +} + +BOOL WINAPI K32GetWsChanges(HANDLE process, PPSAPI_WS_WATCH_INFORMATION info, DWORD size); +BOOL WINAPI GetWsChanges(HANDLE process, PPSAPI_WS_WATCH_INFORMATION info, DWORD size) +{ + return K32GetWsChanges(process, info, size); +} + +BOOL WINAPI K32GetWsChangesEx(HANDLE process, PSAPI_WS_WATCH_INFORMATION_EX *info, DWORD *size); +BOOL WINAPI GetWsChangesEx(HANDLE process, PSAPI_WS_WATCH_INFORMATION_EX *info, DWORD *size) +{ + return K32GetWsChangesEx(process, info, size); +} + +BOOL WINAPI K32InitializeProcessForWsWatch(HANDLE process); +BOOL WINAPI InitializeProcessForWsWatch(HANDLE process) +{ + return K32InitializeProcessForWsWatch(process); +} + +BOOL WINAPI K32QueryWorkingSet(HANDLE process, LPVOID buffer, DWORD size); +BOOL WINAPI QueryWorkingSet(HANDLE process, LPVOID buffer, DWORD size) +{ + return K32QueryWorkingSet(process, buffer, size); +} + +BOOL WINAPI K32QueryWorkingSetEx(HANDLE process, LPVOID buffer, DWORD size); +BOOL WINAPI QueryWorkingSetEx(HANDLE process, LPVOID buffer, DWORD size) +{ + return K32QueryWorkingSetEx(process, buffer, size); +} diff --git a/dlls/psapi/psapi.spec b/dlls/psapi/psapi.spec index 6a7bc14815..7420d00140 100644 --- a/dlls/psapi/psapi.spec +++ b/dlls/psapi/psapi.spec @@ -1,27 +1,27 @@ -@ stdcall EmptyWorkingSet(long) kernel32.K32EmptyWorkingSet -@ stdcall EnumDeviceDrivers(ptr long ptr) kernel32.K32EnumDeviceDrivers -@ stdcall EnumPageFilesA(ptr ptr) kernel32.K32EnumPageFilesA -@ stdcall EnumPageFilesW(ptr ptr) kernel32.K32EnumPageFilesW -@ stdcall EnumProcessModules(long ptr long ptr) kernel32.K32EnumProcessModules -@ stdcall EnumProcessModulesEx(long ptr long ptr long) kernel32.K32EnumProcessModulesEx -@ stdcall EnumProcesses(ptr long ptr) kernel32.K32EnumProcesses -@ stdcall GetDeviceDriverBaseNameA(ptr ptr long) kernel32.K32GetDeviceDriverBaseNameA -@ stdcall GetDeviceDriverBaseNameW(ptr ptr long) kernel32.K32GetDeviceDriverBaseNameW -@ stdcall GetDeviceDriverFileNameA(ptr ptr long) kernel32.K32GetDeviceDriverFileNameA -@ stdcall GetDeviceDriverFileNameW(ptr ptr long) kernel32.K32GetDeviceDriverFileNameW -@ stdcall GetMappedFileNameA(long ptr ptr long) kernel32.K32GetMappedFileNameA -@ stdcall GetMappedFileNameW(long ptr ptr long) kernel32.K32GetMappedFileNameW -@ stdcall GetModuleBaseNameA(long long ptr long) kernel32.K32GetModuleBaseNameA -@ stdcall GetModuleBaseNameW(long long ptr long) kernel32.K32GetModuleBaseNameW -@ stdcall GetModuleFileNameExA(long long ptr long) kernel32.K32GetModuleFileNameExA -@ stdcall GetModuleFileNameExW(long long ptr long) kernel32.K32GetModuleFileNameExW -@ stdcall GetModuleInformation(long long ptr long) kernel32.K32GetModuleInformation -@ stdcall GetPerformanceInfo(ptr long) kernel32.K32GetPerformanceInfo -@ stdcall GetProcessImageFileNameA(long ptr long) kernel32.K32GetProcessImageFileNameA -@ stdcall GetProcessImageFileNameW(long ptr long) kernel32.K32GetProcessImageFileNameW -@ stdcall GetProcessMemoryInfo(long ptr long) kernel32.K32GetProcessMemoryInfo -@ stdcall GetWsChanges(long ptr long) kernel32.K32GetWsChanges -@ stdcall GetWsChangesEx(long ptr ptr) kernel32.K32GetWsChangesEx -@ stdcall InitializeProcessForWsWatch(long) kernel32.K32InitializeProcessForWsWatch -@ stdcall QueryWorkingSet(long ptr long) kernel32.K32QueryWorkingSet -@ stdcall QueryWorkingSetEx(long ptr long) kernel32.K32QueryWorkingSetEx +@ stdcall EmptyWorkingSet(long) +@ stdcall EnumDeviceDrivers(ptr long ptr) +@ stdcall EnumPageFilesA(ptr ptr) +@ stdcall EnumPageFilesW(ptr ptr) +@ stdcall EnumProcessModules(long ptr long ptr) +@ stdcall EnumProcessModulesEx(long ptr long ptr long) +@ stdcall EnumProcesses(ptr long ptr) +@ stdcall GetDeviceDriverBaseNameA(ptr ptr long) +@ stdcall GetDeviceDriverBaseNameW(ptr ptr long) +@ stdcall GetDeviceDriverFileNameA(ptr ptr long) +@ stdcall GetDeviceDriverFileNameW(ptr ptr long) +@ stdcall GetMappedFileNameA(long ptr ptr long) +@ stdcall GetMappedFileNameW(long ptr ptr long) +@ stdcall GetModuleBaseNameA(long long ptr long) +@ stdcall GetModuleBaseNameW(long long ptr long) +@ stdcall GetModuleFileNameExA(long long ptr long) +@ stdcall GetModuleFileNameExW(long long ptr long) +@ stdcall GetModuleInformation(long long ptr long) +@ stdcall GetPerformanceInfo(ptr long) +@ stdcall GetProcessImageFileNameA(long ptr long) +@ stdcall GetProcessImageFileNameW(long ptr long) +@ stdcall GetProcessMemoryInfo(long ptr long) +@ stdcall GetWsChanges(long ptr long) +@ stdcall GetWsChangesEx(long ptr ptr) +@ stdcall InitializeProcessForWsWatch(long) +@ stdcall QueryWorkingSet(long ptr long) +@ stdcall QueryWorkingSetEx(long ptr long)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=56627
Your paranoid android.
=== debian10 (32 bit report) ===
psapi: psapi_main.c:262: Test failed: expected approximately 765446 but got 765950
=== debian10 (32 bit Chinese:China report) ===
psapi: psapi_main.c:262: Test failed: expected approximately 761788 but got 762306 psapi_main.c:271: Test failed: expected approximately 23828 but got 23310
=== debian10 (64 bit WoW report) ===
psapi: psapi_main.c:262: Test failed: expected approximately 749945 but got 750352
Dmitry Timoshkov dmitry@baikal.ru writes:
The application I'm working on hooks psapi.dll APIs and can't cope with PE forwards. Inspection of psapi.dll in Windows shows that it doesn't contain PE forwards at all.
Since the API names are prepened with K32 it's impossible to use -import in the .spec file for automatic forwards generation.
It should work fine with -import. Are you getting an error?
Alexandre Julliard julliard@winehq.org wrote:
The application I'm working on hooks psapi.dll APIs and can't cope with PE forwards. Inspection of psapi.dll in Windows shows that it doesn't contain PE forwards at all.
Since the API names are prepened with K32 it's impossible to use -import in the .spec file for automatic forwards generation.
It should work fine with -import. Are you getting an error?
I get enrties calling to itself because of psapi.h redefinitions, if you know the recipe to avoid that then please add -import instead.
Dmitry Timoshkov dmitry@baikal.ru writes:
Alexandre Julliard julliard@winehq.org wrote:
The application I'm working on hooks psapi.dll APIs and can't cope with PE forwards. Inspection of psapi.dll in Windows shows that it doesn't contain PE forwards at all.
Since the API names are prepened with K32 it's impossible to use -import in the .spec file for automatic forwards generation.
It should work fine with -import. Are you getting an error?
I get enrties calling to itself because of psapi.h redefinitions, if you know the recipe to avoid that then please add -import instead.
I don't see why psapi.h would be an issue for the spec file. Something like this should work:
diff --git a/dlls/psapi/psapi.spec b/dlls/psapi/psapi.spec index 6a7bc14815af..0e2e3eb87b32 100644 --- a/dlls/psapi/psapi.spec +++ b/dlls/psapi/psapi.spec @@ -1,27 +1,27 @@ -@ stdcall EmptyWorkingSet(long) kernel32.K32EmptyWorkingSet -@ stdcall EnumDeviceDrivers(ptr long ptr) kernel32.K32EnumDeviceDrivers -@ stdcall EnumPageFilesA(ptr ptr) kernel32.K32EnumPageFilesA -@ stdcall EnumPageFilesW(ptr ptr) kernel32.K32EnumPageFilesW -@ stdcall EnumProcessModules(long ptr long ptr) kernel32.K32EnumProcessModules -@ stdcall EnumProcessModulesEx(long ptr long ptr long) kernel32.K32EnumProcessModulesEx -@ stdcall EnumProcesses(ptr long ptr) kernel32.K32EnumProcesses -@ stdcall GetDeviceDriverBaseNameA(ptr ptr long) kernel32.K32GetDeviceDriverBaseNameA -@ stdcall GetDeviceDriverBaseNameW(ptr ptr long) kernel32.K32GetDeviceDriverBaseNameW -@ stdcall GetDeviceDriverFileNameA(ptr ptr long) kernel32.K32GetDeviceDriverFileNameA -@ stdcall GetDeviceDriverFileNameW(ptr ptr long) kernel32.K32GetDeviceDriverFileNameW -@ stdcall GetMappedFileNameA(long ptr ptr long) kernel32.K32GetMappedFileNameA -@ stdcall GetMappedFileNameW(long ptr ptr long) kernel32.K32GetMappedFileNameW -@ stdcall GetModuleBaseNameA(long long ptr long) kernel32.K32GetModuleBaseNameA -@ stdcall GetModuleBaseNameW(long long ptr long) kernel32.K32GetModuleBaseNameW -@ stdcall GetModuleFileNameExA(long long ptr long) kernel32.K32GetModuleFileNameExA -@ stdcall GetModuleFileNameExW(long long ptr long) kernel32.K32GetModuleFileNameExW -@ stdcall GetModuleInformation(long long ptr long) kernel32.K32GetModuleInformation -@ stdcall GetPerformanceInfo(ptr long) kernel32.K32GetPerformanceInfo -@ stdcall GetProcessImageFileNameA(long ptr long) kernel32.K32GetProcessImageFileNameA -@ stdcall GetProcessImageFileNameW(long ptr long) kernel32.K32GetProcessImageFileNameW -@ stdcall GetProcessMemoryInfo(long ptr long) kernel32.K32GetProcessMemoryInfo -@ stdcall GetWsChanges(long ptr long) kernel32.K32GetWsChanges -@ stdcall GetWsChangesEx(long ptr ptr) kernel32.K32GetWsChangesEx -@ stdcall InitializeProcessForWsWatch(long) kernel32.K32InitializeProcessForWsWatch -@ stdcall QueryWorkingSet(long ptr long) kernel32.K32QueryWorkingSet -@ stdcall QueryWorkingSetEx(long ptr long) kernel32.K32QueryWorkingSetEx +@ stdcall -import EmptyWorkingSet(long) K32EmptyWorkingSet +@ stdcall -import EnumDeviceDrivers(ptr long ptr) K32EnumDeviceDrivers +@ stdcall -import EnumPageFilesA(ptr ptr) K32EnumPageFilesA +@ stdcall -import EnumPageFilesW(ptr ptr) K32EnumPageFilesW +@ stdcall -import EnumProcessModules(long ptr long ptr) K32EnumProcessModules +@ stdcall -import EnumProcessModulesEx(long ptr long ptr long) K32EnumProcessModulesEx +@ stdcall -import EnumProcesses(ptr long ptr) K32EnumProcesses +@ stdcall -import GetDeviceDriverBaseNameA(ptr ptr long) K32GetDeviceDriverBaseNameA +@ stdcall -import GetDeviceDriverBaseNameW(ptr ptr long) K32GetDeviceDriverBaseNameW +@ stdcall -import GetDeviceDriverFileNameA(ptr ptr long) K32GetDeviceDriverFileNameA +@ stdcall -import GetDeviceDriverFileNameW(ptr ptr long) K32GetDeviceDriverFileNameW +@ stdcall -import GetMappedFileNameA(long ptr ptr long) K32GetMappedFileNameA +@ stdcall -import GetMappedFileNameW(long ptr ptr long) K32GetMappedFileNameW +@ stdcall -import GetModuleBaseNameA(long long ptr long) K32GetModuleBaseNameA +@ stdcall -import GetModuleBaseNameW(long long ptr long) K32GetModuleBaseNameW +@ stdcall -import GetModuleFileNameExA(long long ptr long) K32GetModuleFileNameExA +@ stdcall -import GetModuleFileNameExW(long long ptr long) K32GetModuleFileNameExW +@ stdcall -import GetModuleInformation(long long ptr long) K32GetModuleInformation +@ stdcall -import GetPerformanceInfo(ptr long) K32GetPerformanceInfo +@ stdcall -import GetProcessImageFileNameA(long ptr long) K32GetProcessImageFileNameA +@ stdcall -import GetProcessImageFileNameW(long ptr long) K32GetProcessImageFileNameW +@ stdcall -import GetProcessMemoryInfo(long ptr long) K32GetProcessMemoryInfo +@ stdcall -import GetWsChanges(long ptr long) K32GetWsChanges +@ stdcall -import GetWsChangesEx(long ptr ptr) K32GetWsChangesEx +@ stdcall -import InitializeProcessForWsWatch(long) K32InitializeProcessForWsWatch +@ stdcall -import QueryWorkingSet(long ptr long) K32QueryWorkingSet +@ stdcall -import QueryWorkingSetEx(long ptr long) K32QueryWorkingSetEx
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=56629
Your paranoid android.
=== debian10 (32 bit WoW report) ===
psapi: psapi_main.c:262: Test failed: expected approximately 764855 but got 765336
=== debian10 (64 bit WoW report) ===
psapi: psapi_main.c:262: Test failed: expected approximately 750565 but got 750972
Alexandre Julliard julliard@winehq.org wrote:
The application I'm working on hooks psapi.dll APIs and can't cope with PE forwards. Inspection of psapi.dll in Windows shows that it doesn't contain PE forwards at all.
Since the API names are prepened with K32 it's impossible to use -import in the .spec file for automatic forwards generation.
It should work fine with -import. Are you getting an error?
I get enrties calling to itself because of psapi.h redefinitions, if you know the recipe to avoid that then please add -import instead.
I don't see why psapi.h would be an issue for the spec file.
Of course that's not related and was a part of another attempt, but probably I didn't try hard enough with -import flag.
Something like this should work:
It does. Thanks!