Skip to content

Commit

Permalink
Installer: Use BindImageEx to potentially speed-up loading of DLLs
Browse files Browse the repository at this point in the history
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 <cesarb@cesarb.net>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
  • Loading branch information
cesarb authored and sschuberth committed May 3, 2011
1 parent 0c118c6 commit 60527eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
3 changes: 2 additions & 1 deletion share/WinGit/copy-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 38 additions & 6 deletions share/WinGit/install.iss
Original file line number Diff line number Diff line change
@@ -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)'

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -755,6 +765,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
}
Expand Down

0 comments on commit 60527eb

Please sign in to comment.