MSI: write the encoded GUIDs for product registration in the Installer
registry
Mike McCormack
mike at codeweavers.com
Fri Jul 9 13:32:19 CDT 2004
ChangeLog:
<aric at codeweavers.com>
<mike at codeweavers.com>
* write the encoded GUIDs for product registration in the Installer
registry
-------------- next part --------------
diff -ur dlls/msi.old/action.c dlls/msi/action.c
--- dlls/msi.old/action.c 2004-07-09 13:30:08.000000000 -0500
+++ dlls/msi/action.c 2004-07-09 13:30:26.000000000 -0500
@@ -3132,7 +3132,7 @@
* actually done in the PublishComponents and PublishFeatures
* step, and not here. It appears like the keypath and all that is
* resolved in this step, however actually written in the Publish steps.
- * But we will leave it here for now
+ * But we will leave it here for now because it is unclear
*/
static UINT ACTION_ProcessComponents(MSIHANDLE hPackage)
{
@@ -3181,9 +3181,36 @@
if (rc != ERROR_SUCCESS)
goto end;
- /* I have no idea what goes in here */
+ /* here the guids are 85 base encoded */
for (i = 0; i < package->loaded_features; i++)
- RegSetValueExW(hkey3,package->features[i].Feature,0,REG_SZ,NULL,0);
+ {
+ LPWSTR data = NULL;
+ GUID clsid;
+ int j;
+ INT size;
+
+ size = package->features[i].ComponentCount*21*sizeof(WCHAR);
+ data = HeapAlloc(GetProcessHeap(), 0, size);
+
+ data[0] = 0;
+ for (j = 0; j < package->features[i].ComponentCount; j++)
+ {
+ WCHAR buf[21];
+ TRACE("From %s\n",debugstr_w(package->components
+ [package->features[i].Components[j]].ComponentId));
+ CLSIDFromString(package->components
+ [package->features[i].Components[j]].ComponentId,
+ &clsid);
+ encode_base85_guid(&clsid,buf);
+ TRACE("to %s\n",debugstr_w(buf));
+ strcatW(data,buf);
+ }
+
+ size = strlenW(data)*sizeof(WCHAR);
+ RegSetValueExW(hkey3,package->features[i].Feature,0,REG_SZ,
+ (LPSTR)data,size);
+ HeapFree(GetProcessHeap(),0,data);
+ }
RegCloseKey(hkey3);
RegCloseKey(hkey2);
diff -ur dlls/msi.old/msi.c dlls/msi/msi.c
--- dlls/msi.old/msi.c 2004-07-09 13:30:08.000000000 -0500
+++ dlls/msi/msi.c 2004-07-09 13:30:26.000000000 -0500
@@ -145,6 +145,83 @@
return TRUE;
}
+/* tables for encoding and decoding base85 */
+static unsigned char table_dec85[0x80] = {
+0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
+0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
+0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
+0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
+0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
+0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
+};
+
+static char table_enc85[] =
+"!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
+"PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
+"yz{}~";
+
+/*
+ * Converts a base85 encoded guid into a GUID pointer
+ * Base85 encoded GUIDs should be 20 characters long.
+ *
+ * returns TRUE if successful, FALSE if not
+ */
+BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
+{
+ DWORD i, val = 0, base = 1, *p;
+
+ p = (DWORD*) guid;
+ for( i=0; i<20; i++ )
+ {
+ if( (i%5) == 0 )
+ {
+ val = 0;
+ base = 1;
+ }
+ val += table_dec85[str[i]] * base;
+ if( str[i] >= 0x80 )
+ return FALSE;
+ if( table_dec85[str[i]] == 0xff )
+ return FALSE;
+ if( (i%5) == 4 )
+ p[i/5] = val;
+ base *= 85;
+ }
+ return TRUE;
+}
+
+/*
+ * Encodes a base85 guid given a GUID pointer
+ * Caller should provide a 21 character buffer for the encoded string.
+ *
+ * returns TRUE if successful, FALSE if not
+ */
+BOOL encode_base85_guid( GUID *guid, LPWSTR str )
+{
+ unsigned int x, *p, i;
+
+ p = (unsigned int*) guid;
+ for( i=0; i<4; i++ )
+ {
+ x = p[i];
+ *str++ = table_enc85[x%85];
+ x = x/85;
+ *str++ = table_enc85[x%85];
+ x = x/85;
+ *str++ = table_enc85[x%85];
+ x = x/85;
+ *str++ = table_enc85[x%85];
+ x = x/85;
+ *str++ = table_enc85[x%85];
+ }
+ *str = 0;
+
+ return TRUE;
+}
+
+
VOID MSI_CloseDatabase( VOID *arg )
{
MSIDATABASE *db = (MSIDATABASE *) arg;
diff -ur dlls/msi.old/msipriv.h dlls/msi/msipriv.h
--- dlls/msi.old/msipriv.h 2004-07-09 13:30:08.000000000 -0500
+++ dlls/msi/msipriv.h 2004-07-09 13:30:26.000000000 -0500
@@ -245,6 +245,8 @@
BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
BOOL squash_guid(LPCWSTR in, LPWSTR out);
+BOOL encode_base85_guid(GUID *,LPWSTR);
+BOOL decode_base85_guid(LPCWSTR,GUID*);
/* UI globals */
extern INSTALLUILEVEL gUILevel;
More information about the wine-patches
mailing list