ReactOS 0.4.15-dev-7842-g558ab78
main.c File Reference
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
#include <setupapi.h>
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define WIN32_LEAN_AND_MEAN
 
#define NT_PARAMS   L"NT3.51 Intel Params"
 
#define MSSETUP_PATH   L"~MSSETUP.T\\"
 

Functions

static UINT WINAPI ExtCabCallback (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
 
BOOL DeleteDirectory (LPWSTR lpszDir)
 
VOID GetSystemDrive (LPWSTR lpszDrive)
 
int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 

Macro Definition Documentation

◆ MSSETUP_PATH

#define MSSETUP_PATH   L"~MSSETUP.T\\"

Definition at line 9 of file main.c.

◆ NT_PARAMS

#define NT_PARAMS   L"NT3.51 Intel Params"

Definition at line 8 of file main.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 2 of file main.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 1 of file main.c.

Function Documentation

◆ DeleteDirectory()

BOOL DeleteDirectory ( LPWSTR  lpszDir)

Definition at line 32 of file main.c.

33{
34 SHFILEOPSTRUCT fileop;
35 DWORD len = wcslen(lpszDir);
36 WCHAR *pszFrom = HeapAlloc(GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR));
37 int ret;
38
39 wcscpy(pszFrom, lpszDir);
40 pszFrom[len] = 0;
41 pszFrom[len+1] = 0;
42
43 fileop.hwnd = NULL;
44 fileop.wFunc = FO_DELETE;
45 fileop.pFrom = pszFrom;
46 fileop.pTo = NULL;
49 fileop.lpszProgressTitle = NULL;
50 fileop.hNameMappings = NULL;
51
52 ret = SHFileOperation(&fileop);
53 HeapFree(GetProcessHeap(), 0, pszFrom);
54 return (ret == 0);
55}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define FO_DELETE
Definition: shellapi.h:138
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
#define SHFileOperation
Definition: shellapi.h:696
#define FOF_SILENT
Definition: shellapi.h:143
PVOID hNameMappings
Definition: shellapi.h:351
LPCSTR lpszProgressTitle
Definition: shellapi.h:352
FILEOP_FLAGS fFlags
Definition: shellapi.h:349
BOOL fAnyOperationsAborted
Definition: shellapi.h:350
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by wWinMain().

◆ ExtCabCallback()

static UINT WINAPI ExtCabCallback ( PVOID  Context,
UINT  Notification,
UINT_PTR  Param1,
UINT_PTR  Param2 
)
static

Definition at line 11 of file main.c.

12{
14 FILEPATHS_W *pFilePaths;
15
17
18 switch(Notification)
19 {
21 pInfo = (FILE_IN_CABINET_INFO_W*)Param1;
23 wcscat(pInfo->FullTargetName, pInfo->NameInCabinet);
24 return FILEOP_DOIT;
26 pFilePaths = (FILEPATHS_W*)Param1;
27 return NO_ERROR;
28 }
29 return NO_ERROR;
30}
#define NO_ERROR
Definition: dderror.h:5
#define FILEOP_DOIT
Definition: fileqsup.h:48
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SPFILENOTIFY_FILEEXTRACTED
Definition: setupapi.h:564
#define SPFILENOTIFY_FILEINCABINET
Definition: setupapi.h:562
WCHAR FullTargetName[MAX_PATH]
Definition: setupapi.h:804
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by wWinMain().

◆ GetSystemDrive()

VOID GetSystemDrive ( LPWSTR  lpszDrive)

Definition at line 57 of file main.c.

58{
59 WCHAR szWindir[MAX_PATH];
61 _wsplitpath(szWindir, lpszDrive, NULL, NULL, NULL);
62 wcscat(lpszDrive, L"\\");
63}
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
_CRTIMP void __cdecl _wsplitpath(_In_z_ const wchar_t *_FullPath, _Pre_maybenull_ _Post_z_ wchar_t *_Drive, _Pre_maybenull_ _Post_z_ wchar_t *_Dir, _Pre_maybenull_ _Post_z_ wchar_t *_Filename, _Pre_maybenull_ _Post_z_ wchar_t *_Ext)
#define L(x)
Definition: ntvdm.h:50

Referenced by wWinMain().

◆ wWinMain()

int APIENTRY wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 65 of file main.c.

69{
70 WCHAR szSetupPath[MAX_PATH];
71 WCHAR szFileName[MAX_PATH];
72 WCHAR szCabFileName[MAX_PATH];
73 WCHAR szCabFilePath[MAX_PATH];
74 WCHAR szTempDirName[50];
75 WCHAR szCmdLine[MAX_PATH];
76 WCHAR szTempCmdLine[MAX_PATH];
78 WCHAR szFullTempPath[MAX_PATH];
79 WCHAR szDrive[4];
80 DWORD dwAttrib;
81 PROCESS_INFORMATION processInfo;
82 STARTUPINFO startupInfo;
83 UNREFERENCED_PARAMETER(hPrevInstance);
84 UNREFERENCED_PARAMETER(nCmdShow);
85
86 GetCurrentDirectory(MAX_PATH, szSetupPath);
87 wcscat(szSetupPath, L"\\");
88 wcscpy(szFileName, szSetupPath);
89 wcscat(szFileName, L"setup.lst");
90
92 {
93 MessageBoxW(0, L"Cannot find Setup.lst file", L"Error", MB_OK | MB_ICONERROR);
94 return 1;
95 }
96
97 /* read information from setup.lst */
98 GetPrivateProfileStringW(NT_PARAMS, L"CabinetFile", NULL, szCabFileName, MAX_PATH, szFileName);
99 GetPrivateProfileStringW(NT_PARAMS, L"TmpDirName", NULL, szTempDirName, 50, szFileName);
100 GetPrivateProfileStringW(NT_PARAMS, L"CmdLine", NULL, szCmdLine, MAX_PATH, szFileName);
101
102 wcscpy(szCabFilePath, szSetupPath);
103 wcscat(szCabFilePath, szCabFileName);
104
105 /* ceate temp directory */
106 GetSystemDrive(szDrive);
107 wcscpy(szTempPath, szDrive);
109 wcscpy(szFullTempPath, szTempPath);
110 wcscat(szFullTempPath, szTempDirName);
111 wcscat(szFullTempPath, L"\\");
112
113 if (SHCreateDirectoryEx(0, szFullTempPath, NULL) != ERROR_SUCCESS)
114 {
115 MessageBoxW(0, L"Could not create Temp Directory.", L"Error", MB_OK | MB_ICONERROR);
116 return 1;
117 }
118
119 dwAttrib = GetFileAttributes(szTempPath);
121
122 /* extract files */
123 if (!SetupIterateCabinetW(szCabFilePath, 0, ExtCabCallback, szFullTempPath))
124 {
125 MessageBoxW(0, L"Could not extract cab file", L"Error", MB_OK | MB_ICONERROR);
127 return 1;
128 }
129
130 /* prepare command line */
131 wsprintf(szTempCmdLine, szCmdLine, szFullTempPath, lpCmdLine);
132 wcscpy(szCmdLine, szFullTempPath);
133 wcscat(szCmdLine, szTempCmdLine);
134
135 /* execute the 32-Bit installer */
136 ZeroMemory(&processInfo, sizeof(processInfo));
137 ZeroMemory(&startupInfo, sizeof(startupInfo));
138 startupInfo.cb = sizeof(startupInfo);
139 if (CreateProcessW(NULL, szCmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, szFullTempPath, &startupInfo, &processInfo))
140 {
142 CloseHandle(processInfo.hProcess);
143 CloseHandle(processInfo.hThread);
144 }
145 else
146 {
147 WCHAR szMsg[MAX_PATH];
148 wsprintf(szMsg, L"Failed to load the installer. Error %lu", GetLastError());
149 MessageBoxW(0, szMsg, L"Error", MB_OK | MB_ICONERROR);
151 return 1;
152 }
153
154 /* cleanup */
156
157 return 0;
158}
#define MSSETUP_PATH
Definition: main.c:9
static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
Definition: main.c:11
VOID GetSystemDrive(LPWSTR lpszDrive)
Definition: main.c:57
#define NT_PARAMS
Definition: main.c:8
BOOL DeleteDirectory(LPWSTR lpszDir)
Definition: main.c:32
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4592
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
BOOL WINAPI SetupIterateCabinetW(PCWSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_W MsgHandler, PVOID Context)
Definition: setupcab.c:575
#define INFINITE
Definition: serial.h:102
static char szTempPath[MAX_PATH]
Definition: data.c:16
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define SHCreateDirectoryEx
Definition: shlobj.h:2108
DWORD cb
Definition: winbase.h:831
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:181
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetFileAttributes
Definition: winbase.h:3750
#define SetFileAttributes
Definition: winbase.h:3844
#define GetCurrentDirectory
Definition: winbase.h:3740
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define wsprintf
Definition: winuser.h:5865