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)