Author: dchapyshev
Date: Sun Jul 12 16:21:20 2009
New Revision: 41930
URL:
http://svn.reactos.org/svn/reactos?rev=41930&view=rev
Log:
- Implement QueryFullProcessImageNameA/W (based on Wine code). +35 passed tests
Modified:
trunk/reactos/dll/win32/kernel32/kernel32.pspec
trunk/reactos/dll/win32/kernel32/process/proc.c
Modified: trunk/reactos/dll/win32/kernel32/kernel32.pspec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] Sun Jul 12 16:21:20 2009
@@ -1017,3 +1017,7 @@
@ stdcall lstrlen(str) lstrlenA
@ stdcall lstrlenA(str)
@ stdcall lstrlenW(wstr)
+
+; Functions added in Win Vista
+@ stdcall QueryFullProcessImageNameA(ptr long str ptr)
+@ stdcall QueryFullProcessImageNameW(ptr long wstr ptr)
Modified: trunk/reactos/dll/win32/kernel32/process/proc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/process/proc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/process/proc.c [iso-8859-1] Sun Jul 12 16:21:20 2009
@@ -1006,4 +1006,106 @@
return TRUE;
}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+QueryFullProcessImageNameW(HANDLE hProcess,
+ DWORD dwFlags,
+ LPWSTR lpExeName,
+ PDWORD pdwSize)
+{
+ BYTE Buffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)];
+ UNICODE_STRING *DynamicBuffer = NULL;
+ UNICODE_STRING *Result = NULL;
+ NTSTATUS Status;
+ DWORD Needed;
+
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessImageFileName,
+ Buffer,
+ sizeof(Buffer) - sizeof(WCHAR),
+ &Needed);
+ if (Status == STATUS_INFO_LENGTH_MISMATCH)
+ {
+ DynamicBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Needed + sizeof(WCHAR));
+ if (!DynamicBuffer)
+ {
+ SetLastErrorByStatus(STATUS_NO_MEMORY);
+ return FALSE;
+ }
+
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessImageFileName,
+ (LPBYTE)DynamicBuffer,
+ Needed,
+ &Needed);
+ Result = DynamicBuffer;
+ }
+ else Result = (PUNICODE_STRING)Buffer;
+
+ if (!NT_SUCCESS(Status)) goto Cleanup;
+
+ if (Result->Length / sizeof(WCHAR) + 1 > *pdwSize)
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ goto Cleanup;
+ }
+
+ *pdwSize = Result->Length / sizeof(WCHAR);
+ memcpy(lpExeName, Result->Buffer, Result->Length);
+ lpExeName[*pdwSize] = 0;
+
+Cleanup:
+ RtlFreeHeap(RtlGetProcessHeap(), 0, DynamicBuffer);
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ }
+ return !Status;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+QueryFullProcessImageNameA(HANDLE hProcess,
+ DWORD dwFlags,
+ LPSTR lpExeName,
+ PDWORD pdwSize)
+{
+ DWORD pdwSizeW = *pdwSize;
+ BOOL Result;
+ LPWSTR lpExeNameW;
+
+ lpExeNameW = RtlAllocateHeap(RtlGetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ *pdwSize * sizeof(WCHAR));
+ if (!lpExeNameW)
+ {
+ SetLastErrorByStatus(STATUS_NO_MEMORY);
+ return FALSE;
+ }
+
+ Result = QueryFullProcessImageNameW(hProcess, dwFlags, lpExeNameW, &pdwSizeW);
+
+ if (Result)
+ Result = (0 != WideCharToMultiByte(CP_ACP, 0,
+ lpExeNameW,
+ -1,
+ lpExeName,
+ *pdwSize,
+ NULL, NULL));
+ if (Result)
+ *pdwSize = strlen(lpExeName);
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, lpExeNameW);
+ return Result;
+}
+
/* EOF */