From 60527eb7f44cdcad63d8946e3cc2ff749e43ac33 Mon Sep 17 00:00:00 2001 From: Cesar Eduardo Barros Date: Sat, 30 Apr 2011 18:46:09 -0300 Subject: [PATCH] Installer: Use BindImageEx to potentially speed-up loading of DLLs We need to specify BIND_NO_BOUND_IMPORTS in order to avoid error 0xc0000005 "the application was unable to start correctly" when running "git.exe". According to Daniel Kilma this is due to a problem between binaries created by GCC and the Windows loader. The initial patch was provided by Cesar Eduardo Barros, additional fixes were done by Sebastian Schuberth. Signed-off-by: Cesar Eduardo Barros Signed-off-by: Sebastian Schuberth --- share/WinGit/copy-files.sh | 3 ++- share/WinGit/install.iss | 44 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/share/WinGit/copy-files.sh b/share/WinGit/copy-files.sh index 66721727..317b0e39 100644 --- a/share/WinGit/copy-files.sh +++ b/share/WinGit/copy-files.sh @@ -92,5 +92,6 @@ cp /src/git-cheetah/explorer/git_shell_ext.dll git-cheetah/ && cp /share/WinGit/ReleaseNotes.rtf . && sed 's/^\. .*\(git-completion.bash\)/. \/etc\/\1/' \ < /etc/profile > etc/profile && -cp /share/resources/git.ico etc/ || +cp /share/resources/git.ico etc/ && +find bin libexec -iname \*.exe -o -iname \*.dll | sort > etc/fileList-bindimage.txt || exit 1 diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss index a6a4164f..965c6766 100644 --- a/share/WinGit/install.iss +++ b/share/WinGit/install.iss @@ -1,7 +1,8 @@ -#define APP_NAME 'Git' -#define APP_VERSION '%APPVERSION%' -#define APP_URL 'http://msysgit.googlecode.com/' -#define APP_BUILTINS 'etc\fileList-builtins.txt' +#define APP_NAME 'Git' +#define APP_VERSION '%APPVERSION%' +#define APP_URL 'http://msysgit.googlecode.com/' +#define APP_BUILTINS 'etc\fileList-builtins.txt' +#define APP_BINDIMAGE 'etc\fileList-bindimage.txt' #define COMP_CONSOLE_FONT 'Use a TrueType font in all console windows (not only for Git Bash)' @@ -163,6 +164,9 @@ external 'CreateSymbolicLinkW@Kernel32.dll stdcall delayload setuponly'; external 'CreateSymbolicLinkA@Kernel32.dll stdcall delayload setuponly'; #endif +function BindImageEx(Flags:DWORD;ImageName,DllPath,SymbolPath:AnsiString;StatusRoutine:Integer):Boolean; +external 'BindImageEx@Imagehlp.dll stdcall delayload setuponly'; + const // Git Path options. GP_BashOnly = 1; @@ -178,6 +182,12 @@ const GC_CRLFAlways = 2; GC_CRLFCommitAsIs = 3; + // BindImageEx API constants. + BIND_NO_BOUND_IMPORTS = $00000001; + BIND_NO_UPDATE = $00000002; + BIND_ALL_IMAGES = $00000004; + BIND_CACHE_IMPORT_DLLS = $00000008; + var // Wizard page and variables for the Path options. PathPage:TWizardPage; @@ -742,8 +752,8 @@ end; // beginning of this procedure. procedure CurStepChanged(CurStep:TSetupStep); var - AppDir,FileName,TempName,Cmd,Msg:String; - BuiltIns,EnvPath,EnvHome,EnvSSH:TArrayOfString; + AppDir,DllPath,FileName,TempName,Cmd,Msg:String; + BuiltIns,ImageNames,EnvPath,EnvHome,EnvSSH:TArrayOfString; Count,i:Longint; LinkCreated:Boolean; FindRec:TFindRec; @@ -756,6 +766,28 @@ begin AppDir:=ExpandConstant('{app}'); { + Bind the imported function addresses + } + + try + DllPath:=ExpandConstant('{app}\bin;{sys}'); + + // Load the list of images from a text file. + FileName:=AppDir+'\{#APP_BINDIMAGE}'; + if LoadStringsFromFile(FileName,ImageNames) then begin + Count:=GetArrayLength(ImageNames)-1; + for i:=0 to Count do begin + FileName:=AppDir+'\'+ImageNames[i]; + if not BindImageEx(BIND_NO_BOUND_IMPORTS or BIND_CACHE_IMPORT_DLLS,FileName,DllPath,'',0) then begin + Log('Line {#__LINE__}: Error calling BindImageEx for "'+FileName+'".'); + end; + end; + end; + except + Log('Line {#__LINE__}: An exception occurred while calling BindImageEx.'); + end; + + { Create the built-ins } -- 2.11.4.GIT