c# - Copy an msi to memory, then create a Database object from it -


i'm in deep end here, please accept apologies not knowing i'm on about.

my aim take existing msi, make alterations it, create transform it, leaving msi in it's original state. i'm using dtf (part of wix), suggested in many other questions.

my problem stems fact need 2 database objects create transform; altered database , reference. can't create 2 object same file because first object locks it. trivial option create copy of file in temp directory , create new object new filepath. however, want avoid writing disk except save transform, program may used varying mixtures of vms, local storage , network storage.

from gather, dtf allow create database object handle, current approach somehow create copy of msi in memory handle , pass database constructor create temporary object can make changes before creating transform off it.

i'm @ loss of how achieve this, though, , i'm not sure it's possible. memorymappedfile seemed place start, when creating 1 file it's persistent , can't work out how either make non-persistent mmf based on file or create non-persistent mmf , read msi it.

is there feasible way create transform 1 msi on disk? open absolutely ideas/guidance/appeals accept writing disk because i'm out of depth.

i believe may stuck here. underlying windows installer database apis lock .msi file if open modification. prevent other handles being opened .msi file.

however, there 1 thing try. i'm not sure possible dtf (i know how attempt in native code) but:

  1. open .msi file edit (you'll want experiment both direct , transacted modes since 1 may work other not).

  2. create string (yes, string) "#" + numeric value of datbase handle. in native code can printf("#%u", hdatabase);. string.format using dtf intptr handle of database object might same.

  3. pass #handlenumber string open database api read-only time.

  4. modify the database first handle.

  5. try generating transform.

if doesn't work, there number of other things might try. first, open original handle read-only open database in step 4 transact or direct (basicaly switch them). if doesn't work, try committing database before step 5. however, committing database require writing disk (thus temp file).

anyway, if above not work, i'm quite convinced not possible accomplish want available apis. luck!


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -