mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-24 19:54:25 -04:00
[core] list potentially blocking processes on disk access error
* Using functionality from Process Hacker: https://github.com/processhacker2/processhacker2/ * Part of the #773 enhancement * Also fix minor MinGW and WDK warnings
This commit is contained in:
parent
27bc4cb02b
commit
d5f6ddb653
16 changed files with 654 additions and 26 deletions
|
@ -31,6 +31,9 @@
|
|||
#include <share.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#if !defined(DDKBUILD)
|
||||
#include <psapi.h>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -125,6 +128,31 @@ static __inline wchar_t* utf8_to_wchar(const char* str)
|
|||
return wstr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts an non NUL-terminated UTF-16 string of length len to UTF8 (allocate returned string)
|
||||
* Returns NULL on error
|
||||
*/
|
||||
static __inline char* wchar_len_to_utf8(const wchar_t* wstr, int wlen)
|
||||
{
|
||||
int size = 0;
|
||||
char* str = NULL;
|
||||
|
||||
// Find out the size we need to allocate for our converted string
|
||||
size = WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, NULL, 0, NULL, NULL);
|
||||
if (size <= 1) // An empty string would be size 1
|
||||
return NULL;
|
||||
|
||||
if ((str = (char*)calloc(size, 1)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, str, size, NULL, NULL) != size) {
|
||||
sfree(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static __inline DWORD FormatMessageU(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
||||
DWORD dwLanguageId, char* lpBuffer, DWORD nSize, va_list *Arguments)
|
||||
{
|
||||
|
@ -554,6 +582,24 @@ static __inline DWORD GetModuleFileNameU(HMODULE hModule, char* lpFilename, DWOR
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(DDKBUILD)
|
||||
static __inline DWORD GetModuleFileNameExU(HANDLE hProcess, HMODULE hModule, char* lpFilename, DWORD nSize)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpFilename, nSize);
|
||||
ret = GetModuleFileNameExW(hProcess, hModule, wlpFilename, nSize);
|
||||
err = GetLastError();
|
||||
if ((ret != 0)
|
||||
&& ((ret = wchar_to_utf8_no_alloc(wlpFilename, lpFilename, nSize)) == 0)) {
|
||||
err = GetLastError();
|
||||
}
|
||||
wfree(lpFilename);
|
||||
SetLastError(err);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline DWORD GetFullPathNameU(const char* lpFileName, DWORD nBufferLength, char* lpBuffer, char** lpFilePart)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue