Disabe SetDllDirectories on 32bit builds since it causes a crash

This commit is contained in:
Kovid Goyal 2019-09-06 10:32:48 +05:30
parent 3b3b3292df
commit 0a05d2f578
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 26 additions and 0 deletions

View File

@ -723,5 +723,27 @@ def main():
sign_installers(env) sign_installers(env)
def develop_launcher():
import subprocess
def r(*a):
subprocess.check_call(list(a))
r(
'cl.EXE', '/c', '/EHsc', '/MT', '/W3', '/O1', '/nologo', '/D_UNICODE', '/DUNICODE', '/GS-',
'/DMODULE="calibre.debug"', '/DBASENAME="calibre-debug"', '/DFUNCTION="main"',
r'/TcC:\r\src\bypy\windows\main.c', r'/Fo..\launcher\calibre-debug.obj'
)
r(
'link.EXE', '/MACHINE:X86', '/NODEFAULTLIB', '/ENTRY:start_here',
r'/LIBPATH:..\launcher', '/SUBSYSTEM:CONSOLE',
r'/LIBPATH:C:\r\sw32\sw\private\python/libs', '/RELEASE',
'/MANIFEST:EMBED', r'/MANIFESTINPUT:..\launcher\calibre-debug.obj.manifest',
'user32.lib', 'kernel32.lib', r'/OUT:calibre-debug.exe',
'user32.lib', '/INCREMENTAL:NO', r'..\launcher\calibre-debug.exe.res',
r'..\launcher\calibre-debug.obj', r'..\launcher\calibre-launcher.lib'
)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -80,9 +80,13 @@ load_launcher_dll() {
return; return;
} }
wsprintf(dll_point, L"%s\0\0", L"app\\bin"); wsprintf(dll_point, L"%s\0\0", L"app\\bin");
#if _WIN64
// Restrict the directories from which DLLs can be loaded // Restrict the directories from which DLLs can be loaded
// For some reason I cannot determine, using this in 32bit builds causes
// a crash even if no dlls are loaded.
SETDEFAULTDIRS SetDefaultDllDirectories = (SETDEFAULTDIRS)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories"); SETDEFAULTDIRS SetDefaultDllDirectories = (SETDEFAULTDIRS)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories");
if (SetDefaultDllDirectories) SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); if (SetDefaultDllDirectories) SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
#endif
if (SetDllDirectoryW(buf) == 0) { if (SetDllDirectoryW(buf) == 0) {
show_last_error(L"Failed to set DLL directory"); show_last_error(L"Failed to set DLL directory");
return; return;