| 39 #include "config.h" |
39 #include "config.h" |
| 40 |
40 |
| 41 typedef int (CALLBACK* LPFNPIDGINMAIN)(HINSTANCE, int, char**); |
41 typedef int (CALLBACK* LPFNPIDGINMAIN)(HINSTANCE, int, char**); |
| 42 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCWSTR); |
42 typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCWSTR); |
| 43 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); |
43 typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); |
| |
44 typedef BOOL (WINAPI* LPFNSETPROCESSDEPPOLICY)(DWORD); |
| 44 |
45 |
| 45 static BOOL portable_mode = FALSE; |
46 static BOOL portable_mode = FALSE; |
| 46 |
47 |
| 47 /* |
48 /* |
| 48 * PROTOTYPES |
49 * PROTOTYPES |
| 640 multiple = TRUE; |
641 multiple = TRUE; |
| 641 } |
642 } |
| 642 } |
643 } |
| 643 } |
644 } |
| 644 |
645 |
| |
646 /* Permanently enable DEP if the OS supports it */ |
| |
647 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) { |
| |
648 LPFNSETPROCESSDEPPOLICY MySetProcessDEPPolicy = |
| |
649 (LPFNSETPROCESSDEPPOLICY) |
| |
650 GetProcAddress(hmod, "SetProcessDEPPolicy"); |
| |
651 if (MySetProcessDEPPolicy) |
| |
652 MySetProcessDEPPolicy(1); //PROCESS_DEP_ENABLE |
| |
653 } |
| |
654 |
| 645 if (debug || help || version) { |
655 if (debug || help || version) { |
| 646 /* If stdout hasn't been redirected to a file, alloc a console |
656 /* If stdout hasn't been redirected to a file, alloc a console |
| 647 * (_istty() doesn't work for stuff using the GUI subsystem) */ |
657 * (_istty() doesn't work for stuff using the GUI subsystem) */ |
| 648 if (_fileno(stdout) == -1 || _fileno(stdout) == -2) { |
658 if (_fileno(stdout) == -1 || _fileno(stdout) == -2) { |
| 649 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
659 LPFNATTACHCONSOLE MyAttachConsole = NULL; |
| 650 if ((hmod = GetModuleHandleW(L"kernel32.dll"))) { |
660 if (hmod) |
| 651 MyAttachConsole = |
661 MyAttachConsole = |
| 652 (LPFNATTACHCONSOLE) |
662 (LPFNATTACHCONSOLE) |
| 653 GetProcAddress(hmod, "AttachConsole"); |
663 GetProcAddress(hmod, "AttachConsole"); |
| 654 } |
|
| 655 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) |
664 if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) |
| 656 || AllocConsole()) { |
665 || AllocConsole()) { |
| 657 freopen("CONOUT$", "w", stdout); |
666 freopen("CONOUT$", "w", stdout); |
| 658 freopen("CONOUT$", "w", stderr); |
667 freopen("CONOUT$", "w", stderr); |
| 659 } |
668 } |