Author: mladen.turk(a)jboss.com
Date: 2008-04-07 10:27:14 -0400 (Mon, 07 Apr 2008)
New Revision: 1529
Modified:
trunk/build/install/installer/main.c
Log:
Allow config embedding in exe
Modified: trunk/build/install/installer/main.c
===================================================================
--- trunk/build/install/installer/main.c 2008-04-07 12:55:55 UTC (rev 1528)
+++ trunk/build/install/installer/main.c 2008-04-07 14:27:14 UTC (rev 1529)
@@ -51,6 +51,160 @@
static LPCSTR CMD_QUOTE = " &()[]{}^=;!'+,`~";
static LPSTR ppUnizpArgs[] = { "unzip", "-qq", "-d", NULL,
NULL };
+#define EMBED_SIZE 2048
+#define EMBED_MAX 2044
+
+typedef struct {
+ char s_signature[16];
+ char s_class[EMBED_SIZE];
+ char s_flags[32];
+ UINT32 s_iopts[4];
+ char e_signature[16];
+} st_config;
+
+static BYTE c_signature[] = {
+ 's', 't', 'a', 'r', 't', 'u',
's', 'e', 'r', 's', 'b', 'l', 'o',
'c', 'k', '\0'
+};
+
+/* space in exe stub for user configuration */
+static BYTE conf_in_exe[EMBED_SIZE + 64] = {
+ 'S', 'T', 'A', 'R', 'T', 'U',
'S', 'E', 'R', 'S', 'B', 'L', 'O',
'C', 'K', '\0',
+
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+
+ '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0',
+ 'E', 'N', 'D', 'O', 'F', 'U',
'S', 'E', 'R', 'S', 'B', 'L', 'O',
'C', 'K', '\0',
+};
+
+static st_config *pConfig = NULL;
+
BOOL opt_Quiet = FALSE;
BOOL opt_Verbose = FALSE;
@@ -69,9 +223,11 @@
#define LNGOPT '.'
#define EMSG ""
-static LPSTR szProgramName = NULL;
-static LPSTR szProgramPath = NULL;
-static LPSTR szTempPath = NULL;
+static LPSTR szProgramName = NULL;
+static LPSTR szProgramPath = NULL;
+static LPSTR szProgramExe = NULL;
+static LPSTR szTempPath = NULL;
+static HANDLE hStub = NULL;
static int c_errno_table[] = {
@@ -371,11 +527,11 @@
if (szProgramName)
return szProgramName;
- szProgramPath = (LPSTR)calloc(1, MAX_PATH);
+ szProgramPath = (LPSTR)x_malloc(MAX_PATH);
if (!GetModuleFileNameExA(GetCurrentProcess(), NULL,
szProgramPath, MAX_PATH))
exit(GetLastError());
-
+ szProgramExe = x_strdup(szProgramPath);
if ((p = strrchr(szProgramPath, '\\')))
*(p++) = '\0';
else
@@ -422,7 +578,7 @@
if (!GetModuleFileNameExA(GetCurrentProcess(), NULL,
szProgramPath, MAX_PATH))
exit(GetLastError());
-
+ szProgramExe = x_strdup(szProgramPath);
if ((p = strrchr(szProgramPath, '\\')))
*(p++) = '\0';
else
@@ -739,6 +895,79 @@
return rv;
}
+static INT
+AplMemCmp(LPCVOID lpA, LPCVOID lpB, SIZE_T nBytes)
+{
+ if (nBytes != 0) {
+ const BYTE *p1 = lpA, *p2 = lpB;
+
+ do {
+ if (*p1++ != *p2++)
+ return (*--p1 - *--p2);
+ } while (--nBytes != 0);
+ }
+ return 0;
+}
+
+/*
+ * Find the first occurrence of lpFind in lpMem.
+ * dwLen: The length of lpFind
+ * dwSize: The length of lpMem
+ */
+static LPBYTE
+ApcMemSearch(LPCVOID lpMem, LPCVOID lpFind, SIZE_T dwLen, SIZE_T dwSize)
+{
+ BYTE c, sc;
+ SIZE_T cnt = 0;
+ const BYTE *s = lpMem, *find = lpFind;
+
+ if ((c = *find++) != 0) {
+ do {
+ do {
+ sc = *s++;
+ if (cnt++ > dwSize)
+ return NULL;
+ } while (sc != c);
+ } while (AplMemCmp(s, find, dwLen - 1) != 0);
+ s--;
+ }
+ return (LPBYTE)s;
+}
+
+
+/* Merge the stub with jar file
+ * Fix the userblock bounded code.
+ */
+static BOOL MergeConfig(size_t slen)
+{
+ HANDLE hmap;
+ BOOL rv = FALSE;
+ BYTE bmatch[16];
+
+ BYTE *map, *ss;
+ int i;
+ if ((hmap = CreateFileMapping(hStub, NULL,
+ PAGE_READWRITE, 0, 0, NULL)) == NULL) {
+ x_perror(0, "Mapping Stub");
+ }
+ if ((map = MapViewOfFile(hmap, FILE_MAP_ALL_ACCESS, 0, 0, 0)) == NULL) {
+ x_perror(0, "Mapping Stub View");
+ }
+ /* convert to upper case */
+ for (i = 0; i < 15; i++)
+ bmatch[i] = c_signature[i] - 32;
+ bmatch[15] = 0;
+ if ((ss = ApcMemSearch(map, bmatch, 16, slen)) != NULL) {
+ st_config cfg;
+ memcpy(&cfg, ss, sizeof(st_config));
+ memcpy(ss, pConfig, sizeof(st_config));
+ rv = TRUE;
+ }
+ UnmapViewOfFile(map);
+ CloseHandle(hmap);
+ return rv;
+}
+
static void ExitCleanup(void)
{
static int cleanup = 0;
@@ -785,13 +1014,21 @@
#endif
int r, ch;
int ap = 1;
+ BOOL bRunScript;
+ BOOL bMakeTemp;
+ BOOL bShowSplash;
+ BOOL bShowLicense;
+ BOOL selectDest;
+ DWORD dwWinTimeout;
+ DWORD dwSplTimeout;
+ BOOL bMerge = FALSE;
+
+ LPSTR szCmdLine = NULL;
size_t l;
- BOOL selectDest = TRUE;
- LPSTR szCmdLine = NULL;
CHAR szBuf[MAX_PATH];
CHAR szCmdExe[MAX_PATH];
CHAR szWorkDir[MAX_PATH];
- CHAR szDest[MAX_PATH] = { 0, 0 };
+ CHAR szDest[MAX_PATH] = { 0, 0 };
LPSTR szHtmlPage = NULL;
LPSTR szHtmlTitle = NULL;
@@ -799,17 +1036,28 @@
LPSTR szHtmlResult = NULL;
DWORD dwHtmlWidth = DEF_WWIDTH;
DWORD dwHtmlHeight = DEF_WHEIGHT;
- DWORD dwWinTimeout = INFINITE;
DWORD dwFlags = 0;
+ LPCSTR szEulaPage = "/HTML_EULAMAIN";
PROCESS_INFORMATION prInfo;
- LPCSTR szEulaPage = "/HTML_EULAMAIN";
atexit(ExitCleanup);
+ pConfig = (st_config *)conf_in_exe;
+ /* Read defaults from embedded config
+ */
+ bRunScript = pConfig->s_flags[0];
+ bMakeTemp = pConfig->s_flags[1];
+ selectDest = pConfig->s_flags[2];
+ opt_Verbose = pConfig->s_flags[3];
+ bShowSplash = pConfig->s_flags[4];
+ bShowLicense = pConfig->s_flags[5];
+ dwWinTimeout = pConfig->s_iopts[0];
+ dwSplTimeout = pConfig->s_iopts[1];
+
if (!GuiInitialize()) {
exit(-1);
}
- while ((ch = getopt(__argc, __argv, "aAd:f:gh:n:p:qQr:st:vVw:")) != EOF) {
+ while ((ch = getopt(__argc, __argv, "aAd:f:gh:len:p:qQr:s:S:t:T:uvVw:x"))
!= EOF) {
switch (ch) {
case 'A':
case 'a':
@@ -836,14 +1084,17 @@
szEulaPage = "/HTML_LGPLMAIN";
break;
case 'd':
- if (*optarg != '~') {
+ if (*optarg == '~') {
+ szDest[0] = '~';
+ selectDest = FALSE;
+ }
+ if (*optarg == '?') {
+ selectDest = TRUE;
+ }
+ else {
if (x_fullpath(optarg, szDest))
selectDest = FALSE;
}
- else {
- szDest[0] = '~';
- selectDest = FALSE;
- }
break;
case 'n':
szHtmlTitle = x_strdup(optarg);
@@ -852,8 +1103,13 @@
szHtmlPage = x_fullpath(optarg, NULL);
break;
case 's':
- dwFlags = 1;
+ bShowSplash = TRUE;
+ dwSplTimeout = (DWORD)atoi(optarg);
break;
+ case 'S':
+ bShowSplash = TRUE;
+ dwSplTimeout = (DWORD)atoi(optarg) * 1000;
+ break;
case 'f':
szHtmlResult = x_fullpath(optarg, NULL);
break;
@@ -864,15 +1120,30 @@
szHtmlParams[l] = '\t';
}
break;
+ case 'l':
+ bShowLicense = TRUE;
+ break;
+ case 'e':
+ bMerge = TRUE;
+ break;
case 't':
dwWinTimeout = (DWORD)atoi(optarg);
break;
+ case 'T':
+ dwWinTimeout = (DWORD)atoi(optarg) * 1000;
+ break;
case 'w':
dwHtmlWidth = (DWORD)atoi(optarg);
break;
case 'h':
dwHtmlHeight = (DWORD)atoi(optarg);
break;
+ case 'u':
+ bMakeTemp = FALSE;
+ break;
+ case 'x':
+ bRunScript = TRUE;
+ break;
case '?':
r = EINVAL;
goto cleanup;
@@ -882,6 +1153,34 @@
__argc -= optind;
__argv += optind;
+ if (dwWinTimeout == 0)
+ dwWinTimeout = INFINITE;
+
+ if (bMerge) {
+ BY_HANDLE_FILE_INFORMATION si;
+ if (__argc < 1) {
+ x_perror(EINVAL, "Missing Argument");
+ }
+ GetProgramName();
+ if ((hStub = CreateFile(__argv[0], GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ NULL)) == INVALID_HANDLE_VALUE) {
+ x_perror(0, szProgramExe);
+ }
+ /* Get original stub size */
+ GetFileInformationByHandle(hStub, &si);
+ pConfig->s_flags[0] = bRunScript;
+ pConfig->s_flags[1] = bMakeTemp;
+ pConfig->s_flags[2] = selectDest;
+ pConfig->s_flags[3] = opt_Verbose;
+ pConfig->s_flags[4] = bShowSplash;
+ pConfig->s_flags[5] = bShowLicense;
+ pConfig->s_iopts[0] = dwWinTimeout;
+ pConfig->s_iopts[1] = dwSplTimeout;
+ r = MergeConfig(si.nFileSizeLow);
+ CloseHandle(hStub);
+ goto cleanup;
+ }
if (szHtmlPage) {
if (!szHtmlTitle) {
r = EINVAL;
@@ -907,7 +1206,7 @@
}
/* Standard Install */
- if (!opt_Quiet && !AcceptLicensePage(szEulaPage)) {
+ if (bShowLicense && !AcceptLicensePage(szEulaPage)) {
r = EPERM;
goto cleanup;
}
@@ -919,7 +1218,7 @@
goto cleanup;
}
}
- if (szDest[0] != '~' && access(szDest, 06)) {
+ if (szDest[0] && szDest[0] != '~' && access(szDest, 06)) {
if (errno == ENOENT) {
char msg[MAX_PATH + 64];
sprintf(msg, GuiLoadResource(IDS_NDIRMSG, 0),
@@ -955,12 +1254,23 @@
x_perror(0, "System Directory");
}
- if (!(szTempPath = x_mktemp(NULL, 0))) {
- x_perror(EPERM, "Creating Temp directory");
+ if (bMakeTemp) {
+ if (!(szTempPath = x_mktemp(NULL, 0))) {
+ x_perror(EPERM, "Creating Temp directory");
+ }
+ strcpy(szWorkDir, szTempPath);
+ strcat(szWorkDir, DIR_BATCH);
+ ppUnizpArgs[3] = szTempPath;
}
- strcpy(szWorkDir, szTempPath);
- strcat(szWorkDir, DIR_BATCH);
- ppUnizpArgs[3] = szTempPath;
+ else {
+ if (szDest[0] && szDest[0] != '~')
+ ppUnizpArgs[3] = szDest;
+ else {
+ /* Nothing to do */
+ r = 0;
+ goto cleanup;
+ }
+ }
if (opt_Verbose) {
fprintf(stdout, "Running main: %s\n", szTempPath);
}
@@ -972,17 +1282,18 @@
x_perror(EINVAL, "Uncompressing");
}
DESTROYGLOBALS();
- szCmdLine = BuildCommandLine(szCmdExe,
- CMD_BATCH,
- CMD_PARAM,
- szDest,
- NULL);
- if (RunChildProcess(szCmdExe, szCmdLine, szWorkDir, &prInfo)) {
-
- r = 0;
+ if (bRunScript) {
+ szCmdLine = BuildCommandLine(szCmdExe,
+ CMD_BATCH,
+ CMD_PARAM,
+ szDest,
+ NULL);
+ if (RunChildProcess(szCmdExe, szCmdLine, szWorkDir, &prInfo)) {
+ r = 0;
+ }
+ else
+ r = GetLastError();
}
- else
- r = GetLastError();
#if 0
GuiOkMessage(NULL,
"Continue",