Optimize away more calls to GetModuleHandle(0) with __ImageBase under MSVC
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6918 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
5f1651ab91
commit
daa57f1f33
2 changed files with 19 additions and 4 deletions
|
@ -46,6 +46,13 @@ template<class T> HANDLE CreateFile(const T*p1,DWORD p2,DWORD p3,LPSECURITY_ATTR
|
|||
template<class T> BOOL CreateProcess(const T*p1,const T*p2,LPSECURITY_ATTRIBUTES p3,LPSECURITY_ATTRIBUTES p4,BOOL p5,DWORD p6,LPVOID p7,const T*p8,STARTUPINFO*p9,LPPROCESS_INFORMATION p10) { return sizeof(T) > 1 ? ::CreateProcessW(WP(p1),WP(p2),p3,p4,p5,p6,p7,WP(p8),(STARTUPINFOW*)p9,p10) : ::CreateProcessA(NP(p1),NP(p2),p3,p4,p5,p6,p7,NP(p8),(STARTUPINFOA*)p9,p10); }
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||
#define HINST_THISCOMPONENT ( (HINSTANCE) &__ImageBase )
|
||||
#define HINST_APPLICATION HINST_THISCOMPONENT
|
||||
#else
|
||||
#define HINST_APPLICATION ( (HINSTANCE) GetModuleHandle(NULL) )
|
||||
#endif
|
||||
|
||||
static bool IsWinNT()
|
||||
{
|
||||
|
@ -239,7 +246,7 @@ template<class T> void RegFile(T cmd, const T *file, BOOL x64)
|
|||
}
|
||||
else if (!x64)
|
||||
{
|
||||
if (CALL(GetModuleFileName)(GetModuleHandle(NULL), self, STR_SIZE))
|
||||
if (CALL(GetModuleFileName)(HINST_APPLICATION, self, STR_SIZE))
|
||||
{
|
||||
CALL_wsprintf(cmdline, MKSTR("\"%s\" /%c%s"), self, cmd, file);
|
||||
ready++;
|
||||
|
@ -385,7 +392,7 @@ template<class T> int RegTool()
|
|||
}
|
||||
|
||||
{
|
||||
if (CALL(GetModuleFileName)(GetModuleHandle(NULL), file, STR_SIZE))
|
||||
if (CALL(GetModuleFileName)(HINST_APPLICATION, file, STR_SIZE))
|
||||
{
|
||||
DeleteFileOnReboot(file);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,14 @@
|
|||
#define SHUTDOWN_GRACE_OVERRIDE 0x00000020
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||
#define HINST_THISCOMPONENT ( (HINSTANCE) &__ImageBase )
|
||||
#define HINST_APPLICATION HINST_THISCOMPONENT
|
||||
#else
|
||||
#define HINST_APPLICATION ( (HINSTANCE) GetModuleHandle(NULL) )
|
||||
#endif
|
||||
|
||||
#if !defined(NSIS_CONFIG_VISIBLE_SUPPORT) && !defined(NSIS_CONFIG_SILENT_SUPPORT)
|
||||
#error One of NSIS_CONFIG_SILENT_SUPPORT or NSIS_CONFIG_VISIBLE_SUPPORT must be defined.
|
||||
#endif
|
||||
|
@ -146,7 +154,7 @@ EXTERN_C void NSISWinMainNOCRT()
|
|||
|
||||
#ifndef _WIN64
|
||||
{
|
||||
// KEY_WOW64_xxKEY causes registry functions to fail on WinNT4 & Win2000.
|
||||
// KEY_WOW64_xxKEY flags causes registry functions to fail on WinNT4 & Win2000.
|
||||
// We don't filter them out because all registry instructions are supposed to fail when
|
||||
// accessing a unsupported view and RegKey* takes care of that by looking at the WOW64 flag.
|
||||
FARPROC fp = myGetProcAddress(MGA_IsOS);
|
||||
|
@ -191,7 +199,7 @@ EXTERN_C void NSISWinMainNOCRT()
|
|||
mystrcpy(state_command_line, GetCommandLine());
|
||||
|
||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
g_hInstance = GetModuleHandle(NULL);
|
||||
g_hInstance = HINST_APPLICATION;
|
||||
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
|
||||
cmdline = state_command_line;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue