ReactOS 0.4.16-dev-752-g47bae01
geninst.cpp File Reference
#include "defines.h"
#include <shlobj.h>
#include <shlwapi.h>
#include <setupapi.h>
#include <commctrl.h>
#include "resource.h"
#include "appdb.h"
#include "appinfo.h"
#include "misc.h"
#include "configparser.h"
#include "unattended.h"
#include "minizip/ioapi.h"
#include "minizip/iowin32.h"
#include "minizip/unzip.h"
#include "minizip/ioapi.c"
#include "minizip/iowin32.c"
#include "minizip/unzip.c"
Include dependency graph for geninst.cpp:

Go to the source code of this file.

Classes

struct  CommonInfo
 
struct  InstallInfo
 
struct  UninstallInfo
 

Macros

#define REGPATH_UNINSTALL   L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
 
#define DB_NONE   L"!"
 
#define DB_GENINST_FILES   L"Files"
 
#define DB_GENINST_DIR   L"Dir"
 
#define DB_GENINST_ICON   L"Icon"
 
#define DB_GENINST_LNK   L"Lnk"
 
#define DB_GENINST_DELFILE   L"DelFile"
 
#define DB_GENINST_DELDIR   L"DelDir"
 
#define DB_GENINST_DELDIREMPTY   L"DelDirEmpty"
 
#define DB_GENINST_DELREG   L"DelReg"
 
#define DB_GENINST_DELREGEMPTY   L"DelRegEmpty"
 

Enumerations

enum  {
  UNOP_FILE = 'F' , UNOP_DIR = 'D' , UNOP_EMPTYDIR = 'd' , UNOP_REGKEY = 'K' ,
  UNOP_EMPTYREGKEY = 'k'
}
 
enum  { IM_STARTPROGRESS = WM_APP , IM_PROGRESS , IM_END }
 
enum  UninstallStage { US_ITEMS , US_CONTAINERS , UINSTALLSTAGECOUNT }
 

Functions

static int ExtractFilesFromZip (LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
 
static UINT ExtractZip (LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
 
static UINT ExtractCab (LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
 
static UINT ErrorBox (UINT Error=GetLastError())
 
static LPCWSTR GetCommonString (LPCWSTR Name, CStringW &Output, LPCWSTR Default=L"")
 
static LPCWSTR GetGenerateString (LPCWSTR Name, CStringW &Output, LPCWSTR Default=L"")
 
static void WriteArpEntry (LPCWSTR Name, LPCWSTR Value, UINT Type=REG_SZ)
 
static BOOL AddEntry (WCHAR Type, LPCWSTR Value)
 
static HRESULT GetCustomIconPath (InstallInfo &Info, CStringW &Path)
 
static BOOL GetLocalizedSMFolderName (LPCWSTR WinVal, LPCWSTR RosInf, LPCWSTR RosVal, CStringW &Output)
 
static BOOL CreateShortcut (const CStringW &Target)
 
static BOOL InstallFiles (const CStringW &SourceDirBase, const CStringW &Spec, const CStringW &DestinationDir)
 
static void AddUninstallOperationsFromDB (LPCWSTR Name, WCHAR UnOp, CStringW PathPrefix=CStringW(L""))
 
static BOOL CALLBACK ExtractCallback (const EXTRACTCALLBACKINFO &, void *Cookie)
 
static DWORD CALLBACK ExtractAndInstallThread (LPVOID Parameter)
 
static DWORD CALLBACK WorkerThread (LPVOID Parameter)
 
static INT_PTR CALLBACK UIDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL CreateUI (BOOL Silent, LPTHREAD_START_ROUTINE ThreadProc)
 
BOOL ExtractAndRunGeneratedInstaller (const CAvailableApplicationInfo &AppInfo, LPCWSTR Archive)
 
static DWORD CALLBACK UninstallThread (LPVOID Parameter)
 
BOOL UninstallGenerated (CInstalledApplicationInfo &AppInfo, UninstallCommandFlags Flags)
 

Variables

static struct CommonInfog_pInfo
 

Macro Definition Documentation

◆ DB_GENINST_DELDIR

#define DB_GENINST_DELDIR   L"DelDir"

Definition at line 37 of file geninst.cpp.

◆ DB_GENINST_DELDIREMPTY

#define DB_GENINST_DELDIREMPTY   L"DelDirEmpty"

Definition at line 38 of file geninst.cpp.

◆ DB_GENINST_DELFILE

#define DB_GENINST_DELFILE   L"DelFile"

Definition at line 36 of file geninst.cpp.

◆ DB_GENINST_DELREG

#define DB_GENINST_DELREG   L"DelReg"

Definition at line 39 of file geninst.cpp.

◆ DB_GENINST_DELREGEMPTY

#define DB_GENINST_DELREGEMPTY   L"DelRegEmpty"

Definition at line 40 of file geninst.cpp.

◆ DB_GENINST_DIR

#define DB_GENINST_DIR   L"Dir"

Definition at line 33 of file geninst.cpp.

◆ DB_GENINST_FILES

#define DB_GENINST_FILES   L"Files"

Definition at line 32 of file geninst.cpp.

◆ DB_GENINST_ICON

#define DB_GENINST_ICON   L"Icon"

Definition at line 34 of file geninst.cpp.

◆ DB_GENINST_LNK

#define DB_GENINST_LNK   L"Lnk"

Definition at line 35 of file geninst.cpp.

◆ DB_NONE

#define DB_NONE   L"!"

Definition at line 31 of file geninst.cpp.

◆ REGPATH_UNINSTALL

#define REGPATH_UNINSTALL   L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

Definition at line 29 of file geninst.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UNOP_FILE 
UNOP_DIR 
UNOP_EMPTYDIR 
UNOP_REGKEY 
UNOP_EMPTYREGKEY 

Definition at line 42 of file geninst.cpp.

42 {
43 UNOP_FILE = 'F',
44 UNOP_DIR = 'D',
45 UNOP_EMPTYDIR = 'd',
46 UNOP_REGKEY = 'K',
47 UNOP_EMPTYREGKEY = 'k',
48};
@ UNOP_REGKEY
Definition: geninst.cpp:46
@ UNOP_FILE
Definition: geninst.cpp:43
@ UNOP_DIR
Definition: geninst.cpp:44
@ UNOP_EMPTYDIR
Definition: geninst.cpp:45
@ UNOP_EMPTYREGKEY
Definition: geninst.cpp:47

◆ anonymous enum

anonymous enum
Enumerator
IM_STARTPROGRESS 
IM_PROGRESS 
IM_END 

Definition at line 144 of file geninst.cpp.

#define WM_APP
Definition: eventvwr.h:73
@ IM_PROGRESS
Definition: geninst.cpp:144
@ IM_STARTPROGRESS
Definition: geninst.cpp:144
@ IM_END
Definition: geninst.cpp:144

◆ UninstallStage

Enumerator
US_ITEMS 
US_CONTAINERS 
UINSTALLSTAGECOUNT 

Definition at line 672 of file geninst.cpp.

673{
674 US_ITEMS,
677};
@ UINSTALLSTAGECOUNT
Definition: geninst.cpp:676
@ US_CONTAINERS
Definition: geninst.cpp:675
@ US_ITEMS
Definition: geninst.cpp:674

Function Documentation

◆ AddEntry()

static BOOL AddEntry ( WCHAR  Type,
LPCWSTR  Value 
)
static

Definition at line 218 of file geninst.cpp.

219{
220 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
222 name.Format(L"%c%u", Type, ++Info.EntryCount);
223 UINT err = Info.Entries.SetStringValue(name, Value);
224 if (err)
225 ErrorBox(err);
226 return !err;
227}
Type
Definition: Type.h:7
static UINT ErrorBox(UINT Error=GetLastError())
Definition: geninst.cpp:177
static struct CommonInfo * g_pInfo
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define err(...)
Definition: name.c:39
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AddUninstallOperationsFromDB(), CreateShortcut(), DECLARE_INTERFACE_(), ExtractAndInstallThread(), and InstallFiles().

◆ AddUninstallOperationsFromDB()

static void AddUninstallOperationsFromDB ( LPCWSTR  Name,
WCHAR  UnOp,
CStringW  PathPrefix = CStringW(L"") 
)
static

Definition at line 413 of file geninst.cpp.

414{
415 CStringW item, tmp;
416 if (*GetGenerateString(Name, tmp))
417 {
418 for (int pos = 1; pos > 0;)
419 {
420 pos = tmp.Find(L'|');
421 item = pos <= 0 ? tmp : tmp.Left(pos);
422 tmp = tmp.Mid(pos + 1);
423 AddEntry(UnOp, PathPrefix + item);
424 }
425 }
426}
CStringT Left(int nCount) const
Definition: cstringt.h:776
int Find(_In_ PCXSTR pszSub, _In_opt_ int iStart=0) const noexcept
Definition: cstringt.h:696
CStringT Mid(int iFirst, int nCount) const
Definition: cstringt.h:748
static BOOL AddEntry(WCHAR Type, LPCWSTR Value)
Definition: geninst.cpp:218
static LPCWSTR GetGenerateString(LPCWSTR Name, CStringW &Output, LPCWSTR Default=L"")
Definition: geninst.cpp:198
static ATOM item
Definition: dde.c:856

Referenced by ExtractAndInstallThread().

◆ CreateShortcut()

static BOOL CreateShortcut ( const CStringW Target)
static

Definition at line 275 of file geninst.cpp.

276{
277 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
279 CStringW rel = Info.ShortcutFile, path, dir, tmp;
280
281 if (FAILED(GetSpecialPath(csidl, path, Info.GetGuiOwner())))
282 return TRUE; // Pretend everything is OK
283
284 int cat;
285 if (Info.Parser.GetInt(DB_CATEGORY, cat) && cat == ENUM_CAT_GAMES)
286 {
287 // Try to find the name of the Games folder in the Start Menu
288 if (GetLocalizedSMFolderName(L"SM_GamesName", L"shortcuts.inf", L"Games", tmp))
289 {
290 path = BuildPath(path, tmp);
291 }
292 }
293
294 // SHPathPrepareForWrite will prepare the necessary directories.
295 // Windows and ReactOS SHPathPrepareForWrite do not support '/'.
296 rel.Replace('/', '\\');
297 path = BuildPath(path, rel.GetString());
299 HRESULT hr = SHPathPrepareForWriteW(Info.GetGuiOwner(), NULL, path, SHPPFW);
300 if ((Info.Error = ErrorFromHResult(hr)) != 0)
301 {
302 ErrorBox(Info.Error);
303 return FALSE;
304 }
305
307 hr = link.CoCreateInstance(CLSID_ShellLink, IID_IShellLinkW);
308 if (SUCCEEDED(hr))
309 {
310 if (SUCCEEDED(hr = link->SetPath(Target)))
311 {
313 link->SetWorkingDirectory(tmp);
314
316 {
317 LPWSTR p = tmp.GetBuffer();
319 link->SetIconLocation(p, idx);
320 }
321 CComPtr<IPersistFile> persist;
322 if (SUCCEEDED(hr = link->QueryInterface(IID_IPersistFile, (void**)&persist)))
323 {
324 hr = persist->Save(path, FALSE);
325 }
326 }
327 }
328 if (SUCCEEDED(hr))
329 {
330 if (AddEntry(UNOP_FILE, path))
331 {
334 }
335 }
336 else
337 {
339 }
340 return !Info.Error;
341}
#define DB_CATEGORY
Definition: appinfo.h:89
@ ENUM_CAT_GAMES
Definition: appinfo.h:30
unsigned int dir
Definition: maze.c:112
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd=NULL)
Definition: misc.cpp:480
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:93
static UINT ErrorFromHResult(HRESULT hr)
Definition: misc.h:20
CStringW SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir=NULL)
Definition: misc.cpp:468
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:886
const WCHAR * link
Definition: db.cpp:997
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
static HRESULT GetCustomIconPath(InstallInfo &Info, CStringW &Path)
Definition: geninst.cpp:230
static BOOL GetLocalizedSMFolderName(LPCWSTR WinVal, LPCWSTR RosInf, LPCWSTR RosVal, CStringW &Output)
Definition: geninst.cpp:250
GLfloat GLfloat p
Definition: glext.h:8902
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const GUID IID_IPersistFile
EXTERN_C HRESULT WINAPI SHPathPrepareForWriteW(HWND hwnd, IUnknown *modless, LPCWSTR path, DWORD flags)
Definition: shlfileop.cpp:2237
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2195
#define SHPPFW_IGNOREFILENAME
Definition: shlobj.h:341
#define SHPPFW_DIRCREATE
Definition: shlobj.h:338
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175
#define PathParseIconLocation
Definition: shlwapi.h:1017
BOOL PerUser
Definition: geninst.cpp:167
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ExtractAndInstallThread().

◆ CreateUI()

static BOOL CreateUI ( BOOL  Silent,
LPTHREAD_START_ROUTINE  ThreadProc 
)
static

Definition at line 624 of file geninst.cpp.

625{
626 enum { DLGW = 150, DLGH = 20, PAD = 4, PADx2 = PAD * 2, CHILDCOUNT = 1 };
628 static const WORD DlgTmpl[] =
629 {
630 LOWORD(DlgStyle), HIWORD(DlgStyle), 0, 0, CHILDCOUNT, 0, 0, DLGW, DLGH, 0, 0, 0,
631 PBS_MARQUEE, HIWORD(WS_CHILD | WS_VISIBLE), 0, 0, PAD, PAD, DLGW - PADx2, DLGH - PADx2, 1,
632 'm', 's', 'c', 't', 'l', 's', '_', 'p', 'r', 'o', 'g', 'r', 'e', 's', 's', '3', '2', 0, 0,
633 };
636 if (!hWnd)
637 {
638 ErrorBox();
639 return FALSE;
640 }
641 else if (!Silent)
642 {
644 }
645 MSG Msg;
646 while (GetMessageW(&Msg, NULL, 0, 0))
647 {
650 }
651 return TRUE;
652}
DWORD WINAPI ThreadProc(LPVOID lpParam)
Definition: ServiceMain.c:30
HWND hWnd
Definition: settings.c:17
struct @1645 Msg[]
unsigned short WORD
Definition: ntddk_ex.h:93
static INT_PTR CALLBACK UIDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: geninst.cpp:583
#define PAD
Definition: options.h:30
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_VISIBLE
Definition: pedump.c:620
#define PBS_MARQUEE
Definition: commctrl.h:2203
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define DS_MODALFRAME
Definition: winuser.h:375
#define DS_CENTER
Definition: winuser.h:369
#define DS_NOFAILCREATE
Definition: winuser.h:376
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define SW_SHOW
Definition: winuser.h:778
HWND WINAPI CreateDialogIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by ExtractAndRunGeneratedInstaller(), and UninstallGenerated().

◆ ErrorBox()

static UINT ErrorBox ( UINT  Error = GetLastError())
static

Definition at line 177 of file geninst.cpp.

178{
179 if (!Error)
181 WCHAR buf[400];
184 MessageBoxW(g_pInfo->GetGuiOwner(), buf, 0, MB_OK | MB_ICONSTOP);
185 g_pInfo->Error = Error;
186 return Error;
187}
BOOL Error
Definition: chkdsk.c:66
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _countof(array)
Definition: sndvol32.h:70
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:793
#define MB_ICONSTOP
Definition: winuser.h:806
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by AddEntry(), CreateShortcut(), CreateUI(), ExtractAndInstallThread(), ExtractFilesCallback(), InstallFiles(), UIDlgProc(), UninstallThread(), and WriteArpEntry().

◆ ExtractAndInstallThread()

static DWORD CALLBACK ExtractAndInstallThread ( LPVOID  Parameter)
static

Definition at line 437 of file geninst.cpp.

438{
439 const BOOL PerUserModeDefault = TRUE;
440 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
441 LPCWSTR AppName = Info.AppName, Archive = Info.ArchivePath, None = DB_NONE;
442 CStringW installdir, tempdir, files, shortcut, tmp;
443 HRESULT hr;
444 CRegKey arpkey;
445 Info.ArpKey = &arpkey;
446
447 if (!*GetGenerateString(DB_GENINST_FILES, files, L"*.exe|*.*"))
449
451 if (tmp.CompareNoCase(L"User") == 0)
452 Info.PerUser = TRUE;
453 else if (tmp.CompareNoCase(L"Machine") == 0)
454 Info.PerUser = FALSE;
455 else
456 Info.PerUser = PerUserModeDefault;
457
458 hr = GetProgramFilesPath(installdir, Info.PerUser, Info.GetGuiOwner());
459 if ((Info.Error = ErrorFromHResult(hr)) != 0)
460 return ErrorBox(Info.Error);
461
463 if (tmp.Find('%') == 0 && ExpandEnvStrings(tmp))
464 installdir = tmp;
465 else if (tmp.Compare(None))
466 installdir = BuildPath(installdir, tmp.IsEmpty() ? AppName : tmp.GetString());
467 Info.InstallDir = installdir.GetString();
468 Info.InstallDirLen = installdir.GetLength() + 1;
469 hr = SHPathPrepareForWriteW(Info.GetGuiOwner(), NULL, installdir, SHPPFW_DIRCREATE);
470 if ((Info.Error = ErrorFromHResult(hr)) != 0)
471 return ErrorBox(Info.Error);
472
473 // Create the destination directory, and inside it, a temporary directory
474 // where we will extract the archive to before moving the files to their
475 // final location (adding uninstall entries as we go)
476 tempdir.Format(L"%s\\~RAM%u.tmp", installdir.GetString(), GetCurrentProcessId());
477 Info.Error = CreateDirectoryTree(tempdir.GetString());
478 if (Info.Error)
479 return ErrorBox(Info.Error);
480
481 if (!*GetGenerateString(DB_GENINST_LNK, shortcut))
482 shortcut.Format(L"%s.lnk", AppName);
483 Info.ShortcutFile = shortcut.Compare(None) ? shortcut.GetString() : NULL;
484
485 // Create the uninstall registration key
486 LPCWSTR arpkeyname = AppName;
487 tmp = BuildPath(REGPATH_UNINSTALL, arpkeyname);
490 Info.Error = arpkey.Create(hRoot, tmp, NULL, REG_OPTION_NON_VOLATILE, regsam);
491 if (!Info.Error)
492 {
494 Info.Error = Info.Entries.Create(arpkey, GENERATE_ARPSUBKEY);
495 }
496 if (Info.Error)
497 ErrorBox(Info.Error);
498
499 if (!Info.Error)
500 {
501 BOOL isCab = SplitFileAndDirectory(Archive).Right(4).CompareNoCase(L".cab") == 0;
502 Info.Error = isCab ? ExtractCab(Archive, tempdir, ExtractCallback, &Info)
503 : ExtractZip(Archive, tempdir, ExtractCallback, &Info);
504 }
505
506 if (!Info.Error)
507 {
508 // We now know how many files we extracted, change from marquee to normal progress bar.
509 SendMessage(Info.hDlg, IM_STARTPROGRESS, 0, 0);
510
511 for (int pos = 1; pos > 0 && !Info.Error;)
512 {
513 pos = files.Find(L'|');
514 CStringW item = pos <= 0 ? files : files.Left(pos);
515 files = files.Mid(pos + 1);
516 InstallFiles(tempdir, item, installdir);
517 }
518
519 if (!Info.MainApp.IsEmpty())
520 {
527
528 WriteArpEntry(L"DisplayName", AppName);
529 WriteArpEntry(L"InstallLocation", Info.InstallDir); // Note: This value is used by the uninstaller!
530
531 LPWSTR p = tmp.GetBuffer(1 + MAX_PATH);
532 p[0] = L'\"';
534 tmp.ReleaseBuffer();
535 UINT cch = tmp.GetLength(), bitness = IsSystem64Bit() ? 64 : 32;
536 WCHAR modechar = Info.PerUser ? 'U' : 'M';
537 LPCWSTR unparamsfmt = L"\" /" CMD_KEY_UNINSTALL L" /K%s \"%c%d\\%s\"";
538 (tmp = tmp.Mid(0, cch)).AppendFormat(unparamsfmt, L"", modechar, bitness, arpkeyname);
539 WriteArpEntry(L"UninstallString", tmp);
540 (tmp = tmp.Mid(0, cch)).AppendFormat(unparamsfmt, L" /S", modechar, bitness, arpkeyname);
541 WriteArpEntry(L"QuietUninstallString", tmp);
542
543 hr = GetCustomIconPath(Info, tmp);
545 WriteArpEntry(L"DisplayIcon", hr == S_OK ? tmp : Info.MainApp);
546
547 if (*GetCommonString(DB_VERSION, tmp))
548 WriteArpEntry(L"DisplayVersion", tmp);
549
550 SYSTEMTIME st;
551 GetSystemTime(&st);
552 tmp.Format(L"%.4u%.2u%.2u", st.wYear, st.wMonth, st.wDay);
553 WriteArpEntry(L"InstallDate", tmp);
554
555 if (*GetCommonString(DB_PUBLISHER, tmp))
556 WriteArpEntry(L"Publisher", tmp);
557
558#if DBG
559 tmp.Format(L"sys64=%d rapps%d", IsSystem64Bit(), sizeof(void*) * 8);
560 WriteArpEntry(L"_DEBUG", tmp);
561#endif
562 }
563
564 if (!Info.Error && Info.ShortcutFile)
565 {
566 CreateShortcut(Info.MainApp);
567 }
568 }
569
571 RemoveDirectory(installdir.GetString()); // This is harmless even if we installed something
572 return 0;
573}
#define DB_PUBLISHER
Definition: appinfo.h:90
#define GENERATE_ARPSUBKEY
Definition: appinfo.h:97
#define DB_VERSION
Definition: appinfo.h:88
#define DB_SCOPE
Definition: appinfo.h:93
bool ExpandEnvStrings(CStringW &Str)
Definition: misc.cpp:422
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd=NULL)
Definition: misc.cpp:448
UINT CreateDirectoryTree(LPCWSTR Dir)
Definition: misc.cpp:461
HRESULT GetProgramFilesPath(CStringW &Path, BOOL PerUser, HWND hwnd=NULL)
Definition: misc.cpp:504
BOOL IsSystem64Bit()
Definition: misc.cpp:317
@ None
Definition: install.h:14
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL) noexcept
Definition: atlbase.h:1189
LONG RecurseDeleteKey(LPCTSTR lpszKey) noexcept
Definition: atlbase.h:1414
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
int GetLength() const noexcept
Definition: atlsimpstr.h:362
CStringT Right(int nCount) const
Definition: cstringt.h:788
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
int Compare(_In_z_ PCXSTR psz) const
Definition: cstringt.h:738
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DB_GENINST_DIR
Definition: geninst.cpp:33
#define DB_GENINST_FILES
Definition: geninst.cpp:32
static BOOL CreateShortcut(const CStringW &Target)
Definition: geninst.cpp:275
#define DB_GENINST_DELREG
Definition: geninst.cpp:39
static UINT ExtractCab(LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
Definition: geninst.cpp:135
#define DB_GENINST_DELDIR
Definition: geninst.cpp:37
static void AddUninstallOperationsFromDB(LPCWSTR Name, WCHAR UnOp, CStringW PathPrefix=CStringW(L""))
Definition: geninst.cpp:413
#define DB_GENINST_DELDIREMPTY
Definition: geninst.cpp:38
#define DB_NONE
Definition: geninst.cpp:31
#define DB_GENINST_LNK
Definition: geninst.cpp:35
#define REGPATH_UNINSTALL
Definition: geninst.cpp:29
static BOOL CALLBACK ExtractCallback(const EXTRACTCALLBACKINFO &, void *Cookie)
Definition: geninst.cpp:429
#define DB_GENINST_DELFILE
Definition: geninst.cpp:36
static BOOL InstallFiles(const CStringW &SourceDirBase, const CStringW &Spec, const CStringW &DestinationDir)
Definition: geninst.cpp:344
#define DB_GENINST_DELREGEMPTY
Definition: geninst.cpp:40
static void WriteArpEntry(LPCWSTR Name, LPCWSTR Value, UINT Type=REG_SZ)
Definition: geninst.cpp:206
static LPCWSTR GetCommonString(LPCWSTR Name, CStringW &Output, LPCWSTR Default=L"")
Definition: geninst.cpp:190
static UINT ExtractZip(LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
Definition: geninst.cpp:127
#define S_OK
Definition: intsafe.h:52
static HTREEITEM hRoot
Definition: treeview.c:383
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
@ Archive
Definition: scrrun.idl:75
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wDay
Definition: winbase.h:933
#define CMD_KEY_UNINSTALL
Definition: unattended.h:5
#define RemoveDirectory
Definition: winbase.h:3920
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define GetModuleFileName
Definition: winbase.h:3856
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
#define ERROR_BAD_FORMAT
Definition: winerror.h:114
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define SendMessage
Definition: winuser.h:5855
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ExtractAndRunGeneratedInstaller().

◆ ExtractAndRunGeneratedInstaller()

BOOL ExtractAndRunGeneratedInstaller ( const CAvailableApplicationInfo AppInfo,
LPCWSTR  Archive 
)

Definition at line 655 of file geninst.cpp.

656{
657 InstallInfo Info(AppInfo.szDisplayName, *AppInfo.GetConfigParser(), Archive);
658 g_pInfo = &Info;
659 return CreateUI(Info.Silent, ExtractAndInstallThread) ? !Info.Error : FALSE;
660}
CStringW szDisplayName
Definition: appinfo.h:112
CConfigParser * GetConfigParser() const
Definition: appinfo.h:165
static DWORD CALLBACK ExtractAndInstallThread(LPVOID Parameter)
Definition: geninst.cpp:437
static BOOL CreateUI(BOOL Silent, LPTHREAD_START_ROUTINE ThreadProc)
Definition: geninst.cpp:624

Referenced by HandleGenerateInstallerCommand().

◆ ExtractCab()

static UINT ExtractCab ( LPCWSTR  Archive,
const CStringW OutputDir,
EXTRACTCALLBACK  Callback,
void Cookie 
)
static

Definition at line 135 of file geninst.cpp.

137{
138 if (ExtractFilesFromCab(Archive, OutputDir, Callback, Cookie))
139 return ERROR_SUCCESS;
141 return err ? err : ERROR_INTERNAL_ERROR;
142}
BOOL ExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir, EXTRACTCALLBACK Callback, void *Cookie)
Definition: cabinet.cpp:250
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14

Referenced by ExtractAndInstallThread().

◆ ExtractCallback()

static BOOL CALLBACK ExtractCallback ( const EXTRACTCALLBACKINFO ,
void Cookie 
)
static

Definition at line 429 of file geninst.cpp.

430{
432 Info.Count += 1;
433 return TRUE;
434}

Referenced by ExtractAndInstallThread().

◆ ExtractFilesFromZip()

static int ExtractFilesFromZip ( LPCWSTR  Archive,
const CStringW OutputDir,
EXTRACTCALLBACK  Callback,
void Cookie 
)
static

Definition at line 51 of file geninst.cpp.

53{
54 const UINT pkzefsutf8 = 1 << 11; // APPNOTE; APPENDIX D
57 unzFile hzf = unzOpen2_64(Archive, &zff);
58 if (!hzf)
59 return UNZ_BADZIPFILE;
60 CStringA narrow;
62 int zerr = unzGoToFirstFile(hzf);
63 for (; zerr == UNZ_OK; zerr = unzGoToNextFile(hzf))
64 {
66 zerr = unzGetCurrentFileInfo64(hzf, &fi, NULL, 0, NULL, 0, NULL, 0);
67 if (zerr != UNZ_OK)
68 break;
69 LPSTR file = narrow.GetBuffer(fi.size_filename);
70 zerr = unzGetCurrentFileInfo64(hzf, &fi, file, narrow.GetAllocLength(), NULL, 0, NULL, 0);
71 if (zerr != UNZ_OK)
72 break;
74 narrow.Replace('/', '\\');
75 while (narrow[0] == '\\')
76 narrow = narrow.Mid(1);
77 UINT codepage = (fi.flag & pkzefsutf8) ? CP_UTF8 : 1252;
78 UINT cch = MultiByteToWideChar(codepage, 0, narrow, -1, NULL, 0);
79 cch = MultiByteToWideChar(codepage, 0, narrow, -1, path.GetBuffer(cch - 1), cch);
80 if (!cch)
81 break;
82 path.ReleaseBuffer(cch - 1);
84 BYTE attsys = HIBYTE(fi.version), dos = 0, ntfs = 10, vfat = 14;
85 if ((attsys == dos || attsys == ntfs || attsys == vfat) && LOBYTE(fi.external_fa))
86 fileatt = LOBYTE(fi.external_fa);
87
90 continue; // Skip file
91
92 path = BuildPath(OutputDir, path);
94 if (!dir.IsEmpty() && (err = CreateDirectoryTree(dir)))
95 {
96 zerr = UNZ_ERRNO;
98 break;
99 }
100
101 if ((zerr = unzOpenCurrentFile(hzf)) != UNZ_OK)
102 break;
103 zerr = UNZ_ERRNO;
106 NULL, CREATE_ALWAYS, fileatt, NULL);
108 {
109 DWORD len = 1024 * 4, cb;
110 LPSTR buf = narrow.GetBuffer(len);
111 for (zerr = UNZ_OK; zerr == UNZ_OK;)
112 {
113 len = zerr = unzReadCurrentFile(hzf, buf, len);
114 if (zerr <= 0)
115 break;
116 zerr = WriteFile(hFile, buf, len, &cb, NULL) && cb == len ? UNZ_OK : UNZ_ERRNO;
117 }
119 }
121 }
122 unzClose(hzf);
123 return zerr == UNZ_END_OF_LIST_OF_FILE ? UNZ_OK : zerr;
124}
static BOOL NotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes, EXTRACTCALLBACK Callback, void *Cookie)
Definition: misc.h:58
int GetAllocLength() const noexcept
Definition: atlsimpstr.h:357
#define CloseHandle
Definition: compat.h:739
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: iowin32.c:457
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define CREATE_ALWAYS
Definition: disk.h:72
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
IMAGE_DOS_HEADER dos
Definition: module.c:49
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define GENERIC_WRITE
Definition: nt_native.h:90
#define CP_UTF8
Definition: nls.h:20
Definition: fci.c:127
uLong version
Definition: unzip.h:113
ZPOS64_T uncompressed_size
Definition: unzip.h:120
uLong size_filename
Definition: unzip.h:121
uLong external_fa
Definition: unzip.h:127
unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: unzip.c:783
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition: unzip.c:1129
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition: unzip.c:1183
int ZEXPORT unzOpenCurrentFile(unzFile file)
Definition: unzip.c:1648
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
Definition: unzip.c:1691
int ZEXPORT unzCloseCurrentFile(unzFile file)
Definition: unzip.c:2014
int ZEXPORT unzGoToNextFile(unzFile file)
Definition: unzip.c:1204
int ZEXPORT unzClose(unzFile file)
Definition: unzip.c:813
#define UNZ_BADZIPFILE
Definition: unzip.h:79
#define UNZ_ERRNO
Definition: unzip.h:76
#define UNZ_END_OF_LIST_OF_FILE
Definition: unzip.h:75
voidp unzFile
Definition: unzip.h:70
#define UNZ_OK
Definition: unzip.h:74
int codepage
Definition: win_iconv.c:156
char * LPSTR
Definition: xmlstorage.h:182
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ExtractZip().

◆ ExtractZip()

static UINT ExtractZip ( LPCWSTR  Archive,
const CStringW OutputDir,
EXTRACTCALLBACK  Callback,
void Cookie 
)
static

Definition at line 127 of file geninst.cpp.

129{
130 int zerr = ExtractFilesFromZip(Archive, OutputDir, Callback, Cookie);
131 return zerr == UNZ_ERRNO ? GetLastError() : zerr ? ERROR_INTERNAL_ERROR : 0;
132}
static int ExtractFilesFromZip(LPCWSTR Archive, const CStringW &OutputDir, EXTRACTCALLBACK Callback, void *Cookie)
Definition: geninst.cpp:51

Referenced by ExtractAndInstallThread().

◆ GetCommonString()

static LPCWSTR GetCommonString ( LPCWSTR  Name,
CStringW Output,
LPCWSTR  Default = L"" 
)
static

Definition at line 190 of file geninst.cpp.

191{
192 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
194 return (found && !Output.IsEmpty() ? Output : Output = Default).GetString();
195}
BOOL GetString(const CStringW &KeyName, CStringW &ResultString)
@ Default
Definition: stdole2.idl:392
@ Output
Definition: arc.h:85
CConfigParser & Parser
Definition: geninst.cpp:163

Referenced by ExtractAndInstallThread().

◆ GetCustomIconPath()

static HRESULT GetCustomIconPath ( InstallInfo Info,
CStringW Path 
)
static

Definition at line 230 of file geninst.cpp.

231{
233 {
234 if (Path.Compare(DB_NONE) == 0)
236 Path = BuildPath(Info.InstallDir, Path);
237 int idx = PathParseIconLocation(Path.GetBuffer());
238 Path.ReleaseBuffer();
239 HICON hIco = NULL;
240 if (ExtractIconExW(Path, idx, &hIco, NULL, 1))
241 DestroyIcon(hIco);
242 if (idx)
243 Path.AppendFormat(L",%d", idx);
244 return hIco ? S_OK : S_FALSE;
245 }
247}
PRTL_UNICODE_STRING_BUFFER Path
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define DB_GENINST_ICON
Definition: geninst.cpp:34
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:855
static HICON
Definition: imagelist.c:80
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2139

Referenced by CreateShortcut(), and ExtractAndInstallThread().

◆ GetGenerateString()

static LPCWSTR GetGenerateString ( LPCWSTR  Name,
CStringW Output,
LPCWSTR  Default = L"" 
)
static

Definition at line 198 of file geninst.cpp.

199{
200 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
202 return (r ? Output : Output = Default).GetString();
203}
#define DB_GENINSTSECTION
Definition: appinfo.h:96
UINT GetSectionString(LPCWSTR Section, LPCWSTR Name, CStringW &Result)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by AddUninstallOperationsFromDB(), ExtractAndInstallThread(), and GetCustomIconPath().

◆ GetLocalizedSMFolderName()

static BOOL GetLocalizedSMFolderName ( LPCWSTR  WinVal,
LPCWSTR  RosInf,
LPCWSTR  RosVal,
CStringW Output 
)
static

Definition at line 250 of file geninst.cpp.

251{
252 CRegKey key;
253 if (key.Open(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion", KEY_READ) == ERROR_SUCCESS &&
254 GetRegString(key, WinVal, Output) && !Output.IsEmpty())
255 {
256 return TRUE;
257 }
258 WCHAR windir[MAX_PATH];
259 GetWindowsDirectoryW(windir, _countof(windir));
260 CStringW path = BuildPath(BuildPath(windir, L"inf"), RosInf), section;
261 DWORD lang = 0, lctype = LOCALE_ILANGUAGE | LOCALE_RETURN_NUMBER;
262 if (GetLocaleInfoW(GetUserDefaultLCID(), lctype, (LPWSTR) &lang, sizeof(lang) / sizeof(WCHAR)))
263 {
264 section.Format(L"Strings.%.4x", lang);
265 if (ReadIniValue(path, section, RosVal, Output) > 0)
266 return TRUE;
267 section.Format(L"Strings.%.2x", PRIMARYLANGID(lang));
268 if (ReadIniValue(path, section, RosVal, Output) > 0)
269 return TRUE;
270 }
271 return ReadIniValue(path, L"Strings", RosVal, Output) > 0;
272}
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:399
HRESULT ReadIniValue(LPCWSTR File, LPCWSTR Section, LPCWSTR Name, CStringW &Output)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1211
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
#define PRIMARYLANGID(l)
Definition: nls.h:16
Definition: copy.c:22
Definition: parser.c:56
static const WCHAR lang[]
Definition: wbemdisp.c:287
#define LOCALE_ILANGUAGE
Definition: winnls.h:25

Referenced by CreateShortcut().

◆ InstallFiles()

static BOOL InstallFiles ( const CStringW SourceDirBase,
const CStringW Spec,
const CStringW DestinationDir 
)
static

Definition at line 344 of file geninst.cpp.

346{
347 InstallInfo &Info = *static_cast<InstallInfo *>(g_pInfo);
348 CStringW sourcedir, filespec;
349 filespec = SplitFileAndDirectory(Spec, &sourcedir); // Split "[OptionalDir\]*.ext"
350 sourcedir = BuildPath(SourceDirBase, sourcedir);
351 BOOL success = TRUE;
353 HANDLE hFind = FindFirstFileW(BuildPath(sourcedir, filespec), &wfd);
354 if (hFind == INVALID_HANDLE_VALUE)
355 {
358 return TRUE;
359 else
360 return !ErrorBox(error);
361 }
362
363 for (;;)
364 {
365 CStringW from = BuildPath(sourcedir, wfd.cFileName);
366 CStringW to = BuildPath(DestinationDir, wfd.cFileName);
367 CStringW uninstpath = to.Mid(Info.InstallDirLen - 1);
368 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
369 {
370 LPWSTR p = wfd.cFileName;
371 BOOL dots = p[0] == '.' && (!p[1] || (p[1] == '.' && !p[2]));
372 if (!dots)
373 {
374 Info.Error = CreateDirectoryTree(to);
375 if (Info.Error)
376 {
377 success = !ErrorBox(Info.Error);
378 }
379
380 if (success)
381 {
382 success = InstallFiles(from, filespec, to);
383 }
384 AddEntry(UNOP_EMPTYDIR, uninstpath);
385 }
386 }
387 else
388 {
390 if (success)
391 {
392 if (Info.MainApp.IsEmpty())
393 {
394 Info.MainApp = to;
395 }
396 success = AddEntry(UNOP_FILE, uninstpath);
397 }
398 else
399 {
400 ErrorBox();
401 }
402 SendMessage(g_pInfo->hDlg, IM_PROGRESS, 0, 0);
403 }
404
405 if (!success || !FindNextFileW(hFind, &wfd))
406 break;
407 }
408 FindClose(hFind);
409 return success;
410}
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
#define MOVEFILE_COPY_ALLOWED
Definition: filesup.h:29
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
CardRegion * from
Definition: spigame.cpp:19
#define success(from, fromstr, to, tostr)
#define MoveFileEx
Definition: winbase.h:3903

Referenced by ExtractAndInstallThread(), and InstallFiles().

◆ UIDlgProc()

static INT_PTR CALLBACK UIDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 583 of file geninst.cpp.

584{
585 HWND hPB = GetDlgItem(hDlg, 1);
586 switch(uMsg)
587 {
588 case IM_STARTPROGRESS:
591 SendMessageW(hPB, PBM_SETRANGE32, 0, g_pInfo->Count);
592 SendMessageW(hPB, PBM_SETPOS, 0, 0);
593 break;
594 case IM_PROGRESS:
595 SendMessageW(hPB, PBM_DELTAPOS, 1, 0);
596 break;
597 case IM_END:
598 DestroyWindow(hDlg);
599 break;
600 case WM_INITDIALOG:
601 {
603 g_pInfo->hDlg = hDlg;
605 SendMessageW(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIco);
606 SendMessageW(hDlg, WM_SETTEXT, 0, (LPARAM)g_pInfo->AppName);
608 {
609 ErrorBox();
610 SendMessageW(hDlg, IM_END, 0, 0);
611 }
612 break;
613 }
614 case WM_CLOSE:
615 return TRUE;
616 case WM_DESTROY:
617 PostMessage(NULL, WM_QUIT, 0, 0);
618 break;
619 }
620 return FALSE;
621}
#define IDI_MAIN
Definition: resource.h:4
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
HINSTANCE hInst
Definition: dxdiag.c:13
static DWORD CALLBACK WorkerThread(LPVOID Parameter)
Definition: geninst.cpp:576
#define PBM_SETRANGE32
Definition: commctrl.h:2193
#define PBM_DELTAPOS
Definition: commctrl.h:2190
#define PBM_SETPOS
Definition: commctrl.h:2189
#define PBM_SETMARQUEE
Definition: commctrl.h:2204
#define CTF_COINIT
Definition: shlwapi.h:1964
#define ICON_BIG
Definition: tnclass.cpp:51
#define SetWindowLongPtr
Definition: treelist.c:70
#define WM_CLOSE
Definition: winuser.h:1624
#define WM_QUIT
Definition: winuser.h:1626
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SETTEXT
Definition: winuser.h:1620
#define PostMessage
Definition: winuser.h:5844
#define WM_DESTROY
Definition: winuser.h:1612
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GWL_STYLE
Definition: winuser.h:855
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2161
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CreateUI().

◆ UninstallGenerated()

BOOL UninstallGenerated ( CInstalledApplicationInfo AppInfo,
UninstallCommandFlags  Flags 
)

Definition at line 815 of file geninst.cpp.

816{
818 g_pInfo = &Info;
819 return CreateUI(Info.Silent, UninstallThread) ? !Info.Error : FALSE;
820}
@ UCF_SILENT
Definition: appinfo.h:77
static DWORD CALLBACK UninstallThread(LPVOID Parameter)
Definition: geninst.cpp:680
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CInstalledApplicationInfo::UninstallApplication().

◆ UninstallThread()

static DWORD CALLBACK UninstallThread ( LPVOID  Parameter)
static

Definition at line 680 of file geninst.cpp.

681{
682 UninstallInfo &Info = *static_cast<UninstallInfo *>(g_pInfo);
683
684 CStringW tmp, path, installdir;
686 tmp.Format(path.GetString(), Info.AppName);
687 if (!Info.Silent &&
688 MessageBox(Info.GetGuiOwner(), tmp, Info.AppName, MB_YESNO | MB_ICONQUESTION) != IDYES)
689 {
690 Info.Error = ERROR_CANCELLED;
691 SendMessage(Info.hDlg, IM_END, 0, 0);
692 return 0;
693 }
694
695 Info.Error = Info.Entries.Open(*Info.ArpKey, GENERATE_ARPSUBKEY, KEY_READ);
696 if (Info.Error)
697 return ErrorBox(Info.Error);
698
699 RegQueryInfoKey(Info.Entries, NULL, NULL, NULL, NULL, NULL, NULL, &Info.Count, NULL, NULL, NULL, NULL);
700 Info.Count *= UINSTALLSTAGECOUNT;
701 SendMessage(Info.hDlg, IM_STARTPROGRESS, 0, 0);
702
703 if (!GetRegString(*Info.ArpKey, L"InstallLocation", installdir) || installdir.IsEmpty())
705
706 for (UINT stage = 0; stage < UINSTALLSTAGECOUNT; ++stage)
707 {
708 for (UINT vi = 0;; ++vi)
709 {
711 DWORD valsize = _countof(value), size = sizeof(data) - sizeof(WCHAR), rt;
713 UINT err = RegEnumValue(Info.Entries, vi, value, &valsize, NULL, &rt, (BYTE*)data, &size);
714 if (err)
715 {
717 {
718 return ErrorBox(err);
719 }
720 break;
721 }
722
723 LPCWSTR str = data;
724 WORD op = value[0];
725 switch(*data ? MAKEWORD(stage, op) : 0)
726 {
729 {
730 REGSAM wowsam = 0;
731 HKEY hKey = NULL;
732 path.Format(L"%.4s", data);
733 if (path.CompareNoCase(L"HKCR") == 0)
735 else if (path.CompareNoCase(L"HKCU") == 0)
737 else if (path.CompareNoCase(L"HKLM") == 0)
739
740 if (data[4] == '6' && data[5] == '4')
741 wowsam = KEY_WOW64_64KEY;
742 else if (data[4] == '3' && data[5] == '2')
743 wowsam = KEY_WOW64_32KEY;
744
745 str = &data[wowsam ? 6 : 4];
746 if (!hKey || *str != L'\\')
747 break;
748 tmp = SplitFileAndDirectory(++str, &path);
749 if (!tmp.IsEmpty() && !path.IsEmpty())
750 {
751 CRegKey key;
752 err = key.Open(hKey, path, DELETE | wowsam);
753 if (err == ERROR_SUCCESS)
754 {
755 if (op == UNOP_REGKEY)
756 err = key.RecurseDeleteKey(tmp);
757 else if (RegKeyHasValues(hKey, str, wowsam) == S_FALSE)
758 key.DeleteSubKey(tmp); // DelRegEmpty ignores errors
759 }
760 switch(err)
761 {
762 case ERROR_SUCCESS:
765 break;
766 default:
767 return ErrorBox(err);
768 }
769 }
770 break;
771 }
772
774 {
775 if (*data == L'\\')
776 str = (path = BuildPath(installdir, data));
777
778 if (!DeleteFile(str))
779 {
780 err = GetLastError();
782 {
783 return ErrorBox(err);
784 }
785 }
786 break;
787 }
788
791 {
792 if (*data == L'\\')
793 str = (path = BuildPath(installdir, data));
794
795 if (op == UNOP_DIR)
796 DeleteDirectoryTree(str, Info.GetGuiOwner());
797 else
799 break;
800 }
801 }
802 SendMessage(Info.hDlg, IM_PROGRESS, 0, 0);
803 }
804 }
805 if (!Info.Error)
806 {
808 if (Info.Error)
809 return ErrorBox(Info.Error);
810 }
811 return 0;
812}
HRESULT RegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam=0)
Definition: misc.cpp:381
#define IDS_INSTGEN_CONFIRMUNINST
Definition: resource.h:237
static DWORD RemoveInstalledAppFromRegistry(const CAppInfo *Info)
Definition: appdb.cpp:315
UINT op
Definition: effect.c:236
#define ERROR_INVALID_NAME
Definition: compat.h:103
FxAutoRegKey hKey
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
struct msdos_volume_info vi
Definition: mkdosfs.c:440
#define DELETE
Definition: nt_native.h:57
#define UNICODE_NULL
const WCHAR * str
#define MAKEWORD(a, b)
Definition: typedefs.h:248
Definition: pdh_main.c:94
#define DeleteFile
Definition: winbase.h:3789
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_CANCELLED
Definition: winerror.h:726
#define RegEnumValue
Definition: winreg.h:511
#define RegQueryInfoKey
Definition: winreg.h:521
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MB_YESNO
Definition: winuser.h:820
#define MB_ICONQUESTION
Definition: winuser.h:792
#define MessageBox
Definition: winuser.h:5834
#define IDYES
Definition: winuser.h:838

Referenced by UninstallGenerated().

◆ WorkerThread()

static DWORD CALLBACK WorkerThread ( LPVOID  Parameter)
static

Definition at line 576 of file geninst.cpp.

577{
579 return SendMessage(g_pInfo->hDlg, IM_END, 0, 0);
580}
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:754
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by UIDlgProc().

◆ WriteArpEntry()

static void WriteArpEntry ( LPCWSTR  Name,
LPCWSTR  Value,
UINT  Type = REG_SZ 
)
static

Definition at line 206 of file geninst.cpp.

207{
208 // Write a "Add/Remove programs" value if we have a valid uninstaller key
209 if (g_pInfo->ArpKey)
210 {
211 UINT err = g_pInfo->ArpKey->SetStringValue(Name, Value, Type);
212 if (err)
213 ErrorBox(err);
214 }
215}

Referenced by ExtractAndInstallThread().

Variable Documentation

◆ g_pInfo