mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
Rebase against 148fc1adb53aa1d78a67b2a0ee5ea8058d92589a
This commit is contained in:
parent
dfc3b0f583
commit
813de5d6f8
@ -1,19 +1,19 @@
|
||||
From 5cf696c2cb00fd040ddba99ac291806e5ce3c9bf Mon Sep 17 00:00:00 2001
|
||||
From 223addb60e053484eaa77df434898419683e926b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Sun, 19 Feb 2017 05:38:40 +0100
|
||||
Subject: [PATCH] kernel32: Make K32GetPerformanceInfo faster.
|
||||
|
||||
---
|
||||
dlls/kernel32/cpu.c | 32 ++++++++------------------------
|
||||
server/process.c | 18 ++++++++++++++++++
|
||||
server/protocol.def | 8 ++++++++
|
||||
3 files changed, 34 insertions(+), 24 deletions(-)
|
||||
dlls/kernelbase/debug.c | 44 ++++++++++++++---------------------------
|
||||
server/process.c | 18 +++++++++++++++++
|
||||
server/protocol.def | 8 ++++++++
|
||||
3 files changed, 41 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c
|
||||
index 7668a10ea..96180bed4 100644
|
||||
--- a/dlls/kernel32/cpu.c
|
||||
+++ b/dlls/kernel32/cpu.c
|
||||
@@ -211,7 +211,6 @@ BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size)
|
||||
diff --git a/dlls/kernelbase/debug.c b/dlls/kernelbase/debug.c
|
||||
index 6acdf0f1ea95..8f021ebb0d21 100644
|
||||
--- a/dlls/kernelbase/debug.c
|
||||
+++ b/dlls/kernelbase/debug.c
|
||||
@@ -1449,7 +1449,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH K32GetPerformanceInfo( PPERFORMANCE_INFORMATION in
|
||||
{
|
||||
SYSTEM_PERFORMANCE_INFORMATION perf;
|
||||
SYSTEM_BASIC_INFORMATION basic;
|
||||
@ -21,7 +21,19 @@ index 7668a10ea..96180bed4 100644
|
||||
DWORD info_size;
|
||||
NTSTATUS status;
|
||||
|
||||
@@ -240,34 +239,19 @@ BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size)
|
||||
@@ -1462,9 +1461,9 @@ BOOL WINAPI DECLSPEC_HOTPATCH K32GetPerformanceInfo( PPERFORMANCE_INFORMATION in
|
||||
}
|
||||
|
||||
status = NtQuerySystemInformation( SystemPerformanceInformation, &perf, sizeof(perf), NULL );
|
||||
- if (!set_ntstatus( status )) return FALSE;
|
||||
+ if (status) goto err;
|
||||
status = NtQuerySystemInformation( SystemBasicInformation, &basic, sizeof(basic), NULL );
|
||||
- if (!set_ntstatus( status )) return FALSE;
|
||||
+ if (status) goto err;
|
||||
|
||||
info->cb = sizeof(*info);
|
||||
info->CommitTotal = perf.TotalCommittedPages;
|
||||
@@ -1478,37 +1477,24 @@ BOOL WINAPI DECLSPEC_HOTPATCH K32GetPerformanceInfo( PPERFORMANCE_INFORMATION in
|
||||
info->KernelNonpaged = perf.NonPagedPoolUsage;
|
||||
info->PageSize = basic.PageSize;
|
||||
|
||||
@ -37,18 +49,19 @@ index 7668a10ea..96180bed4 100644
|
||||
{
|
||||
- SetLastError( ERROR_OUTOFMEMORY );
|
||||
- return FALSE;
|
||||
+ info->ProcessCount = reply->processes;
|
||||
+ info->HandleCount = reply->handles;
|
||||
+ info->ThreadCount = reply->threads;
|
||||
}
|
||||
- }
|
||||
- status = NtQuerySystemInformation( SystemProcessInformation, process, info_size, &info_size );
|
||||
- if (!status) break;
|
||||
- HeapFree( GetProcessHeap(), 0, process );
|
||||
- if (status != STATUS_INFO_LENGTH_MISMATCH)
|
||||
- goto err;
|
||||
- {
|
||||
- SetLastError( RtlNtStatusToDosError( status ) );
|
||||
- return FALSE;
|
||||
+ info->ProcessCount = reply->processes;
|
||||
+ info->HandleCount = reply->handles;
|
||||
+ info->ThreadCount = reply->threads;
|
||||
}
|
||||
}
|
||||
+ SERVER_END_REQ;
|
||||
|
||||
- info->HandleCount = info->ProcessCount = info->ThreadCount = 0;
|
||||
- spi = process;
|
||||
- for (;;)
|
||||
@ -60,15 +73,22 @@ index 7668a10ea..96180bed4 100644
|
||||
- spi = (SYSTEM_PROCESS_INFORMATION *)((char *)spi + spi->NextEntryOffset);
|
||||
- }
|
||||
- HeapFree( GetProcessHeap(), 0, process );
|
||||
+ SERVER_END_REQ;
|
||||
+
|
||||
+ if (status) goto err;
|
||||
return TRUE;
|
||||
+
|
||||
+err:
|
||||
+ SetLastError( RtlNtStatusToDosError( status ) );
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
|
||||
err:
|
||||
diff --git a/server/process.c b/server/process.c
|
||||
index beaa68603..2dacc4d5c 100644
|
||||
index 3156e1bc82a5..da5c55e5368a 100644
|
||||
--- a/server/process.c
|
||||
+++ b/server/process.c
|
||||
@@ -1799,3 +1799,21 @@ DECL_HANDLER(resume_process)
|
||||
@@ -1830,3 +1830,21 @@ DECL_HANDLER(resume_process)
|
||||
release_object( process );
|
||||
}
|
||||
}
|
||||
@ -91,10 +111,10 @@ index beaa68603..2dacc4d5c 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/server/protocol.def b/server/protocol.def
|
||||
index e450388c1..1c1459f3c 100644
|
||||
index ef10b5e1438c..ca34c9dc1b4b 100644
|
||||
--- a/server/protocol.def
|
||||
+++ b/server/protocol.def
|
||||
@@ -3946,3 +3946,11 @@ struct handle_info
|
||||
@@ -3992,3 +3992,11 @@ struct handle_info
|
||||
@REQ(resume_process)
|
||||
obj_handle_t handle; /* process handle */
|
||||
@END
|
||||
@ -107,5 +127,5 @@ index e450388c1..1c1459f3c 100644
|
||||
+ unsigned int handles; /* number of handles */
|
||||
+@END
|
||||
--
|
||||
2.21.0
|
||||
2.26.2
|
||||
|
||||
|
@ -1,84 +1,62 @@
|
||||
From b9e418cc3e9cf7808285b2000db6f8163a48eb47 Mon Sep 17 00:00:00 2001
|
||||
From 4c2836f5afe797f9b5cbe7efd37b9879abe623db Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Wed, 16 Mar 2016 20:23:28 +0800
|
||||
Subject: [PATCH] kernel32: Implement K32GetMappedFileName. (v2)
|
||||
|
||||
---
|
||||
dlls/kernel32/virtual.c | 67 +++++++++++++++++++++++++++++++++++--------
|
||||
dlls/psapi/tests/psapi_main.c | 22 +++-----------
|
||||
2 files changed, 59 insertions(+), 30 deletions(-)
|
||||
dlls/kernelbase/debug.c | 87 ++++++++++++++++++++++++++++++++---
|
||||
dlls/psapi/tests/psapi_main.c | 22 ++-------
|
||||
2 files changed, 85 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c
|
||||
index c7a15cd..f2a2c71 100644
|
||||
--- a/dlls/kernel32/virtual.c
|
||||
+++ b/dlls/kernel32/virtual.c
|
||||
@@ -650,29 +650,72 @@ BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT_PTR max )
|
||||
diff --git a/dlls/kernelbase/debug.c b/dlls/kernelbase/debug.c
|
||||
index 48c949355ad7..92f5750aa580 100644
|
||||
--- a/dlls/kernelbase/debug.c
|
||||
+++ b/dlls/kernelbase/debug.c
|
||||
@@ -1247,15 +1247,59 @@ DWORD WINAPI DECLSPEC_HOTPATCH K32GetDeviceDriverFileNameW( void *image_base, WC
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static DWORD FILE_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen )
|
||||
+{
|
||||
+ DWORD ret;
|
||||
+
|
||||
+ if (srclen < 0) srclen = lstrlenW( src ) + 1;
|
||||
+ if (!destlen)
|
||||
+ {
|
||||
+ if (!AreFileApisANSI())
|
||||
+ {
|
||||
+ UNICODE_STRING strW;
|
||||
+ strW.Buffer = (WCHAR *)src;
|
||||
+ strW.Length = srclen * sizeof(WCHAR);
|
||||
+ ret = RtlUnicodeStringToOemSize( &strW ) - 1;
|
||||
+ }
|
||||
+ else
|
||||
+ RtlUnicodeToMultiByteSize( &ret, src, srclen * sizeof(WCHAR) );
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (!AreFileApisANSI())
|
||||
+ RtlUnicodeToOemN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
|
||||
+ else
|
||||
+ RtlUnicodeToMultiByteN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
|
||||
/***********************************************************************
|
||||
- * K32GetMappedFileNameA (KERNEL32.@)
|
||||
+ * K32GetMappedFileNameW (KERNEL32.@)
|
||||
* K32GetMappedFileNameA (kernelbase.@)
|
||||
*/
|
||||
-DWORD WINAPI K32GetMappedFileNameA(HANDLE process, LPVOID lpv, LPSTR file_name, DWORD size)
|
||||
+DWORD WINAPI K32GetMappedFileNameW(HANDLE process, LPVOID addr, LPWSTR file_name, DWORD size)
|
||||
DWORD WINAPI DECLSPEC_HOTPATCH K32GetMappedFileNameA( HANDLE process, void *addr, char *name, DWORD size )
|
||||
{
|
||||
- FIXME_(file)("(%p, %p, %p, %d): stub\n", process, lpv, file_name, size);
|
||||
+ MEMORY_SECTION_NAME *name;
|
||||
+ SIZE_T buf_len;
|
||||
+ NTSTATUS status;
|
||||
+
|
||||
+ TRACE_(file)("(%p, %p, %p, %d)\n", process, addr, file_name, size);
|
||||
+
|
||||
+ if (!file_name || !size)
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_PARAMETER);
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
- if (file_name && size)
|
||||
- file_name[0] = '\0';
|
||||
+ buf_len = sizeof(*name) + size * sizeof(WCHAR);
|
||||
+ name = HeapAlloc(GetProcessHeap(), 0, buf_len);
|
||||
+ if (!name)
|
||||
+ {
|
||||
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
- FIXME( "(%p, %p, %p, %d): stub\n", process, addr, name, size );
|
||||
- if (name && size) name[0] = 0;
|
||||
- return 0;
|
||||
+ status = NtQueryVirtualMemory(process, addr, MemorySectionName, name, buf_len, &buf_len);
|
||||
+ if (status)
|
||||
+ {
|
||||
+ HeapFree(GetProcessHeap(), 0, name);
|
||||
+ SetLastError(RtlNtStatusToDosError(status));
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(file_name, name->SectionFileName.Buffer, name->SectionFileName.MaximumLength);
|
||||
+ buf_len = name->SectionFileName.Length;
|
||||
+
|
||||
+ HeapFree(GetProcessHeap(), 0, name);
|
||||
+
|
||||
+ return buf_len;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
- * K32GetMappedFileNameW (KERNEL32.@)
|
||||
+ * K32GetMappedFileNameA (KERNEL32.@)
|
||||
*/
|
||||
-DWORD WINAPI K32GetMappedFileNameW(HANDLE process, LPVOID lpv, LPWSTR file_name, DWORD size)
|
||||
+DWORD WINAPI K32GetMappedFileNameA(HANDLE process, LPVOID addr, LPSTR file_name, DWORD size)
|
||||
{
|
||||
- FIXME_(file)("(%p, %p, %p, %d): stub\n", process, lpv, file_name, size);
|
||||
+ WCHAR file_nameW[MAX_PATH];
|
||||
+ DWORD ret;
|
||||
|
||||
- if (file_name && size)
|
||||
- file_name[0] = '\0';
|
||||
+ TRACE_(file)("(%p, %p, %p, %d)\n", process, addr, file_name, size);
|
||||
|
||||
- return 0;
|
||||
+ if (!file_name || !size)
|
||||
+
|
||||
+ TRACE("(%p, %p, %p, %d)\n", process, addr, name, size);
|
||||
+
|
||||
+ if (!name || !size)
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_PARAMETER);
|
||||
+ return 0;
|
||||
@ -87,21 +65,65 @@ index c7a15cd..f2a2c71 100644
|
||||
+ ret = K32GetMappedFileNameW(process, addr, file_nameW, MAX_PATH);
|
||||
+ if (ret)
|
||||
+ {
|
||||
+ ret = FILE_name_WtoA(file_nameW, -1, file_name, size);
|
||||
+ ret = FILE_name_WtoA(file_nameW, -1, name, size);
|
||||
+ if (ret > 1)
|
||||
+ ret--; /* don't account for terminating NUL */
|
||||
+ else
|
||||
+ file_name[0] = 0;
|
||||
+ name[0] = 0;
|
||||
+ }
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
||||
@@ -1264,9 +1308,40 @@ DWORD WINAPI DECLSPEC_HOTPATCH K32GetMappedFileNameA( HANDLE process, void *addr
|
||||
*/
|
||||
DWORD WINAPI DECLSPEC_HOTPATCH K32GetMappedFileNameW( HANDLE process, void *addr, WCHAR *name, DWORD size )
|
||||
{
|
||||
- FIXME( "(%p, %p, %p, %d): stub\n", process, addr, name, size );
|
||||
- if (name && size) name[0] = 0;
|
||||
- return 0;
|
||||
+ MEMORY_SECTION_NAME *section;
|
||||
+ SIZE_T buf_len;
|
||||
+ NTSTATUS status;
|
||||
+
|
||||
+ TRACE("(%p, %p, %p, %d)\n", process, addr, name, size);
|
||||
+
|
||||
+ if (!name || !size)
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_PARAMETER);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ buf_len = sizeof(*section) + size * sizeof(WCHAR);
|
||||
+ section = HeapAlloc(GetProcessHeap(), 0, buf_len);
|
||||
+ if (!section)
|
||||
+ {
|
||||
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ status = NtQueryVirtualMemory(process, addr, MemorySectionName, section, buf_len, &buf_len);
|
||||
+ if (status)
|
||||
+ {
|
||||
+ HeapFree(GetProcessHeap(), 0, section);
|
||||
+ SetLastError(RtlNtStatusToDosError(status));
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(name, section->SectionFileName.Buffer, section->SectionFileName.MaximumLength);
|
||||
+ buf_len = section->SectionFileName.Length;
|
||||
+
|
||||
+ HeapFree(GetProcessHeap(), 0, section);
|
||||
+
|
||||
+ return buf_len;
|
||||
}
|
||||
|
||||
|
||||
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
|
||||
index af69646..e92b55b 100644
|
||||
index 9886bc476740..99e87db9543e 100644
|
||||
--- a/dlls/psapi/tests/psapi_main.c
|
||||
+++ b/dlls/psapi/tests/psapi_main.c
|
||||
@@ -407,27 +407,22 @@ static void test_GetMappedFileName(void)
|
||||
@@ -418,27 +418,22 @@ static void test_GetMappedFileName(void)
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath));
|
||||
ok(!ret, "GetMappedFileName should fail\n");
|
||||
@ -129,7 +151,7 @@ index af69646..e92b55b 100644
|
||||
ok(szMapBaseName && *szMapBaseName, "szMapPath=\"%s\"\n", szMapPath);
|
||||
if (szMapBaseName)
|
||||
{
|
||||
@@ -465,29 +460,25 @@ todo_wine
|
||||
@@ -476,29 +471,25 @@ todo_wine
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, 0);
|
||||
ok(!ret, "GetMappedFileName should fail\n");
|
||||
@ -160,7 +182,7 @@ index af69646..e92b55b 100644
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameW(GetCurrentProcess(), base, map_nameW, ARRAY_SIZE(map_nameW));
|
||||
@@ -505,10 +496,9 @@ todo_wine
|
||||
@@ -516,10 +507,9 @@ todo_wine
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameW(current_process, base, map_nameW, sizeof(map_nameW)/sizeof(map_nameW[0]));
|
||||
@ -172,7 +194,7 @@ index af69646..e92b55b 100644
|
||||
if (nt_get_mapped_file_name(current_process, base, nt_map_name, sizeof(nt_map_name)/sizeof(nt_map_name[0])))
|
||||
{
|
||||
ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name);
|
||||
@@ -519,16 +509,14 @@ todo_wine
|
||||
@@ -530,16 +520,14 @@ todo_wine
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name, sizeof(map_name));
|
||||
@ -190,7 +212,7 @@ index af69646..e92b55b 100644
|
||||
ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, got %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
@@ -540,7 +528,6 @@ todo_wine
|
||||
@@ -551,7 +539,6 @@ todo_wine
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameA(0, base, map_name, sizeof(map_name));
|
||||
ok(!ret, "GetMappedFileName should fail\n");
|
||||
@ -198,7 +220,7 @@ index af69646..e92b55b 100644
|
||||
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
||||
|
||||
UnmapViewOfFile(base);
|
||||
@@ -559,7 +546,6 @@ todo_wine
|
||||
@@ -570,7 +557,6 @@ todo_wine
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name));
|
||||
ok(!ret, "GetMappedFileName should fail\n");
|
||||
@ -206,7 +228,7 @@ index af69646..e92b55b 100644
|
||||
ok(GetLastError() == ERROR_FILE_INVALID, "expected ERROR_FILE_INVALID, got %d\n", GetLastError());
|
||||
|
||||
CloseHandle(current_process);
|
||||
@@ -606,7 +592,7 @@ static void test_GetProcessImageFileName(void)
|
||||
@@ -617,7 +603,7 @@ static void test_GetProcessImageFileName(void)
|
||||
if(ret && ret1)
|
||||
{
|
||||
/* Windows returns 2*strlen-1 */
|
||||
@ -216,5 +238,5 @@ index af69646..e92b55b 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.7.4
|
||||
2.26.2
|
||||
|
||||
|
@ -52,7 +52,7 @@ usage()
|
||||
# Get the upstream commit sha
|
||||
upstream_commit()
|
||||
{
|
||||
echo "1976685a0f57bdec939228d73f6252c68ccb8f80"
|
||||
echo "148fc1adb53aa1d78a67b2a0ee5ea8058d92589a"
|
||||
}
|
||||
|
||||
# Show version information
|
||||
@ -3162,7 +3162,7 @@ fi
|
||||
# Patchset kernel32-K32GetPerformanceInfo
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/cpu.c, server/process.c, server/protocol.def
|
||||
# | * dlls/kernelbase/debug.c, server/process.c, server/protocol.def
|
||||
# |
|
||||
if test "$enable_kernel32_K32GetPerformanceInfo" -eq 1; then
|
||||
patch_apply kernel32-K32GetPerformanceInfo/0001-kernel32-Make-K32GetPerformanceInfo-faster.patch
|
||||
@ -4756,7 +4756,7 @@ fi
|
||||
# | * [#27248] Implement K32GetMappedFileName
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/virtual.c, dlls/ntdll/directory.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/tests/info.c, dlls/ntdll/virtual.c,
|
||||
# | * dlls/kernelbase/debug.c, dlls/ntdll/directory.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/tests/info.c, dlls/ntdll/virtual.c,
|
||||
# | dlls/psapi/tests/psapi_main.c, server/mapping.c, server/protocol.def
|
||||
# |
|
||||
if test "$enable_ntdll_NtQueryVirtualMemory" -eq 1; then
|
||||
|
Loading…
Reference in New Issue
Block a user