Topic: Wim Mounting with CAPI  (Read 5195 times)

0 Members and 1 Guest are viewing this topic.

Wim Mounting with CAPI
« on: March 02, 2011, 08:23:27 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
Hi all,

I finished adding wim mounting/unmounting functions to the CAPI

Supported WimTools are ImageX.exe and WimUtil.exe

Synatx help for the API menu (don't forget to add the APIDef to script.project) and html help for paraglider's chm are also included.

Changes to CAPI
Added new functions for mounting and unmouting wim images via API and changed old clean [UnMountWim] to [Clean_UnMountWim] and set to use new functions.

Functions added: [MountWim] [UnMountWim] [MountWim_ImageX] [UnMountWim_ImageX] [MountWim_WimUtil] [UnMountWim_WimUtil] [MountWim_DISM] [UnMountWim_DISM]

To keep the API as "dumb" and generic as possible The mount tool is decided by the project and is read from Project.ini
Code: [Select]
[ProjectInfo]
WimTools=   

Example for ImageX
Code: [Select]
[ProjectInfo]
WimTools=ImageX
imagex=C:\WinBuilder\Projects\Tools\Win7PE_SE\X64\imagex.exe

Example for WimUtil
Code: [Select]
[ProjectInfo]
WimTools=WimUtil
WimUtil=C:\WinBuilder\Projects\Tools\win7pe_SE\x86\WimUtil.exe

all file exist, error checking, mount test, and directory creation is done by the API leaving a very small and convenient footprint for .script developers


I have converted the current Win7PE_SE  to run using the API Mount/Unmount and the modified scripts are attached for your testing pleasure. new API commands work very well and cut down a large amount of redundant code used as well as being very easy to use for individual scripts for special mounting/unmounting needs, unlike trying to use functions from 54-Mount.script.

hope you like. let me know if there is something that needs fixed.

Homes32

http://homes32.winbuilder.net/projects/random/capiwim.rar
« Last Edit: March 03, 2011, 05:23:49 AM by Homes32 »

Re: Wim Mounting with CAPI
« Reply #1 on: March 02, 2011, 11:40:56 AM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Hi Homes32,

thanks a lot, give me ~2 days to check, Gena will be ready for beta tests hopefully in 2 days and I can not focus anything else for a while............

Besides, maybe related to topic, here is something which might take your interest:

as mentioned here post25 by JFX
http://www.msfn.org/board/topic/149758-win7pe-se/page__view__findpost__p__957972
w7pese requires latest imagex (wimmount) for w7sp1 source.

this is not news to me, since JFX told me about that weeks ago but he was waiting final sp1 to be sure....
as mentioned at post26, extracting boot.wim and install.wim with 7z seems not too bad ideas,
besides one should better learn wimb's makepe3 too....
and at wim-image creation step, other tools than imagex can be used (if no waik installed, dll already exists in source, x86 dll work with x86 application on hostosx64)
things need to be arranged to use extracted files directly.......
maybe related to this subject, maybe not, in either case, give me some days to respond you about this organisation.

ps: also check http://theoven.org//index.php?topic=84.0

See you. :turtle:

Re: Wim Mounting with CAPI
« Reply #2 on: March 02, 2011, 12:57:58 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
as mentioned here post25 by JFX
http://www.msfn.org/board/topic/149758-win7pe-se/page__view__findpost__p__957972
w7pese requires latest imagex (wimmount) for w7sp1 source.

this is not news to me, since JFX told me about that weeks ago but he was waiting final sp1 to be sure....
as mentioned at post26, extracting boot.wim and install.wim with 7z seems not too bad ideas,
besides one should better learn wimb's makepe3 too....
and at wim-image creation step, other tools than imagex can be used (if no waik installed, dll already exists in source, x86 dll work with x86 application on hostosx64)
things need to be arranged to use extracted files directly.......

interesting. I will have to do some tests with this...another good reason to "standardize" wim mounting

at one time I converted Win7PE_SE over to use DISM for mounting/unmounting but it was very slow like newer ImageX and DISM cannont capture wim images which makes it useless for post-building a project. besides it was a nuisance to get setup on non Win7 system. nikazzz had a good thing going with WimUtil.exe but it used vista waik files same as current version of Win7PE_SE. and it seems Booty#1 abandoned his attempt to make a wimtool. seems this whole stupid problem with redistributable files would be solved if Micro$soft would only ship imagex or DLLs on the Win7 DVD


ps. I also sent a copy of this topic and files to ChrisR for his tests. I don't know when he will get a chance to look though, as his new job is keeping him busy.

Re: Wim Mounting with CAPI
« Reply #3 on: March 02, 2011, 01:07:21 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
ChrisR not active for a while now,
I can make his login here if he asks, serving as a secret development forum, it is truely easier to communicate with forum than e-mail, just let me know.

If I remember right, gimagex can be used with new dll too, to only compress ??????

Billy has older tools that would be nice if shipped redistributable... never see such thing yet, but in time I feel .wim files will be handled more easly with tools. Remember old days when 7z can not extract wim  :cool:

Re: Wim Mounting with CAPI
« Reply #4 on: March 02, 2011, 05:17:29 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
I don't seem to have the ability to edit my posts. :(

here is an updated CommonApi script with support for mounting/unmounting with DISM (DISM support was not implemented in 1st version)

http://homes32.winbuilder.net/projects/random/capiwim.rar


I thought perhaps that DISM (since it is available unpacked on the win7 DVD) or 7z could be used to extract just the needed .dll's and driver for WimUtil.exe to work. although there is still the issue of the slower mount times. :( I'll see what I can come up with.

Re: Wim Mounting with CAPI
« Reply #5 on: March 02, 2011, 06:47:15 PM »

Galapo

  • Gena Baker
  • Grand Chef
  • *****
  • Location: Australia
  • Date Registered: Sep 2010
  • Posts: 1915
I don't seem to have the ability to edit my posts. :(

Once you reach 10 posts you'll become a "Jr. Member" and the permission of editing your own posts will be automatically applied. A few other permission sets will also be enabled.

Regards,
Galapo.

Re: Wim Mounting with CAPI
« Reply #6 on: March 03, 2011, 04:39:46 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
ok thanks for the info.

Re: Wim Mounting with CAPI
« Reply #7 on: March 03, 2011, 02:18:27 PM »

Galapo

  • Gena Baker
  • Grand Chef
  • *****
  • Location: Australia
  • Date Registered: Sep 2010
  • Posts: 1915
So you're now at 10 posts -- can you see whether you can modify your posts?

Re: Wim Mounting with CAPI
« Reply #8 on: March 04, 2011, 05:35:42 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
yep. I can modify posts now.

Re: Wim Mounting with CAPI
« Reply #9 on: March 10, 2011, 03:17:57 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Hi Homes32,

verry sorry for response delays, we are verrry busy for Gena release which come verrrry close......
Just I want you to know I did not forget....

See you. :turtle:

Re: Wim Mounting with CAPI
« Reply #10 on: March 11, 2011, 03:01:55 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
don't worry. I understand. I have been taking the time to work on Win7PE_SE...more to follow.

I'm excited for you guys that all your hard work is about to pay off!! :)

-Homes32

Re: Wim Mounting with CAPI
« Reply #11 on: March 11, 2011, 03:15:47 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
as you know, a side effect of our Gena work is improving capi that increase compatibility with pe2/3 projects with application scripts:

I just made an update to capi on w7pese server from Gena, main credits to awesome coding skills of Galapo.
2 significant things:
*
Add_Shortcut,AutoStart
now works as expected in pe2/3
*
sharing scripts (share script or any other method) now have correct shorcut creation in startmenu folder.
--> this was pretty anoying when sharing scripts, now with empty startmenu folder selection, everything nicely fits where they should be :).


there is one slight issue, which is not related to capi but w7pese, (same issue would not appear in any other pe2/3 project.....)
you can find details here post 42 46
http://www.msfn.org/board/topic/149758-win7pe-se/page__st__40

back to Gena now, thanks for understanding, See you :).
« Last Edit: March 11, 2011, 03:16:29 PM by Lancelot »

Re: Wim Mounting with CAPI
« Reply #12 on: March 14, 2011, 06:10:51 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Hi Homes32,

At last Gena Ready,
http://theoven.org//index.php?topic=86.0

and now I can read your post carelfully, yes I understand your idea  :thumbsup:

I update capi of w7pese, and I leave further decisions to you, ChrisR and Galapo .

Here are my comments.


better you invent a new *single api, fully flexible and expandable.
so far, all new* api's we introduced to capi are designed with that way since we would not want to recreate a new api in future serving same task of an existing one.
This is the only way to avoid bulks of today & future, and cleaning some hard-paths of past.

what is in my mind is:
something like:
Image=Run,%API%,Image_Process

ps: use single api to lower wb ram bug (there are tons of bugs, tons of workarounds, this is one of them)

something like:
Image,Mount,<file>,<dir>,RO
Image,Mount,<file>,<dir>,RW
Image,UnMount,<dir>

[Image_Process]
Run,%API%,Image_Process_#1,#1,#2,#3,#4,#5,#6,#7,#8,#9

[Image_Process_Mount]
...
[Image_Process_UnMount]
......

to keep backward compatibiltiy:

......
iniread,%projectinfo%,ImageHandle,Exe,%Capi_wim_Exe%
If,.......iniread,%projectinfo%,WimHandle,MountROParameter,%Capi_wim_exe_par%
If,........iniread,%projectinfo%,WimHandle,MountRWParameter,%Capi_wim_exe_par%
Shellexecute...........


a trick is, when you iniread empty, than arrange to use old design. (+use old design with readenv since there may not be a projectinfo file)

this way, you would hit all points:
single new api command, easly expandable through projectinfo, and having smallest command line executed through building :), holding backward compatibility.
even more, no need to use Api_type ;). Even live98 can use this api if live98 one day pack files into .wim and wants to mount later to change registry etc. :>.
more more: keep in mind there will be more pex in future, following ms, a long while with wim, probably with new methods and in future new parameters, and in time more utilities and methods to use these wim files....... and even for new and old file formats (img - sdi - and maybe in future ms decide wm2 :))

I hope you understand.

To me it is a nice oppurtinity to clean mainly wim handling.
As written initially, I leave development of this new api to you, Galapo and ChrisR.

Forum already public and continue opening gates widely to discuss things easly.

Have fun.  :great:
« Last Edit: March 14, 2011, 06:12:36 PM by Lancelot »

Re: Wim Mounting with CAPI
« Reply #13 on: March 16, 2011, 04:08:29 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109

better you invent a new *single api, fully flexible and expandable.
so far, all new* api's we introduced to capi are designed with that way since we would not want to recreate a new api in future serving same task of an existing one.
This is the only way to avoid bulks of today & future, and cleaning some hard-paths of past.

what is in my mind is:
something like:
Image=Run,%API%,Image_Process

ps: use single api to lower wb ram bug (there are tons of bugs, tons of workarounds, this is one of them)

something like:
Image,Mount,<file>,<dir>,RO
Image,Mount,<file>,<dir>,RW
Image,UnMount,<dir>

[Image_Process]
Run,%API%,Image_Process_#1,#1,#2,#3,#4,#5,#6,#7,#8,#9

[Image_Process_Mount]
...
[Image_Process_UnMount]
......

to keep backward compatibiltiy:

......
iniread,%projectinfo%,ImageHandle,Exe,%Capi_wim_Exe%
If,.......iniread,%projectinfo%,WimHandle,MountROParameter,%Capi_wim_exe_par%
If,........iniread,%projectinfo%,WimHandle,MountRWParameter,%Capi_wim_exe_par%
Shellexecute...........


a trick is, when you iniread empty, than arrange to use old design. (+use old design with readenv since there may not be a projectinfo file)

this way, you would hit all points:
single new api command, easly expandable through projectinfo, and having smallest command line executed through building :), holding backward compatibility.
even more, no need to use Api_type ;). Even live98 can use this api if live98 one day pack files into .wim and wants to mount later to change registry etc. :>.
more more: keep in mind there will be more pex in future, following ms, a long while with wim, probably with new methods and in future new parameters, and in time more utilities and methods to use these wim files....... and even for new and old file formats (img - sdi - and maybe in future ms decide wm2 :))

I hope you understand.

To me it is a nice oppurtinity to clean mainly wim handling.
As written initially, I leave development of this new api to you, Galapo and ChrisR.

good comments...I thought of something similar after my inital submission, but you expanded on it very well. I'll see what I can come up with after I finish rewrite of WimUtil.

Re: Wim Mounting with CAPI
« Reply #14 on: March 16, 2011, 09:40:12 AM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Happy development homes32  :thumbsup:

there are many ways to make something good, above only theorical ideas,
I trust your further judgements since you are quite experienced about things. :great:

keep in mind there does not have to be an image to be mounted/unmounted ;).

Keep the good work.  :grin:

Re: Wim Mounting with CAPI
« Reply #15 on: April 02, 2011, 04:30:21 AM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
I wrote it for the CAPI we should discuss Image integration, but in the other thread.
Code: [Select]

[ExtractWim]
// ExtractWim,WimFile,WimIndex,Target,[File]
// #1=WimFile, #2=Index #3=Target, #4=File
If,#4,Equal,"",Run,%API%,ExtractWim_All,#1,#2,#3,#4,#5,#6,#7,#8,#9
Else,Run,%API%,ExtractWim_One,#1,#2,#3,#4,#5,#6,#7,#8,#9

[ExtractWim_All]
// #1=WimFile, #2=Index #3=Target
Echo,"Extracting all files from [#1 - Index: #2] to [#3]... (This may take awhile)"
If,ExistFile,%Tools%\%SysType%\7z.exe,ShellExecute,Hide,%Tools%\%SysType%\7z.exe,"x -y #$q#1#$q -i!#2\*.* -o#$q#3#$q"
Else,ShellExecute,Open,%Tools%\7z.exe,"x -y #$q#1#$q -i!#2\ -o#$q#3#$q"

[ExtractWim_One]
// #1=WimFile, #2=Index #3=Target, #4=File
Echo,"Extracting #4 from [#1 - Index: #2] to [#3]..."
If,ExistFile,%Tools%\%SysType%\7z.exe,ShellExecute,Hide,%Tools%\%SysType%\7z.exe,"e -y #$q#1#$q -i!#2\#4 -o#$q#3#$q"
Else,ShellExecute,Hide,%Tools%\7z.exe,"e -y #$q#1#$q -i!#2\#4 -o#$q#3#$q"
StrFormat,FILENAME,#4,%FileName%
If,ExistFile,#3\#4,Echo,"Extraction FAILED for [%FileName%] : %ExitCode% :(",Warn
If,ExistFile,#3\#4,Message,"Extractiont FAILED for [%FileName%] : %ExitCode% :(",ERROR
If,Not,ExistFile,#3\#4,Echo,"Extraction Successful :)"

Hi homes32, I feel better to post here ;)

do you have the idea of using require_file api linked to ExtractWim overall operations. If yes than it would probably give hard times to all since mannnny scripts use direct filecopy etc. on component-basic scripts...... (you know the reason)

If idea is using above at prepe, to extract wimgapi.dll etc. for things, and than extract all to a folder if prefered (meee :)) (and maybe some others prefer wimmount....), than wouldn't it be better to implement above to relevant 1 or 2 scripts , like JFX way ;).

With other words, What I mean:
prepe using "ExtractWim" script api to make 7z-wim operations easly.

here is to demonstrate:
http://www.mediafire.com/?9tmdlwpo7t5507k

See you.  :cheers:
« Last Edit: April 02, 2011, 04:30:56 AM by Lancelot »

Re: Wim Mounting with CAPI
« Reply #16 on: April 03, 2011, 05:27:47 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109
do you have the idea of using require_file api linked to ExtractWim overall operations. If yes than it would probably give hard times to all since mannnny scripts use direct filecopy etc. on component-basic scripts...... (you know the reason)
no. I briefly entertained the idea at one time but there are to many issues with this method; including extensive rewrites of many scripts.

If idea is using above at prepe, to extract wimgapi.dll etc. for things, and than extract all to a folder if preferred (meee :)) (and maybe some others prefer wimmount....), than wouldn't it be better to implement above to relevant 1 or 2 scripts , like JFX way ;).

With other words, What I mean:
prepe using "ExtractWim" script api to make 7z-wim operations easly.
this was my main goal when writing this code. to extract wimgapi.dll, etc for use with wimutil.exe
separate script is fine since projects will probably only use once. probably best in PreConfig when checking sources, etc.

Re: Wim Mounting with CAPI
« Reply #17 on: April 03, 2011, 08:18:08 AM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Hi Homes32,

including extensive rewrites of many scripts.
yep I fully understand your idea behind...... it could be easy today but since the end of 2009, for known reasons, things changed the other way..... shortly idiots  :chair:.
Still possible, when time found and things become more stable......

Besides, In practice, I use same nice apis-macros for same tasks on scripts, giving example, Gena have same ImportInfTHive api individually on 2 different scripts which I believe number will increase in time by easy copy-paste  :dance:.

What I mean: I find your 7z api quite nice & tidy to be used on scripts where required, PreConfig and maybe some tools/debug scripts :thumbsup:..... and in future........ 

See you.   :turtle:

Re: Wim Mounting with CAPI
« Reply #18 on: April 19, 2011, 04:23:25 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 109

better you invent a new *single api, fully flexible and expandable.
so far, all new* api's we introduced to capi are designed with that way since we would not want to recreate a new api in future serving same task of an existing one.
This is the only way to avoid bulks of today & future, and cleaning some hard-paths of past.

....

more more: keep in mind there will be more pex in future, following ms, a long while with wim, probably with new methods and in future new parameters, and in time more utilities and methods to use these wim files....... and even for new and old file formats (img - sdi - and maybe in future ms decide wm2 :))


Image, <Operation: Mount/Unmount/Capture/Extract>, <WimFile>, <ImageIndex>, <MountDir>, <Parameters: RO/RW/Commit/Hide>

I'm seeing a few issues arising if this approach is to be used for more than just wim handling. the biggest being how to decide what the image is (ex. wim/img/wm2) do you add another command? (ex. Image,WIM,Mount...) or have CAPI guess based on .ext and hope it works.
also what about the project.ini structure.? I'm thinking something like this:
Code: [Select]
[CAPI-Image-MountRW]
ImageX=/Mountrw <WimFile> <WimIndex> <MountDir>
WimUtil=/Mount <WimFile> <WimIndex> <MountDir> /RW [/hide]

[CAPI-Image-MountRO]
ImageX=/Mount <WimFile> <WimIndex> <MountDir>
WimUtil=/Mount <WimFile> <WimIndex> <MountDir> [/hide]

for each command and then using StringReplace internally to put the correct information in place of the "tag" (in memory)

does anybody have any thoughts/concerns/ideas before I start coding?
« Last Edit: April 19, 2011, 04:24:20 AM by Homes32 »

Re: Wim Mounting with CAPI
« Reply #19 on: April 19, 2011, 02:06:13 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6984
Hi Homes32,

I agree adding another command, what you think for this:

Image,Wim,<Operation: Mount/Unmount/Capture/Extract>, <WimFile>, <ImageIndex>, <MountDir>, <Parameters: RO(Default)/RW/Commit/Hide>
Image,Img,<Operation: Mount/Unmount/Capture/Extract>, <WimFile>, <ImageIndex>, <MountDir>, <Parameters: RO(Default)/RW/Commit/Hide>
....

besides, now I think, each operation may have slightly different syntax

Image,Wim,Mount,C:\test.wim,2,C:\test
Image,Img,Mount,C:\test.img,Z:,imageoffset

Image,Wim,Unmount,C:\test
Image,Img,Unmount,Z:

Image,Wim,Extract,C:\test.wim,C:\test
Image,Wim,Extract,C:\test.wim,C:\test,windows\system32\blabla.dll,

(only ideas, change the way you like, I only wrote to demonstrate how they look)

etc. etc. etc.
but for now, only concentrating wim is enough.  :lol: :thumbsup:

maybe you can organise project.ini like in capi...... this way project admin not only control the utility to be used for different filetype, but also can control different utilities for different tasks.

Also it would help you test things easier.


in capi:
[Image_Process]
Run,%ProjectInfo%,Image_Process_#1,#1,#2,#3,#4,#5,#6,#7,#8,#9

and inside ProjectInfo you are free......


or if it is required or more confortable,

[Image_Process]
Run,%Capi_ImageHandle%,Image_Process_#1,#1,#2,#3,#4,#5,#6,#7,#8,#9

%Capi_ImageHandle% defined in script.project
%Capi_ImageHandle%=%projectdir%\Build\My_ImageHandle.script


this way, when projectinfo organisation can be called "perfect", agreed by all, we can implement to capi too ;). Time always self proves things........ (or even we can not reach perfect, above would work nicely ....)

ps: we made same trick on capi for runfromram/cd as well as shortcut so one can easly use an external script to handle these situations...... Even in practice, Gena uses an external shortcut script linked from capi  :wink: This way, as I wrote above, future shortcut handlings are full flexible to future projects without altering capi.

 :cheers:
« Last Edit: April 19, 2011, 02:07:04 PM by Lancelot »

 

Powered by EzPortal