ReactOS  0.4.13-dev-982-g9853eab
files.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winver.h"
#include "winternl.h"
#include "setupapi.h"
#include "advpub.h"
#include "fdi.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "advpack_private.h"
Include dependency graph for files.c:

Go to the source code of this file.

Classes

struct  FILELIST
 
struct  SESSION
 
struct  tagLANGANDCODEPAGE
 

Macros

#define ROOT_LENGTH   3
 
#define EXTRACT_FILLFILELIST   0x00000001
 
#define EXTRACT_EXTRACTFILES   0x00000002
 

Typedefs

typedef struct tagLANGANDCODEPAGE LANGANDCODEPAGE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advpack)
 
static LPWSTR ansi_to_unicode_list (LPCSTR ansi_list)
 
HRESULT WINAPI AddDelBackupEntryA (LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, LPCSTR lpcszBaseName, DWORD dwFlags)
 
HRESULT WINAPI AddDelBackupEntryW (LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, LPCWSTR lpcszBaseName, DWORD dwFlags)
 
static UINT CALLBACK pQuietQueueCallback (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
 
static UINT CALLBACK pQueueCallback (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
 
HRESULT WINAPI AdvInstallFileA (HWND hwnd, LPCSTR lpszSourceDir, LPCSTR lpszSourceFile, LPCSTR lpszDestDir, LPCSTR lpszDestFile, DWORD dwFlags, DWORD dwReserved)
 
HRESULT WINAPI AdvInstallFileW (HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSourceFile, LPCWSTR lpszDestDir, LPCWSTR lpszDestFile, DWORD dwFlags, DWORD dwReserved)
 
static HRESULT DELNODE_recurse_dirtree (LPWSTR fname, DWORD flags)
 
HRESULT WINAPI DelNodeA (LPCSTR pszFileOrDirName, DWORD dwFlags)
 
HRESULT WINAPI DelNodeW (LPCWSTR pszFileOrDirName, DWORD dwFlags)
 
HRESULT WINAPI DelNodeRunDLL32A (HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
 
HRESULT WINAPI DelNodeRunDLL32W (HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
 
static HRESULT (WINAPI *pExtract)(SESSION *
 
static LPSTR convert_file_list (LPCSTR FileList, DWORD *dwNumFiles)
 
static void free_file_node (struct FILELIST *pNode)
 
static BOOL file_in_list (LPCSTR szFile, LPCSTR szFileList)
 
static DWORD fill_file_list (SESSION *session, LPCSTR szCabName, LPCSTR szFileList)
 
static void free_file_list (SESSION *session)
 
HRESULT WINAPI ExtractFilesA (LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, LPCSTR FileList, LPVOID LReserved, DWORD Reserved)
 
HRESULT WINAPI ExtractFilesW (LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags, LPCWSTR FileList, LPVOID LReserved, DWORD Reserved)
 
HRESULT WINAPI FileSaveMarkNotExistA (LPSTR pszFileList, LPSTR pszDir, LPSTR pszBaseName)
 
HRESULT WINAPI FileSaveMarkNotExistW (LPWSTR pszFileList, LPWSTR pszDir, LPWSTR pszBaseName)
 
HRESULT WINAPI FileSaveRestoreA (HWND hDlg, LPSTR pszFileList, LPSTR pszDir, LPSTR pszBaseName, DWORD dwFlags)
 
HRESULT WINAPI FileSaveRestoreW (HWND hDlg, LPWSTR pszFileList, LPWSTR pszDir, LPWSTR pszBaseName, DWORD dwFlags)
 
HRESULT WINAPI FileSaveRestoreOnINFA (HWND hWnd, LPCSTR pszTitle, LPCSTR pszINF, LPCSTR pszSection, LPCSTR pszBackupDir, LPCSTR pszBaseBackupFile, DWORD dwFlags)
 
HRESULT WINAPI FileSaveRestoreOnINFW (HWND hWnd, LPCWSTR pszTitle, LPCWSTR pszINF, LPCWSTR pszSection, LPCWSTR pszBackupDir, LPCWSTR pszBaseBackupFile, DWORD dwFlags)
 
HRESULT WINAPI GetVersionFromFileA (LPCSTR Filename, LPDWORD MajorVer, LPDWORD MinorVer, BOOL Version)
 
HRESULT WINAPI GetVersionFromFileW (LPCWSTR Filename, LPDWORD MajorVer, LPDWORD MinorVer, BOOL Version)
 
HRESULT WINAPI GetVersionFromFileExA (LPCSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion)
 
HRESULT WINAPI GetVersionFromFileExW (LPCWSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion)
 

Variables

static LPCSTR
 

Macro Definition Documentation

◆ EXTRACT_EXTRACTFILES

#define EXTRACT_EXTRACTFILES   0x00000002

Definition at line 521 of file files.c.

◆ EXTRACT_FILLFILELIST

#define EXTRACT_FILLFILELIST   0x00000001

Definition at line 520 of file files.c.

◆ ROOT_LENGTH

#define ROOT_LENGTH   3

Definition at line 167 of file files.c.

Typedef Documentation

◆ LANGANDCODEPAGE

Function Documentation

◆ AddDelBackupEntryA()

HRESULT WINAPI AddDelBackupEntryA ( LPCSTR  lpcszFileList,
LPCSTR  lpcszBackupDir,
LPCSTR  lpcszBaseName,
DWORD  dwFlags 
)

Definition at line 59 of file files.c.

61 {
62  UNICODE_STRING backupdir, basename;
63  LPWSTR filelist;
65  HRESULT res;
66 
67  TRACE("(%s, %s, %s, %d)\n", debugstr_a(lpcszFileList),
68  debugstr_a(lpcszBackupDir), debugstr_a(lpcszBaseName), dwFlags);
69 
70  if (lpcszFileList)
71  filelist = ansi_to_unicode_list(lpcszFileList);
72  else
73  filelist = NULL;
74 
75  RtlCreateUnicodeStringFromAsciiz(&backupdir, lpcszBackupDir);
77 
78  if (lpcszBackupDir)
79  backup = backupdir.Buffer;
80  else
81  backup = NULL;
82 
83  res = AddDelBackupEntryW(filelist, backup, basename.Buffer, dwFlags);
84 
85  HeapFree(GetProcessHeap(), 0, filelist);
86 
87  RtlFreeUnicodeString(&backupdir);
89 
90  return res;
91 }
static long backup()
Definition: maze.c:403
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static void basename(LPCWSTR path, LPWSTR name)
Definition: profile.c:38
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static LPWSTR ansi_to_unicode_list(LPCSTR ansi_list)
Definition: files.c:40
GLuint res
Definition: glext.h:9613
HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, LPCWSTR lpcszBaseName, DWORD dwFlags)
Definition: files.c:117
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by FileSaveMarkNotExistA().

◆ AddDelBackupEntryW()

HRESULT WINAPI AddDelBackupEntryW ( LPCWSTR  lpcszFileList,
LPCWSTR  lpcszBackupDir,
LPCWSTR  lpcszBaseName,
DWORD  dwFlags 
)

Definition at line 117 of file files.c.

119 {
120  WCHAR szIniPath[MAX_PATH];
121  LPCWSTR szString = NULL;
122 
123  static const WCHAR szBackupEntry[] = {
124  '-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0
125  };
126 
127  static const WCHAR backslash[] = {'\\',0};
128  static const WCHAR ini[] = {'.','i','n','i',0};
129  static const WCHAR backup[] = {'b','a','c','k','u','p',0};
130 
131  TRACE("(%s, %s, %s, %d)\n", debugstr_w(lpcszFileList),
132  debugstr_w(lpcszBackupDir), debugstr_w(lpcszBaseName), dwFlags);
133 
134  if (!lpcszFileList || !*lpcszFileList)
135  return S_OK;
136 
137  if (lpcszBackupDir)
138  lstrcpyW(szIniPath, lpcszBackupDir);
139  else
140  GetWindowsDirectoryW(szIniPath, MAX_PATH);
141 
142  lstrcatW(szIniPath, backslash);
143  lstrcatW(szIniPath, lpcszBaseName);
144  lstrcatW(szIniPath, ini);
145 
147 
148  if (dwFlags & AADBE_ADD_ENTRY)
149  szString = szBackupEntry;
150  else if (dwFlags & AADBE_DEL_ENTRY)
151  szString = NULL;
152 
153  /* add or delete the INI entries */
154  while (*lpcszFileList)
155  {
156  WritePrivateProfileStringW(backup, lpcszFileList, szString, szIniPath);
157  lpcszFileList += lstrlenW(lpcszFileList) + 1;
158  }
159 
160  /* hide the INI file */
162 
163  return S_OK;
164 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
static long backup()
Definition: maze.c:403
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define lstrlenW
Definition: compat.h:407
#define AADBE_DEL_ENTRY
Definition: advpub.h:116
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
TConfig ini
Definition: tnconfig.cpp:45
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
#define S_OK
Definition: intsafe.h:59
#define lstrcpyW
Definition: compat.h:406
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define AADBE_ADD_ENTRY
Definition: advpub.h:115
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by AddDelBackupEntryA(), and FileSaveMarkNotExistW().

◆ AdvInstallFileA()

HRESULT WINAPI AdvInstallFileA ( HWND  hwnd,
LPCSTR  lpszSourceDir,
LPCSTR  lpszSourceFile,
LPCSTR  lpszDestDir,
LPCSTR  lpszDestFile,
DWORD  dwFlags,
DWORD  dwReserved 
)

Definition at line 196 of file files.c.

199 {
200  UNICODE_STRING sourcedir, sourcefile;
201  UNICODE_STRING destdir, destfile;
202  HRESULT res;
203 
204  TRACE("(%p, %s, %s, %s, %s, %d, %d)\n", hwnd, debugstr_a(lpszSourceDir),
205  debugstr_a(lpszSourceFile), debugstr_a(lpszDestDir),
206  debugstr_a(lpszDestFile), dwFlags, dwReserved);
207 
208  if (!lpszSourceDir || !lpszSourceFile || !lpszDestDir)
209  return E_INVALIDARG;
210 
211  RtlCreateUnicodeStringFromAsciiz(&sourcedir, lpszSourceDir);
212  RtlCreateUnicodeStringFromAsciiz(&sourcefile, lpszSourceFile);
213  RtlCreateUnicodeStringFromAsciiz(&destdir, lpszDestDir);
214  RtlCreateUnicodeStringFromAsciiz(&destfile, lpszDestFile);
215 
216  res = AdvInstallFileW(hwnd, sourcedir.Buffer, sourcefile.Buffer,
217  destdir.Buffer, destfile.Buffer, dwFlags, dwReserved);
218 
219  RtlFreeUnicodeString(&sourcedir);
220  RtlFreeUnicodeString(&sourcefile);
221  RtlFreeUnicodeString(&destdir);
222  RtlFreeUnicodeString(&destfile);
223 
224  return res;
225 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSourceFile, LPCWSTR lpszDestDir, LPCWSTR lpszDestFile, DWORD dwFlags, DWORD dwReserved)
Definition: files.c:249
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLuint res
Definition: glext.h:9613

◆ AdvInstallFileW()

HRESULT WINAPI AdvInstallFileW ( HWND  hwnd,
LPCWSTR  lpszSourceDir,
LPCWSTR  lpszSourceFile,
LPCWSTR  lpszDestDir,
LPCWSTR  lpszDestFile,
DWORD  dwFlags,
DWORD  dwReserved 
)

Definition at line 249 of file files.c.

252 {
253  PSP_FILE_CALLBACK_W pFileCallback;
254  LPWSTR szDestFilename;
255  LPCWSTR szPath;
256  WCHAR szRootPath[ROOT_LENGTH];
257  DWORD dwLen, dwLastError;
258  HSPFILEQ fileQueue;
259  PVOID pContext;
260 
261  TRACE("(%p, %s, %s, %s, %s, %d, %d)\n", hwnd, debugstr_w(lpszSourceDir),
262  debugstr_w(lpszSourceFile), debugstr_w(lpszDestDir),
263  debugstr_w(lpszDestFile), dwFlags, dwReserved);
264 
265  if (!lpszSourceDir || !lpszSourceFile || !lpszDestDir)
266  return E_INVALIDARG;
267 
268  fileQueue = SetupOpenFileQueue();
269  if (fileQueue == INVALID_HANDLE_VALUE)
271 
272  pContext = NULL;
273  dwLastError = ERROR_SUCCESS;
274 
275  lstrcpynW(szRootPath, lpszSourceDir, ROOT_LENGTH);
276  szPath = lpszSourceDir + ROOT_LENGTH;
277 
278  /* use lpszSourceFile as destination filename if lpszDestFile is NULL */
279  if (lpszDestFile)
280  {
281  dwLen = lstrlenW(lpszDestFile);
282  szDestFilename = HeapAlloc(GetProcessHeap(), 0, (dwLen+1) * sizeof(WCHAR));
283  lstrcpyW(szDestFilename, lpszDestFile);
284  }
285  else
286  {
287  dwLen = lstrlenW(lpszSourceFile);
288  szDestFilename = HeapAlloc(GetProcessHeap(), 0, (dwLen+1) * sizeof(WCHAR));
289  lstrcpyW(szDestFilename, lpszSourceFile);
290  }
291 
292  /* add the file copy operation to the setup queue */
293  if (!SetupQueueCopyW(fileQueue, szRootPath, szPath, lpszSourceFile, NULL,
294  NULL, lpszDestDir, szDestFilename, dwFlags))
295  {
296  dwLastError = GetLastError();
297  goto done;
298  }
299 
301  0, 0, NULL);
302  if (!pContext)
303  {
304  dwLastError = GetLastError();
305  goto done;
306  }
307 
308  /* don't output anything for AIF_QUIET */
309  if (dwFlags & AIF_QUIET)
310  pFileCallback = pQuietQueueCallback;
311  else
312  pFileCallback = pQueueCallback;
313 
314  /* perform the file copy */
315  if (!SetupCommitFileQueueW(hwnd, fileQueue, pFileCallback, pContext))
316  {
317  dwLastError = GetLastError();
318  goto done;
319  }
320 
321 done:
323  SetupCloseFileQueue(fileQueue);
324 
325  HeapFree(GetProcessHeap(), 0, szDestFilename);
326 
327  return HRESULT_FROM_WIN32(dwLastError);
328 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HSPFILEQ WINAPI SetupOpenFileQueue(VOID)
Definition: fileqsup.c:161
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI SetupQueueCopyW(HSPFILEQ queue, PCWSTR src_root, PCWSTR src_path, PCWSTR src_file, PCWSTR src_descr, PCWSTR src_tag, PCWSTR dst_dir, PCWSTR dst_file, DWORD style)
Definition: queue.c:622
#define lstrlenW
Definition: compat.h:407
#define lstrcpynW
Definition: compat.h:397
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static UINT CALLBACK pQueueCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: files.c:175
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT(CALLBACK * PSP_FILE_CALLBACK_W)(IN PVOID Context, IN UINT Notification, IN UINT_PTR Param1, IN UINT_PTR Param2)
Definition: fileqsup.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SetupCommitFileQueueW(IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL)
Definition: fileqsup.c:617
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1704
#define AIF_QUIET
Definition: advpub.h:127
PVOID WINAPI SetupInitDefaultQueueCallbackEx(HWND owner, HWND progress, UINT msg, DWORD reserved1, PVOID reserved2)
Definition: queue.c:1686
#define lstrcpyW
Definition: compat.h:406
LPCWSTR szPath
Definition: env.c:35
static UINT CALLBACK pQuietQueueCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: files.c:169
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define ROOT_LENGTH
Definition: files.c:167
BOOL WINAPI SetupCloseFileQueue(IN HSPFILEQ QueueHandle)
Definition: fileqsup.c:217
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by AdvInstallFileA().

◆ ansi_to_unicode_list()

static LPWSTR ansi_to_unicode_list ( LPCSTR  ansi_list)
static

Definition at line 40 of file files.c.

41 {
42  DWORD len, wlen = 0;
43  LPWSTR list;
44  LPCSTR ptr = ansi_list;
45 
46  while (*ptr) ptr += lstrlenA(ptr) + 1;
47  len = ptr + 1 - ansi_list;
48  wlen = MultiByteToWideChar(CP_ACP, 0, ansi_list, len, NULL, 0);
49  list = HeapAlloc(GetProcessHeap(), 0, wlen * sizeof(WCHAR));
50  MultiByteToWideChar(CP_ACP, 0, ansi_list, len, list, wlen);
51  return list;
52 }
#define CP_ACP
Definition: compat.h:99
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define list
Definition: rosglue.h:35
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddDelBackupEntryA().

◆ convert_file_list()

static LPSTR convert_file_list ( LPCSTR  FileList,
DWORD dwNumFiles 
)
static

Definition at line 546 of file files.c.

547 {
548  DWORD dwLen;
549  const char *first = FileList;
550  const char *last = FileList + strlen(FileList) - 1;
551  LPSTR szConvertedList, temp;
552 
553  /* any number of these chars before the list is OK */
554  while (first < last && (*first == ' ' || *first == '\t' || *first == ':'))
555  first++;
556 
557  /* any number of these chars after the list is OK */
558  while (last > first && (*last == ' ' || *last == '\t' || *last == ':'))
559  last--;
560 
561  if (first == last)
562  return NULL;
563 
564  dwLen = last - first + 3; /* room for double-null termination */
565  szConvertedList = HeapAlloc(GetProcessHeap(), 0, dwLen);
566  lstrcpynA(szConvertedList, first, dwLen - 1);
567  szConvertedList[dwLen - 1] = '\0';
568 
569  /* empty list */
570  if (!szConvertedList[0])
571  {
572  HeapFree(GetProcessHeap(), 0, szConvertedList);
573  return NULL;
574  }
575 
576  *dwNumFiles = 1;
577 
578  /* convert the colons to double-null termination */
579  temp = szConvertedList;
580  while (*temp)
581  {
582  if (*temp == ':')
583  {
584  *temp = '\0';
585  (*dwNumFiles)++;
586  }
587 
588  temp++;
589  }
590 
591  return szConvertedList;
592 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
POINT last
Definition: font.c:46
vector< FileInfo > FileList
Definition: DriveVolume.h:63
const GLint * first
Definition: glext.h:5794
char * LPSTR
Definition: xmlstorage.h:182
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
static calc_node_t temp
Definition: rpn_ieee.c:38
#define lstrcpynA
Definition: compat.h:408
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by ExtractFilesA().

◆ DELNODE_recurse_dirtree()

static HRESULT DELNODE_recurse_dirtree ( LPWSTR  fname,
DWORD  flags 
)
static

Definition at line 330 of file files.c.

331 {
332  DWORD fattrs = GetFileAttributesW(fname);
333  HRESULT ret = E_FAIL;
334 
335  static const WCHAR asterisk[] = {'*',0};
336  static const WCHAR dot[] = {'.',0};
337  static const WCHAR dotdot[] = {'.','.',0};
338 
339  if (fattrs & FILE_ATTRIBUTE_DIRECTORY)
340  {
341  HANDLE hFindFile;
342  WIN32_FIND_DATAW w32fd;
343  BOOL done = TRUE;
344  int fname_len = lstrlenW(fname);
345 
346  /* Generate a path with wildcard suitable for iterating */
347  if (fname_len && fname[fname_len-1] != '\\') fname[fname_len++] = '\\';
348  lstrcpyW(fname + fname_len, asterisk);
349 
350  if ((hFindFile = FindFirstFileW(fname, &w32fd)) != INVALID_HANDLE_VALUE)
351  {
352  /* Iterate through the files in the directory */
353  for (done = FALSE; !done; done = !FindNextFileW(hFindFile, &w32fd))
354  {
355  TRACE("%s\n", debugstr_w(w32fd.cFileName));
356  if (lstrcmpW(dot, w32fd.cFileName) != 0 &&
357  lstrcmpW(dotdot, w32fd.cFileName) != 0)
358  {
359  lstrcpyW(fname + fname_len, w32fd.cFileName);
360  if (DELNODE_recurse_dirtree(fname, flags) != S_OK)
361  {
362  break; /* Failure */
363  }
364  }
365  }
366  FindClose(hFindFile);
367  }
368 
369  /* We're done with this directory, so restore the old path without wildcard */
370  *(fname + fname_len) = '\0';
371 
372  if (done)
373  {
374  TRACE("%s: directory\n", debugstr_w(fname));
376  {
377  ret = S_OK;
378  }
379  }
380  }
381  else
382  {
383  TRACE("%s: file\n", debugstr_w(fname));
385  {
386  ret = S_OK;
387  }
388  }
389 
390  return ret;
391 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define TRUE
Definition: types.h:120
static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
Definition: files.c:330
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define S_OK
Definition: intsafe.h:59
#define lstrcpyW
Definition: compat.h:406
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by DelNodeW().

◆ DelNodeA()

HRESULT WINAPI DelNodeA ( LPCSTR  pszFileOrDirName,
DWORD  dwFlags 
)

Definition at line 398 of file files.c.

399 {
400  UNICODE_STRING fileordirname;
401  HRESULT res;
402 
403  TRACE("(%s, %d)\n", debugstr_a(pszFileOrDirName), dwFlags);
404 
405  RtlCreateUnicodeStringFromAsciiz(&fileordirname, pszFileOrDirName);
406 
407  res = DelNodeW(fileordirname.Buffer, dwFlags);
408 
409  RtlFreeUnicodeString(&fileordirname);
410 
411  return res;
412 }
HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags)
Definition: files.c:432
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLuint res
Definition: glext.h:9613

◆ DelNodeRunDLL32A()

HRESULT WINAPI DelNodeRunDLL32A ( HWND  hWnd,
HINSTANCE  hInst,
LPSTR  cmdline,
INT  show 
)

Definition at line 459 of file files.c.

460 {
462  HRESULT hr;
463 
464  TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
465 
467 
468  hr = DelNodeRunDLL32W(hWnd, hInst, params.Buffer, show);
469 
471 
472  return hr;
473 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
Definition: files.c:490
HWND hWnd
Definition: settings.c:17
TCHAR * cmdline
Definition: stretchblt.cpp:32
GLenum const GLfloat * params
Definition: glext.h:5645
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
HINSTANCE hInst
Definition: dxdiag.c:13

◆ DelNodeRunDLL32W()

HRESULT WINAPI DelNodeRunDLL32W ( HWND  hWnd,
HINSTANCE  hInst,
LPWSTR  cmdline,
INT  show 
)

Definition at line 490 of file files.c.

491 {
492  LPWSTR szFilename, szFlags;
493  LPWSTR cmdline_copy, cmdline_ptr;
494  DWORD dwFlags = 0;
495  HRESULT res;
496 
497  TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_w(cmdline), show);
498 
499  cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
500  cmdline_ptr = cmdline_copy;
501  lstrcpyW(cmdline_copy, cmdline);
502 
503  /* get the parameters at indexes 0 and 1 respectively */
504  szFilename = get_parameter(&cmdline_ptr, ',', TRUE);
505  szFlags = get_parameter(&cmdline_ptr, ',', TRUE);
506 
507  if (szFlags)
508  dwFlags = atolW(szFlags);
509 
510  res = DelNodeW(szFilename, dwFlags);
511 
512  HeapFree(GetProcessHeap(), 0, cmdline_copy);
513 
514  return res;
515 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define lstrlenW
Definition: compat.h:407
HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags)
Definition: files.c:432
#define debugstr_w
Definition: kernel32.h:32
WINE_UNICODE_INLINE long int atolW(const WCHAR *str)
Definition: unicode.h:310
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted) DECLSPEC_HIDDEN
Definition: install.c:201
HINSTANCE hInst
Definition: dxdiag.c:13
#define lstrcpyW
Definition: compat.h:406
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DelNodeRunDLL32A().

◆ DelNodeW()

HRESULT WINAPI DelNodeW ( LPCWSTR  pszFileOrDirName,
DWORD  dwFlags 
)

Definition at line 432 of file files.c.

433 {
434  WCHAR fname[MAX_PATH];
435  HRESULT ret = E_FAIL;
436 
437  TRACE("(%s, %d)\n", debugstr_w(pszFileOrDirName), dwFlags);
438 
439  if (dwFlags)
440  FIXME("Flags ignored!\n");
441 
442  if (pszFileOrDirName && *pszFileOrDirName)
443  {
444  lstrcpyW(fname, pszFileOrDirName);
445 
446  /* TODO: Should check for system directory deletion etc. here */
447 
449  }
450 
451  return ret;
452 }
static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
Definition: files.c:330
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define lstrcpyW
Definition: compat.h:406

Referenced by del_dirs_callback(), DelNodeA(), and DelNodeRunDLL32W().

◆ ExtractFilesA()

HRESULT WINAPI ExtractFilesA ( LPCSTR  CabName,
LPCSTR  ExpandDir,
DWORD  Flags,
LPCSTR  FileList,
LPVOID  LReserved,
DWORD  Reserved 
)

Definition at line 688 of file files.c.

690 {
691  SESSION session;
693  HRESULT res = S_OK;
694  DWORD dwFileCount = 0;
695  DWORD dwFilesFound = 0;
696  LPSTR szConvertedList = NULL;
697 
698  TRACE("(%s, %s, %d, %s, %p, %d)\n", debugstr_a(CabName), debugstr_a(ExpandDir),
699  Flags, debugstr_a(FileList), LReserved, Reserved);
700 
701  if (!CabName || !ExpandDir)
702  return E_INVALIDARG;
703 
706 
707  hCabinet = LoadLibraryA("cabinet.dll");
708  if (!hCabinet)
709  return E_FAIL;
710 
711  ZeroMemory(&session, sizeof(SESSION));
712 
713  pExtract = (void *)GetProcAddress(hCabinet, "Extract");
714  if (!pExtract)
715  {
716  res = E_FAIL;
717  goto done;
718  }
719 
720  lstrcpyA(session.Destination, ExpandDir);
721 
722  if (FileList)
723  {
724  szConvertedList = convert_file_list(FileList, &dwFileCount);
725  if (!szConvertedList)
726  {
727  res = E_FAIL;
728  goto done;
729  }
730 
731  dwFilesFound = fill_file_list(&session, CabName, szConvertedList);
732  if (dwFilesFound != dwFileCount)
733  {
734  res = E_FAIL;
735  goto done;
736  }
737  }
738  else
739  session.Operation |= EXTRACT_FILLFILELIST;
740 
741  session.Operation |= EXTRACT_EXTRACTFILES;
742  res = pExtract(&session, CabName);
743 
744 done:
745  free_file_list(&session);
747  HeapFree(GetProcessHeap(), 0, szConvertedList);
748 
749  return res;
750 }
static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileList)
Definition: files.c:624
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define EXTRACT_EXTRACTFILES
Definition: files.c:521
vector< FileInfo > FileList
Definition: DriveVolume.h:63
#define ZeroMemory
Definition: winbase.h:1635
char * LPSTR
Definition: xmlstorage.h:182
#define E_FAIL
Definition: ddrawi.h:102
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
static void free_file_list(SESSION *session)
Definition: files.c:651
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define EXTRACT_FILLFILELIST
Definition: files.c:520
static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
Definition: files.c:546
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
#define GetProcessHeap()
Definition: compat.h:395
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
static HMODULE hCabinet
Definition: urlmon_main.c:45
Definition: files.c:529
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
INT Operation
Definition: files.c:534
#define S_OK
Definition: intsafe.h:59
GLuint res
Definition: glext.h:9613
#define GetProcAddress(x, y)
Definition: compat.h:410
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
CHAR Destination[MAX_PATH]
Definition: files.c:535
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by ExtractFilesW().

◆ ExtractFilesW()

HRESULT WINAPI ExtractFilesW ( LPCWSTR  CabName,
LPCWSTR  ExpandDir,
DWORD  Flags,
LPCWSTR  FileList,
LPVOID  LReserved,
DWORD  Reserved 
)

Definition at line 780 of file files.c.

782 {
783  char *cab_name = NULL, *expand_dir = NULL, *file_list = NULL;
784  HRESULT hres = S_OK;
785 
786  TRACE("(%s, %s, %d, %s, %p, %d)\n", debugstr_w(CabName), debugstr_w(ExpandDir),
787  Flags, debugstr_w(FileList), LReserved, Reserved);
788 
789  if(CabName) {
790  cab_name = heap_strdupWtoA(CabName);
791  if(!cab_name)
792  return E_OUTOFMEMORY;
793  }
794 
795  if(ExpandDir) {
796  expand_dir = heap_strdupWtoA(ExpandDir);
797  if(!expand_dir)
799  }
800 
801  if(SUCCEEDED(hres) && FileList) {
802  file_list = heap_strdupWtoA(FileList);
803  if(!file_list)
805  }
806 
807  /* cabinet.dll, which does the real job of extracting files, doesn't have UNICODE API,
808  so we need W->A conversion at some point anyway. */
809  if(SUCCEEDED(hres))
810  hres = ExtractFilesA(cab_name, expand_dir, Flags, file_list, LReserved, Reserved);
811 
812  heap_free(cab_name);
813  heap_free(expand_dir);
814  heap_free(file_list);
815  return hres;
816 }
vector< FileInfo > FileList
Definition: DriveVolume.h:63
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, LPCSTR FileList, LPVOID LReserved, DWORD Reserved)
Definition: files.c:688
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static char * heap_strdupWtoA(const WCHAR *str)
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by extract_cab_file().

◆ file_in_list()

static BOOL file_in_list ( LPCSTR  szFile,
LPCSTR  szFileList 
)
static

Definition at line 601 of file files.c.

602 {
603  DWORD dwLen = lstrlenA(szFile);
604  DWORD dwTestLen;
605 
606  while (*szFileList)
607  {
608  dwTestLen = lstrlenA(szFileList);
609 
610  if (dwTestLen == dwLen)
611  {
612  if (!lstrcmpiA(szFile, szFileList))
613  return TRUE;
614  }
615 
616  szFileList += dwTestLen + 1;
617  }
618 
619  return FALSE;
620 }
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
unsigned long DWORD
Definition: ntddk_ex.h:95
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145

Referenced by fill_file_list().

◆ FileSaveMarkNotExistA()

HRESULT WINAPI FileSaveMarkNotExistA ( LPSTR  pszFileList,
LPSTR  pszDir,
LPSTR  pszBaseName 
)

Definition at line 823 of file files.c.

824 {
825  TRACE("(%s, %s, %s)\n", debugstr_a(pszFileList),
826  debugstr_a(pszDir), debugstr_a(pszBaseName));
827 
828  return AddDelBackupEntryA(pszFileList, pszDir, pszBaseName, AADBE_DEL_ENTRY);
829 }
#define AADBE_DEL_ENTRY
Definition: advpub.h:116
HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, LPCSTR lpcszBaseName, DWORD dwFlags)
Definition: files.c:59
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR pszDir
Definition: shellapi.h:580

◆ FileSaveMarkNotExistW()

HRESULT WINAPI FileSaveMarkNotExistW ( LPWSTR  pszFileList,
LPWSTR  pszDir,
LPWSTR  pszBaseName 
)

Definition at line 846 of file files.c.

847 {
848  TRACE("(%s, %s, %s)\n", debugstr_w(pszFileList),
849  debugstr_w(pszDir), debugstr_w(pszBaseName));
850 
851  return AddDelBackupEntryW(pszFileList, pszDir, pszBaseName, AADBE_DEL_ENTRY);
852 }
#define AADBE_DEL_ENTRY
Definition: advpub.h:116
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR pszDir
Definition: shellapi.h:580
HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, LPCWSTR lpcszBaseName, DWORD dwFlags)
Definition: files.c:117

◆ FileSaveRestoreA()

HRESULT WINAPI FileSaveRestoreA ( HWND  hDlg,
LPSTR  pszFileList,
LPSTR  pszDir,
LPSTR  pszBaseName,
DWORD  dwFlags 
)

Definition at line 859 of file files.c.

861 {
862  UNICODE_STRING filelist, dir, basename;
863  HRESULT hr;
864 
865  TRACE("(%p, %s, %s, %s, %d)\n", hDlg, debugstr_a(pszFileList),
866  debugstr_a(pszDir), debugstr_a(pszBaseName), dwFlags);
867 
868  RtlCreateUnicodeStringFromAsciiz(&filelist, pszFileList);
871 
872  hr = FileSaveRestoreW(hDlg, filelist.Buffer, dir.Buffer,
873  basename.Buffer, dwFlags);
874 
875  RtlFreeUnicodeString(&filelist);
878 
879  return hr;
880 }
HRESULT hr
Definition: shlfolder.c:183
static void basename(LPCWSTR path, LPWSTR name)
Definition: profile.c:38
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
unsigned int dir
Definition: maze.c:112
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
_In_ LPCSTR pszDir
Definition: shellapi.h:580
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HRESULT WINAPI FileSaveRestoreW(HWND hDlg, LPWSTR pszFileList, LPWSTR pszDir, LPWSTR pszBaseName, DWORD dwFlags)
Definition: files.c:904

◆ FileSaveRestoreOnINFA()

HRESULT WINAPI FileSaveRestoreOnINFA ( HWND  hWnd,
LPCSTR  pszTitle,
LPCSTR  pszINF,
LPCSTR  pszSection,
LPCSTR  pszBackupDir,
LPCSTR  pszBaseBackupFile,
DWORD  dwFlags 
)

Definition at line 918 of file files.c.

921 {
923  UNICODE_STRING backupdir, backupfile;
924  HRESULT hr;
925 
926  TRACE("(%p, %s, %s, %s, %s, %s, %d)\n", hWnd, debugstr_a(pszTitle),
927  debugstr_a(pszINF), debugstr_a(pszSection), debugstr_a(pszBackupDir),
928  debugstr_a(pszBaseBackupFile), dwFlags);
929 
931  RtlCreateUnicodeStringFromAsciiz(&inf, pszINF);
933  RtlCreateUnicodeStringFromAsciiz(&backupdir, pszBackupDir);
934  RtlCreateUnicodeStringFromAsciiz(&backupfile, pszBaseBackupFile);
935 
936  hr = FileSaveRestoreOnINFW(hWnd, title.Buffer, inf.Buffer, section.Buffer,
937  backupdir.Buffer, backupfile.Buffer, dwFlags);
938 
940  RtlFreeUnicodeString(&inf);
942  RtlFreeUnicodeString(&backupdir);
943  RtlFreeUnicodeString(&backupfile);
944 
945  return hr;
946 }
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HRESULT WINAPI FileSaveRestoreOnINFW(HWND hWnd, LPCWSTR pszTitle, LPCWSTR pszINF, LPCWSTR pszSection, LPCWSTR pszBackupDir, LPCWSTR pszBaseBackupFile, DWORD dwFlags)
Definition: files.c:971
static char title[]
Definition: ps.c:92

◆ FileSaveRestoreOnINFW()

HRESULT WINAPI FileSaveRestoreOnINFW ( HWND  hWnd,
LPCWSTR  pszTitle,
LPCWSTR  pszINF,
LPCWSTR  pszSection,
LPCWSTR  pszBackupDir,
LPCWSTR  pszBaseBackupFile,
DWORD  dwFlags 
)

Definition at line 971 of file files.c.

974 {
975  FIXME("(%p, %s, %s, %s, %s, %s, %d): stub\n", hWnd, debugstr_w(pszTitle),
976  debugstr_w(pszINF), debugstr_w(pszSection), debugstr_w(pszBackupDir),
977  debugstr_w(pszBaseBackupFile), dwFlags);
978 
979  return E_FAIL;
980 }
HWND hWnd
Definition: settings.c:17
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by FileSaveRestoreOnINFA().

◆ FileSaveRestoreW()

HRESULT WINAPI FileSaveRestoreW ( HWND  hDlg,
LPWSTR  pszFileList,
LPWSTR  pszDir,
LPWSTR  pszBaseName,
DWORD  dwFlags 
)

Definition at line 904 of file files.c.

906 {
907  FIXME("(%p, %s, %s, %s, %d) stub\n", hDlg, debugstr_w(pszFileList),
908  debugstr_w(pszDir), debugstr_w(pszBaseName), dwFlags);
909 
910  return E_FAIL;
911 }
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ LPCSTR pszDir
Definition: shellapi.h:580
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by FileSaveRestoreA().

◆ fill_file_list()

static DWORD fill_file_list ( SESSION session,
LPCSTR  szCabName,
LPCSTR  szFileList 
)
static

Definition at line 624 of file files.c.

625 {
626  DWORD dwNumFound = 0;
627  struct FILELIST *pNode;
628 
629  session->Operation |= EXTRACT_FILLFILELIST;
630  if (pExtract(session, szCabName) != S_OK)
631  {
632  session->Operation &= ~EXTRACT_FILLFILELIST;
633  return -1;
634  }
635 
636  pNode = session->FileList;
637  while (pNode)
638  {
639  if (!file_in_list(pNode->FileName, szFileList))
640  pNode->DoExtract = FALSE;
641  else
642  dwNumFound++;
643 
644  pNode = pNode->next;
645  }
646 
647  session->Operation &= ~EXTRACT_FILLFILELIST;
648  return dwNumFound;
649 }
struct FILELIST * FileList
Definition: files.c:532
#define EXTRACT_FILLFILELIST
Definition: files.c:520
BOOL DoExtract
Definition: files.c:526
unsigned long DWORD
Definition: ntddk_ex.h:95
struct FILELIST * next
Definition: files.c:525
INT Operation
Definition: files.c:534
LPSTR FileName
Definition: files.c:524
#define S_OK
Definition: intsafe.h:59
static BOOL file_in_list(LPCSTR szFile, LPCSTR szFileList)
Definition: files.c:601

Referenced by ExtractFilesA().

◆ free_file_list()

static void free_file_list ( SESSION session)
static

Definition at line 651 of file files.c.

652 {
653  struct FILELIST *next, *curr = session->FileList;
654 
655  while (curr)
656  {
657  next = curr->next;
658  free_file_node(curr);
659  curr = next;
660  }
661 }
static void free_file_node(struct FILELIST *pNode)
Definition: files.c:594
struct FILELIST * FileList
Definition: files.c:532
struct FILELIST * next
Definition: files.c:525
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by ExtractFilesA().

◆ free_file_node()

static void free_file_node ( struct FILELIST pNode)
static

Definition at line 594 of file files.c.

595 {
596  HeapFree(GetProcessHeap(), 0, pNode->FileName);
597  HeapFree(GetProcessHeap(), 0, pNode);
598 }
#define GetProcessHeap()
Definition: compat.h:395
LPSTR FileName
Definition: files.c:524
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by free_file_list().

◆ GetVersionFromFileA()

HRESULT WINAPI GetVersionFromFileA ( LPCSTR  Filename,
LPDWORD  MajorVer,
LPDWORD  MinorVer,
BOOL  Version 
)

Definition at line 987 of file files.c.

989 {
990  TRACE("(%s, %p, %p, %d)\n", debugstr_a(Filename), MajorVer, MinorVer, Version);
991  return GetVersionFromFileExA(Filename, MajorVer, MinorVer, Version);
992 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:925
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
HRESULT WINAPI GetVersionFromFileExA(LPCSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion)
Definition: files.c:1018

◆ GetVersionFromFileExA()

HRESULT WINAPI GetVersionFromFileExA ( LPCSTR  lpszFilename,
LPDWORD  pdwMSVer,
LPDWORD  pdwLSVer,
BOOL  bVersion 
)

Definition at line 1018 of file files.c.

1020 {
1022  HRESULT res;
1023 
1024  TRACE("(%s, %p, %p, %d)\n", debugstr_a(lpszFilename),
1025  pdwMSVer, pdwLSVer, bVersion);
1026 
1028 
1029  res = GetVersionFromFileExW(filename.Buffer, pdwMSVer, pdwLSVer, bVersion);
1030 
1032 
1033  return res;
1034 }
const char * filename
Definition: ioapi.h:135
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion)
Definition: files.c:1054
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
GLuint res
Definition: glext.h:9613

Referenced by GetVersionFromFileA().

◆ GetVersionFromFileExW()

HRESULT WINAPI GetVersionFromFileExW ( LPCWSTR  lpszFilename,
LPDWORD  pdwMSVer,
LPDWORD  pdwLSVer,
BOOL  bVersion 
)

Definition at line 1054 of file files.c.

1056 {
1057  VS_FIXEDFILEINFO *pFixedVersionInfo;
1058  LANGANDCODEPAGE *pLangAndCodePage;
1059  DWORD dwHandle, dwInfoSize;
1060  WCHAR szWinDir[MAX_PATH];
1061  WCHAR szFile[MAX_PATH];
1062  LPVOID pVersionInfo = NULL;
1063  BOOL bFileCopied = FALSE;
1064  UINT uValueLen;
1065 
1066  static const WCHAR backslash[] = {'\\',0};
1067  static const WCHAR translation[] = {
1068  '\\','V','a','r','F','i','l','e','I','n','f','o',
1069  '\\','T','r','a','n','s','l','a','t','i','o','n',0
1070  };
1071 
1072  TRACE("(%s, %p, %p, %d)\n", debugstr_w(lpszFilename),
1073  pdwMSVer, pdwLSVer, bVersion);
1074 
1075  *pdwLSVer = 0;
1076  *pdwMSVer = 0;
1077 
1078  lstrcpynW(szFile, lpszFilename, MAX_PATH);
1079 
1080  dwInfoSize = GetFileVersionInfoSizeW(szFile, &dwHandle);
1081  if (!dwInfoSize)
1082  {
1083  /* check that the file exists */
1085  return S_OK;
1086 
1087  /* file exists, but won't be found by GetFileVersionInfoSize,
1088  * so copy it to the temp dir where it will be found.
1089  */
1090  GetWindowsDirectoryW(szWinDir, MAX_PATH);
1091  GetTempFileNameW(szWinDir, NULL, 0, szFile);
1092  CopyFileW(lpszFilename, szFile, FALSE);
1093  bFileCopied = TRUE;
1094 
1095  dwInfoSize = GetFileVersionInfoSizeW(szFile, &dwHandle);
1096  if (!dwInfoSize)
1097  goto done;
1098  }
1099 
1100  pVersionInfo = HeapAlloc(GetProcessHeap(), 0, dwInfoSize);
1101  if (!pVersionInfo)
1102  goto done;
1103 
1104  if (!GetFileVersionInfoW(szFile, dwHandle, dwInfoSize, pVersionInfo))
1105  goto done;
1106 
1107  if (bVersion)
1108  {
1109  if (!VerQueryValueW(pVersionInfo, backslash,
1110  (LPVOID *)&pFixedVersionInfo, &uValueLen))
1111  goto done;
1112 
1113  if (!uValueLen)
1114  goto done;
1115 
1116  *pdwMSVer = pFixedVersionInfo->dwFileVersionMS;
1117  *pdwLSVer = pFixedVersionInfo->dwFileVersionLS;
1118  }
1119  else
1120  {
1121  if (!VerQueryValueW(pVersionInfo, translation,
1122  (LPVOID *)&pLangAndCodePage, &uValueLen))
1123  goto done;
1124 
1125  if (!uValueLen)
1126  goto done;
1127 
1128  *pdwMSVer = pLangAndCodePage->wLanguage;
1129  *pdwLSVer = pLangAndCodePage->wCodePage;
1130  }
1131 
1132 done:
1133  HeapFree(GetProcessHeap(), 0, pVersionInfo);
1134 
1135  if (bFileCopied)
1136  DeleteFileW(szFile);
1137 
1138  return S_OK;
1139 }
#define TRUE
Definition: types.h:120
#define lstrcpynW
Definition: compat.h:397
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:616
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:850
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

Referenced by GetVersionFromFileExA(), and GetVersionFromFileW().

◆ GetVersionFromFileW()

HRESULT WINAPI GetVersionFromFileW ( LPCWSTR  Filename,
LPDWORD  MajorVer,
LPDWORD  MinorVer,
BOOL  Version 
)

Definition at line 999 of file files.c.

1001 {
1002  TRACE("(%s, %p, %p, %d)\n", debugstr_w(Filename), MajorVer, MinorVer, Version);
1003  return GetVersionFromFileExW(Filename, MajorVer, MinorVer, Version);
1004 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:925
#define debugstr_w
Definition: kernel32.h:32
HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion)
Definition: files.c:1054
#define TRACE(s)
Definition: solgame.cpp:4

◆ HRESULT()

static HRESULT ( WINAPI pExtract)
static

◆ pQueueCallback()

static UINT CALLBACK pQueueCallback ( PVOID  Context,
UINT  Notification,
UINT_PTR  Param1,
UINT_PTR  Param2 
)
static

Definition at line 175 of file files.c.

177 {
178  /* only be verbose for error notifications */
179  if (!Notification ||
180  Notification == SPFILENOTIFY_RENAMEERROR ||
181  Notification == SPFILENOTIFY_DELETEERROR ||
182  Notification == SPFILENOTIFY_COPYERROR)
183  {
184  return SetupDefaultQueueCallbackW(Context, Notification,
185  Param1, Param2);
186  }
187 
188  return 1;
189 }
#define SPFILENOTIFY_RENAMEERROR
Definition: fileqsup.h:33
#define SPFILENOTIFY_COPYERROR
Definition: fileqsup.h:37
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1777
#define SPFILENOTIFY_DELETEERROR
Definition: fileqsup.h:29

Referenced by AdvInstallFileW().

◆ pQuietQueueCallback()

static UINT CALLBACK pQuietQueueCallback ( PVOID  Context,
UINT  Notification,
UINT_PTR  Param1,
UINT_PTR  Param2 
)
static

Definition at line 169 of file files.c.

171 {
172  return 1;
173 }

Referenced by AdvInstallFileW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advpack  )

Variable Documentation

◆ LPCSTR

Definition at line 541 of file files.c.