/* vifm
* Copyright (C) 2001 Ken Steen.
* Copyright (C) 2011 xaizek.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "utils.h"
#include "utils_int.h"
#include <ntdef.h>
#include <objidl.h>
#include <shlguid.h>
#include <shobjidl.h>
#include <windows.h>
#include <curses.h>
#include <fcntl.h>
#include <unistd.h> /* _dup2() _pipe() _spawnvp() close() dup() pipe() */
#include <ctype.h> /* toupper() */
#include <errno.h> /* EEXIST ENOMEM errno */
#include <stddef.h> /* NULL size_t */
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* EXIT_SUCCESS free() */
#include <string.h> /* strcat() strchr() strcpy() strdup() strlen() */
#include <stdio.h> /* FILE SEEK_SET fread() fclose() snprintf() */
#include "../cfg/config.h"
#include "../compat/fs_limits.h"
#include "../compat/mntent.h"
#include "../compat/os.h"
#include "../compat/wcwidth.h"
#include "../ui/ui.h"
#include "../running.h"
#include "../status.h"
#include "cancellation.h"
#include "env.h"
#include "fs.h"
#include "log.h"
#include "macros.h"
#include "path.h"
#include "selector.h"
#include "str.h"
#include "test_helpers.h"
#include "utf8.h"
#define PE_HDR_SIGNATURE 0x00004550U
#define PE_HDR_OFFSET 0x3cU
#define PE_HDR_SUBSYSTEM_OFFSET 0x5cU
#define SUBSYSTEM_GUI 2
static const char PATHEXT_EXT_DEF[] = ".bat;.exe;.com";
static void process_cancel_request(pid_t pid,
const cancellation_t *cancellation);
TSTATIC int should_wait_for_program(const char cmd[]);
static DWORD handle_process(const char cmd[], HANDLE proc, int *got_exit_code);
static char * base64_encode(const char str[]);
static int get_subsystem(const char filename[]);
static int get_stream_subsystem(FILE *fp);
static FILE * read_cmd_output_internal(const char cmd[], int out_pipe[2],
int preserve_stdin);
static int get_set_owner_privilege(void);
static char * get_root_path(const char path[]);
static BOOL CALLBACK close_app_enum(HWND hwnd, LPARAM lParam);
void