Commit fc173ccc authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Reimplement GetProcessVersion() in kernelbase.

parent 54a7e592
...@@ -793,7 +793,7 @@ ...@@ -793,7 +793,7 @@
# @ stub GetProcessorSystemCycleTime # @ stub GetProcessorSystemCycleTime
@ stdcall -import GetProcessTimes(long ptr ptr ptr ptr) @ stdcall -import GetProcessTimes(long ptr ptr ptr ptr)
# @ stub GetProcessUserModeExceptionPolicy # @ stub GetProcessUserModeExceptionPolicy
@ stdcall GetProcessVersion(long) @ stdcall -import GetProcessVersion(long)
@ stdcall GetProcessWorkingSetSize(long ptr ptr) @ stdcall GetProcessWorkingSetSize(long ptr ptr)
@ stdcall -import GetProcessWorkingSetSizeEx(long ptr ptr ptr) @ stdcall -import GetProcessWorkingSetSizeEx(long ptr ptr ptr)
@ stdcall -import GetProductInfo(long long long long ptr) @ stdcall -import GetProductInfo(long long long long ptr)
......
...@@ -452,61 +452,6 @@ BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PD ...@@ -452,61 +452,6 @@ BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PD
/*********************************************************************** /***********************************************************************
* GetProcessVersion (KERNEL32.@)
*/
DWORD WINAPI GetProcessVersion( DWORD pid )
{
HANDLE process;
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
SIZE_T count;
PEB peb;
IMAGE_DOS_HEADER dos;
IMAGE_NT_HEADERS nt;
DWORD ver = 0;
if (!pid || pid == GetCurrentProcessId())
{
IMAGE_NT_HEADERS *pnt;
if ((pnt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress )))
return ((pnt->OptionalHeader.MajorSubsystemVersion << 16) |
pnt->OptionalHeader.MinorSubsystemVersion);
return 0;
}
process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, pid);
if (!process) return 0;
status = NtQueryInformationProcess(process, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
if (status) goto err;
status = NtReadVirtualMemory(process, pbi.PebBaseAddress, &peb, sizeof(peb), &count);
if (status || count != sizeof(peb)) goto err;
memset(&dos, 0, sizeof(dos));
status = NtReadVirtualMemory(process, peb.ImageBaseAddress, &dos, sizeof(dos), &count);
if (status || count != sizeof(dos)) goto err;
if (dos.e_magic != IMAGE_DOS_SIGNATURE) goto err;
memset(&nt, 0, sizeof(nt));
status = NtReadVirtualMemory(process, (char *)peb.ImageBaseAddress + dos.e_lfanew, &nt, sizeof(nt), &count);
if (status || count != sizeof(nt)) goto err;
if (nt.Signature != IMAGE_NT_SIGNATURE) goto err;
ver = MAKELONG(nt.OptionalHeader.MinorSubsystemVersion, nt.OptionalHeader.MajorSubsystemVersion);
err:
CloseHandle(process);
if (status != STATUS_SUCCESS)
SetLastError(RtlNtStatusToDosError(status));
return ver;
}
/***********************************************************************
* SetProcessWorkingSetSize [KERNEL32.@] * SetProcessWorkingSetSize [KERNEL32.@]
* Sets the min/max working set sizes for a specified process. * Sets the min/max working set sizes for a specified process.
* *
......
...@@ -636,7 +636,7 @@ ...@@ -636,7 +636,7 @@
@ stdcall GetProcessPriorityBoost(long ptr) @ stdcall GetProcessPriorityBoost(long ptr)
@ stdcall GetProcessShutdownParameters(ptr ptr) @ stdcall GetProcessShutdownParameters(ptr ptr)
@ stdcall GetProcessTimes(long ptr ptr ptr ptr) @ stdcall GetProcessTimes(long ptr ptr ptr ptr)
@ stdcall GetProcessVersion(long) kernel32.GetProcessVersion @ stdcall GetProcessVersion(long)
@ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr) @ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr)
# @ stub GetProcessorSystemCycleTime # @ stub GetProcessorSystemCycleTime
@ stdcall GetProductInfo(long long long long ptr) @ stdcall GetProductInfo(long long long long ptr)
......
...@@ -815,6 +815,29 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetProcessTimes( HANDLE process, FILETIME *create, ...@@ -815,6 +815,29 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetProcessTimes( HANDLE process, FILETIME *create,
/*********************************************************************** /***********************************************************************
* GetProcessVersion (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH GetProcessVersion( DWORD pid )
{
SECTION_IMAGE_INFORMATION info;
NTSTATUS status;
HANDLE process;
if (pid && pid != GetCurrentProcessId())
{
if (!(process = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, pid ))) return 0;
status = NtQueryInformationProcess( process, ProcessImageInformation, &info, sizeof(info), NULL );
CloseHandle( process );
}
else status = NtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation,
&info, sizeof(info), NULL );
if (!set_ntstatus( status )) return 0;
return MAKELONG( info.SubsystemVersionLow, info.SubsystemVersionHigh );
}
/***********************************************************************
* GetProcessWorkingSetSizeEx (kernelbase.@) * GetProcessWorkingSetSizeEx (kernelbase.@)
*/ */
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx( HANDLE process, SIZE_T *minset, BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx( HANDLE process, SIZE_T *minset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment