Commit 9bbf3f90 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernel32: Moved GetModuleFileNameEx[AW] to kernel32.

parent e6dd213d
...@@ -774,6 +774,8 @@ ...@@ -774,6 +774,8 @@
@ stdcall K32EnumProcesses(ptr long ptr) @ stdcall K32EnumProcesses(ptr long ptr)
@ stdcall K32GetModuleBaseNameA(long long ptr long) @ stdcall K32GetModuleBaseNameA(long long ptr long)
@ stdcall K32GetModuleBaseNameW(long long ptr long) @ stdcall K32GetModuleBaseNameW(long long ptr long)
@ stdcall K32GetModuleFileNameExA(long long ptr long)
@ stdcall K32GetModuleFileNameExW(long long ptr long)
@ stdcall K32GetProcessMemoryInfo(long ptr long) @ stdcall K32GetProcessMemoryInfo(long ptr long)
@ stdcall K32QueryWorkingSet(long ptr long) @ stdcall K32QueryWorkingSet(long ptr long)
@ stdcall K32QueryWorkingSetEx(long ptr long) @ stdcall K32QueryWorkingSetEx(long ptr long)
......
...@@ -1228,6 +1228,61 @@ DWORD WINAPI K32GetModuleBaseNameA(HANDLE process, HMODULE module, ...@@ -1228,6 +1228,61 @@ DWORD WINAPI K32GetModuleBaseNameA(HANDLE process, HMODULE module,
return ret; return ret;
} }
/***********************************************************************
* K32GetModuleFileNameExW (KERNEL32.@)
*/
DWORD WINAPI K32GetModuleFileNameExW(HANDLE process, HMODULE module,
LPWSTR file_name, DWORD size)
{
LDR_MODULE ldr_module;
if(!get_ldr_module(process, module, &ldr_module))
return 0;
size = min(ldr_module.FullDllName.Length / sizeof(WCHAR), size);
if (!ReadProcessMemory(process, ldr_module.FullDllName.Buffer,
file_name, size * sizeof(WCHAR), NULL))
return 0;
file_name[size] = 0;
return size;
}
/***********************************************************************
* K32GetModuleFileNameExA (KERNEL32.@)
*/
DWORD WINAPI K32GetModuleFileNameExA(HANDLE process, HMODULE module,
LPSTR file_name, DWORD size)
{
WCHAR *ptr;
TRACE("(hProcess=%p, hModule=%p, %p, %d)\n", process, module, file_name, size);
if (!file_name || !size) return 0;
if ( process == GetCurrentProcess() )
{
DWORD len = GetModuleFileNameA( module, file_name, size );
if (size) file_name[size - 1] = '\0';
return len;
}
if (!(ptr = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)))) return 0;
if (!K32GetModuleFileNameExW(process, module, ptr, size))
{
file_name[0] = '\0';
}
else
{
if (!WideCharToMultiByte( CP_ACP, 0, ptr, -1, file_name, size, NULL, NULL ))
file_name[size - 1] = 0;
}
HeapFree(GetProcessHeap(), 0, ptr);
return strlen(file_name);
}
#ifdef __i386__ #ifdef __i386__
/*********************************************************************** /***********************************************************************
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
@ stdcall GetMappedFileNameW(long ptr ptr long) @ stdcall GetMappedFileNameW(long ptr ptr long)
@ stdcall GetModuleBaseNameA(long long ptr long) kernel32.K32GetModuleBaseNameA @ stdcall GetModuleBaseNameA(long long ptr long) kernel32.K32GetModuleBaseNameA
@ stdcall GetModuleBaseNameW(long long ptr long) kernel32.K32GetModuleBaseNameW @ stdcall GetModuleBaseNameW(long long ptr long) kernel32.K32GetModuleBaseNameW
@ stdcall GetModuleFileNameExA(long long ptr long) @ stdcall GetModuleFileNameExA(long long ptr long) kernel32.K32GetModuleFileNameExA
@ stdcall GetModuleFileNameExW(long long ptr long) @ stdcall GetModuleFileNameExW(long long ptr long) kernel32.K32GetModuleFileNameExW
@ stdcall GetModuleInformation(long long ptr long) @ stdcall GetModuleInformation(long long ptr long)
@ stdcall GetPerformanceInfo(ptr long) @ stdcall GetPerformanceInfo(ptr long)
@ stdcall GetProcessImageFileNameA(long ptr long) kernel32.K32GetProcessImageFileNameA @ stdcall GetProcessImageFileNameA(long ptr long) kernel32.K32GetProcessImageFileNameA
......
...@@ -263,62 +263,6 @@ DWORD WINAPI GetMappedFileNameW(HANDLE hProcess, LPVOID lpv, LPWSTR lpFilename, ...@@ -263,62 +263,6 @@ DWORD WINAPI GetMappedFileNameW(HANDLE hProcess, LPVOID lpv, LPWSTR lpFilename,
} }
/*********************************************************************** /***********************************************************************
* GetModuleFileNameExA (PSAPI.@)
*/
DWORD WINAPI GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule,
LPSTR lpFileName, DWORD nSize)
{
WCHAR *ptr;
TRACE("(hProcess=%p, hModule=%p, %p, %d)\n",
hProcess, hModule, lpFileName, nSize);
if (!lpFileName || !nSize) return 0;
if ( hProcess == GetCurrentProcess() )
{
DWORD len = GetModuleFileNameA( hModule, lpFileName, nSize );
if (nSize) lpFileName[nSize - 1] = '\0';
return len;
}
if (!(ptr = HeapAlloc(GetProcessHeap(), 0, nSize * sizeof(WCHAR)))) return 0;
if (!GetModuleFileNameExW(hProcess, hModule, ptr, nSize))
{
lpFileName[0] = '\0';
}
else
{
if (!WideCharToMultiByte( CP_ACP, 0, ptr, -1, lpFileName, nSize, NULL, NULL ))
lpFileName[nSize - 1] = 0;
}
HeapFree(GetProcessHeap(), 0, ptr);
return strlen(lpFileName);
}
/***********************************************************************
* GetModuleFileNameExW (PSAPI.@)
*/
DWORD WINAPI GetModuleFileNameExW(HANDLE hProcess, HMODULE hModule,
LPWSTR lpFileName, DWORD nSize)
{
LDR_MODULE LdrModule;
if(!PSAPI_GetLdrModule(hProcess, hModule, &LdrModule))
return 0;
nSize = min(LdrModule.FullDllName.Length / sizeof(WCHAR), nSize);
if (!ReadProcessMemory(hProcess, LdrModule.FullDllName.Buffer,
lpFileName, nSize * sizeof(WCHAR), NULL))
return 0;
lpFileName[nSize] = 0;
return nSize;
}
/***********************************************************************
* GetModuleInformation (PSAPI.@) * GetModuleInformation (PSAPI.@)
*/ */
BOOL WINAPI GetModuleInformation(HANDLE hProcess, HMODULE hModule, BOOL WINAPI GetModuleInformation(HANDLE hProcess, HMODULE hModule,
......
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