Tor  0.4.7.0-alpha-dev
process_win32.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 /**
7  * \file process_win32.h
8  * \brief Header for process_win32.c
9  **/
10 
11 #ifndef TOR_PROCESS_WIN32_H
12 #define TOR_PROCESS_WIN32_H
13 
14 #ifdef _WIN32
15 
16 #include "orconfig.h"
17 #include "lib/malloc/malloc.h"
19 
20 #include <windows.h>
21 
22 struct process_t;
23 
24 struct process_win32_t;
25 typedef struct process_win32_t process_win32_t;
26 
27 process_win32_t *process_win32_new(void);
28 void process_win32_free_(process_win32_t *win32_process);
29 #define process_win32_free(s) \
30  FREE_AND_NULL(process_win32_t, process_win32_free_, (s))
31 
32 void process_win32_init(void);
33 void process_win32_deinit(void);
34 
35 process_status_t process_win32_exec(struct process_t *process);
36 bool process_win32_terminate(struct process_t *process);
37 
38 process_pid_t process_win32_get_pid(struct process_t *process);
39 
40 int process_win32_write(struct process_t *process, buf_t *buffer);
41 int process_win32_read_stdout(struct process_t *process, buf_t *buffer);
42 int process_win32_read_stderr(struct process_t *process, buf_t *buffer);
43 
44 void process_win32_trigger_completion_callbacks(void);
45 
46 /* Timer handling. */
47 void process_win32_timer_start(void);
48 void process_win32_timer_stop(void);
49 bool process_win32_timer_running(void);
50 
51 #ifdef PROCESS_WIN32_PRIVATE
52 STATIC void process_win32_timer_callback(periodic_timer_t *, void *);
53 STATIC bool process_win32_timer_test_process(process_t *);
54 
55 /* I/O pipe handling. */
56 struct process_win32_handle_t;
57 typedef struct process_win32_handle_t process_win32_handle_t;
58 
59 typedef enum process_win32_pipe_type_t {
60  /** This pipe is used for reading. */
61  PROCESS_WIN32_PIPE_TYPE_READER,
62 
63  /** This pipe is used for writing. */
64  PROCESS_WIN32_PIPE_TYPE_WRITER
65 } process_win32_pipe_type_t;
66 
67 STATIC bool process_win32_create_pipe(HANDLE *,
68  HANDLE *,
69  SECURITY_ATTRIBUTES *,
70  process_win32_pipe_type_t);
71 
72 STATIC void process_win32_cleanup_handle(process_win32_handle_t *handle);
73 
74 STATIC VOID WINAPI process_win32_stdout_read_done(DWORD,
75  DWORD,
76  LPOVERLAPPED);
77 STATIC VOID WINAPI process_win32_stderr_read_done(DWORD,
78  DWORD,
79  LPOVERLAPPED);
80 STATIC VOID WINAPI process_win32_stdin_write_done(DWORD,
81  DWORD,
82  LPOVERLAPPED);
83 
84 STATIC int process_win32_read_from_handle(process_win32_handle_t *,
85  buf_t *,
86  LPOVERLAPPED_COMPLETION_ROUTINE);
87 STATIC bool process_win32_handle_read_completion(process_win32_handle_t *,
88  DWORD,
89  DWORD);
90 
91 STATIC char *format_win_cmdline_argument(const char *arg);
92 STATIC char *tor_join_win_cmdline(const char *argv[]);
93 #endif /* defined(PROCESS_WIN32_PRIVATE) */
94 
95 #endif /* defined(_WIN32) */
96 
97 #endif /* !defined(TOR_PROCESS_WIN32_H) */
Header for compat_libevent.c.
Headers for util_malloc.c.
process_status_t
Definition: process.h:26
#define STATIC
Definition: testsupport.h:32