ReactOS 0.4.15-dev-8100-g1887773
misc.c File Reference
#include "setupapi_private.h"
#include <winver.h>
#include <lzexpand.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  callback_context
 

Functions

DWORD GetFunctionPointer (IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
 
DWORD FreeFunctionPointer (IN HMODULE ModulePointer, IN PVOID FunctionPointer)
 
VOID WINAPI MyFree (LPVOID lpMem)
 
LPVOID WINAPI MyMalloc (DWORD dwSize)
 
LPVOID WINAPI MyRealloc (LPVOID lpSrc, DWORD dwSize)
 
LPWSTR WINAPI pSetupDuplicateString (LPCWSTR lpSrc)
 
LONG WINAPI QueryRegistryValue (HKEY hKey, LPCWSTR lpValueName, LPBYTE *lpData, LPDWORD lpType, LPDWORD lpcbData)
 
LPWSTR WINAPI pSetupMultiByteToUnicode (LPCSTR lpMultiByteStr, UINT uCodePage)
 
LPSTR WINAPI pSetupUnicodeToMultiByte (LPCWSTR lpUnicodeStr, UINT uCodePage)
 
BOOL WINAPI DoesUserHavePrivilege (LPCWSTR lpPrivilegeName)
 
BOOL WINAPI pSetupEnablePrivilege (LPCWSTR lpPrivilegeName, BOOL bEnable)
 
BOOL WINAPI DelayedMove (LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
 
BOOL WINAPI FileExists (LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFileFindData)
 
DWORD WINAPI CaptureStringArg (LPCWSTR pSrc, LPWSTR *pDst)
 
DWORD WINAPI pSetupCaptureAndConvertAnsiArg (LPCSTR pSrc, LPWSTR *pDst)
 
DWORD WINAPI pSetupOpenAndMapFileForRead (LPCWSTR lpFileName, LPDWORD lpSize, LPHANDLE lpFile, LPHANDLE lpMapping, LPVOID *lpBuffer)
 
BOOL WINAPI pSetupUnmapAndCloseFile (HANDLE hFile, HANDLE hMapping, LPVOID lpBuffer)
 
DWORD WINAPI StampFileSecurity (LPCWSTR lpFileName, PSECURITY_DESCRIPTOR pSecurityDescriptor)
 
DWORD WINAPI TakeOwnershipOfFile (LPCWSTR lpFileName)
 
DWORD WINAPI RetreiveFileSecurity (LPCWSTR lpFileName, PSECURITY_DESCRIPTOR *pSecurityDescriptor)
 
DWORD WINAPI pSetupGetGlobalFlags (void)
 
void WINAPI pSetupModifyGlobalFlags (DWORD mask, DWORD flags)
 
void WINAPI pSetupSetGlobalFlags (DWORD flags)
 
BOOL WINAPI SetupGetNonInteractiveMode (VOID)
 
BOOL WINAPI SetupSetNonInteractiveMode (BOOL NonInteractiveFlag)
 
VOID WINAPI AssertFail (LPSTR lpFile, UINT uLine, LPSTR lpMessage)
 
DWORD WINAPI GetSetFileTimestamp (LPCWSTR lpFileName, LPFILETIME lpCreationTime, LPFILETIME lpLastAccessTime, LPFILETIME lpLastWriteTime, BOOLEAN bSetFileTime)
 
LPWSTR WINAPI pSetupGetFileTitle (LPCWSTR lpFileName)
 
BOOL WINAPI pSetupConcatenatePaths (LPWSTR lpPath, LPCWSTR lpAppend, DWORD dwBufferSize, LPDWORD lpRequiredSize)
 
VOID WINAPI pSetupCenterWindowRelativeToParent (HWND hwnd)
 
BOOL WINAPI pSetupGetVersionInfoFromImage (LPWSTR lpFileName, PULARGE_INTEGER lpFileVersion, LPWORD lpVersionVarSize)
 
BOOL WINAPI SetupUninstallOEMInfW (PCWSTR inf_file, DWORD flags, PVOID reserved)
 
BOOL WINAPI SetupUninstallOEMInfA (PCSTR inf_file, DWORD flags, PVOID reserved)
 
DWORD WINAPI InstallCatalog (LPCSTR catalog, LPCSTR basename, LPSTR fullname)
 
DWORD WINAPI pSetupInstallCatalog (LPCWSTR catalog, LPCWSTR basename, LPWSTR fullname)
 
static UINT detect_compression_type (LPCWSTR file)
 
static BOOL get_file_size (LPCWSTR file, DWORD *size)
 
static BOOL get_file_sizes_none (LPCWSTR source, DWORD *source_size, DWORD *target_size)
 
static BOOL get_file_sizes_lz (LPCWSTR source, DWORD *source_size, DWORD *target_size)
 
static UINT CALLBACK file_compression_info_callback (PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
 
static BOOL get_file_sizes_cab (LPCWSTR source, DWORD *source_size, DWORD *target_size)
 
BOOL WINAPI SetupGetFileCompressionInfoExA (PCSTR source, PSTR name, DWORD len, PDWORD required, PDWORD source_size, PDWORD target_size, PUINT type)
 
BOOL WINAPI SetupGetFileCompressionInfoExW (PCWSTR source, PWSTR name, DWORD len, PDWORD required, PDWORD source_size, PDWORD target_size, PUINT type)
 
DWORD WINAPI SetupGetFileCompressionInfoA (PCSTR source, PSTR *name, PDWORD source_size, PDWORD target_size, PUINT type)
 
DWORD WINAPI SetupGetFileCompressionInfoW (PCWSTR source, PWSTR *name, PDWORD source_size, PDWORD target_size, PUINT type)
 
static DWORD decompress_file_lz (LPCWSTR source, LPCWSTR target)
 
static UINT CALLBACK decompress_or_copy_callback (PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
 
static DWORD decompress_file_cab (LPCWSTR source, LPCWSTR target)
 
DWORD WINAPI SetupDecompressOrCopyFileA (PCSTR source, PCSTR target, PUINT type)
 
DWORD WINAPI SetupDecompressOrCopyFileW (PCWSTR source, PCWSTR target, PUINT type)
 
static BOOL TrimGuidString (PCWSTR szString, LPWSTR szNewString)
 
DWORD WINAPI pSetupGuidFromString (PCWSTR pString, LPGUID lpGUID)
 
DWORD WINAPI pSetupStringFromGuid (LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
 
BOOL WINAPI pSetupIsGuidNull (LPGUID lpGUID)
 
BOOL WINAPI pSetupIsUserAdmin (VOID)
 
HSPFILELOG WINAPI SetupInitializeFileLogW (LPCWSTR LogFileName, DWORD Flags)
 
HSPFILELOG WINAPI SetupInitializeFileLogA (LPCSTR LogFileName, DWORD Flags)
 
BOOL WINAPI SetupTerminateFileLog (HANDLE FileLogHandle)
 
void WINAPI SetupCloseLog (void)
 
BOOL WINAPI SetupOpenLog (BOOL reserved)
 
BOOL WINAPI SetupLogErrorA (LPCSTR message, LogSeverity severity)
 
BOOL WINAPI SetupLogErrorW (LPCWSTR message, LogSeverity severity)
 

Variables

static const WCHAR BackSlash [] = {'\\',0}
 
static const WCHAR TranslationRegKey [] = {'\\','V','e','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n',0}
 
static HANDLE setupact = INVALID_HANDLE_VALUE
 
static HANDLE setuperr = INVALID_HANDLE_VALUE
 
static CRITICAL_SECTION setupapi_cs = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
DWORD GlobalSetupFlags = 0
 

Function Documentation

◆ AssertFail()

VOID WINAPI AssertFail ( LPSTR  lpFile,
UINT  uLine,
LPSTR  lpMessage 
)

Definition at line 905 of file misc.c.

906{
907 CHAR szModule[MAX_PATH];
908 CHAR szBuffer[2048];
910// LPSTR lpBuffer;
911
912 TRACE("%s %u %s\n", lpFile, uLine, lpMessage);
913
915 lpName = strrchr(szModule, '\\');
916 if (lpName != NULL)
917 lpName++;
918 else
919 lpName = szModule;
920
921 wsprintfA(szBuffer,
922 "Assertion failure at line %u in file %s: %s\n\nCall DebugBreak()?",
923 uLine, lpFile, lpMessage);
924
925 if (MessageBoxA(NULL, szBuffer, lpName, MB_SETFOREGROUND |
927 DebugBreak();
928}
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR lpName
Definition: winbase.h:2789
void WINAPI DebugBreak(void)
#define MB_SETFOREGROUND
Definition: winuser.h:814
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_TASKMODAL
Definition: winuser.h:816
#define MB_YESNO
Definition: winuser.h:817
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)
#define MB_ICONERROR
Definition: winuser.h:787
#define IDYES
Definition: winuser.h:835
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

◆ CaptureStringArg()

DWORD WINAPI CaptureStringArg ( LPCWSTR  pSrc,
LPWSTR pDst 
)

Definition at line 547 of file misc.c.

548{
549 if (pDst == NULL)
551
552 *pDst = pSetupDuplicateString(pSrc);
553
554 return ERROR_SUCCESS;
555}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LPWSTR WINAPI pSetupDuplicateString(LPCWSTR lpSrc)
Definition: misc.c:198

◆ decompress_file_cab()

static DWORD decompress_file_cab ( LPCWSTR  source,
LPCWSTR  target 
)
static

Definition at line 1640 of file misc.c.

1641{
1642 struct callback_context context = {0, target};
1643 BOOL ret;
1644
1646
1647 if (ret) return ERROR_SUCCESS;
1648 else return GetLastError();
1649}
static UINT CALLBACK decompress_or_copy_callback(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: misc.c:1618
BOOL WINAPI SetupIterateCabinetW(PCWSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_W MsgHandler, PVOID Context)
Definition: setupcab.c:575
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum target
Definition: glext.h:7315
Definition: http.c:7252
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by SetupDecompressOrCopyFileW().

◆ decompress_file_lz()

static DWORD decompress_file_lz ( LPCWSTR  source,
LPCWSTR  target 
)
static

Definition at line 1582 of file misc.c.

1583{
1584 DWORD ret;
1585 LONG error;
1586 INT src, dst;
1587 OFSTRUCT sof, dof;
1588
1589 if ((src = LZOpenFileW( (LPWSTR)source, &sof, OF_READ )) < 0)
1590 {
1591 ERR("cannot open source file for reading\n");
1592 return ERROR_FILE_NOT_FOUND;
1593 }
1594 if ((dst = LZOpenFileW( (LPWSTR)target, &dof, OF_CREATE )) < 0)
1595 {
1596 ERR("cannot open target file for writing\n");
1597 LZClose( src );
1598 return ERROR_FILE_NOT_FOUND;
1599 }
1600 if ((error = LZCopy( src, dst )) >= 0) ret = ERROR_SUCCESS;
1601 else
1602 {
1603 WARN("failed to decompress file %d\n", error);
1605 }
1606
1607 LZClose( src );
1608 LZClose( dst );
1609 return ret;
1610}
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:580
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:467
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:595
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
long LONG
Definition: pedump.c:60
int32_t INT
Definition: typedefs.h:58
#define OF_READ
Definition: winbase.h:116
#define OF_CREATE
Definition: winbase.h:125
#define ERROR_INVALID_DATA
Definition: winerror.h:116
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SetupDecompressOrCopyFileW().

◆ decompress_or_copy_callback()

static UINT CALLBACK decompress_or_copy_callback ( PVOID  context,
UINT  notification,
UINT_PTR  param1,
UINT_PTR  param2 
)
static

Definition at line 1618 of file misc.c.

1619{
1620 struct callback_context *context_info = context;
1622
1623 switch (notification)
1624 {
1626 {
1627 if (context_info->has_extracted)
1628 return FILEOP_ABORT;
1629
1630 TRACE("Requesting extraction of cabinet file %s\n",
1631 wine_dbgstr_w(info->NameInCabinet));
1632 strcpyW( info->FullTargetName, context_info->target );
1633 context_info->has_extracted = TRUE;
1634 return FILEOP_DOIT;
1635 }
1636 default: return NO_ERROR;
1637 }
1638}
#define NO_ERROR
Definition: dderror.h:5
#define TRUE
Definition: types.h:120
#define FILEOP_DOIT
Definition: fileqsup.h:48
#define FILEOP_ABORT
Definition: fileqsup.h:47
#define wine_dbgstr_w
Definition: kernel32.h:34
#define strcpyW(d, s)
Definition: unicode.h:35
#define SPFILENOTIFY_FILEINCABINET
Definition: setupapi.h:562
BOOL has_extracted
Definition: misc.c:1614
LPCWSTR target
Definition: misc.c:1615

Referenced by decompress_file_cab().

◆ DelayedMove()

BOOL WINAPI DelayedMove ( LPCWSTR  lpExistingFileName,
LPCWSTR  lpNewFileName 
)

Definition at line 482 of file misc.c.

483{
484 return MoveFileExW(lpExistingFileName, lpNewFileName,
486}
BOOL WINAPI MoveFileExW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName OPTIONAL, IN DWORD dwFlags)
Definition: move.c:1120
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:400

◆ detect_compression_type()

static UINT detect_compression_type ( LPCWSTR  file)
static

Definition at line 1293 of file misc.c.

1294{
1295 DWORD size;
1296 HANDLE handle;
1298 static const BYTE LZ_MAGIC[] = { 0x53, 0x5a, 0x44, 0x44, 0x88, 0xf0, 0x27, 0x33 };
1299 static const BYTE MSZIP_MAGIC[] = { 0x4b, 0x57, 0x41, 0x4a };
1300 static const BYTE NTCAB_MAGIC[] = { 0x4d, 0x53, 0x43, 0x46 };
1301 BYTE buffer[8];
1302
1305 {
1306 ERR("cannot open file %s\n", debugstr_w(file));
1307 return FILE_COMPRESSION_NONE;
1308 }
1309 if (!ReadFile( handle, buffer, sizeof(buffer), &size, NULL ) || size != sizeof(buffer))
1310 {
1312 return FILE_COMPRESSION_NONE;
1313 }
1314 if (!memcmp( buffer, LZ_MAGIC, sizeof(LZ_MAGIC) )) type = FILE_COMPRESSION_WINLZA;
1316 else if (!memcmp( buffer, NTCAB_MAGIC, sizeof(NTCAB_MAGIC) )) type = FILE_COMPRESSION_MSZIP; /* not a typo */
1317
1319 return type;
1320}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MSZIP_MAGIC
Definition: cabinet.c:218
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
#define debugstr_w
Definition: kernel32.h:32
unsigned int UINT
Definition: ndis.h:50
#define FILE_COMPRESSION_WINLZA
Definition: setupapi.h:359
#define FILE_COMPRESSION_MSZIP
Definition: setupapi.h:362
#define FILE_COMPRESSION_NONE
Definition: setupapi.h:356
Definition: fci.c:127
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SetupDecompressOrCopyFileW(), and SetupGetFileCompressionInfoExW().

◆ DoesUserHavePrivilege()

BOOL WINAPI DoesUserHavePrivilege ( LPCWSTR  lpPrivilegeName)

Definition at line 366 of file misc.c.

367{
368 HANDLE hToken;
370 PTOKEN_PRIVILEGES lpPrivileges;
371 LUID PrivilegeLuid;
372 DWORD i;
373 BOOL bResult = FALSE;
374
375 TRACE("%s\n", debugstr_w(lpPrivilegeName));
376
378 return FALSE;
379
381 {
383 {
384 CloseHandle(hToken);
385 return FALSE;
386 }
387 }
388
389 lpPrivileges = MyMalloc(dwSize);
390 if (lpPrivileges == NULL)
391 {
392 CloseHandle(hToken);
393 return FALSE;
394 }
395
396 if (!GetTokenInformation(hToken, TokenPrivileges, lpPrivileges, dwSize, &dwSize))
397 {
398 MyFree(lpPrivileges);
399 CloseHandle(hToken);
400 return FALSE;
401 }
402
403 CloseHandle(hToken);
404
405 if (!LookupPrivilegeValueW(NULL, lpPrivilegeName, &PrivilegeLuid))
406 {
407 MyFree(lpPrivileges);
408 return FALSE;
409 }
410
411 for (i = 0; i < lpPrivileges->PrivilegeCount; i++)
412 {
413 if (lpPrivileges->Privileges[i].Luid.HighPart == PrivilegeLuid.HighPart &&
414 lpPrivileges->Privileges[i].Luid.LowPart == PrivilegeLuid.LowPart)
415 {
416 bResult = TRUE;
417 }
418 }
419
420 MyFree(lpPrivileges);
421
422 return bResult;
423}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define GetCurrentProcess()
Definition: compat.h:759
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
LONG HighPart
DWORD LowPart
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenPrivileges
Definition: setypes.h:968

◆ file_compression_info_callback()

static UINT CALLBACK file_compression_info_callback ( PVOID  context,
UINT  notification,
UINT_PTR  param1,
UINT_PTR  param2 
)
static

Definition at line 1373 of file misc.c.

1374{
1375 DWORD *size = context;
1377
1378 switch (notification)
1379 {
1381 {
1382 *size = info->FileSize;
1383 return FILEOP_SKIP;
1384 }
1385 default: return NO_ERROR;
1386 }
1387}
#define FILEOP_SKIP
Definition: fileqsup.h:49

Referenced by get_file_sizes_cab().

◆ FileExists()

BOOL WINAPI FileExists ( LPCWSTR  lpFileName,
LPWIN32_FIND_DATAW  lpFileFindData 
)

Definition at line 502 of file misc.c.

503{
504 WIN32_FIND_DATAW FindData;
505 HANDLE hFind;
506 UINT uErrorMode;
507 DWORD dwError;
508
510
511 hFind = FindFirstFileW(lpFileName, &FindData);
512 if (hFind == INVALID_HANDLE_VALUE)
513 {
514 dwError = GetLastError();
515 SetErrorMode(uErrorMode);
516 SetLastError(dwError);
517 return FALSE;
518 }
519
520 FindClose(hFind);
521
522 if (lpFileFindData)
523 memcpy(lpFileFindData, &FindData, sizeof(WIN32_FIND_DATAW));
524
525 SetErrorMode(uErrorMode);
526
527 return TRUE;
528}
#define SetLastError(x)
Definition: compat.h:752
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:751
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
_In_ LPCSTR lpFileName
Definition: winbase.h:3071

Referenced by SetupInitializeFileLogW().

◆ FreeFunctionPointer()

DWORD FreeFunctionPointer ( IN HMODULE  ModulePointer,
IN PVOID  FunctionPointer 
)

Definition at line 105 of file misc.c.

108{
109 if (ModulePointer == NULL)
110 return ERROR_SUCCESS;
111 if (FreeLibrary(ModulePointer))
112 return ERROR_SUCCESS;
113 else
114 return GetLastError();
115}
#define FreeLibrary(x)
Definition: compat.h:748

Referenced by SetupDiCallClassInstaller().

◆ get_file_size()

static BOOL get_file_size ( LPCWSTR  file,
DWORD size 
)
static

Definition at line 1322 of file misc.c.

1323{
1324 HANDLE handle;
1325
1328 {
1329 ERR("cannot open file %s\n", debugstr_w(file));
1330 return FALSE;
1331 }
1332 *size = GetFileSize( handle, NULL );
1334 return TRUE;
1335}
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331

◆ get_file_sizes_cab()

static BOOL get_file_sizes_cab ( LPCWSTR  source,
DWORD source_size,
DWORD target_size 
)
static

Definition at line 1389 of file misc.c.

1390{
1391 DWORD size;
1392 BOOL ret = TRUE;
1393
1394 if (source_size)
1395 {
1396 if (!get_file_size( source, &size )) ret = FALSE;
1397 else *source_size = size;
1398 }
1399 if (target_size)
1400 {
1402 }
1403 return ret;
1404}
static UINT CALLBACK file_compression_info_callback(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: misc.c:1373
static DWORD get_file_size(void)
Definition: integrity.c:149

Referenced by SetupGetFileCompressionInfoExW().

◆ get_file_sizes_lz()

static BOOL get_file_sizes_lz ( LPCWSTR  source,
DWORD source_size,
DWORD target_size 
)
static

Definition at line 1347 of file misc.c.

1348{
1349 DWORD size;
1350 BOOL ret = TRUE;
1351
1352 if (source_size)
1353 {
1354 if (!get_file_size( source, &size )) ret = FALSE;
1355 else *source_size = size;
1356 }
1357 if (target_size)
1358 {
1359 INT file;
1360 OFSTRUCT of;
1361
1362 if ((file = LZOpenFileW( (LPWSTR)source, &of, OF_READ )) < 0)
1363 {
1364 ERR("cannot open source file for reading\n");
1365 return FALSE;
1366 }
1367 *target_size = LZSeek( file, 0, 2 );
1368 LZClose( file );
1369 }
1370 return ret;
1371}
LONG WINAPI LZSeek(HFILE fd, LONG off, INT type)
Definition: lzexpand.c:431

Referenced by SetupGetFileCompressionInfoExW().

◆ get_file_sizes_none()

static BOOL get_file_sizes_none ( LPCWSTR  source,
DWORD source_size,
DWORD target_size 
)
static

Definition at line 1337 of file misc.c.

1338{
1339 DWORD size;
1340
1341 if (!get_file_size( source, &size )) return FALSE;
1342 if (source_size) *source_size = size;
1343 if (target_size) *target_size = size;
1344 return TRUE;
1345}

Referenced by SetupGetFileCompressionInfoExW().

◆ GetFunctionPointer()

DWORD GetFunctionPointer ( IN PWSTR  InstallerName,
OUT HMODULE ModulePointer,
OUT PVOID FunctionPointer 
)

Definition at line 44 of file misc.c.

48{
50 LPSTR FunctionNameA = NULL;
51 PWCHAR Comma;
52 DWORD rc;
53
54 *ModulePointer = NULL;
55 *FunctionPointer = NULL;
56
57 Comma = strchrW(InstallerName, ',');
58 if (!Comma)
59 {
61 goto cleanup;
62 }
63
64 /* Load library */
65 *Comma = '\0';
66 hModule = LoadLibraryW(InstallerName);
67 *Comma = ',';
68 if (!hModule)
69 {
70 rc = GetLastError();
71 goto cleanup;
72 }
73
74 /* Skip comma spaces */
75 while (*Comma == ',' || isspaceW(*Comma))
76 Comma++;
77
78 /* W->A conversion for function name */
79 FunctionNameA = pSetupUnicodeToMultiByte(Comma, CP_ACP);
80 if (!FunctionNameA)
81 {
82 rc = GetLastError();
83 goto cleanup;
84 }
85
86 /* Search function */
87 *FunctionPointer = GetProcAddress(hModule, FunctionNameA);
88 if (!*FunctionPointer)
89 {
90 rc = GetLastError();
91 goto cleanup;
92 }
93
94 *ModulePointer = hModule;
95 rc = ERROR_SUCCESS;
96
98 if (rc != ERROR_SUCCESS && hModule)
100 MyFree(FunctionNameA);
101 return rc;
102}
HMODULE hModule
Definition: animate.c:44
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
static void cleanup(void)
Definition: main.c:1335
LPSTR WINAPI pSetupUnicodeToMultiByte(LPCWSTR lpUnicodeStr, UINT uCodePage)
Definition: misc.c:327
#define strchrW(s, c)
Definition: unicode.h:40
#define isspaceW(n)
Definition: unicode.h:58
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by SetupDiCallClassInstaller(), and SetupDiGetClassDevPropertySheetsW().

◆ GetSetFileTimestamp()

DWORD WINAPI GetSetFileTimestamp ( LPCWSTR  lpFileName,
LPFILETIME  lpCreationTime,
LPFILETIME  lpLastAccessTime,
LPFILETIME  lpLastWriteTime,
BOOLEAN  bSetFileTime 
)

Definition at line 948 of file misc.c.

953{
955 BOOLEAN bRet;
956 DWORD dwError = ERROR_SUCCESS;
957
958 TRACE("%s %p %p %p %x\n", debugstr_w(lpFileName), lpCreationTime,
959 lpLastAccessTime, lpLastWriteTime, bSetFileTime);
960
962 bSetFileTime ? GENERIC_WRITE : GENERIC_READ,
964 NULL,
966 0,
967 NULL);
968
970 return GetLastError();
971
972 if (bSetFileTime)
973 bRet = SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime);
974 else
975 bRet = GetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime);
976
977 if (bRet == FALSE)
978 dwError = GetLastError();
979
981
982 return dwError;
983}
unsigned char BOOLEAN
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetFileTime(IN HANDLE hFile, CONST FILETIME *lpCreationTime OPTIONAL, CONST FILETIME *lpLastAccessTime OPTIONAL, CONST FILETIME *lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:948
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90

◆ InstallCatalog()

DWORD WINAPI InstallCatalog ( LPCSTR  catalog,
LPCSTR  basename,
LPSTR  fullname 
)

Definition at line 1259 of file misc.c.

1260{
1261 FIXME("%s, %s, %p\n", debugstr_a(catalog), debugstr_a(basename), fullname);
1262 return 0;
1263}
#define FIXME(fmt,...)
Definition: debug.h:114
static void basename(LPCWSTR path, LPWSTR name)
Definition: profile.c:38
#define debugstr_a
Definition: kernel32.h:31
const char * fullname
Definition: shader.c:1766

◆ MyFree()

VOID WINAPI MyFree ( LPVOID  lpMem)

Definition at line 128 of file misc.c.

129{
130 TRACE("%p\n", lpMem);
131 HeapFree(GetProcessHeap(), 0, lpMem);
132}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by AddDriverToList(), CheckSectionValid(), CM_Add_ID_ExA(), CM_Connect_MachineA(), CM_Create_DevNode_ExA(), CM_Delete_DevNode_Key_Ex(), CM_Free_Resource_Conflict_Handle(), CM_Get_Device_ID_List_ExA(), CM_Get_Device_ID_List_Size_ExA(), CM_Get_Device_Interface_List_ExA(), CM_Get_Device_Interface_List_Size_ExA(), CM_Get_DevNode_Custom_Property_ExA(), CM_Get_HW_Prof_Flags_ExA(), CM_Locate_DevNode_ExA(), CM_Open_Class_Key_ExA(), CM_Open_DevNode_Key_Ex(), CM_Query_Resource_Conflict_List(), CM_Register_Device_Interface_ExA(), CM_Set_DevNode_Registry_Property_ExA(), CM_Set_HW_Prof_Flags_ExA(), CM_Unregister_Device_Interface_ExA(), DoesUserHavePrivilege(), FixupServiceBinaryPath(), GetDeviceInstanceKeyPath(), GetFunctionPointer(), GetHardwareAndCompatibleIDsLists(), GetStringField(), InfIsFromOEMLocation(), InstallOneService(), profile_items_callback(), pSetupGetVersionInfoFromImage(), pSetupMultiByteToUnicode(), pSetupStringTableAddString(), pSetupStringTableAddStringEx(), pSetupStringTableDestroy(), pSetupStringTableDuplicate(), pSetupStringTableInitialize(), pSetupStringTableInitializeEx(), pSetupUnicodeToMultiByte(), QueryRegistryValue(), registry_callback(), RetreiveFileSecurity(), SETUP_GetClassIconInfo(), SETUP_GetIconIndex(), SETUP_PropertyAddPropertyAdvancedHandler(), SETUP_PropertyChangeHandler(), SetupCopyOEMInfA(), SetupCopyOEMInfW(), SetupDecompressOrCopyFileA(), SetupDiBuildClassInfoListExA(), SetupDiBuildDriverInfoList(), SetupDiClassGuidsFromNameExA(), SetupDiClassNameFromGuidExA(), SetupDiClassNameFromGuidExW(), SetupDiCreateDeviceInfoA(), SetupDiCreateDeviceInfoListExA(), SetupDiCreateDeviceInfoListExW(), SetupDiCreateDeviceInterfaceA(), SetupDiCreateDeviceInterfaceRegKeyA(), SetupDiCreateDevRegKeyA(), SetupDiDestroyClassImageList(), SetupDiGetActualSectionToInstallExA(), SetupDiGetClassDescriptionExA(), SetupDiGetClassDescriptionExW(), SetupDiGetClassDevsExA(), SetupDiGetClassImageListExA(), SetupDiGetClassImageListExW(), SetupDiGetDeviceInstanceIdA(), SetupDiGetDeviceInterfaceDetailA(), SetupDiGetDriverInfoDetailA(), SetupDiGetDriverInfoDetailW(), SetupDiGetINFClassA(), SetupDiInstallClassExA(), SetupDiInstallDeviceInterfaces(), SetupDiLoadClassIcon(), SetupDiOpenClassRegKeyExA(), SetupDiOpenDeviceInfoA(), SetupDiOpenDeviceInterfaceA(), SetupGetFileCompressionInfoA(), SetupGetFileCompressionInfoExA(), SetupGetFileCompressionInfoW(), SetupGetInfFileListA(), SetupGetInfFileListW(), SetupQueueCopySectionW(), TakeOwnershipOfFile(), and test_SetupGetFileCompressionInfo().

◆ MyMalloc()

LPVOID WINAPI MyMalloc ( DWORD  dwSize)

Definition at line 147 of file misc.c.

148{
149 TRACE("%lu\n", dwSize);
150 return HeapAlloc(GetProcessHeap(), 0, dwSize);
151}
#define HeapAlloc
Definition: compat.h:733

Referenced by AddDriverToList(), CM_Delete_DevNode_Key_Ex(), CM_Get_Device_ID_List_ExA(), CM_Get_Device_Interface_List_ExA(), CM_Open_DevNode_Key_Ex(), CM_Query_Resource_Conflict_List(), CM_Set_DevNode_Registry_Property_ExA(), Concatenate(), DoesUserHavePrivilege(), FixupServiceBinaryPath(), GetDeviceInstanceKeyPath(), GetHardwareAndCompatibleIDsLists(), GetStringField(), InfIsFromOEMLocation(), InstallOneService(), profile_items_callback(), pSetupDuplicateString(), pSetupGetVersionInfoFromImage(), pSetupMultiByteToUnicode(), pSetupStringTableAddString(), pSetupStringTableAddStringEx(), pSetupStringTableDuplicate(), pSetupStringTableInitialize(), pSetupStringTableInitializeEx(), pSetupStringTableSetExtraData(), pSetupUnicodeToMultiByte(), QueryRegistryValue(), registry_callback(), RetreiveFileSecurity(), SETUP_GetClassIconInfo(), SETUP_GetIconIndex(), SETUP_PropertyAddPropertyAdvancedHandler(), SETUP_PropertyChangeHandler(), SetupCopyOEMInfA(), SetupCopyOEMInfW(), SetupDiCreateDeviceInfoListExW(), SetupDiGetActualSectionToInstallExA(), SetupDiGetClassDescriptionExA(), SetupDiGetDeviceInstanceIdA(), SetupDiGetDeviceInterfaceDetailA(), SetupDiGetDriverInfoDetailA(), SetupDiGetINFClassA(), SetupGetFileCompressionInfoA(), SetupGetFileCompressionInfoW(), SetupGetInfFileListA(), SetupGetInfFileListW(), SetupQueueCopySectionW(), and TakeOwnershipOfFile().

◆ MyRealloc()

LPVOID WINAPI MyRealloc ( LPVOID  lpSrc,
DWORD  dwSize 
)

Definition at line 172 of file misc.c.

173{
174 TRACE("%p %lu\n", lpSrc, dwSize);
175
176 if (lpSrc == NULL)
177 return HeapAlloc(GetProcessHeap(), 0, dwSize);
178
179 return HeapReAlloc(GetProcessHeap(), 0, lpSrc, dwSize);
180}
#define HeapReAlloc
Definition: compat.h:734

Referenced by RetreiveFileSecurity().

◆ pSetupCaptureAndConvertAnsiArg()

◆ pSetupCenterWindowRelativeToParent()

VOID WINAPI pSetupCenterWindowRelativeToParent ( HWND  hwnd)

Definition at line 1108 of file misc.c.

1109{
1110 HWND hwndOwner;
1111 POINT ptOrigin;
1112 RECT rcWindow;
1113 RECT rcOwner;
1114 INT nWindowWidth, nWindowHeight;
1115 INT nOwnerWidth, nOwnerHeight;
1116 INT posX, posY;
1117
1118 hwndOwner = GetWindow(hwnd, GW_OWNER);
1119 if (hwndOwner == NULL)
1120 return;
1121
1122 ptOrigin.x = 0;
1123 ptOrigin.y = 0;
1124 ClientToScreen(hwndOwner, &ptOrigin);
1125
1126 GetWindowRect(hwnd, &rcWindow);
1127 GetClientRect(hwndOwner, &rcOwner);
1128
1129 nWindowWidth = rcWindow.right - rcWindow.left;
1130 nWindowHeight = rcWindow.bottom - rcWindow.top;
1131
1132 nOwnerWidth = rcOwner.right - rcOwner.left;
1133 nOwnerHeight = rcOwner.bottom - rcOwner.top;
1134
1135 posX = ((nOwnerWidth - nWindowWidth) / 2) + ptOrigin.x;
1136 posY = ((nOwnerHeight - nWindowHeight) / 2) + ptOrigin.y;
1137
1138 MoveWindow(hwnd, posX, posY, nWindowWidth, nWindowHeight, 0);
1139}
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define GW_OWNER
Definition: winuser.h:766
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

◆ pSetupConcatenatePaths()

BOOL WINAPI pSetupConcatenatePaths ( LPWSTR  lpPath,
LPCWSTR  lpAppend,
DWORD  dwBufferSize,
LPDWORD  lpRequiredSize 
)

Definition at line 1040 of file misc.c.

1044{
1045 DWORD dwPathSize;
1046 DWORD dwAppendSize;
1047 DWORD dwTotalSize;
1048 BOOL bBackslash = FALSE;
1049
1050 TRACE("%s %s %lu %p\n", debugstr_w(lpPath), debugstr_w(lpAppend),
1051 dwBufferSize, lpRequiredSize);
1052
1053 dwPathSize = lstrlenW(lpPath);
1054
1055 /* Ignore trailing backslash */
1056 if (lpPath[dwPathSize - 1] == (WCHAR)'\\')
1057 dwPathSize--;
1058
1059 dwAppendSize = lstrlenW(lpAppend);
1060
1061 /* Does the source string have a leading backslash? */
1062 if (lpAppend[0] == (WCHAR)'\\')
1063 {
1064 bBackslash = TRUE;
1065 dwAppendSize--;
1066 }
1067
1068 dwTotalSize = dwPathSize + dwAppendSize + 2;
1069 if (lpRequiredSize != NULL)
1070 *lpRequiredSize = dwTotalSize;
1071
1072 /* Append a backslash to the destination string */
1073 if (bBackslash == FALSE)
1074 {
1075 if (dwPathSize < dwBufferSize)
1076 {
1077 lpPath[dwPathSize - 1] = (WCHAR)'\\';
1078 dwPathSize++;
1079 }
1080 }
1081
1082 if (dwPathSize + dwAppendSize < dwBufferSize)
1083 {
1084 lstrcpynW(&lpPath[dwPathSize],
1085 lpAppend,
1086 dwAppendSize);
1087 }
1088
1089 if (dwBufferSize >= dwTotalSize)
1090 lpPath[dwTotalSize - 1] = 0;
1091
1092 return (dwBufferSize >= dwTotalSize);
1093}
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ pSetupDuplicateString()

LPWSTR WINAPI pSetupDuplicateString ( LPCWSTR  lpSrc)

Definition at line 198 of file misc.c.

199{
200 LPWSTR lpDst;
201
202 TRACE("%s\n", debugstr_w(lpSrc));
203
204 lpDst = MyMalloc((lstrlenW(lpSrc) + 1) * sizeof(WCHAR));
205 if (lpDst == NULL)
206 return NULL;
207
208 strcpyW(lpDst, lpSrc);
209
210 return lpDst;
211}

Referenced by CaptureStringArg(), CheckSectionValid(), and profile_items_callback().

◆ pSetupEnablePrivilege()

BOOL WINAPI pSetupEnablePrivilege ( LPCWSTR  lpPrivilegeName,
BOOL  bEnable 
)

Definition at line 440 of file misc.c.

441{
443 HANDLE hToken;
444 BOOL bResult;
445
446 TRACE("%s %s\n", debugstr_w(lpPrivilegeName), bEnable ? "TRUE" : "FALSE");
447
449 return FALSE;
450
451 Privileges.PrivilegeCount = 1;
452 Privileges.Privileges[0].Attributes = (bEnable) ? SE_PRIVILEGE_ENABLED : 0;
453
454 if (!LookupPrivilegeValueW(NULL, lpPrivilegeName,
455 &Privileges.Privileges[0].Luid))
456 {
457 CloseHandle(hToken);
458 return FALSE;
459 }
460
461 bResult = AdjustTokenPrivileges(hToken, FALSE, &Privileges, 0, NULL, NULL);
462
463 CloseHandle(hToken);
464
465 return bResult;
466}
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
_In_ BOOL bEnable
Definition: winddi.h:3426
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET * Privileges
Definition: sefuncs.h:17
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by SaveDefaultUserHive().

◆ pSetupGetFileTitle()

LPWSTR WINAPI pSetupGetFileTitle ( LPCWSTR  lpFileName)

Definition at line 998 of file misc.c.

999{
1000 LPWSTR ptr;
1001 LPWSTR ret;
1002 WCHAR c;
1003
1004 TRACE("%s\n", debugstr_w(lpFileName));
1005
1007 ret = ptr;
1008 while (TRUE)
1009 {
1010 c = *ptr;
1011
1012 if (c == 0)
1013 break;
1014
1015 ptr++;
1016 if (c == (WCHAR)'\\' || c == (WCHAR)'/' || c == (WCHAR)':')
1017 ret = ptr;
1018 }
1019
1020 return ret;
1021}
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
static PVOID ptr
Definition: dispmode.c:27

◆ pSetupGetGlobalFlags()

DWORD WINAPI pSetupGetGlobalFlags ( void  )

Definition at line 850 of file misc.c.

851{
852 return GlobalSetupFlags;
853}
DWORD GlobalSetupFlags
Definition: misc.c:845

◆ pSetupGetVersionInfoFromImage()

BOOL WINAPI pSetupGetVersionInfoFromImage ( LPWSTR  lpFileName,
PULARGE_INTEGER  lpFileVersion,
LPWORD  lpVersionVarSize 
)

Definition at line 1158 of file misc.c.

1161{
1162 DWORD dwHandle;
1163 DWORD dwSize;
1164 LPVOID lpInfo;
1165 UINT uSize;
1166 VS_FIXEDFILEINFO *lpFixedInfo;
1167 LPWORD lpVarSize;
1168
1170 if (dwSize == 0)
1171 return FALSE;
1172
1173 lpInfo = MyMalloc(dwSize);
1174 if (lpInfo == NULL)
1175 return FALSE;
1176
1177 if (!GetFileVersionInfoW(lpFileName, 0, dwSize, lpInfo))
1178 {
1179 MyFree(lpInfo);
1180 return FALSE;
1181 }
1182
1183 if (!VerQueryValueW(lpInfo, BackSlash,
1184 (LPVOID*)&lpFixedInfo, &uSize))
1185 {
1186 MyFree(lpInfo);
1187 return FALSE;
1188 }
1189
1190 lpFileVersion->LowPart = lpFixedInfo->dwFileVersionLS;
1191 lpFileVersion->HighPart = lpFixedInfo->dwFileVersionMS;
1192
1193 *lpVersionVarSize = 0;
1194 if (!VerQueryValueW(lpInfo, TranslationRegKey,
1195 (LPVOID*)&lpVarSize, &uSize))
1196 {
1197 MyFree(lpInfo);
1198 return TRUE;
1199 }
1200
1201 if (uSize >= 4)
1202 {
1203 *lpVersionVarSize = *lpVarSize;
1204 }
1205
1206 MyFree(lpInfo);
1207
1208 return TRUE;
1209}
static const WCHAR TranslationRegKey[]
Definition: misc.c:29
static const WCHAR BackSlash[]
Definition: misc.c:28
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
$ULONG LowPart
Definition: ntbasedef.h:569
$ULONG HighPart
Definition: ntbasedef.h:570
uint16_t * LPWORD
Definition: typedefs.h:56

◆ pSetupGuidFromString()

DWORD WINAPI pSetupGuidFromString ( PCWSTR  pString,
LPGUID  lpGUID 
)

Definition at line 1751 of file misc.c.

1752{
1754 WCHAR szBuffer[39];
1755
1756 if (!TrimGuidString(pString, szBuffer))
1757 {
1759 }
1760
1761 Status = UuidFromStringW(szBuffer, lpGUID);
1762 if (Status != RPC_S_OK)
1763 {
1765 }
1766
1767 return NO_ERROR;
1768}
static BOOL TrimGuidString(PCWSTR szString, LPWSTR szNewString)
Definition: misc.c:1725
FxString * pString
Status
Definition: gdiplustypes.h:25
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:614
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_INVALID_STRING_UUID
Definition: winerror.h:1016

Referenced by DisplayClassProperties(), and GetDeviceDisplayInfo().

◆ pSetupInstallCatalog()

DWORD WINAPI pSetupInstallCatalog ( LPCWSTR  catalog,
LPCWSTR  basename,
LPWSTR  fullname 
)

Definition at line 1268 of file misc.c.

1269{
1270 HCATADMIN admin;
1271 HCATINFO cat;
1272
1273 TRACE ("%s, %s, %p\n", debugstr_w(catalog), debugstr_w(basename), fullname);
1274
1275 if (!CryptCATAdminAcquireContext(&admin,NULL,0))
1276 return GetLastError();
1277
1278 if (!(cat = CryptCATAdminAddCatalog( admin, (PWSTR)catalog, (PWSTR)basename, 0 )))
1279 {
1280 DWORD rc = GetLastError();
1282 return rc;
1283 }
1286
1287 if (fullname)
1288 FIXME("not returning full installed catalog path\n");
1289
1290 return NO_ERROR;
1291}
BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags)
Definition: crypt.c:444
HCATINFO WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile, PWSTR selectBaseName, DWORD flags)
Definition: crypt.c:162
BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
Definition: crypt.c:412
BOOL WINAPI CryptCATAdminAcquireContext(HCATADMIN *catAdmin, const GUID *sys, DWORD dwFlags)
Definition: crypt.c:97
uint16_t * PWSTR
Definition: typedefs.h:56

◆ pSetupIsGuidNull()

BOOL WINAPI pSetupIsGuidNull ( LPGUID  lpGUID)

Definition at line 1807 of file misc.c.

1808{
1809 return IsEqualGUID(lpGUID, &GUID_NULL);
1810}
#define GUID_NULL
Definition: ks.h:106
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

◆ pSetupIsUserAdmin()

BOOL WINAPI pSetupIsUserAdmin ( VOID  )

Definition at line 1817 of file misc.c.

1818{
1820 BOOL bResult = FALSE;
1821 PSID lpSid;
1822
1824 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
1825 &lpSid))
1826 {
1827 return FALSE;
1828 }
1829
1830 if (!CheckTokenMembership(NULL, lpSid, &bResult))
1831 {
1832 bResult = FALSE;
1833 }
1834
1835 FreeSid(lpSid);
1836
1837 return bResult;
1838}
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by CM_Add_Empty_Log_Conf_Ex(), CM_Add_ID_ExW(), CM_Create_DevNode_ExW(), CM_Delete_DevNode_Key_Ex(), CM_Disable_DevNode_Ex(), CM_Enable_DevNode_Ex(), CM_Free_Log_Conf_Ex(), CM_Move_DevNode_Ex(), CM_Run_Detection_Ex(), CM_Set_HW_Prof_Ex(), CM_Setup_DevNode_Ex(), CMP_Report_LogOn(), and SetupInitializeFileLogW().

◆ pSetupModifyGlobalFlags()

void WINAPI pSetupModifyGlobalFlags ( DWORD  mask,
DWORD  flags 
)

Definition at line 858 of file misc.c.

859{
860 FIXME( "stub\n" );
862}
GLenum GLint GLuint mask
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161

Referenced by pSetupSetGlobalFlags(), and SetupSetNonInteractiveMode().

◆ pSetupMultiByteToUnicode()

LPWSTR WINAPI pSetupMultiByteToUnicode ( LPCSTR  lpMultiByteStr,
UINT  uCodePage 
)

Definition at line 281 of file misc.c.

282{
283 LPWSTR lpUnicodeStr;
284 int nLength;
285
286 TRACE("%s %d\n", debugstr_a(lpMultiByteStr), uCodePage);
287
288 nLength = MultiByteToWideChar(uCodePage, 0, lpMultiByteStr,
289 -1, NULL, 0);
290 if (nLength == 0)
291 return NULL;
292
293 lpUnicodeStr = MyMalloc(nLength * sizeof(WCHAR));
294 if (lpUnicodeStr == NULL)
295 {
297 return NULL;
298 }
299
300 if (!MultiByteToWideChar(uCodePage, 0, lpMultiByteStr,
301 nLength, lpUnicodeStr, nLength))
302 {
303 MyFree(lpUnicodeStr);
304 return NULL;
305 }
306
307 return lpUnicodeStr;
308}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define MultiByteToWideChar
Definition: compat.h:110
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by CM_Get_DevNode_Custom_Property_ExA(), pSetupCaptureAndConvertAnsiArg(), SetupCopyOEMInfA(), SetupDecompressOrCopyFileA(), SetupDiBuildClassInfoListExA(), SetupDiClassGuidsFromNameExA(), SetupDiClassNameFromGuidExA(), SetupDiCreateDeviceInfoA(), SetupDiCreateDeviceInfoListExA(), SetupDiCreateDeviceInterfaceA(), SetupDiCreateDeviceInterfaceRegKeyA(), SetupDiCreateDevRegKeyA(), SetupDiGetActualSectionToInstallExA(), SetupDiGetClassDescriptionExA(), SetupDiGetClassDevsExA(), SetupDiGetClassImageListExA(), SetupDiGetINFClassA(), SetupDiInstallClassExA(), SetupDiOpenClassRegKeyExA(), SetupDiOpenDeviceInfoA(), SetupDiOpenDeviceInterfaceA(), SetupGetFileCompressionInfoExA(), and SetupGetInfFileListA().

◆ pSetupOpenAndMapFileForRead()

DWORD WINAPI pSetupOpenAndMapFileForRead ( LPCWSTR  lpFileName,
LPDWORD  lpSize,
LPHANDLE  lpFile,
LPHANDLE  lpMapping,
LPVOID lpBuffer 
)

Definition at line 604 of file misc.c.

609{
610 DWORD dwError;
611
612 TRACE("%s %p %p %p %p\n",
613 debugstr_w(lpFileName), lpSize, lpFile, lpMapping, lpBuffer);
614
616 OPEN_EXISTING, 0, NULL);
617 if (*lpFile == INVALID_HANDLE_VALUE)
618 return GetLastError();
619
620 *lpSize = GetFileSize(*lpFile, NULL);
621 if (*lpSize == INVALID_FILE_SIZE)
622 {
623 dwError = GetLastError();
624 CloseHandle(*lpFile);
625 return dwError;
626 }
627
628 *lpMapping = CreateFileMappingW(*lpFile, NULL, PAGE_READONLY, 0,
629 *lpSize, NULL);
630 if (*lpMapping == NULL)
631 {
632 dwError = GetLastError();
633 CloseHandle(*lpFile);
634 return dwError;
635 }
636
637 *lpBuffer = MapViewOfFile(*lpMapping, FILE_MAP_READ, 0, 0, *lpSize);
638 if (*lpBuffer == NULL)
639 {
640 dwError = GetLastError();
641 CloseHandle(*lpMapping);
642 CloseHandle(*lpFile);
643 return dwError;
644 }
645
646 return ERROR_SUCCESS;
647}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define PAGE_READONLY
Definition: compat.h:138
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
#define INVALID_FILE_SIZE
Definition: winbase.h:548

◆ pSetupSetGlobalFlags()

void WINAPI pSetupSetGlobalFlags ( DWORD  flags)

Definition at line 867 of file misc.c.

868{
869 pSetupModifyGlobalFlags(0xFFFFFFFF, flags);
870}
void WINAPI pSetupModifyGlobalFlags(DWORD mask, DWORD flags)
Definition: misc.c:858

◆ pSetupStringFromGuid()

DWORD WINAPI pSetupStringFromGuid ( LPGUID  lpGUID,
PWSTR  pString,
DWORD  dwStringLen 
)

Definition at line 1775 of file misc.c.

1776{
1778 RPC_WSTR rpcBuffer;
1779 WCHAR szBuffer[39];
1780
1781 if (dwStringLen < 39)
1782 {
1784 }
1785
1786 Status = UuidToStringW(lpGUID, &rpcBuffer);
1787 if (Status != RPC_S_OK)
1788 {
1789 return Status;
1790 }
1791
1792 wcscpy(szBuffer, L"{");
1793 wcscat(szBuffer, rpcBuffer);
1794 wcscat(szBuffer, L"}");
1795
1796 wcscpy(pString, szBuffer);
1797
1798 RpcStringFreeW(&rpcBuffer);
1799 return NO_ERROR;
1800}
#define L(x)
Definition: ntvdm.h:50
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:540
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:175
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by CM_Get_Class_Registry_PropertyW(), CreateSymbolicLink(), and SetupDiCallClassInstaller().

◆ pSetupUnicodeToMultiByte()

LPSTR WINAPI pSetupUnicodeToMultiByte ( LPCWSTR  lpUnicodeStr,
UINT  uCodePage 
)

Definition at line 327 of file misc.c.

328{
329 LPSTR lpMultiByteStr;
330 int nLength;
331
332 TRACE("%s %d\n", debugstr_w(lpUnicodeStr), uCodePage);
333
334 nLength = WideCharToMultiByte(uCodePage, 0, lpUnicodeStr, -1,
335 NULL, 0, NULL, NULL);
336 if (nLength == 0)
337 return NULL;
338
339 lpMultiByteStr = MyMalloc(nLength);
340 if (lpMultiByteStr == NULL)
341 return NULL;
342
343 if (!WideCharToMultiByte(uCodePage, 0, lpUnicodeStr, -1,
344 lpMultiByteStr, nLength, NULL, NULL))
345 {
346 MyFree(lpMultiByteStr);
347 return NULL;
348 }
349
350 return lpMultiByteStr;
351}
#define WideCharToMultiByte
Definition: compat.h:111

Referenced by GetFunctionPointer(), and SetupGetFileCompressionInfoExA().

◆ pSetupUnmapAndCloseFile()

BOOL WINAPI pSetupUnmapAndCloseFile ( HANDLE  hFile,
HANDLE  hMapping,
LPVOID  lpBuffer 
)

Definition at line 664 of file misc.c.

665{
666 TRACE("%p %p %p\n",
667 hFile, hMapping, lpBuffer);
668
670 return FALSE;
671
672 if (!CloseHandle(hMapping))
673 return FALSE;
674
675 if (!CloseHandle(hFile))
676 return FALSE;
677
678 return TRUE;
679}
#define UnmapViewOfFile
Definition: compat.h:746

◆ QueryRegistryValue()

LONG WINAPI QueryRegistryValue ( HKEY  hKey,
LPCWSTR  lpValueName,
LPBYTE lpData,
LPDWORD  lpType,
LPDWORD  lpcbData 
)

Definition at line 234 of file misc.c.

239{
240 LONG lError;
241
242 TRACE("%p %s %p %p %p\n",
243 hKey, debugstr_w(lpValueName), lpData, lpType, lpcbData);
244
245 /* Get required buffer size */
246 *lpcbData = 0;
247 lError = RegQueryValueExW(hKey, lpValueName, 0, lpType, NULL, lpcbData);
248 if (lError != ERROR_SUCCESS)
249 return lError;
250
251 /* Allocate buffer */
252 *lpData = MyMalloc(*lpcbData);
253 if (*lpData == NULL)
255
256 /* Query registry value */
257 lError = RegQueryValueExW(hKey, lpValueName, 0, lpType, *lpData, lpcbData);
258 if (lError != ERROR_SUCCESS)
259 MyFree(*lpData);
260
261 return lError;
262}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey

◆ RetreiveFileSecurity()

DWORD WINAPI RetreiveFileSecurity ( LPCWSTR  lpFileName,
PSECURITY_DESCRIPTOR pSecurityDescriptor 
)

Definition at line 794 of file misc.c.

796{
797 PSECURITY_DESCRIPTOR SecDesc;
798 DWORD dwSize = 0x100;
799 DWORD dwError;
800
801 TRACE("%s %p\n", debugstr_w(lpFileName), pSecurityDescriptor);
802
803 SecDesc = MyMalloc(dwSize);
804 if (SecDesc == NULL)
806
809 SecDesc, dwSize, &dwSize))
810 {
811 *pSecurityDescriptor = SecDesc;
812 return ERROR_SUCCESS;
813 }
814
815 dwError = GetLastError();
816 if (dwError != ERROR_INSUFFICIENT_BUFFER)
817 {
818 MyFree(SecDesc);
819 return dwError;
820 }
821
822 SecDesc = MyRealloc(SecDesc, dwSize);
823 if (SecDesc == NULL)
825
828 SecDesc, dwSize, &dwSize))
829 {
830 *pSecurityDescriptor = SecDesc;
831 return ERROR_SUCCESS;
832 }
833
834 dwError = GetLastError();
835 MyFree(SecDesc);
836
837 return dwError;
838}
BOOL WINAPI GetFileSecurityW(LPCWSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded)
Definition: security.c:1404
LPVOID WINAPI MyRealloc(LPVOID lpSrc, DWORD dwSize)
Definition: misc.c:172
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define OWNER_SECURITY_INFORMATION
Definition: setypes.h:123
#define GROUP_SECURITY_INFORMATION
Definition: setypes.h:124

◆ SetupCloseLog()

void WINAPI SetupCloseLog ( void  )

Definition at line 2017 of file misc.c.

2018{
2020
2023
2026
2028}
static HANDLE setupact
Definition: misc.c:32
static HANDLE setuperr
Definition: misc.c:33
static CRITICAL_SECTION setupapi_cs
Definition: misc.c:34
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by DllMain(), and test_SetupLogError().

◆ SetupDecompressOrCopyFileA()

DWORD WINAPI SetupDecompressOrCopyFileA ( PCSTR  source,
PCSTR  target,
PUINT  type 
)

Definition at line 1656 of file misc.c.

1657{
1658 DWORD ret = 0;
1659 WCHAR *sourceW = NULL, *targetW = NULL;
1660
1661 if (source && !(sourceW = pSetupMultiByteToUnicode( source, CP_ACP ))) return FALSE;
1662 if (target && !(targetW = pSetupMultiByteToUnicode( target, CP_ACP )))
1663 {
1664 MyFree( sourceW );
1666 }
1667
1669
1670 MyFree( sourceW );
1671 MyFree( targetW );
1672
1673 return ret;
1674}
DWORD WINAPI SetupDecompressOrCopyFileW(PCWSTR source, PCWSTR target, PUINT type)
Definition: misc.c:1690
static const WCHAR sourceW[]
Definition: jsregexp.c:37

Referenced by test_SetupDecompressOrCopyFile().

◆ SetupDecompressOrCopyFileW()

DWORD WINAPI SetupDecompressOrCopyFileW ( PCWSTR  source,
PCWSTR  target,
PUINT  type 
)

Definition at line 1690 of file misc.c.

1691{
1692 UINT comp;
1694
1695 if (!source || !target) return ERROR_INVALID_PARAMETER;
1696
1697 if (!type) comp = detect_compression_type( source );
1698 else comp = *type;
1699
1700 switch (comp)
1701 {
1704 else ret = GetLastError();
1705 break;
1708 break;
1712 break;
1713 default:
1714 WARN("unknown compression type %d\n", comp);
1715 break;
1716 }
1717
1718 TRACE("%s -> %s %d\n", debugstr_w(source), debugstr_w(target), comp);
1719 return ret;
1720}
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
static DWORD decompress_file_cab(LPCWSTR source, LPCWSTR target)
Definition: misc.c:1640
static DWORD decompress_file_lz(LPCWSTR source, LPCWSTR target)
Definition: misc.c:1582
static UINT detect_compression_type(LPCWSTR file)
Definition: misc.c:1293
#define FILE_COMPRESSION_NTCAB
Definition: setupapi.h:364

Referenced by SetupDecompressOrCopyFileA().

◆ SetupGetFileCompressionInfoA()

DWORD WINAPI SetupGetFileCompressionInfoA ( PCSTR  source,
PSTR name,
PDWORD  source_size,
PDWORD  target_size,
PUINT  type 
)

Definition at line 1512 of file misc.c.

1514{
1515 BOOL ret;
1516 DWORD error, required;
1517 LPSTR actual_name;
1518
1519 TRACE("%s, %p, %p, %p, %p\n", debugstr_a(source), name, source_size, target_size, type);
1520
1521 if (!source || !name || !source_size || !target_size || !type)
1523
1525 if (!(actual_name = MyMalloc( required ))) return ERROR_NOT_ENOUGH_MEMORY;
1526
1527 ret = SetupGetFileCompressionInfoExA( source, actual_name, required, &required,
1528 source_size, target_size, type );
1529 if (!ret)
1530 {
1531 error = GetLastError();
1532 MyFree( actual_name );
1533 return error;
1534 }
1535 *name = actual_name;
1536 return ERROR_SUCCESS;
1537}
BOOL WINAPI SetupGetFileCompressionInfoExA(PCSTR source, PSTR name, DWORD len, PDWORD required, PDWORD source_size, PDWORD target_size, PUINT type)
Definition: misc.c:1411
Definition: name.c:39

Referenced by test_SetupGetFileCompressionInfo().

◆ SetupGetFileCompressionInfoExA()

BOOL WINAPI SetupGetFileCompressionInfoExA ( PCSTR  source,
PSTR  name,
DWORD  len,
PDWORD  required,
PDWORD  source_size,
PDWORD  target_size,
PUINT  type 
)

Definition at line 1411 of file misc.c.

1413{
1414 BOOL ret;
1415 WCHAR *nameW = NULL, *sourceW = NULL;
1416 DWORD nb_chars = 0;
1417 LPSTR nameA;
1418
1419 TRACE("%s, %p, %d, %p, %p, %p, %p\n", debugstr_a(source), name, len, required,
1420 source_size, target_size, type);
1421
1422 if (!source || !(sourceW = pSetupMultiByteToUnicode( source, CP_ACP ))) return FALSE;
1423
1424 if (name)
1425 {
1427 if (!(nameW = HeapAlloc( GetProcessHeap(), 0, nb_chars * sizeof(WCHAR) )))
1428 {
1429 MyFree( sourceW );
1430 return FALSE;
1431 }
1432 }
1433 ret = SetupGetFileCompressionInfoExW( sourceW, nameW, nb_chars, &nb_chars, source_size, target_size, type );
1434 if (ret)
1435 {
1436 if ((nameA = pSetupUnicodeToMultiByte( nameW, CP_ACP )))
1437 {
1438 if (name && len >= nb_chars) lstrcpyA( name, nameA );
1439 else
1440 {
1442 ret = FALSE;
1443 }
1444 MyFree( nameA );
1445 }
1446 }
1447 if (required) *required = nb_chars;
1448 HeapFree( GetProcessHeap(), 0, nameW );
1449 MyFree( sourceW );
1450
1451 return ret;
1452}
static const WCHAR nameW[]
Definition: main.c:46
BOOL WINAPI SetupGetFileCompressionInfoExW(PCWSTR source, PWSTR name, DWORD len, PDWORD required, PDWORD source_size, PDWORD target_size, PUINT type)
Definition: misc.c:1472
GLenum GLsizei len
Definition: glext.h:6722
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100

Referenced by main(), and SetupGetFileCompressionInfoA().

◆ SetupGetFileCompressionInfoExW()

BOOL WINAPI SetupGetFileCompressionInfoExW ( PCWSTR  source,
PWSTR  name,
DWORD  len,
PDWORD  required,
PDWORD  source_size,
PDWORD  target_size,
PUINT  type 
)

Definition at line 1472 of file misc.c.

1474{
1475 UINT comp;
1476 BOOL ret = FALSE;
1477 DWORD source_len;
1478
1479 TRACE("%s, %p, %d, %p, %p, %p, %p\n", debugstr_w(source), name, len, required,
1480 source_size, target_size, type);
1481
1482 if (!source) return FALSE;
1483
1484 source_len = lstrlenW( source ) + 1;
1485 if (required) *required = source_len;
1486 if (name && len >= source_len)
1487 {
1488 lstrcpyW( name, source );
1489 ret = TRUE;
1490 }
1491 else return FALSE;
1492
1494 if (type) *type = comp;
1495
1496 switch (comp)
1497 {
1499 case FILE_COMPRESSION_NTCAB: ret = get_file_sizes_cab( source, source_size, target_size ); break;
1500 case FILE_COMPRESSION_NONE: ret = get_file_sizes_none( source, source_size, target_size ); break;
1501 case FILE_COMPRESSION_WINLZA: ret = get_file_sizes_lz( source, source_size, target_size ); break;
1502 default: break;
1503 }
1504 return ret;
1505}
#define lstrcpyW
Definition: compat.h:749
static BOOL get_file_sizes_none(LPCWSTR source, DWORD *source_size, DWORD *target_size)
Definition: misc.c:1337
static BOOL get_file_sizes_cab(LPCWSTR source, DWORD *source_size, DWORD *target_size)
Definition: misc.c:1389
static BOOL get_file_sizes_lz(LPCWSTR source, DWORD *source_size, DWORD *target_size)
Definition: misc.c:1347

Referenced by SetupGetFileCompressionInfoExA(), and SetupGetFileCompressionInfoW().

◆ SetupGetFileCompressionInfoW()

DWORD WINAPI SetupGetFileCompressionInfoW ( PCWSTR  source,
PWSTR name,
PDWORD  source_size,
PDWORD  target_size,
PUINT  type 
)

Definition at line 1555 of file misc.c.

1557{
1558 BOOL ret;
1559 DWORD error, required;
1560 LPWSTR actual_name;
1561
1562 TRACE("%s, %p, %p, %p, %p\n", debugstr_w(source), name, source_size, target_size, type);
1563
1564 if (!source || !name || !source_size || !target_size || !type)
1566
1568 if (!(actual_name = MyMalloc( required*sizeof(WCHAR) ))) return ERROR_NOT_ENOUGH_MEMORY;
1569
1570 ret = SetupGetFileCompressionInfoExW( source, actual_name, required, &required,
1571 source_size, target_size, type );
1572 if (!ret)
1573 {
1574 error = GetLastError();
1575 MyFree( actual_name );
1576 return error;
1577 }
1578 *name = actual_name;
1579 return ERROR_SUCCESS;
1580}

◆ SetupGetNonInteractiveMode()

BOOL WINAPI SetupGetNonInteractiveMode ( VOID  )

Definition at line 875 of file misc.c.

876{
878}
#define PSPGF_NONINTERACTIVE

◆ SetupInitializeFileLogA()

HSPFILELOG WINAPI SetupInitializeFileLogA ( LPCSTR  LogFileName,
DWORD  Flags 
)

Definition at line 1965 of file misc.c.

1966{
1968 LPWSTR LogFileNameW = NULL;
1969
1970 TRACE("%s, 0x%x\n",debugstr_a(LogFileName),Flags);
1971
1972 if (LogFileName)
1973 {
1974 LogFileNameW = strdupAtoW(LogFileName);
1975
1976 if (!LogFileNameW)
1977 {
1978 /* not enough memory */
1980 return INVALID_HANDLE_VALUE;
1981 }
1982
1983 hLog = SetupInitializeFileLogW(LogFileNameW, Flags);
1984 HeapFree(GetProcessHeap(), 0, LogFileNameW);
1985 }
1986 else
1987 {
1989 }
1990
1991 return hLog;
1992}
static HANDLE hLog
Definition: misc.cpp:13
static WCHAR * strdupAtoW(const char *str)
Definition: main.c:65
HSPFILELOG WINAPI SetupInitializeFileLogW(LPCWSTR LogFileName, DWORD Flags)
Definition: misc.c:1843
_Must_inspect_result_ _In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PUNICODE_STRING LogFileName
Definition: nttmapi.h:324
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ SetupInitializeFileLogW()

HSPFILELOG WINAPI SetupInitializeFileLogW ( LPCWSTR  LogFileName,
DWORD  Flags 
)

Definition at line 1843 of file misc.c.

1844{
1845 struct FileLog * Log;
1846 HANDLE hLog;
1847 WCHAR Windir[MAX_PATH];
1848 DWORD ret;
1849
1850 TRACE("%s, 0x%x\n",debugstr_w(LogFileName),Flags);
1851
1853 {
1855 {
1856 /* insufficient privileges */
1858 return INVALID_HANDLE_VALUE;
1859 }
1860
1862 {
1863 /* invalid parameter */
1865 return INVALID_HANDLE_VALUE;
1866 }
1867
1869 if (!ret || ret >= MAX_PATH)
1870 {
1871 /* generic failure */
1872 return INVALID_HANDLE_VALUE;
1873 }
1874
1875 /* append path */
1876 wcscat(Windir, L"repair\\setup.log");
1877 }
1878 else
1879 {
1880 if (!LogFileName)
1881 {
1882 /* invalid parameter */
1884 return INVALID_HANDLE_VALUE;
1885 }
1886 /* copy filename */
1887 wcsncpy(Windir, LogFileName, MAX_PATH);
1888 }
1889
1890 if (FileExists(Windir, NULL))
1891 {
1892 /* take ownership */
1893 ret = TakeOwnershipOfFile(Windir);
1894
1895 if (ret != ERROR_SUCCESS)
1896 {
1897 /* failed */
1899 return INVALID_HANDLE_VALUE;
1900 }
1901
1903 {
1904 /* failed */
1905 return INVALID_HANDLE_VALUE;
1906 }
1907
1908 if ((Flags & SPFILELOG_FORCENEW))
1909 {
1910 if (!DeleteFileW(Windir))
1911 {
1912 /* failed */
1913 return INVALID_HANDLE_VALUE;
1914 }
1915 }
1916 }
1917
1918 /* open log file */
1919 hLog = CreateFileW(Windir,
1922 NULL,
1925 NULL);
1926
1928 {
1929 /* failed */
1930 return INVALID_HANDLE_VALUE;
1931 }
1932
1933 /* close log handle */
1935
1936 /* allocate file log struct */
1937 Log = HeapAlloc(GetProcessHeap(), 0, sizeof(struct FileLog));
1938 if (!Log)
1939 {
1940 /* not enough memory */
1942 return INVALID_HANDLE_VALUE;
1943 }
1944
1945 /* initialize log */
1946 Log->LogName = HeapAlloc(GetProcessHeap(), 0, (wcslen(Windir)+1) * sizeof(WCHAR));
1947 if (!Log->LogName)
1948 {
1949 /* not enough memory */
1950 HeapFree(GetProcessHeap(), 0, Log);
1952 return INVALID_HANDLE_VALUE;
1953 }
1954
1955 wcscpy(Log->LogName, Windir);
1958
1959 return (HSPFILELOG)Log;
1960}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2397
DWORD WINAPI TakeOwnershipOfFile(LPCWSTR lpFileName)
Definition: misc.c:720
BOOL WINAPI pSetupIsUserAdmin(VOID)
Definition: misc.c:1817
BOOL WINAPI FileExists(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFileFindData)
Definition: misc.c:502
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OPEN_ALWAYS
Definition: disk.h:70
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define SPFILELOG_FORCENEW
Definition: setupapi.h:577
#define SPFILELOG_QUERYONLY
Definition: setupapi.h:578
#define SPFILELOG_SYSTEMLOG
Definition: setupapi.h:575
DWORD SystemLog
DWORD ReadOnly
LPWSTR LogName

Referenced by SetupInitializeFileLogA().

◆ SetupLogErrorA()

BOOL WINAPI SetupLogErrorA ( LPCSTR  message,
LogSeverity  severity 
)

Definition at line 2084 of file misc.c.

2085{
2086 static const char null[] = "(null)";
2087 BOOL ret;
2088 DWORD written;
2089 DWORD len;
2090
2092
2094 {
2096 ret = FALSE;
2097 goto done;
2098 }
2099
2100 if (message == NULL)
2101 message = null;
2102
2103 len = lstrlenA(message);
2104
2105 ret = WriteFile(setupact, message, len, &written, NULL);
2106 if (!ret)
2107 goto done;
2108
2109 if (severity >= LogSevMaximum)
2110 {
2111 ret = FALSE;
2112 goto done;
2113 }
2114
2116 ret = WriteFile(setuperr, message, len, &written, NULL);
2117
2118done:
2120 return ret;
2121}
int null(void)
Definition: ftp.c:1794
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLenum GLenum severity
Definition: glext.h:7750
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define LogSevMaximum
Definition: setupapi.h:457
#define LogSevInformation
Definition: setupapi.h:453
Definition: tftpd.h:60
#define ERROR_FILE_INVALID
Definition: winerror.h:585

Referenced by SetupLogErrorW(), and test_SetupLogError().

◆ SetupLogErrorW()

BOOL WINAPI SetupLogErrorW ( LPCWSTR  message,
LogSeverity  severity 
)

Definition at line 2126 of file misc.c.

2127{
2128 LPSTR msg = NULL;
2129 DWORD len;
2130 BOOL ret;
2131
2132 if (message)
2133 {
2136 if (msg == NULL)
2137 {
2139 return FALSE;
2140 }
2142 }
2143
2144 /* This is the normal way to proceed. The log files are ASCII files
2145 * and W is to be converted.
2146 */
2148
2150 return ret;
2151}
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI SetupLogErrorA(LPCSTR message, LogSeverity severity)
Definition: misc.c:2084

◆ SetupOpenLog()

BOOL WINAPI SetupOpenLog ( BOOL  reserved)

Definition at line 2033 of file misc.c.

2034{
2036
2037 static const WCHAR setupactlog[] = {'\\','s','e','t','u','p','a','c','t','.','l','o','g',0};
2038 static const WCHAR setuperrlog[] = {'\\','s','e','t','u','p','e','r','r','.','l','o','g',0};
2039
2041
2043 {
2045 return TRUE;
2046 }
2047
2049 lstrcatW(path, setupactlog);
2050
2054 {
2056 return FALSE;
2057 }
2058
2060
2062 lstrcatW(path, setuperrlog);
2063
2067 {
2071 return FALSE;
2072 }
2073
2075
2077
2078 return TRUE;
2079}
#define SetFilePointer
Definition: compat.h:743
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define FILE_END
Definition: winbase.h:114

Referenced by test_SetupLogError().

◆ SetupSetNonInteractiveMode()

BOOL WINAPI SetupSetNonInteractiveMode ( BOOL  NonInteractiveFlag)

Definition at line 883 of file misc.c.

884{
885 BOOL OldValue;
886
889 NonInteractiveFlag ? PSPGF_NONINTERACTIVE : 0);
890
891 return OldValue;
892}

◆ SetupTerminateFileLog()

BOOL WINAPI SetupTerminateFileLog ( HANDLE  FileLogHandle)

Definition at line 1997 of file misc.c.

1998{
1999 struct FileLog * Log;
2000
2001 TRACE ("%p\n",FileLogHandle);
2002
2003 Log = (struct FileLog *)FileLogHandle;
2004
2005 /* free file log handle */
2006 HeapFree(GetProcessHeap(), 0, Log->LogName);
2007 HeapFree(GetProcessHeap(), 0, Log);
2008
2010
2011 return TRUE;
2012}

◆ SetupUninstallOEMInfA()

BOOL WINAPI SetupUninstallOEMInfA ( PCSTR  inf_file,
DWORD  flags,
PVOID  reserved 
)

Definition at line 1243 of file misc.c.

1244{
1245 BOOL ret;
1246 WCHAR *inf_fileW = NULL;
1247
1248 TRACE("%s, 0x%08x, %p\n", debugstr_a(inf_file), flags, reserved);
1249
1250 if (inf_file && !(inf_fileW = strdupAtoW( inf_file ))) return FALSE;
1251 ret = SetupUninstallOEMInfW( inf_fileW, flags, reserved );
1252 HeapFree( GetProcessHeap(), 0, inf_fileW );
1253 return ret;
1254}
BOOL WINAPI SetupUninstallOEMInfW(PCWSTR inf_file, DWORD flags, PVOID reserved)
Definition: misc.c:1214
r reserved
Definition: btrfs.c:3006
Definition: inf.c:49

◆ SetupUninstallOEMInfW()

BOOL WINAPI SetupUninstallOEMInfW ( PCWSTR  inf_file,
DWORD  flags,
PVOID  reserved 
)

Definition at line 1214 of file misc.c.

1215{
1216 static const WCHAR infW[] = {'\\','i','n','f','\\',0};
1218
1219 TRACE("%s, 0x%08x, %p\n", debugstr_w(inf_file), flags, reserved);
1220
1221 if (!inf_file)
1222 {
1224 return FALSE;
1225 }
1226
1227 if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE;
1228
1229 strcatW( target, infW );
1231
1232 if (flags & SUOI_FORCEDELETE)
1233 return DeleteFileW(target);
1234
1235 FIXME("not deleting %s\n", debugstr_w(target));
1236
1237 return TRUE;
1238}
static const WCHAR infW[]
Definition: axinstall.c:35
#define strcatW(d, s)
Definition: unicode.h:36
#define SUOI_FORCEDELETE
Definition: setupapi.h:664

Referenced by SetupUninstallOEMInfA().

◆ StampFileSecurity()

DWORD WINAPI StampFileSecurity ( LPCWSTR  lpFileName,
PSECURITY_DESCRIPTOR  pSecurityDescriptor 
)

Definition at line 695 of file misc.c.

696{
697 TRACE("%s %p\n", debugstr_w(lpFileName), pSecurityDescriptor);
698
701 pSecurityDescriptor))
702 return GetLastError();
703
704 return ERROR_SUCCESS;
705}
BOOL WINAPI SetFileSecurityW(LPCWSTR lpFileName, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: security.c:1509

◆ TakeOwnershipOfFile()

DWORD WINAPI TakeOwnershipOfFile ( LPCWSTR  lpFileName)

Definition at line 720 of file misc.c.

721{
722 SECURITY_DESCRIPTOR SecDesc;
723 HANDLE hToken = NULL;
724 PTOKEN_OWNER pOwner = NULL;
725 DWORD dwError;
727
728 TRACE("%s\n", debugstr_w(lpFileName));
729
731 return GetLastError();
732
733 if (!GetTokenInformation(hToken, TokenOwner, NULL, 0, &dwSize))
734 {
735 goto fail;
736 }
737
738 pOwner = (PTOKEN_OWNER)MyMalloc(dwSize);
739 if (pOwner == NULL)
740 {
741 CloseHandle(hToken);
743 }
744
745 if (!GetTokenInformation(hToken, TokenOwner, pOwner, dwSize, &dwSize))
746 {
747 goto fail;
748 }
749
751 {
752 goto fail;
753 }
754
755 if (!SetSecurityDescriptorOwner(&SecDesc, pOwner->Owner, FALSE))
756 {
757 goto fail;
758 }
759
761 {
762 goto fail;
763 }
764
765 MyFree(pOwner);
766 CloseHandle(hToken);
767
768 return ERROR_SUCCESS;
769
770fail:;
771 dwError = GetLastError();
772
773 MyFree(pOwner);
774
775 if (hToken != NULL)
776 CloseHandle(hToken);
777
778 return dwError;
779}
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
PSID Owner
Definition: setypes.h:1028
@ TokenOwner
Definition: setypes.h:969
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
struct _TOKEN_OWNER * PTOKEN_OWNER

Referenced by SetupInitializeFileLogW().

◆ TrimGuidString()

static BOOL TrimGuidString ( PCWSTR  szString,
LPWSTR  szNewString 
)
static

Definition at line 1725 of file misc.c.

1726{
1727 WCHAR szBuffer[39];
1728 INT Index;
1729
1730 if (wcslen(szString) == 38)
1731 {
1732 if ((szString[0] == L'{') && (szString[37] == L'}'))
1733 {
1734 for (Index = 0; Index < wcslen(szString); Index++)
1735 szBuffer[Index] = szString[Index + 1];
1736
1737 szBuffer[36] = L'\0';
1738 wcscpy(szNewString, szBuffer);
1739 return TRUE;
1740 }
1741 }
1742 szNewString[0] = L'\0';
1743 return FALSE;
1744}
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by pSetupGuidFromString().

Variable Documentation

◆ BackSlash

const WCHAR BackSlash[] = {'\\',0}
static

Definition at line 28 of file misc.c.

Referenced by pSetupGetVersionInfoFromImage().

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, &setupapi_cs,
0, 0, { (DWORD_PTR)(__FILE__ ": setupapi_cs") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: misc.c:35
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 35 of file misc.c.

◆ GlobalSetupFlags

◆ setupact

HANDLE setupact = INVALID_HANDLE_VALUE
static

Definition at line 32 of file misc.c.

Referenced by SetupCloseLog(), SetupLogErrorA(), and SetupOpenLog().

◆ setupapi_cs

static CRITICAL_SECTION setupapi_cs = { &critsect_debug, -1, 0, 0, 0, 0 }
static

Definition at line 34 of file misc.c.

Referenced by SetupCloseLog(), SetupLogErrorA(), and SetupOpenLog().

◆ setuperr

HANDLE setuperr = INVALID_HANDLE_VALUE
static

Definition at line 33 of file misc.c.

Referenced by SetupCloseLog(), SetupLogErrorA(), and SetupOpenLog().

◆ TranslationRegKey

const WCHAR TranslationRegKey[] = {'\\','V','e','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n',0}
static

Definition at line 29 of file misc.c.

Referenced by pSetupGetVersionInfoFromImage().