mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 06:48:26 -04:00
[wue] add experimental option to replace Windows bootloaders with the 24H2 _EX versions
* This aims at creating installation media that is compatible with systems where 'Microsoft Windows Production PCA 2011' has been revoked. * Doesn't work, since the bootloaders being applied by the first stage installer come from \sources\install.wim[#]\windows\system32\Recovery\Winre.wim[#]\Windows\Boot\ (instead of \sources\boot.wim[#]\Windows\Boot\ as one would naturally expect) and Microsoft botched the ones they included there by using completely vulnerable (and therefore revoked) ones. See https://github.com/pbatard/rufus/issues/2244#issuecomment-2400380839. * Still, I sure haven't gone through this excruciating ACL bullshit for nothing, so you get an experimental option, behind the expert mode curtain.
This commit is contained in:
parent
c800448c62
commit
fd5c366938
9 changed files with 360 additions and 49 deletions
|
@ -26,6 +26,8 @@
|
|||
#include <stdio.h>
|
||||
#include <shlobj.h>
|
||||
#include <ctype.h>
|
||||
#include <aclapi.h>
|
||||
#include <accctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <shellapi.h>
|
||||
#include <shlwapi.h>
|
||||
|
@ -89,6 +91,9 @@ static __inline char* wchar_to_utf8(const wchar_t* wstr)
|
|||
int size = 0;
|
||||
char* str = NULL;
|
||||
|
||||
if (wstr == NULL)
|
||||
return NULL;
|
||||
|
||||
// Convert the empty string too
|
||||
if (wstr[0] == 0)
|
||||
return (char*)calloc(1, 1);
|
||||
|
@ -568,6 +573,52 @@ static __inline const char* PathFindFileNameU(const char* szPath)
|
|||
return &szPath[i];
|
||||
}
|
||||
|
||||
static __inline char* PathCombineU(char* lpDest, char* lpDir, char* lpFile)
|
||||
{
|
||||
wchar_t* wret = NULL;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
wchar_t wlpDest[MAX_PATH];
|
||||
wconvert(lpDir);
|
||||
wconvert(lpFile);
|
||||
wret = PathCombineW(wlpDest, wlpDir, wlpFile);
|
||||
err = GetLastError();
|
||||
wfree(lpDir);
|
||||
wfree(lpFile);
|
||||
if (wret == NULL)
|
||||
return NULL;
|
||||
wchar_to_utf8_no_alloc(wlpDest, lpDest, MAX_PATH);
|
||||
SetLastError(err);
|
||||
return lpDest;
|
||||
}
|
||||
|
||||
static __inline HANDLE FindFirstFileU(char* lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
|
||||
{
|
||||
HANDLE ret = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAW wFindFileData = { 0 };
|
||||
wconvert(lpFileName);
|
||||
ret = FindFirstFileW(wlpFileName, &wFindFileData);
|
||||
if (ret != INVALID_HANDLE_VALUE) {
|
||||
memcpy(lpFindFileData, &wFindFileData, offsetof(WIN32_FIND_DATAW, cFileName));
|
||||
wchar_to_utf8_no_alloc(wFindFileData.cFileName, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName));
|
||||
wchar_to_utf8_no_alloc(wFindFileData.cAlternateFileName, lpFindFileData->cAlternateFileName, sizeof(lpFindFileData->cAlternateFileName));
|
||||
}
|
||||
wfree(lpFileName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline BOOL FindNextFileU(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
WIN32_FIND_DATAW wFindFileData = { 0 };
|
||||
ret = FindNextFileW(hFindFile, &wFindFileData);
|
||||
if (ret) {
|
||||
memcpy(lpFindFileData, &wFindFileData, offsetof(WIN32_FIND_DATAW, cFileName));
|
||||
wchar_to_utf8_no_alloc(wFindFileData.cFileName, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName));
|
||||
wchar_to_utf8_no_alloc(wFindFileData.cAlternateFileName, lpFindFileData->cAlternateFileName, sizeof(lpFindFileData->cAlternateFileName));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// This function differs from regular GetTextExtentPoint in that it uses a zero terminated string
|
||||
static __inline BOOL GetTextExtentPointU(HDC hdc, const char* lpString, LPSIZE lpSize)
|
||||
{
|
||||
|
@ -819,6 +870,28 @@ static __inline BOOL SetFileAttributesU(const char* lpFileName, DWORD dwFileAttr
|
|||
return ret;
|
||||
}
|
||||
|
||||
static __inline DWORD GetNamedSecurityInfoU(const char* lpObjectName, SE_OBJECT_TYPE ObjectType,
|
||||
SECURITY_INFORMATION SecurityInfo, PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl,
|
||||
PACL* ppSacl, PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
|
||||
{
|
||||
DWORD ret;
|
||||
wconvert(lpObjectName);
|
||||
ret = GetNamedSecurityInfoW(wlpObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup,
|
||||
ppDacl, ppSacl, ppSecurityDescriptor);
|
||||
wfree(lpObjectName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline DWORD SetNamedSecurityInfoU(const char* lpObjectName, SE_OBJECT_TYPE ObjectType,
|
||||
SECURITY_INFORMATION SecurityInfo, PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
|
||||
{
|
||||
DWORD ret;
|
||||
wconvert(lpObjectName);
|
||||
ret = SetNamedSecurityInfoW(wlpObjectName, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
|
||||
wfree(lpObjectName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline int SHCreateDirectoryExU(HWND hwnd, const char* pszPath, SECURITY_ATTRIBUTES *psa)
|
||||
{
|
||||
int ret = ERROR_INVALID_DATA;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue