source for win64interrupt

The WinAPI funcion DebugBreakProcess must be called from the same bitness as the target process, so win64interrupt is a small 64bit executable calling this function.

Task-number: QTCREATORBUG-2521
Change-Id: I3259d505b9b228be72ca4eaca42a9cde5b4984ac
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
David Schulz
2012-01-13 13:01:55 +01:00
committed by hjk
parent 7dbc6014e3
commit ac3093058c

View File

@@ -0,0 +1,75 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#if _WIN32_WINNT < 0x0501
#error Must target Windows NT 5.0.1 or later for DebugBreakProcess
#endif
#include <Windows.h>
/* To debug break a 64bit application under Windows, you must call
* DebugBreakProcess() from an 64bit apllication. Therefore:
*
* This code must be compiled with a 64bit compiler
* Compile with one of these lines:
* gcc-64bit:
* gcc -o ..\..\..\bin\win64interrupt.exe win64interrupt.c
* cl-64bit:
* cl -o ..\..\..\bin\win64interrupt.exe win64interrupt.c
*/
int main(int argc, char *argv[])
{
HANDLE proc;
BOOL break_result;
DWORD proc_id;
if (argc != 2)
return 1;
proc_id = strtoul(argv[1], NULL, 0);
if (proc_id == 0)
return 2;
proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
if (!proc)
return 3;
break_result = DebugBreakProcess(proc);
CloseHandle(proc);
return !break_result;
}