Jump to content











Photo
- - - - -

Problem with RegAddBoot in Win7PE_SE Release (build 2010-12-10)


  • This topic is locked This topic is locked
10 replies to this topic

#1 WetHat

WetHat

    Member

  • Members
  • 50 posts
  • Location:Black Forest
  •  
    Germany

Posted 30 December 2010 - 06:16 PM

Hi ChrisR et al.,

I believe I found an issue in the implementation of RegAddBoot in Win7PE_SE_2010_12_10. During build I kept getting an error complaining about a missing script section [RegAdd_boot2] while creating file associations. Inspection of the common_api.script lead me to believe that the RegAddBoot api command has been refactored. An older implementation (version 2010-09-17) used two utility commands RegAdd_boot1 and RegAdd_boot2 which were called depending on the value of %API_TYPE%. The current implementation uses %Capi_RegAddBootMethod% instead to determine which utility script to call (RegAdd_boot_NMcfg or RegAdd_boot_ExpEnvVar). Unfortunately this refactoring was not done everywhere. Other scripts in common_api still call the old utility methods (RegAdd_boot1 and RegAdd_boot2). To complete the refactoring I suggest the following changes to common_api.script:


@@ +1948,8 -1948,8 @@

[do_associate_action1]

If,Not,#2,Equal,icon,reg_add,0x2,%reg%\Classes\#1\shell\#2\command,,"#$q#3#$q#$s#$q#$p1#$q"

If,#5,Equal,True,Begin

< If,#4,Equal,,Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,#3

> If,#4,Equal,,Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,#3

< Else,Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,"#3,#4"

> Else,Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,"#3,#4"

End

Else,Begin

If,#4,Equal,,reg_add,0x2,%reg%\Classes\#1\DefaultIcon,,"#$q#3#$q"

@@ +1959,8 -1959,8 @@

[do_associate_action2]

If,Not,#2,Equal,icon,IniWriteTextLine,%PE_CFG%,registry,"#$qHKLM#$q#$c0x1#$c#$qSOFTWARE\Classes\#1\shell\#2\command#$q#$c#$q#$q#$c#$q#3#$q#$s#$q#$p1#$q"

If,#5,Equal,True,Begin

< If,#4,Equal,,Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,#3

> If,#4,Equal,,Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,#3

< Else,Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,"#3,#4"

> Else,Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\#1\DefaultIcon,,"#3,#4"

End

Else,Begin

If,#4,Equal,,IniWriteTextLine,%PE_CFG%,registry,"#$qHKLM#$q#$c0x2#$c#$qSOFTWARE\Classes\#1\DefaultIcon#$q#$c#$q#$q#$c#$q#3#$q"

@@ +2968,7 -2968,7 @@

End

//this makes all with no folder --> explorer shell to programs -- bsexplorer to root If,Not,%ToRoot%,Equal,,If,#1,Equal,StartMenu,Set,#1,""

If,#1,Equal,StartMenu,Set,#1,#2

< If,#1,Equal,EditWith,Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\*\shell\#2#$s#4\command,,"#3 #$q#$p1#$q"

> If,#1,Equal,EditWith,Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\*\shell\#2#$s#4\command,,"#3 #$q#$p1#$q"

Else,Begin

If,#1,Equal,Autorun,Run,%API%,Add_Auto_Run%API_TYPE%,#4,#3,#6,#8

Else,IniWriteTextLine,%PE_CFG%,shortcut,"#1|#4|#3|#7|#6"

@@ +3120,7 -3120,7 @@

If,#4,Equal,,If,Not,#3,Equal,%PE_Programs%\%programFolder%\%programExe%,StrFormat,RTrim,%CFilename%,4,#4

End

If,#4,Equal,,Set,#4,%ProgramTitle%

< Run,%API%,RegAdd_boot%API_TYPE%,HKLM,0x2,Software\Classes\*\shell\#2#$s#4\command,,"#3 #$q#$p1#$q"

> Run,%API%,RegAdd_boot_%Capi_RegAddBootMethod%,HKLM,0x2,Software\Classes\*\shell\#2#$s#4\command,,"#3 #$q#$p1#$q"



[AddShortcut98NO]

Echo,"Capi Setting: No Add_Shortcut",Warn


What do you think?

Happy new year from WetHat

#2 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 30 December 2010 - 09:56 PM

Hi Wethat!

Seems you are the first victim of the unlogical Common-API logic!

API means "Application Programming Interface" and should be an entry point for every (application) project to do something, mainly with app scripts.

Our current Common-API does a lot of functions which makes writing of app scripts much more easier, but is has one really big disadvantage: It tries to implement the internal functionality of the calling project.
That nearly automatically implements: Whenever somebody writes a new project, API is a candidate to be adapted.

But it is difficult to adapt: Currently all XP based projects are %API_Type%=1, and all Vista and Win7 based projects are %API_Type%=2.
How to distinguish between projects?
In the actual Common API there are already some checks for 'Leopard', which is one, AND ONLY ONE, distinct project ... ;)

Common_ApiEx.script(858): If,%ProjectName%,Equal,"Leopard",Set,"%PE_Programs%","X:\Program#$sFiles"
Common_ApiEx.script(1883): If,NOT,"%ProjectName%",Equal,"Leopard",Begin
Common_ApiEx.script(2250): If,NOT,"%ProjectName%",Equal,"Leopard",IniRead,%ProjectInfo%,"%OsType%Info","WimTools","%WimTools%"

Maybe the next Common-API release has a check for Win7PE_SE_2010_12_10, too. etc. etc. ... (noblesse oblige) :whistling:

BTW: I did not test your supposed fix, but it looks reasonable. On the other hand: Do you want to remain the fix-supplyer, whenever a project changes, or a new project is published?

If you want to read some background, please look to the topic http://reboot.pro/18...dpost__p__11740

Peter

#3 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10549 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 31 December 2010 - 03:17 AM

Please refrain the tone in your comments Peter. It is not the way to improve the current state of API commands.

If you would like to see changes/improvements to occur, I'd suggest you get your hands on the code just like WetHat did.

Otherwise, these type of comments are not constructive nor welcome at all.

#4 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 31 December 2010 - 09:17 AM

If you would like to see changes/improvements to occur, I'd suggest you get your hands on the code just like WetHat did.

Since some weeks I'm doing so.
This is my way:
Attached File  hookapi.gif   38.44KB   40 downloads
As soon it is ready for the publicity, I'll publish.

Peter

#5 paraglider

paraglider

    Gold Member

  • .script developer
  • 1729 posts
  • Location:NC,USA
  •  
    United States

Posted 31 December 2010 - 10:30 AM

I think the common api would be alot simpler / easier to maintain / faster if it was refactored into 3 seperate files - one contains the api functions that have the same implementation for all project types, one file for the xp specific functionality, a third file for all vista / win7 specific functionality. That way the implementation function names could be the same for all project types only the api file name changes.

In additon projects that use the common api should conform to the common api for that project type instead of making project specific changes in the the common api i.e. there should not be specfic tests for leopard in the common api.

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15111 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 31 December 2010 - 12:21 PM

I think the common api would be alot simpler / easier to maintain / faster if it was refactored into 3 seperate files - one contains the api functions that have the same implementation for all project types, one file for the xp specific functionality, a third file for all vista / win7 specific functionality. That way the implementation function names could be the same for all project types only the api file name changes.

In additon projects that use the common api should conform to the common api for that project type instead of making project specific changes in the the common api i.e. there should not be specfic tests for leopard in the common api.


"Common sense" applied to "Common API". ;)

Wonko approves of this. :whistling:

:cheers:
Wonko

#7 sbaeder

sbaeder

    Gold Member

  • .script developer
  • 1338 posts
  • Location:usa - massachusettes
  •  
    United States

Posted 31 December 2010 - 08:46 PM

I was also thinking of this, but an API is an API...the internals of it (and even it is split into different files for maintenance) is more of an implementation detail. That is where I think Peter's initial comments went off track a bit...Does it really matter to the end user what sort of things happen inside the API? I guess correct, and efficient execution are important, but do they care about internal variables and how the functions are maintained? At the end of the day, an API is an API, and as long as the name of the API, and the parameters passed (order and types) stay the same, then it should be good to go.

So instead of three separate files, couldn't we find a way that we can more easily maintain the contents, but still produce a single file that can be picked up and used... Since each "function" is a named section of the file, it seems we could have some sort of process to append the different pieces together to make a single output...

In reality, I tend to view the API as just an extension of the basic winbuilder engine. Some things are best left to the core engine to do (like low level access to the OS) while other things can just as easily be "coded" using the existing script engine primitives. This is like the gcc (and other compilers), where some things cause the compiler to generate raw code, and others cause the compiler to refer to the glibc library (an API) and C++ has its own library, etc...

But, maybe we should move this to a better topic for further discussion, since the original "problem" has been identified and a solution proposed...

Scott

#8 WetHat

WetHat

    Member

  • Members
  • 50 posts
  • Location:Black Forest
  •  
    Germany

Posted 01 January 2011 - 10:04 AM

I think the common api would be alot simpler / easier to maintain / faster if it was refactored into 3 seperate files - one contains the api functions that have the same implementation for all project types, one file for the xp specific functionality, a third file for all vista / win7 specific functionality. That way the implementation function names could be the same for all project types only the api file name changes.


I fully agree with your view, paraglider!

WetHat

#9 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10549 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 02 January 2011 - 01:50 AM

Yes, an API needs to the project agnostic and there is indeed the need to discuss ways of keeping the API simple as well.

Nevertheless, this topic introduces an improvement by WetHat and is not an occasion to voice unwarranted criticism.

----

Since we are like-minded about the need to improve app scripts, I would suggest Sbaeder to open a new topic where we can define a set of standards to be uphold on API commands.

If we don't, we will risk seeing app scripts moving away from the principles that make life easier for everyone who writes scripts.

Thank you. :thumbsup:

This topic will now be closed.

#10 sbaeder

sbaeder

    Gold Member

  • .script developer
  • 1338 posts
  • Location:usa - massachusettes
  •  
    United States

Posted 02 January 2011 - 04:46 AM

Since we are like-minded about the need to improve app scripts, I would suggest Sbaeder to open a new topic where we can define a set of standards to be uphold on API commands.

See http://reboot.pro/13519/

#11 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 03 January 2011 - 06:04 PM

Thank you WetHat for seeing this error, that will be corrected in the current version of API.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users