mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.3.x] added : pykd.dll ( bootstrapper for windbg )
git-svn-id: https://pykd.svn.codeplex.com/svn@90068 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
21405b24c5
commit
16ebf54df7
@ -45,6 +45,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D1F122
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "kdlibcpp\tests\targetapp\targetapp_vc120.vcxproj", "{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "kdlibcpp\tests\targetapp\targetapp_vc120.vcxproj", "{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pykd_bootstrapper", "pykd_bootstrapper\pykd_bootstrapper_vc120.vcxproj", "{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug_2.7|Any CPU = Debug_2.7|Any CPU
|
Debug_2.7|Any CPU = Debug_2.7|Any CPU
|
||||||
@ -222,6 +224,34 @@ Global
|
|||||||
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Win32.Build.0 = Release|Win32
|
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Win32.Build.0 = Release|Win32
|
||||||
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.ActiveCfg = Release|x64
|
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.ActiveCfg = Release|x64
|
||||||
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.Build.0 = Release|x64
|
{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.Build.0 = Release|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|Any CPU.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|Mixed Platforms.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|Mixed Platforms.Build.0 = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|Win32.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|Win32.Build.0 = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|x64.ActiveCfg = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug_2.7|x64.Build.0 = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|Any CPU.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|Mixed Platforms.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|Mixed Platforms.Build.0 = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|Win32.ActiveCfg = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|Win32.Build.0 = Debug_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|x64.ActiveCfg = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Debug|x64.Build.0 = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|Any CPU.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|Mixed Platforms.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|Mixed Platforms.Build.0 = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|Win32.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|Win32.Build.0 = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|x64.ActiveCfg = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release_2.7|x64.Build.0 = Debug_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|Any CPU.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|Mixed Platforms.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|Mixed Platforms.Build.0 = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|Win32.ActiveCfg = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|Win32.Build.0 = Release_2.7|Win32
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|x64.ActiveCfg = Release_2.7|x64
|
||||||
|
{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}.Release|x64.Build.0 = Release_2.7|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -75,19 +75,23 @@
|
|||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
<PostBuildEventUseInBuild>true</PostBuildEventUseInBuild>
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
19
pykd_bootstrapper/dllmain.cpp
Normal file
19
pykd_bootstrapper/dllmain.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||||
|
DWORD ul_reason_for_call,
|
||||||
|
LPVOID lpReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
switch (ul_reason_for_call)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
4
pykd_bootstrapper/export.def
Normal file
4
pykd_bootstrapper/export.def
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
EXPORTS
|
||||||
|
DebugExtensionInitialize
|
||||||
|
DebugExtensionUninitialize
|
||||||
|
py
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="boost" version="1.57.0.0" targetFramework="Native" />
|
||||||
|
<package id="Python27" version="2.7.6" targetFramework="Native" />
|
||||||
|
<package id="boost_python" version="1.57.0.0" targetFramework="Native" />
|
||||||
|
</packages>
|
220
pykd_bootstrapper/pykd_bootstrapper_vc120.vcxproj
Normal file
220
pykd_bootstrapper/pykd_bootstrapper_vc120.vcxproj
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug_2.7|Win32">
|
||||||
|
<Configuration>Debug_2.7</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug_2.7|x64">
|
||||||
|
<Configuration>Debug_2.7</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release_2.7|Win32">
|
||||||
|
<Configuration>Release_2.7</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release_2.7|x64">
|
||||||
|
<Configuration>Release_2.7</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{CA0252CE-EF81-4DD8-A96F-A0E0E3644B7B}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>pykd_bootstrapper</RootNamespace>
|
||||||
|
<ProjectName>pykd_ext</ProjectName>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||||
|
<RestorePackages>true</RestorePackages>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<NuGetPackageImportStamp>7f4aed3e</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<TargetName>pykd</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<TargetName>pykd</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>pykd</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>pykd</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PYKD_BOOTSTRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(ProjectDir)..\kdlibcpp\include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
|
||||||
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PYKD_BOOTSTRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(ProjectDir)..\kdlibcpp\include;</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
|
||||||
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYKD_BOOTSTRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(ProjectDir)..\kdlibcpp\include;</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
|
||||||
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYKD_BOOTSTRAPPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(ProjectDir)..\kdlibcpp\include;</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
|
||||||
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">false</CompileAsManaged>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">false</CompileAsManaged>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">false</CompileAsManaged>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">false</CompileAsManaged>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_2.7|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="windbgext.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="export.def" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="packages.pykd_bootstrapper_vc120.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\kdlibcpp\source\kdlib_vc120.vcxproj">
|
||||||
|
<Project>{3e9c538f-f060-4e86-ab7d-d44439615b63}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
|
<Import Project="..\packages\boost.1.57.0.0\build\native\boost.targets" Condition="Exists('..\packages\boost.1.57.0.0\build\native\boost.targets')" />
|
||||||
|
<Import Project="..\packages\Python27.2.7.6\build\python27.targets" Condition="Exists('..\packages\Python27.2.7.6\build\python27.targets')" />
|
||||||
|
<Import Project="..\packages\boost_python.1.57.0.0\build\native\boost_python.targets" Condition="Exists('..\packages\boost_python.1.57.0.0\build\native\boost_python.targets')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\boost.1.57.0.0\build\native\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost.1.57.0.0\build\native\boost.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\Python27.2.7.6\build\python27.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Python27.2.7.6\build\python27.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\boost_python.1.57.0.0\build\native\boost_python.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_python.1.57.0.0\build\native\boost_python.targets'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
130
pykd_bootstrapper/pykd_bootstrapper_vc120.vcxproj.filters
Normal file
130
pykd_bootstrapper/pykd_bootstrapper_vc120.vcxproj.filters
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="windbgext.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\converter\boost_python.converter.arg_to_python_base.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\converter\boost_python.converter.builtin_converters.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\converter\boost_python.converter.from_python.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\converter\boost_python.converter.registry.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\converter\boost_python.converter.type_id.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.class.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.enum.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.function.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.function_doc_signature.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.inheritance.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.iterator.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.life_support.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.pickle_support.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\object\boost_python.object.stl_iterator.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.dict.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.errors.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.exec.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.import.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.list.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.long.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.module.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.numeric.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.object_operators.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.object_protocol.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.slice.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.str.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.tuple.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_python.wrapper.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="export.def">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="packages.pykd_bootstrapper_vc120.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
8
pykd_bootstrapper/stdafx.cpp
Normal file
8
pykd_bootstrapper/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// pykd_bootstrapper.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: reference any additional headers you need in STDAFX.H
|
||||||
|
// and not in this file
|
16
pykd_bootstrapper/stdafx.h
Normal file
16
pykd_bootstrapper/stdafx.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
// Windows Header Files:
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
8
pykd_bootstrapper/targetver.h
Normal file
8
pykd_bootstrapper/targetver.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||||
|
|
||||||
|
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||||
|
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
459
pykd_bootstrapper/windbgext.cpp
Normal file
459
pykd_bootstrapper/windbgext.cpp
Normal file
@ -0,0 +1,459 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
|
||||||
|
namespace python = boost::python;
|
||||||
|
|
||||||
|
#include "kdlib/windbg.h"
|
||||||
|
|
||||||
|
using namespace kdlib;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class PykdBootsTrapper: public windbg::WindbgExtension
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
KDLIB_EXT_COMMAND_METHOD(py);
|
||||||
|
|
||||||
|
virtual void setUp();
|
||||||
|
|
||||||
|
virtual void tearDown();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void startConsole();
|
||||||
|
|
||||||
|
void printUsage();
|
||||||
|
|
||||||
|
void printException();
|
||||||
|
|
||||||
|
std::string getScriptFileName(const std::string &scriptName);
|
||||||
|
|
||||||
|
std::string findScript(const std::string &fullFileName);
|
||||||
|
|
||||||
|
PyThreadState *m_pyState;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class AutoRestorePyState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
AutoRestorePyState()
|
||||||
|
{
|
||||||
|
m_state = PyEval_SaveThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit AutoRestorePyState(PyThreadState **state)
|
||||||
|
{
|
||||||
|
*state = PyEval_SaveThread();
|
||||||
|
m_state = *state;
|
||||||
|
}
|
||||||
|
|
||||||
|
~AutoRestorePyState()
|
||||||
|
{
|
||||||
|
PyEval_RestoreThread(m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
PyThreadState* m_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DbgOut : public windbg::WindbgOut
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void write(const std::wstring& str) {
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
windbg::WindbgOut::write(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writedml(const std::wstring& str) {
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
windbg::WindbgOut::writedml(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flush() {
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring encoding() {
|
||||||
|
return L"ascii";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DbgIn : public windbg::WindbgIn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::wstring readline() {
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return kdlib::windbg::WindbgIn::readline();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring encoding() {
|
||||||
|
return L"ascii";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class InterruptWatch : public windbg::InterruptWatch
|
||||||
|
{
|
||||||
|
virtual bool onInterrupt()
|
||||||
|
{
|
||||||
|
HANDLE quitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
PyGILState_STATE state = PyGILState_Ensure();
|
||||||
|
Py_AddPendingCall(&quit, (void*)quitEvent);
|
||||||
|
PyGILState_Release(state);
|
||||||
|
WaitForSingleObject(quitEvent, INFINITE);
|
||||||
|
CloseHandle(quitEvent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int quit(void *context)
|
||||||
|
{
|
||||||
|
HANDLE quitEvent = (HANDLE)context;
|
||||||
|
kdlib::eprintln(L"User Interrupt: CTRL+BREAK");
|
||||||
|
PyErr_SetString(PyExc_SystemExit, "CTRL+BREAK");
|
||||||
|
SetEvent(quitEvent);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KDLIB_WINDBG_EXTENSION_INIT(PykdBootsTrapper);
|
||||||
|
|
||||||
|
KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, py)
|
||||||
|
{
|
||||||
|
ArgsList args = getArgs();
|
||||||
|
|
||||||
|
bool global = false;
|
||||||
|
bool local = false;
|
||||||
|
bool clean = false;
|
||||||
|
|
||||||
|
ArgsList::iterator foundArg;
|
||||||
|
|
||||||
|
if (!args.empty())
|
||||||
|
{
|
||||||
|
if (args[0] == "-h" || args[0] == "--help")
|
||||||
|
{
|
||||||
|
printUsage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (args[0] == "-g" || args[0] == "--global")
|
||||||
|
{
|
||||||
|
global = true;
|
||||||
|
args.erase(args.begin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (args[0] == "-l" || args[0] == "--local")
|
||||||
|
{
|
||||||
|
local = true;
|
||||||
|
args.erase(args.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PyThreadState *localState = NULL;
|
||||||
|
PyThreadState *globalState = NULL;
|
||||||
|
|
||||||
|
PyEval_RestoreThread(m_pyState);
|
||||||
|
|
||||||
|
std::string scriptFileName;
|
||||||
|
if (args.size() > 0)
|
||||||
|
{
|
||||||
|
scriptFileName = getScriptFileName(args[0]);
|
||||||
|
|
||||||
|
if (scriptFileName.empty())
|
||||||
|
{
|
||||||
|
kdlib::eprintln(L"script file not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global = !(global || local) ? false : global; //set local by default
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
global = !(global || local) ? true : global; //set global by default
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!global)
|
||||||
|
{
|
||||||
|
globalState = PyThreadState_Swap(NULL);
|
||||||
|
|
||||||
|
Py_NewInterpreter();
|
||||||
|
|
||||||
|
localState = PyThreadState_Get();
|
||||||
|
|
||||||
|
python::object sys = python::import("sys");
|
||||||
|
|
||||||
|
sys.attr("stdout") = python::object(::DbgOut());
|
||||||
|
sys.attr("stderr") = python::object(::DbgOut());
|
||||||
|
sys.attr("stdin") = python::object(::DbgIn());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size() == 0)
|
||||||
|
{
|
||||||
|
startConsole();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string scriptFileName = getScriptFileName(args[0]);
|
||||||
|
|
||||||
|
// óñòàíàâèëèâàåì ïèòîíîâñêèå àðãóìåíòû
|
||||||
|
char **pythonArgs = new char*[args.size()];
|
||||||
|
|
||||||
|
pythonArgs[0] = const_cast<char*>(scriptFileName.c_str());
|
||||||
|
|
||||||
|
for (size_t i = 1; i < args.size(); ++i)
|
||||||
|
pythonArgs[i] = const_cast<char*>(args[i].c_str());
|
||||||
|
|
||||||
|
PySys_SetArgv((int)args.size(), pythonArgs);
|
||||||
|
|
||||||
|
delete[] pythonArgs;
|
||||||
|
|
||||||
|
// ïîëó÷àåì äîñòïó ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||||
|
python::object main = python::import("__main__");
|
||||||
|
|
||||||
|
python::object global(main.attr("__dict__"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
InterruptWatch interruptWatch;
|
||||||
|
|
||||||
|
python::exec_file(scriptFileName.c_str(), global);
|
||||||
|
}
|
||||||
|
catch (python::error_already_set const &)
|
||||||
|
{
|
||||||
|
printException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!global)
|
||||||
|
{
|
||||||
|
PyInterpreterState *interpreter = localState->interp;
|
||||||
|
|
||||||
|
while (interpreter->tstate_head != NULL)
|
||||||
|
{
|
||||||
|
PyThreadState *threadState = (PyThreadState*)(interpreter->tstate_head);
|
||||||
|
|
||||||
|
PyThreadState_Clear(threadState);
|
||||||
|
|
||||||
|
PyThreadState_Swap(NULL);
|
||||||
|
|
||||||
|
PyThreadState_Delete(threadState);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyInterpreterState_Clear(interpreter);
|
||||||
|
|
||||||
|
PyInterpreterState_Delete(interpreter);
|
||||||
|
|
||||||
|
PyThreadState_Swap(globalState);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pyState = PyEval_SaveThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void PykdBootsTrapper::setUp()
|
||||||
|
{
|
||||||
|
WindbgExtension::setUp();
|
||||||
|
|
||||||
|
PyEval_InitThreads();
|
||||||
|
|
||||||
|
Py_Initialize();
|
||||||
|
|
||||||
|
python::object main = boost::python::import("__main__");
|
||||||
|
|
||||||
|
python::object main_namespace = main.attr("__dict__");
|
||||||
|
|
||||||
|
python::object pykd = python::import("pykd");
|
||||||
|
|
||||||
|
// äåëàåì àíàëîã from pykd import *
|
||||||
|
python::dict pykd_namespace(pykd.attr("__dict__"));
|
||||||
|
|
||||||
|
python::list iterkeys(pykd_namespace.iterkeys());
|
||||||
|
|
||||||
|
for (int i = 0; i < boost::python::len(iterkeys); i++)
|
||||||
|
{
|
||||||
|
std::string key = boost::python::extract<std::string>(iterkeys[i]);
|
||||||
|
|
||||||
|
main_namespace[key] = pykd_namespace[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Python debug output console helper classes
|
||||||
|
python::class_<::DbgOut>("dout", "dout", python::no_init)
|
||||||
|
.def("write", &::DbgOut::write)
|
||||||
|
.def("flush", &::DbgOut::flush)
|
||||||
|
.add_property("encoding", &::DbgOut::encoding);
|
||||||
|
|
||||||
|
python::class_<::DbgIn>("din", "din", python::no_init)
|
||||||
|
.def("readline", &::DbgIn::readline)
|
||||||
|
.add_property("encoding", &::DbgIn::encoding);
|
||||||
|
|
||||||
|
python::object sys = python::import("sys");
|
||||||
|
|
||||||
|
sys.attr("stdout") = python::object(::DbgOut());
|
||||||
|
sys.attr("stderr") = python::object(::DbgOut());
|
||||||
|
sys.attr("stdin") = python::object(::DbgIn());
|
||||||
|
|
||||||
|
m_pyState = PyEval_SaveThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void PykdBootsTrapper::tearDown()
|
||||||
|
{
|
||||||
|
PyEval_RestoreThread(m_pyState);
|
||||||
|
|
||||||
|
Py_Finalize();
|
||||||
|
|
||||||
|
WindbgExtension::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void PykdBootsTrapper::startConsole()
|
||||||
|
{
|
||||||
|
|
||||||
|
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||||
|
python::object main = python::import("__main__");
|
||||||
|
|
||||||
|
python::object global(main.attr("__dict__"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
InterruptWatch interruptWatch;
|
||||||
|
|
||||||
|
python::exec("__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()\n", global);
|
||||||
|
}
|
||||||
|
catch (python::error_already_set const &)
|
||||||
|
{
|
||||||
|
printException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void PykdBootsTrapper::printUsage()
|
||||||
|
{
|
||||||
|
kdlib::dprintln(L"usage: !py [options] [file]");
|
||||||
|
kdlib::dprintln(L"Options:");
|
||||||
|
kdlib::dprintln(L"-g --global : run code in the common namespace");
|
||||||
|
kdlib::dprintln(L"-l --local : run code in the isolate namespace");
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string PykdBootsTrapper::getScriptFileName(const std::string &scriptName)
|
||||||
|
{
|
||||||
|
std::string scriptFileName = findScript(scriptName);
|
||||||
|
|
||||||
|
if (scriptFileName.empty())
|
||||||
|
{
|
||||||
|
std::string scriptNameLow;
|
||||||
|
scriptNameLow.resize(scriptName.size());
|
||||||
|
std::transform(
|
||||||
|
scriptName.begin(),
|
||||||
|
scriptName.end(),
|
||||||
|
scriptNameLow.begin(),
|
||||||
|
::tolower);
|
||||||
|
if (scriptNameLow.rfind(".py") != (scriptNameLow.length() - 3))
|
||||||
|
scriptFileName = findScript(scriptName + ".py");
|
||||||
|
}
|
||||||
|
|
||||||
|
return scriptFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string PykdBootsTrapper::findScript(const std::string &fullFileName)
|
||||||
|
{
|
||||||
|
if (GetFileAttributesA(fullFileName.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||||
|
return fullFileName;
|
||||||
|
|
||||||
|
python::object sys = python::import("sys");
|
||||||
|
|
||||||
|
python::list pathList(sys.attr("path"));
|
||||||
|
|
||||||
|
python::ssize_t n = python::len(pathList);
|
||||||
|
|
||||||
|
for (python::ssize_t i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
std::string path = boost::python::extract<std::string>(pathList[i]);
|
||||||
|
|
||||||
|
DWORD bufSize = SearchPathA(
|
||||||
|
path.c_str(),
|
||||||
|
fullFileName.c_str(),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (bufSize > 0)
|
||||||
|
{
|
||||||
|
bufSize += 1;
|
||||||
|
std::vector<char> fullFileNameCStr(bufSize);
|
||||||
|
char *partFileNameCStr = NULL;
|
||||||
|
|
||||||
|
bufSize = SearchPathA(
|
||||||
|
path.c_str(),
|
||||||
|
fullFileName.c_str(),
|
||||||
|
NULL,
|
||||||
|
bufSize,
|
||||||
|
&fullFileNameCStr[0],
|
||||||
|
&partFileNameCStr);
|
||||||
|
|
||||||
|
if (bufSize > 0)
|
||||||
|
{
|
||||||
|
return std::string(&fullFileNameCStr[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
void PykdBootsTrapper::printException()
|
||||||
|
{
|
||||||
|
// îøèáêà â ñêðèïòå
|
||||||
|
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
|
||||||
|
|
||||||
|
PyErr_Fetch(&errtype, &errvalue, &traceback);
|
||||||
|
|
||||||
|
PyErr_NormalizeException(&errtype, &errvalue, &traceback);
|
||||||
|
|
||||||
|
if (errtype == PyExc_SystemExit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
python::object tracebackModule = python::import("traceback");
|
||||||
|
|
||||||
|
std::wstringstream sstr;
|
||||||
|
|
||||||
|
python::object lst =
|
||||||
|
python::object(tracebackModule.attr("format_exception"))(
|
||||||
|
python::handle<>(errtype),
|
||||||
|
python::handle<>(python::allow_null(errvalue)),
|
||||||
|
python::handle<>(python::allow_null(traceback)));
|
||||||
|
|
||||||
|
sstr << std::endl << std::endl;
|
||||||
|
|
||||||
|
for (long i = 0; i < python::len(lst); ++i)
|
||||||
|
sstr << std::wstring(python::extract<std::wstring>(lst[i])) << std::endl;
|
||||||
|
|
||||||
|
kdlib::eprintln(sstr.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue
Block a user