# -*- coding: utf-8 -*-
# $Id$
"""
This module is here to externalize some Windows specifics that gives pychecker
a hard time when running on non-Windows systems.
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard Python imports.
import os
# Windows specific imports.
# Validation Kit imports.
#
# Windows specific implementation of base functions.
#
"""
The Windows version of base.processInterrupt
Note! This doesn't work terribly well with a lot of processes.
"""
try:
#GenerateConsoleCtrlEvent = ctypes.windll.kernel32.GenerateConsoleCtrlEvent
#rc = GenerateConsoleCtrlEvent(1, uPid);
#reporter.log('GenerateConsoleCtrlEvent -> %s' % (rc,));
except:
return fRc;
""" Posts a WM_CLOSE message to the specified thread."""
try:
except:
return fRc;
""" Posts a WM_QUIT message to the specified thread."""
try:
except:
return fRc;
""" The Windows version of base.processTerminate """
try:
except:
else:
try:
except:
return fRc;
""" The Windows version of base.processKill """
return processTerminate(uPid);
""" The Windows version of base.processExists """
try:
except:
else:
return fRc;
""" The Windows version of base.processCheckPidAndName """
try:
for oProcess in aoProcesses:
break;
except:
return fRc;
#
# Some helper functions.
#
"""
Returns a (pid, handle, tid) tuple on success. (-1, None) on failure (logged).
"""
# Construct a command line.
sCmdLine = '';
if sCmdLine == '':
sCmdLine += '"';
else:
sCmdLine += ' "';
sCmdLine += '"';
# Try start the process.
try:
sCmdLine, # CommandLine
None, # ProcessAttributes
None, # ThreadAttibutes
1, # fInheritHandles
None, # Environment
None, # CurrentDirectory.
except:
return (-1, None, -1);
# Dispense with the thread handle.
try:
except:
# Try get full access to the process.
try:
hProcess, \
| win32con.SYNCHRONIZE \
False, \
0);
except:
"""
Polls the process handle to see if it has finished (True) or not (False).
"""
try:
except:
return True;
"""
Terminates the process.
"""
try:
except:
return False;
return True;