├── .gitattributes ├── .gitignore ├── AutoProfilingForm ├── AutoProfilingForm.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── GameDB.xml ├── MdiChildFoRunGame.Designer.cs ├── MdiChildFoRunGame.cs ├── MdiChildFoRunGame.resx ├── MdiChildForAllAndEstimate.Designer.cs ├── MdiChildForAllAndEstimate.cs ├── MdiChildForAllAndEstimate.resx ├── MdiChildForAnalysis.Designer.cs ├── MdiChildForAnalysis.cs ├── MdiChildForAnalysis.resx ├── MdiChildForAnalysisAll.Designer.cs ├── MdiChildForAnalysisAll.cs ├── MdiChildForAnalysisAll.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── DataSources │ │ ├── AutoProfilingForm.Properties.Resources.datasource │ │ ├── AutoProfilingForm.Properties.Settings.datasource │ │ └── MdiChildFoRunGame.datasource │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── bin │ └── Release │ │ ├── AutoProfilingForm.exe │ │ ├── AutoProfilingForm.pdb │ │ ├── AutoProfilingForm.vshost.exe │ │ ├── AutoProfilingForm.vshost.exe.manifest │ │ ├── AutoProfilingTool.exe │ │ ├── ConsoleControl.dll │ │ ├── ConsoleControl.pdb │ │ ├── ConsoleControlAPI.dll │ │ ├── ConsoleControlAPI.pdb │ │ ├── HookD3D.dll │ │ ├── HookD3DAll.dll │ │ ├── netchartdir_cp.dll │ │ └── netchartdir_cp.xml └── clougame.arff ├── AutoProfilingTool.v10.sdf ├── AutoProfilingTool.v10.sln ├── AutoProfilingTool.v10.suo ├── AutoProfilingTool.v10.vcxproj ├── AutoProfilingTool.v10.vcxproj.filters ├── AutoProfilingTool.v10.vcxproj.user ├── AutoProfilingTool ├── AutoProfilingTool.vcxproj ├── AutoProfilingTool.vcxproj.filters ├── AutoProfilingTool.vcxproj.user ├── AutoRrofilingTool.vcxproj ├── AutoRrofilingTool.vcxproj.filters ├── ReadMe.txt ├── common.h ├── detours │ ├── detours.h │ ├── detours.lib │ └── detours.pdb ├── gamecharactormaker.cpp ├── gamecharactormaker.h ├── log.cpp ├── log.h ├── main.cpp ├── profile.input.txt ├── schedulewindow.cpp └── schedulewindow.h ├── ConsoleControl ├── ConsoleControl.Designer.cs ├── ConsoleControl.cs ├── ConsoleControl.csproj ├── ConsoleControl.resx ├── ConsoleEventArgs.cs ├── KeyMapping.cs ├── Properties │ └── AssemblyInfo.cs └── bin │ └── Release │ ├── ConsoleControl.dll │ ├── ConsoleControl.pdb │ ├── ConsoleControlAPI.dll │ └── ConsoleControlAPI.pdb ├── ConsoleControlAPI ├── ConsoleControlAPI.csproj ├── Imports.cs ├── ProcessEventArgs.cs ├── ProcessInterface.cs ├── Properties │ └── AssemblyInfo.cs └── bin │ └── Release │ ├── ConsoleControlAPI.dll │ └── ConsoleControlAPI.pdb ├── ConsoleControlBack ├── ConsoleControl.dll ├── ConsoleControl.pdb ├── ConsoleControl.xml ├── ConsoleControlAPI.dll ├── ConsoleControlAPI.pdb └── ConsoleControlAPI.xml ├── Debug ├── AutoProfilingTool.exe ├── AutoProfilingTool.ilk ├── AutoProfilingTool.pdb ├── HookD3DAll.dll ├── HookD3DAll.exp ├── HookD3DAll.ilk ├── HookD3DAll.lib ├── HookD3DAll.pdb └── Utility.lib ├── HookD3D ├── HookD3D.vcxproj ├── HookD3D.vcxproj.filters ├── HookD3D.vcxproj.user ├── ReadMe.txt ├── d3dsource.cpp ├── detours │ ├── detours.h │ ├── detours.lib │ └── detours.pdb ├── dllentry.cpp ├── hook-function.cpp ├── hook-function.h ├── hook_direct3D_API.cpp ├── hook_direct3D_API.h ├── hookcommon.h ├── hookd3d.def ├── inforecoder.h ├── inforecorder.cpp ├── lightweightrecoder.cpp ├── lightweightreocder.h ├── nvapi.lib ├── videosource.h └── windowsource.cpp ├── HookD3DAll ├── HookD3DAll.vcxproj ├── HookD3DAll.vcxproj.filters ├── HookD3DAll.vcxproj.user ├── ReadMe.txt ├── detours │ ├── detours.h │ ├── detours.lib │ └── detours.pdb ├── dll_entry.cpp ├── hook_common.h ├── hookd3dall.def ├── nvapi.lib ├── recoder.cpp ├── recorder.h ├── wrap_device_nontrivial.cpp ├── wrap_device_trivial.cpp ├── wrap_direct3d9.cpp ├── wrap_direct3d9.h ├── wrap_direct3dcubetexture9.cpp ├── wrap_direct3dcubetexture9.h ├── wrap_direct3ddevice9.h ├── wrap_direct3dindexbuffer9.cpp ├── wrap_direct3dindexbuffer9.h ├── wrap_direct3dpixelshader9.cpp ├── wrap_direct3dpixelshader9.h ├── wrap_direct3dstateblock9.cpp ├── wrap_direct3dstateblock9.h ├── wrap_direct3dsurface9.cpp ├── wrap_direct3dsurface9.h ├── wrap_direct3dswapchain9.cpp ├── wrap_direct3dswapchain9.h ├── wrap_direct3dtexture9.cpp ├── wrap_direct3dtexture9.h ├── wrap_direct3dvertexbuffer9.cpp ├── wrap_direct3dvertexbuffer9.h ├── wrap_direct3dvertexdeclaration9.cpp ├── wrap_direct3dvertexdeclaration9.h ├── wrap_direct3dvertexshader9.cpp ├── wrap_direct3dvertexshader9.h ├── wrap_direct3dvolume9.cpp ├── wrap_direct3dvolume9.h ├── wrap_direct3dvolumetexture9.cpp └── wrap_direct3dvolumetexture9.h ├── NetChart ├── chartdir.lic ├── netchartdir_cp.dll └── netchartdir_cp.xml ├── README.md ├── Release ├── AutoProfilingTool.exe ├── AutoProfilingTool.pdb ├── HookD3D.dll ├── HookD3D.exp ├── HookD3D.lib ├── HookD3D.pdb ├── HookD3DAll.dll ├── HookD3DAll.exp ├── HookD3DAll.lib ├── HookD3DAll.pdb └── Utility.lib └── Utility ├── CpuWatch.cpp ├── CpuWatch.h ├── GpuWatch.cpp ├── GpuWatch.h ├── ReadMe.txt ├── Utility.vcxproj ├── Utility.vcxproj.filters ├── Utility.vcxproj.user ├── adl_sdk ├── adl_defines.h ├── adl_sdk.h └── adl_structures.h ├── hash.cpp ├── hash_set.cpp ├── hash_set.h ├── log.cpp ├── log.h ├── nv_sdk └── nvapi.h ├── nvapi.lib ├── stdafx.h ├── targetver.h └── utility.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | 32 | # Thumbnails 33 | ._* 34 | 35 | # Files that might appear on external disk 36 | .Spotlight-V100 37 | .Trashes 38 | 39 | # Directories potentially created on remote AFP share 40 | .AppleDB 41 | .AppleDesktop 42 | Network Trash Folder 43 | Temporary Items 44 | .apdisk 45 | .svn 46 | -------------------------------------------------------------------------------- /AutoProfilingForm/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace AutoProfilingForm 11 | { 12 | public partial class Form1 : Form 13 | { 14 | 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void runGameRToolStripMenuItem_Click(object sender, EventArgs e) 21 | { 22 | MdiChildFoRunGame frmChidChildForRunGame = MdiChildFoRunGame.GetForm(); 23 | frmChidChildForRunGame.MdiParent = this; 24 | frmChidChildForRunGame.WindowState = FormWindowState.Maximized; 25 | frmChidChildForRunGame.Show(); 26 | } 27 | 28 | private void analysisAToolStripMenuItem_Click(object sender, EventArgs e) 29 | { 30 | 31 | } 32 | 33 | private void analysisWindowSizeWToolStripMenuItem_Click(object sender, EventArgs e) 34 | { 35 | MdiChildForAnalysis frmChildForAnalysis = MdiChildForAnalysis.GetForm(); 36 | frmChildForAnalysis.MdiParent = this; 37 | frmChildForAnalysis.WindowState = FormWindowState.Maximized; 38 | frmChildForAnalysis.Show(); 39 | } 40 | 41 | private void analysisAllTToolStripMenuItem_Click(object sender, EventArgs e) 42 | { 43 | MdiChildForAnalysisAll frmChildForAnalysisAll = MdiChildForAnalysisAll.GetForm(); 44 | frmChildForAnalysisAll.MdiParent = this; 45 | frmChildForAnalysisAll.WindowState = FormWindowState.Maximized; 46 | frmChildForAnalysisAll.Show(); 47 | } 48 | 49 | private void allCharactorAndEstimateToolStripMenuItem_Click(object sender, EventArgs e) 50 | { 51 | MdiChildForAllAndEstimate frmChildForAllCharactor = MdiChildForAllAndEstimate.GetForm(); 52 | frmChildForAllCharactor.MdiParent = this; 53 | frmChildForAllCharactor.WindowState = FormWindowState.Maximized; 54 | frmChildForAllCharactor.Show(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /AutoProfilingForm/GameDB.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Trine 5 | F:\TestDemo\Games\Trine 6 | F:\TestDemo\AllResultSets 7 | Trine.single.set 8 | HookD3DAll.dll 9 | 10 | 11 | DemoUnity 12 | F:\TestDemo\Games\4-0_AngryBots 13 | F:\TestDemo\AllResultSets 14 | DemoUnity.single.set 15 | HookD3DAll.dll 16 | 17 | -------------------------------------------------------------------------------- /AutoProfilingForm/MdiChildForAllAndEstimate.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AutoProfilingForm/MdiChildForAnalysis.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AutoProfilingForm/MdiChildForAnalysisAll.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AutoProfilingForm/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace AutoProfilingForm 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("AutoProfilingForm")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AutoProfilingForm")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("e49f9097-9ea2-4f8c-9e8a-c87db6dd5ecc")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/DataSources/AutoProfilingForm.Properties.Resources.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | AutoProfilingForm.Properties.Resources, AutoProfilingForm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/DataSources/AutoProfilingForm.Properties.Settings.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | AutoProfilingForm.Properties.Settings, AutoProfilingForm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/DataSources/MdiChildFoRunGame.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | AutoProfilingForm.MdiChildFoRunGame, AutoProfilingForm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本: 4.0.30319.18449 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AutoProfilingForm.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 返回此类使用的、缓存的 ResourceManager 实例。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoProfilingForm.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 为所有资源查找重写当前线程的 CurrentUICulture 属性, 56 | /// 方法是使用此强类型资源类。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18449 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AutoProfilingForm.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AutoProfilingForm/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/AutoProfilingForm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/AutoProfilingForm.exe -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/AutoProfilingForm.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/AutoProfilingForm.pdb -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/AutoProfilingForm.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/AutoProfilingForm.vshost.exe -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/AutoProfilingForm.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/AutoProfilingTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/AutoProfilingTool.exe -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/ConsoleControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/ConsoleControl.dll -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/ConsoleControl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/ConsoleControl.pdb -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/ConsoleControlAPI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/ConsoleControlAPI.dll -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/ConsoleControlAPI.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/ConsoleControlAPI.pdb -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/HookD3D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/HookD3D.dll -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/HookD3DAll.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/HookD3DAll.dll -------------------------------------------------------------------------------- /AutoProfilingForm/bin/Release/netchartdir_cp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingForm/bin/Release/netchartdir_cp.dll -------------------------------------------------------------------------------- /AutoProfilingTool.v10.sdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingTool.v10.sdf -------------------------------------------------------------------------------- /AutoProfilingTool.v10.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingTool.v10.suo -------------------------------------------------------------------------------- /AutoProfilingTool.v10.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {630627F4-128B-4FE1-B207-4F14A5D4089F} 15 | Win32Proj 16 | AutoProfilingToolv10 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | 24 | 25 | Application 26 | false 27 | true 28 | Unicode 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | Level3 51 | Disabled 52 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 53 | 54 | 55 | Windows 56 | true 57 | 58 | 59 | 60 | 61 | Level3 62 | 63 | 64 | MaxSpeed 65 | true 66 | true 67 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 68 | 69 | 70 | Windows 71 | true 72 | true 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /AutoProfilingTool.v10.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | -------------------------------------------------------------------------------- /AutoProfilingTool.v10.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /AutoProfilingTool/AutoProfilingTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {4F56DE92-AD06-479A-BFD8-502782A97039} 15 | Win32Proj 16 | AutoProfilingTool 17 | 18 | 19 | 20 | Application 21 | true 22 | MultiByte 23 | 24 | 25 | Application 26 | false 27 | true 28 | MultiByte 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | Level3 51 | Disabled 52 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 53 | 54 | 55 | Console 56 | true 57 | 58 | 59 | 60 | 61 | Level3 62 | 63 | 64 | MaxSpeed 65 | true 66 | true 67 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 68 | 69 | 70 | Console 71 | true 72 | true 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /AutoProfilingTool/AutoProfilingTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 32 | 33 | 源文件 34 | 35 | 36 | 源文件 37 | 38 | 39 | 源文件 40 | 41 | 42 | 源文件 43 | 44 | 45 | -------------------------------------------------------------------------------- /AutoProfilingTool/AutoProfilingTool.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /AutoProfilingTool/AutoRrofilingTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {270C5374-2F8B-457D-8920-83A93E6C772F} 15 | Win32Proj 16 | AutoRrofilingTool 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | MultiByte 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | {1d728a27-4457-4fab-90bb-0439452b5356} 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /AutoProfilingTool/AutoRrofilingTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | Resource Files 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /AutoProfilingTool/ReadMe.txt: -------------------------------------------------------------------------------- 1 | this project is for auto-profiling. 2 | author: Alan Zhang, alanzw@163.com 3 | 4 | the main idea is to generate game charactor files and get the most suitable scheduling time for a cloud gaming system. -------------------------------------------------------------------------------- /AutoProfilingTool/common.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_H__ 2 | #define __COMMON_H__ 3 | // for common use in auto profiling tool 4 | 5 | // the input data is in sencods or fps level 6 | enum UNIT{ 7 | UNIT_FPS, 8 | UNIT_SECONDS 9 | }; 10 | 11 | 12 | // the inteval for each unit 13 | enum IntervalBase{ 14 | SECOND_INTERVAL_BASE = 10, 15 | FPS_INTERVAL_BASE = 300 16 | 17 | }; 18 | 19 | // the increasing speed 20 | enum IntervalIncreaseStep{ 21 | SECOND_INCREASE_SPEED = 5, 22 | FPS_INCREASE_SPEED = 150 23 | }; 24 | 25 | // the max step 26 | enum MaxInterval{ 27 | SECOND_MAX_STEP = 100, 28 | FPS_MAX_STEP = 3000 29 | }; 30 | 31 | enum VARIANCE_TYPE{ 32 | CPU_VAR, 33 | GPU_VAR 34 | }; 35 | 36 | 37 | #pragma comment(lib, "detours\\detours.lib") 38 | 39 | #endif -------------------------------------------------------------------------------- /AutoProfilingTool/detours/detours.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingTool/detours/detours.lib -------------------------------------------------------------------------------- /AutoProfilingTool/detours/detours.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingTool/detours/detours.pdb -------------------------------------------------------------------------------- /AutoProfilingTool/gamecharactormaker.h: -------------------------------------------------------------------------------- 1 | #ifndef __GAMECHARACTORMAKER_H__ 2 | #define __GAMECHARACTORMAKER_H__ 3 | // this is for the charactor maker for any d3d game. record the cpu usage, gpu usage and the fps 4 | #include 5 | #include "..\Utility\log.h" 6 | #include "common.h" 7 | 8 | #define DEFAULT_DLL_NAME "HookD3D.dll" 9 | 10 | class CharactorMaker{ 11 | char * gameName, *dllName, *gameFolder; 12 | char * saveDirectory, * outputFileName; 13 | 14 | char argList[128]; 15 | char path[MAX_PATH]; 16 | int runTime; // the max time to run, in minutes 17 | 18 | UNIT unit; // identify the recording time interval, in frame or in seconds 19 | Log * charactorLogger; // write to file 20 | 21 | bool limitFps; 22 | bool toLogFrame; 23 | int maxFps; 24 | 25 | public: 26 | inline void setEnableFrameLog(bool val){ toLogFrame = val; } 27 | inline void setMaxFps(int mfps){ limitFps = true; maxFps = mfps; } 28 | 29 | inline void setSaveDirectory(char * directory){ 30 | this->saveDirectory = _strdup(directory); 31 | } 32 | inline void setOutputFileName(char * fileName){ 33 | this->outputFileName = _strdup(fileName); 34 | } 35 | 36 | // load game accordingly 37 | void loadGame(); 38 | 39 | // load game with hookd3d.dll 40 | void loadGame(char * _gameName); 41 | 42 | // load game with specified dll 43 | void loadGame(char * _gameName, char * _dllName); 44 | 45 | void dealArgv(int argc, char ** argv, int startIndex, int stopIndex); // read the arg list for the loader and format the argList 46 | 47 | // the runtime indicate the time to run 48 | 49 | CharactorMaker(char * _gameName, char * _gameFolder, int _runtime, UNIT _unit); 50 | 51 | CharactorMaker(char * _gameName, char *_dllName, char * _gameFolder, int _runtime, UNIT _unit); 52 | ~CharactorMaker(); 53 | }; 54 | 55 | 56 | #endif -------------------------------------------------------------------------------- /AutoProfilingTool/log.cpp: -------------------------------------------------------------------------------- 1 | #include "log.h" 2 | #include 3 | #include 4 | 5 | #define MAX_CHAR 512 6 | 7 | Log::Log(const char *filename){ 8 | init(filename); 9 | 10 | } 11 | Log::~Log(){ 12 | close(); 13 | 14 | } 15 | 16 | 17 | // this is for the log component 18 | void Log::init(const char * filename){ 19 | strcpy(fname_, filename); 20 | fs_.open(fname_, ios::out); 21 | 22 | log("Log::init(), filename = %s.\n", fname_); 23 | 24 | } 25 | 26 | void Log::close(){ 27 | log("Log::close() called.\n"); 28 | fs_.close(); 29 | } 30 | 31 | void Log::log(const char * text, ...){ 32 | //if (!is_init_) init("fuck.log"); 33 | char buffer[MAX_CHAR]; 34 | char timestr[30]; 35 | 36 | tv = time(0); 37 | tm* ltime = localtime(&tv); 38 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 39 | 40 | va_list ap; 41 | va_start(ap, text); 42 | vsprintf(buffer, text, ap); 43 | va_end(ap); 44 | DWORD thread = GetCurrentThreadId(); 45 | fs_ << timestr << ": " << " [tid: " << thread << "]" << buffer; 46 | fs_.flush(); 47 | } 48 | 49 | void Log::slog(const char* text, ...) { 50 | char buffer[MAX_CHAR]; 51 | 52 | char timestr[30]; 53 | 54 | tv = time(0); 55 | tm* ltime = localtime(&tv); 56 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 57 | 58 | va_list ap; 59 | va_start(ap, text); 60 | vsprintf(buffer, text, ap); 61 | va_end(ap); 62 | DWORD thread = GetCurrentThreadId(); 63 | fs_ << timestr << ": " << " [tid: " << thread << "]" << buffer; 64 | fs_.flush(); 65 | } 66 | 67 | void Log::logscreen(const char * text, ...){ 68 | char buffer[MAX_CHAR]; 69 | char timestr[30]; 70 | 71 | tv = time(0); 72 | tm * ltime = localtime(&tv); 73 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 74 | 75 | va_list ap; 76 | va_start(ap, text); 77 | vsprintf(buffer, text, ap); 78 | va_end(ap); 79 | 80 | cerr << timestr << ": " << buffer; 81 | cerr.flush(); 82 | } -------------------------------------------------------------------------------- /AutoProfilingTool/log.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOG_H__ 2 | #define __LOG_H__ 3 | // this for the log system for the project 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | 13 | class Log { 14 | time_t tv; 15 | public: 16 | void init(const char* fname); 17 | void log(const char* text, ...); 18 | void slog(const char* text, ...); 19 | void logscreen(const char * text, ...); 20 | void close(); 21 | 22 | Log(const char * filename); 23 | ~Log(); 24 | 25 | private: 26 | char fname_[100]; 27 | ofstream fs_; 28 | }; 29 | 30 | #endif -------------------------------------------------------------------------------- /AutoProfilingTool/main.cpp: -------------------------------------------------------------------------------- 1 | // the main entry of the tool 2 | 3 | #include 4 | #include "gamecharactormaker.h" 5 | #include "schedulewindow.h" 6 | #if 1 7 | 8 | #define DEFAULT_GAME_FOLDER "\\Games\\" 9 | #else 10 | #define DEFAULT_GAME_FOLDER "\\" 11 | #endif 12 | using namespace std; 13 | // para: argv0, the tool name 14 | // 15 | 16 | int usage(int argc){ 17 | cout << "usage:\n\tAutoProfilingTool [-U ] [[-S ] or [-I ]] [-D -P [-O [-F ] -G ...]." << endl; 18 | cout << "\t-U: the specific the unit to recoder, can be UNIT_FPS or UNIT_SECONDS." << endl; 19 | cout << "\t-I: the file contains the names of all the games' charactor file." << endl; 20 | cout << "\t-D: the specified the dll to use. if dll name is 'hookd3dall.dll', may need to use -u to specific the record unit for game." << endl; 21 | cout << "\t-F: the is to limit the games FPS." << endl; 22 | cout << "\t-G: the ... contains all the games to run and log the charactor to files." << endl; 23 | cout << "\t-P: the to save the ouputfile." << endl; 24 | cout << "\t-O: the to specfic the output file name." << endl; 25 | 26 | if (argc <= 2){ 27 | cout << "usage: AutoProfilingTool -I , or AutoProfileTool -D -G ...." << endl; 28 | return -1; 29 | } 30 | else if (argc > 3){ 31 | 32 | } 33 | 34 | } 35 | 36 | 37 | // the arg list, the argv is valid 38 | void dealArgList(int argc, char ** argv){ 39 | for (int i = 0; i < argc; i++){ 40 | if (!strcmp(argv[i], "-I")){ 41 | // schedule window 42 | 43 | } 44 | else if (!strcmp(argv[i], "-D") || !strcmp(argv[i], "-F") || !strcmp(argv[i], "-G")){ 45 | // charactor maker 46 | } 47 | } 48 | } 49 | 50 | int main(int argc, char ** argv){ 51 | if (argc <= 2){ 52 | usage(argc); 53 | return -1; 54 | } 55 | 56 | char * inputSet = NULL, *inputFile = NULL, * dllName = NULL, * gameName = NULL, * log = NULL; 57 | char * saveDirectory = NULL, * outputFileName = NULL; 58 | 59 | int maxFps = 0 ; 60 | bool limitFps = false, enableLogFrame = false; 61 | UNIT unitType = UNIT::UNIT_FPS; 62 | 63 | bool getWindow = false; 64 | // deal the args 65 | for (int i = 0; i < argc; i++){ 66 | if (!strcmp(argv[i], "-U") || !strcmp(argv[i], "-u")){ 67 | if (!strcmp(argv[i + 1], "UNIT_SECONDS")){ 68 | unitType = UNIT_SECONDS; 69 | } 70 | } 71 | else if (!strcmp(argv[i], "-I") || !strcmp(argv[i], "-i")){ 72 | // schedule window 73 | inputSet = _strdup(argv[i + 1]); 74 | ScheduleWindow * scheduleWindowForSet = new ScheduleWindow(inputSet, unitType); 75 | scheduleWindowForSet->processInputSet(inputSet); 76 | getWindow = true; 77 | break; 78 | } 79 | else if (!strcmp(argv[i], "-S") || !strcmp(argv[i], "-s")){ 80 | inputFile = _strdup(argv[i + 1]); 81 | 82 | ScheduleWindow * scheduleWindowForSingle = new ScheduleWindow(inputFile, 0, unitType); 83 | 84 | scheduleWindowForSingle->getScheduleWindow(inputFile); 85 | getWindow = true; 86 | break; 87 | } 88 | else if (!strcmp(argv[i], "-D") || !strcmp(argv[i], "-d")){ 89 | // charactor maker 90 | dllName = _strdup(argv[i + 1]); 91 | } 92 | else if (!strcmp(argv[i], "-F") || !strcmp(argv[i], "-f")){ 93 | // charactor maker 94 | limitFps = true; 95 | maxFps = atoi(argv[i + 1]); 96 | 97 | }else if(!strcmp(argv[i], "-G") || !strcmp(argv[i], "-f")){ 98 | // charactor maker 99 | gameName = _strdup(argv[i + 1]); 100 | 101 | } 102 | else if(!strcmp(argv[i], "-L") || !strcmp(argv[i], "-l")){ 103 | log = _strdup(argv[i+1]); 104 | enableLogFrame = true; 105 | } 106 | else if(!strcmp(argv[i], "-P") || !strcmp(argv[i], "-p")){ 107 | saveDirectory = _strdup(argv[i+1]); 108 | } 109 | else if(!strcmp(argv[i], "-O") || !strcmp(argv[i], "-o")){ 110 | outputFileName = _strdup(argv[i+1]); 111 | } 112 | } 113 | // here to create charactor maker 114 | if (getWindow){ 115 | 116 | } 117 | else{ 118 | CharactorMaker * cmaker = new CharactorMaker(gameName, dllName, DEFAULT_GAME_FOLDER, 1, UNIT_FPS); 119 | 120 | if (limitFps){ 121 | printf("[main]: limitFps true?\n"); 122 | cmaker->setMaxFps(maxFps); 123 | } 124 | if(enableLogFrame){ 125 | printf("[main]: allow to log frame data.\n"); 126 | cmaker->setEnableFrameLog(true); 127 | } 128 | 129 | if(saveDirectory != NULL){ 130 | cmaker->setSaveDirectory(saveDirectory); 131 | } 132 | if(outputFileName != NULL){ 133 | cmaker->setOutputFileName(outputFileName); 134 | } 135 | 136 | cmaker->loadGame(); 137 | } 138 | return 0; 139 | } -------------------------------------------------------------------------------- /AutoProfilingTool/profile.input.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/AutoProfilingTool/profile.input.txt -------------------------------------------------------------------------------- /ConsoleControl/ConsoleControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ConsoleControl 2 | { 3 | partial class ConsoleControl 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region 组件设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.richTextBoxConsole = new System.Windows.Forms.RichTextBox(); 32 | this.SuspendLayout(); 33 | // 34 | // richTextBoxConsole 35 | // 36 | this.richTextBoxConsole.BackColor = System.Drawing.Color.Black; 37 | this.richTextBoxConsole.Dock = System.Windows.Forms.DockStyle.Fill; 38 | this.richTextBoxConsole.ForeColor = System.Drawing.Color.White; 39 | this.richTextBoxConsole.Location = new System.Drawing.Point(0, 0); 40 | this.richTextBoxConsole.Name = "richTextBoxConsole"; 41 | this.richTextBoxConsole.Size = new System.Drawing.Size(150, 150); 42 | this.richTextBoxConsole.TabIndex = 0; 43 | this.richTextBoxConsole.Text = ""; 44 | // 45 | // ConsoleControl 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.Controls.Add(this.richTextBoxConsole); 50 | this.Name = "ConsoleControl"; 51 | this.ResumeLayout(false); 52 | 53 | } 54 | 55 | #endregion 56 | 57 | private System.Windows.Forms.RichTextBox richTextBoxConsole; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ConsoleControl/ConsoleControl.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {45B56EF2-E04D-4925-BBEA-3A5B6F9DBD5E} 9 | Library 10 | Properties 11 | ConsoleControl 12 | ConsoleControl 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | UserControl 48 | 49 | 50 | ConsoleControl.cs 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ConsoleControl.cs 60 | 61 | 62 | 63 | 64 | {7BEB3808-504D-4A34-A4F9-A6B5BCD954D7} 65 | ConsoleControlAPI 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /ConsoleControl/ConsoleControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /ConsoleControl/ConsoleEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ConsoleControl 7 | { 8 | /// 9 | /// the ConsoleEventArgs are arguments for a console event 10 | /// 11 | public class ConsoleEventArgs : EventArgs 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public ConsoleEventArgs() { } 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// the content 21 | public ConsoleEventArgs(string content) 22 | { 23 | // set the content 24 | Content = content; 25 | } 26 | 27 | /// 28 | /// Gets the content. 29 | /// 30 | public string Content 31 | { 32 | get; 33 | private set; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ConsoleControl/KeyMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace ConsoleControl 8 | { 9 | /// 10 | /// A keymapping defines how a key combination should be mapped to SendKeys message. 11 | /// 12 | public class KeyMapping 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public KeyMapping() { } 18 | 19 | /// 20 | /// Initalizes a new instance of the class 21 | /// 22 | /// if set to true [control]. 23 | /// if set to true [alt]. 24 | /// if set to true [shift]. 25 | /// The key code. 26 | /// The send keys mapping. 27 | /// The stream mapping. 28 | public KeyMapping(bool control, bool alt, bool shift, Keys keyCode, string sendKeyMapping, string streamMapping) 29 | { 30 | IsControlPressed = control; 31 | IsAltPressed = alt; 32 | IsShiftPressed = shift; 33 | KeyCode = KeyCode; 34 | SendKeysMapping = sendKeyMapping; 35 | StreamMapping = streamMapping; 36 | } 37 | 38 | /// 39 | /// Gets or sets a value indicating whether this instace is control pressed 40 | /// 41 | /// 42 | /// true if this instance is control pressed; otherwise, false. 43 | /// 44 | public bool IsControlPressed 45 | { 46 | get; 47 | set; 48 | } 49 | /// 50 | /// Gets or sets a value indicating whether alt is pressed. 51 | /// 52 | /// 53 | /// true if this instance is alt pressed; otherwise, false. 54 | /// 55 | public bool IsAltPressed 56 | { 57 | get; 58 | set; 59 | } 60 | 61 | /// 62 | /// Gets or sets a value indicating whether this instance is shift pressed. 63 | /// 64 | /// 65 | /// true is this instance is shift pressed; otherwise, false. 66 | /// 67 | public bool IsShiftPressed 68 | { 69 | get; 70 | set; 71 | } 72 | 73 | /// 74 | /// Gets or sets the key code 75 | /// 76 | /// 77 | /// the key code. 78 | /// 79 | public Keys KeyCode 80 | { 81 | get; 82 | set; 83 | } 84 | 85 | /// 86 | /// 87 | /// Gets or sets the send keys mapping. 88 | /// 89 | /// the send keys mapping. 90 | public string SendKeysMapping 91 | { 92 | get; 93 | set; 94 | } 95 | /// 96 | /// Gets or sets the stream mapping. 97 | /// 98 | /// the stream mapping. 99 | public string StreamMapping 100 | { 101 | get; 102 | set; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /ConsoleControl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("ConsoleControl")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConsoleControl")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("de6a31a1-c9ba-4be5-a99b-d599c7d1257b")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ConsoleControl/bin/Release/ConsoleControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControl/bin/Release/ConsoleControl.dll -------------------------------------------------------------------------------- /ConsoleControl/bin/Release/ConsoleControl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControl/bin/Release/ConsoleControl.pdb -------------------------------------------------------------------------------- /ConsoleControl/bin/Release/ConsoleControlAPI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControl/bin/Release/ConsoleControlAPI.dll -------------------------------------------------------------------------------- /ConsoleControl/bin/Release/ConsoleControlAPI.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControl/bin/Release/ConsoleControlAPI.pdb -------------------------------------------------------------------------------- /ConsoleControlAPI/ConsoleControlAPI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {7BEB3808-504D-4A34-A4F9-A6B5BCD954D7} 9 | Library 10 | Properties 11 | ConsoleControlAPI 12 | ConsoleControlAPI 13 | v4.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 56 | -------------------------------------------------------------------------------- /ConsoleControlAPI/Imports.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace ConsoleControlAPI 8 | { 9 | internal static class Imports 10 | { 11 | /// 12 | /// Sends a specified signal to a console process group that shares the console associated with the calling process. 13 | /// 14 | /// The type of signal to be generated. 15 | /// The identifier of the process group to receive the signal. A process group is created when the CREATE_NEW_PROCESS_GROUP flag is specified in a call to the CreateProcess function. The process identifier of the new process is also the process group identifier of a new process group. The process group includes all processes that are descendants of the root process. Only those processes in the group that share the same console as the calling process receive the signal. In other words, if a process in the group creates a new console, that process does not receive the signal, nor do its descendants. 16 | /// If this parameter is zero, the signal is generated in all processes that share the console of the calling process. 17 | /// If the function succeeds, the return value is nonzero. 18 | /// If the function fails, the return value is zero. To get extended error information, call GetLastError. 19 | [DllImport("Kernel32.dll")] 20 | public static extern bool GenerateConsoleCtrlEvent(CTRL_EVENT dwCtrlEvent, UInt32 dwProcessGroupId); 21 | } 22 | 23 | /// 24 | /// The type of signal to be generated. 25 | /// 26 | internal enum CTRL_EVENT : uint 27 | { 28 | /// 29 | /// Generates a CTRL+C signal. This signal cannot be generated for process groups. If dwProcessGroupId is nonzero, this function will succeed, but the CTRL+C signal will not be received by processes within the specified process group. 30 | /// 31 | CTRL_C_EVENT = 0, 32 | 33 | /// 34 | /// Generates a CTRL+BREAK signal. 35 | /// 36 | CTRL_BREAK_EVENT = 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ConsoleControlAPI/ProcessEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ConsoleControlAPI 7 | { 8 | /// 9 | /// The ProcessEventArgs are arguments for a console event. 10 | /// 11 | public class ProcessEventArgs : EventArgs 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public ProcessEventArgs() 17 | { 18 | } 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// The content. 24 | public ProcessEventArgs(string content) 25 | { 26 | // Set the content and code. 27 | Content = content; 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The code. 34 | public ProcessEventArgs(int code) 35 | { 36 | // Set the content and code. 37 | Code = code; 38 | } 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The content. 44 | /// The code. 45 | public ProcessEventArgs(string content, int code) 46 | { 47 | // Set the content and code. 48 | Content = content; 49 | Code = code; 50 | } 51 | 52 | /// 53 | /// Gets the content. 54 | /// 55 | public string Content { get; private set; } 56 | 57 | /// 58 | /// Gets or sets the code. 59 | /// 60 | /// 61 | /// The code. 62 | /// 63 | public int? Code { get; private set; } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ConsoleControlAPI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("ConsoleControlAPI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConsoleControlAPI")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("738d5512-6630-4ad8-ba12-b2e8ea8d1de4")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ConsoleControlAPI/bin/Release/ConsoleControlAPI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlAPI/bin/Release/ConsoleControlAPI.dll -------------------------------------------------------------------------------- /ConsoleControlAPI/bin/Release/ConsoleControlAPI.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlAPI/bin/Release/ConsoleControlAPI.pdb -------------------------------------------------------------------------------- /ConsoleControlBack/ConsoleControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlBack/ConsoleControl.dll -------------------------------------------------------------------------------- /ConsoleControlBack/ConsoleControl.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlBack/ConsoleControl.pdb -------------------------------------------------------------------------------- /ConsoleControlBack/ConsoleControlAPI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlBack/ConsoleControlAPI.dll -------------------------------------------------------------------------------- /ConsoleControlBack/ConsoleControlAPI.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/ConsoleControlBack/ConsoleControlAPI.pdb -------------------------------------------------------------------------------- /Debug/AutoProfilingTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/AutoProfilingTool.exe -------------------------------------------------------------------------------- /Debug/AutoProfilingTool.ilk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/AutoProfilingTool.ilk -------------------------------------------------------------------------------- /Debug/AutoProfilingTool.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/AutoProfilingTool.pdb -------------------------------------------------------------------------------- /Debug/HookD3DAll.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/HookD3DAll.dll -------------------------------------------------------------------------------- /Debug/HookD3DAll.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/HookD3DAll.exp -------------------------------------------------------------------------------- /Debug/HookD3DAll.ilk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/HookD3DAll.ilk -------------------------------------------------------------------------------- /Debug/HookD3DAll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/HookD3DAll.lib -------------------------------------------------------------------------------- /Debug/HookD3DAll.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/HookD3DAll.pdb -------------------------------------------------------------------------------- /Debug/Utility.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Debug/Utility.lib -------------------------------------------------------------------------------- /HookD3D/HookD3D.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A40C2F77-3EF1-43CF-8BAC-B96F249EB58C} 15 | Win32Proj 16 | HookD3D 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | MultiByte 23 | 24 | 25 | DynamicLibrary 26 | false 27 | true 28 | MultiByte 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include; 43 | $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86; 44 | 45 | 46 | false 47 | $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include; 48 | $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86; 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | WIN32;_WIN32_DCOM;_DEBUG;_WINDOWS;_USRDLL;HOOKD3D_EXPORTS;%(PreprocessorDefinitions) 57 | 58 | 59 | Windows 60 | true 61 | hookd3d.def 62 | 63 | 64 | 65 | 66 | Level3 67 | 68 | 69 | MaxSpeed 70 | true 71 | true 72 | WIN32;_WIN32_DCOM;NDEBUG;_WINDOWS;_USRDLL;HOOKD3D_EXPORTS;%(PreprocessorDefinitions) 73 | 74 | 75 | Windows 76 | true 77 | true 78 | true 79 | hookd3d.def 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | {d16eb61c-da30-4174-bc6f-45324e72eafb} 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /HookD3D/HookD3D.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 35 | 36 | 源文件 37 | 38 | 39 | 源文件 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | 源文件 49 | 50 | 51 | 源文件 52 | 53 | 54 | 55 | 56 | 资源文件 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /HookD3D/HookD3D.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /HookD3D/ReadMe.txt: -------------------------------------------------------------------------------- 1 | this project is for hook d3d and get the usage and fps 2 | 3 | export HookD3D.dll 4 | used by GameCharactorMaker 5 | 6 | 7 | also, I need a tool to generate video file, a tool to encoding ? ( how about a simple video streming system ) 8 | I need a tool to identify the resource requirement for each stage( capturing, transcoding, encoding[x264 and cuda]) 9 | A basic version is to auto run the games and record the game's resource requirement with cmd flag to identify use 10 | second or fps, log into files and then get the scheduling window -------------------------------------------------------------------------------- /HookD3D/d3dsource.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3D/d3dsource.cpp -------------------------------------------------------------------------------- /HookD3D/detours/detours.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3D/detours/detours.lib -------------------------------------------------------------------------------- /HookD3D/detours/detours.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3D/detours/detours.pdb -------------------------------------------------------------------------------- /HookD3D/hook-function.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOOK_FUNCTION_H__ 2 | #define __HOOK_FUNCTION_H__ 3 | 4 | #pragma once 5 | #include "../utility/log.h" 6 | #include "hookcommon.h" 7 | #include "lightweightreocder.h" 8 | #include "inforecoder.h" 9 | 10 | #define HOOKALL 11 | 12 | #pragma comment(lib, "d3d10.lib") 13 | #pragma comment(lib, "d3d10_1.lib") 14 | #pragma comment(lib, "d3d11.lib") 15 | #pragma comment(lib, "nvapi.lib") 16 | #pragma comment(lib, "winmm.lib") 17 | 18 | //extern Log * logger; 19 | extern InfoRecorder * infoRecorder; 20 | // 21 | extern TDirect3DCreate9 pD3d; 22 | extern TD3D9CreateDevice pD3D9CreateDevice; 23 | extern TD3D9GetSwapChain pD3D9GetSwapChain; 24 | extern TD3D9DevicePresent pD3D9DevicePresent; 25 | extern TSwapChainPresent pSwapChainPresent; 26 | 27 | extern TD3D10CreateDeviceAndSwapChain pD3D10CreateDeviceAndSwapChain; 28 | extern TD3D10CreateDeviceAndSwapChain1 pD3D10CreateDeviceAndSwapChain1; 29 | extern TD3D11CreateDeviceAndSwapChain pD3D11CreateDeviceAndSwapChain; 30 | extern TCreateDXGIFactory pCreateDXGIFactory; 31 | 32 | extern void release_hook_resources(); 33 | 34 | // --- DirectX 9 --- 35 | DllExport IDirect3D9* WINAPI hook_d3d(UINT SDKVersion); 36 | 37 | DllExport HRESULT __stdcall hook_D3D9CreateDevice( 38 | IDirect3DDevice9 * This, 39 | UINT Adapter, 40 | D3DDEVTYPE DeviceType, 41 | HWND hFocusWindow, 42 | DWORD BehaviorFlags, 43 | D3DPRESENT_PARAMETERS *pPresentationParameters, 44 | IDirect3DDevice9 **ppReturnedDeviceInterface 45 | ); 46 | 47 | DllExport HRESULT __stdcall hook_D3D9GetSwapChain( 48 | IDirect3DDevice9 *This, 49 | UINT iSwapChain, 50 | IDirect3DSwapChain9 **ppSwapChain 51 | ); 52 | 53 | DllExport HRESULT __stdcall hook_D3D9SwapChainPresent( 54 | IDirect3DSwapChain9 * This, 55 | CONST RECT* pSourceRect, 56 | CONST RECT* pDestRect, 57 | HWND hDestWindowOverride, 58 | CONST RGNDATA* pDirtyRegion, 59 | DWORD dwFlags 60 | ); 61 | 62 | DllExport HRESULT __stdcall hook_D3D9DevicePresent( 63 | IDirect3DDevice9 * This, 64 | CONST RECT* pSourceRect, 65 | CONST RECT* pDestRect, 66 | HWND hDestWindowOverride, 67 | CONST RGNDATA* pDirtyRegion 68 | ); 69 | 70 | #ifdef HOOKALL 71 | 72 | // ---- DXGI ----- 73 | DllExport HRESULT __stdcall hook_CreateDXGIFactory(REFIID riid, void ** ppFactory); 74 | 75 | DllExport HRESULT __stdcall hook_DXGICreateSwapChain(IDXGIFactory * This, IUnknown * pDevice, DXGI_SWAP_CHAIN_DESC * pDesc, IDXGISwapChain ** ppSwapChain); 76 | 77 | // --- directx 10 / 10.1 / 11 ----- 78 | DllExport HRESULT __stdcall hook_D3D10CreateDeviceAndSwapChain(IDXGIAdapter * pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, UINT SDKVersion, DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D10Device ** ppDevice); 79 | 80 | DllExport HRESULT __stdcall hook_D3D10CreateDeviceAndSwapChain1(IDXGIAdapter * pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, D3D10_FEATURE_LEVEL1 HardwareLevel, UINT SDKVersion, DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D10Device1 ** ppDevice); 81 | 82 | DllExport HRESULT __stdcall hook_D3D11CreateDeviceAndSwapChain(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, const DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D11Device ** ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext **ppImmediateContext); 83 | 84 | // ---- 85 | 86 | DllExport HRESULT __stdcall hook_DXGISwapChainPresent(IDXGISwapChain * This, UINT SyncInterval, UINT Flags); 87 | 88 | #endif 89 | 90 | 91 | void get_proc_name(); 92 | 93 | extern CpuWatch observe_cpu; 94 | extern GpuWatch observe_gpu; 95 | #if 0 96 | IDirect3D9* (WINAPI* Direct3DCreate9Next)(UINT SDKVersion); 97 | 98 | IDirect3D9* WINAPI Direct3DCreate9Callback(UINT SDKVersion); 99 | #endif 100 | 101 | void WINAPI ExitProcessCallback(UINT uExitCode); 102 | 103 | 104 | /// global varibles 105 | 106 | extern bool rateControl; 107 | extern int maxFps; 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /HookD3D/hook_direct3D_API.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "d3d10_1.h" 6 | #include "d3dx9tex.h" 7 | #include "dxerr.h" 8 | #include "../utility/log.h" 9 | #include "detours\detours.h" 10 | #include "../utility/utility.h" 11 | #include "../utility/ga_confvar.h" 12 | #include 13 | #include "../utility/ga_win32.h" 14 | 15 | #define BITSPERPIXEL 32 16 | #define ENCODING_MOD_BASE 2 17 | #define MAX_STRIDE 4 18 | using namespace std; 19 | 20 | 21 | typedef HRESULT (STDMETHODCALLTYPE *TD3D9DevicePresent)( 22 | IDirect3DDevice9 * This, 23 | CONST RECT* pSourceRect, 24 | CONST RECT* pDestRect, 25 | HWND hDestWindowOverride, 26 | CONST RGNDATA* pDirtyRegion 27 | ); 28 | 29 | typedef HRESULT (STDMETHODCALLTYPE *TSwapChainPresent)( 30 | IDirect3DSwapChain9 * This, 31 | CONST RECT* pSourceRect, 32 | CONST RECT* pDestRect, 33 | HWND hDestWindowOverride, 34 | CONST RGNDATA* pDirtyRegion, 35 | DWORD dwFlags 36 | ); 37 | 38 | struct vsource_frame { 39 | long long imgpts; // presentation timestamp 40 | //enum vsource_format pixelformat; // rgba or yuv420p 41 | PixelFormat pixelformat; 42 | int linesize[MAX_STRIDE]; // strides for YUV 43 | int realwidth; 44 | int realheight; 45 | int realstride; 46 | int realsize; 47 | // internal data - should not change after initialized 48 | int maxstride; 49 | int imgbufsize; 50 | unsigned char *imgbuf; 51 | unsigned char *imgbuf_internal; 52 | int alignment; 53 | }; 54 | 55 | #pragma comment(lib,"detours\detours.lib") 56 | 57 | #define DllImport _declspec( dllimport ) 58 | #define DllExport _declspec( dllexport ) 59 | 60 | class hook_direct3D_API 61 | { 62 | public: 63 | hook_direct3D_API(void); 64 | ~hook_direct3D_API(void); 65 | 66 | 67 | static bool D3D9_screen_capture(IDirect3DDevice9 * pDevice); 68 | 69 | int ga_hook_video_rate_control(); 70 | long pcdiff_us(LARGE_INTEGER t1, LARGE_INTEGER t2, LARGE_INTEGER freq); 71 | 72 | //hook D3DDevice present 73 | DllExport HRESULT _stdcall 74 | hook_D3D9DevicePresent(IDirect3DDevice9 *p_d3d_device,CONST RECT* p_source_rect,CONST RECT* p_dest_rect,HWND hDestWindowOverride,CONST RGNDATA *p_dirty_region); 75 | //hook D3D9 swap chain present 76 | DllExport HRESULT _stdcall 77 | hook_DXGI_swap_chain_present(IDXGISwapChain *p_swap_chain,UINT sync_interval,UINT flags); 78 | 79 | public: 80 | TD3D9DevicePresent pD3D9DevicePresent; 81 | TSwapChainPresent pSwapChainPresent; 82 | 83 | static int d3d_device_present_hooked; 84 | static int swap_chain_present_hooked; 85 | 86 | static int resolution_inited; 87 | static int video_rate_inited; 88 | static int vsource_inited; 89 | static int capture_inited; 90 | static int game_width; 91 | static int game_height; 92 | 93 | static int encoder_width; 94 | static int encoder_height; 95 | static map ga_vars; 96 | static map::iterator ga_vmi = ga_vars.begin(); 97 | 98 | 99 | static int enable_server_rate_control; 100 | static int server_token_fill_interval; 101 | static int server_num_token_to_fill; 102 | static int server_max_tokens; 103 | static int video_fps; 104 | static int frame_interval; 105 | static IDirect3DSurface9 *resolvedSurface; 106 | static IDirect3DSurface9 *offscreenSurface; 107 | }; 108 | 109 | -------------------------------------------------------------------------------- /HookD3D/hookcommon.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOOKCOMMON_H__ 2 | #define __HOOKCOMMON_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "d3d10_1.h" 8 | #include 9 | #include "d3dx9tex.h" 10 | #include "dxerr.h" 11 | #include "detours\detours.h" 12 | #include "../Utility/CpuWatch.h" 13 | #include "../Utility/GpuWatch.h" 14 | 15 | #pragma comment(lib, "d3d9.lib") 16 | #pragma comment(lib, "d3dx9.lib") 17 | 18 | #pragma comment(lib, "dxguid.lib") 19 | #pragma comment(lib, "comctl32.lib") 20 | #pragma comment(lib, "detours/detours.lib") 21 | 22 | #define DllImport _declspec( dllimport ) 23 | #define DllExport _declspec( dllexport ) 24 | #define STATISTIC_FRAMES 100 25 | #define TIME_INTERVAL 1000 //every 100ms caculate the CPU/GPU utilization 26 | 27 | typedef HRESULT(STDMETHODCALLTYPE *TGetRawInputData) ( 28 | HRAWINPUT hRawInput, 29 | UINT uiCommand, 30 | LPVOID pData, 31 | PUINT pcbSize, 32 | UINT cbSizeHeader 33 | ); 34 | 35 | // --- Common Release --- 36 | typedef ULONG(STDMETHODCALLTYPE *TRelease) (IUnknown *comobj); 37 | // --- DirectX 9 --- 38 | typedef IDirect3D9* (STDMETHODCALLTYPE *TDirect3DCreate9)( 39 | UINT SDKVersion 40 | ); 41 | 42 | typedef HRESULT(STDMETHODCALLTYPE *TD3D9CreateDevice)( 43 | IDirect3DDevice9 * This, 44 | UINT Adapter, 45 | D3DDEVTYPE DeviceType, 46 | HWND hFocusWindow, 47 | DWORD BehaviorFlags, 48 | D3DPRESENT_PARAMETERS *pPresentationParameters, 49 | IDirect3DDevice9 **ppReturnedDeviceInterface 50 | ); 51 | 52 | typedef HRESULT(STDMETHODCALLTYPE *TD3D9DevicePresent)( 53 | IDirect3DDevice9 * This, 54 | CONST RECT* pSourceRect, 55 | CONST RECT* pDestRect, 56 | HWND hDestWindowOverride, 57 | CONST RGNDATA* pDirtyRegion 58 | ); 59 | 60 | typedef HRESULT(STDMETHODCALLTYPE *TSwapChainPresent)( 61 | IDirect3DSwapChain9 * This, 62 | CONST RECT* pSourceRect, 63 | CONST RECT* pDestRect, 64 | HWND hDestWindowOverride, 65 | CONST RGNDATA* pDirtyRegion, 66 | DWORD dwFlags 67 | ); 68 | 69 | typedef HRESULT(STDMETHODCALLTYPE *TD3D9GetSwapChain)( 70 | IDirect3DDevice9 *This, 71 | UINT iSwapChain, 72 | IDirect3DSwapChain9 **ppSwapChain 73 | ); 74 | 75 | // ------ DXGI------- 76 | 77 | typedef HRESULT(STDMETHODCALLTYPE * TDXGISwapChainPresent)( 78 | IDXGISwapChain * This, 79 | UINT SyncInterval, 80 | UINT Flags); 81 | 82 | typedef HRESULT(STDMETHODCALLTYPE * TCreateDXGIFactory)( 83 | REFIID riid, void ** ppFactory); 84 | 85 | typedef HRESULT(STDMETHODCALLTYPE * TDXGICreateSwapChain)(IDXGIFactory * This, IUnknown * pDevice, DXGI_SWAP_CHAIN_DESC * pDesc, IDXGISwapChain ** ppSwapChain); 86 | 87 | // ---- directx 10 / 10.1 88 | typedef HRESULT(STDMETHODCALLTYPE *TD3D10CreateDeviceAndSwapChain)(IDXGIAdapter * pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, UINT SDKVersion, DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D10Device ** ppDevice); 89 | 90 | typedef HRESULT(STDMETHODCALLTYPE * TD3D10CreateDeviceAndSwapChain1)(IDXGIAdapter * pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, D3D10_FEATURE_LEVEL1 HardwareLevel, UINT SDKVersion, DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D10Device1 **ppDevice); 91 | 92 | // -- directx 11 --- 93 | typedef HRESULT(STDMETHODCALLTYPE *TD3D11CreateDeviceAndSwapChain)(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, const DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain ** ppSwapChain, ID3D11Device ** ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext ** ppImmediateContext); 94 | 95 | #endif -------------------------------------------------------------------------------- /HookD3D/hookd3d.def: -------------------------------------------------------------------------------- 1 | LIBRARY HookD3D.dll 2 | EXPROTS -------------------------------------------------------------------------------- /HookD3D/inforecoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __INFORECORDER_H__ 2 | #define __INFORECORDER_H__ 3 | 4 | #include 5 | #include 6 | 7 | #include "lightweightreocder.h" 8 | #include "..\Utility\CpuWatch.h" 9 | #include "..\Utility\GpuWatch.h" 10 | 11 | class InfoRecorder{ 12 | 13 | LARGE_INTEGER secondEnd, secondStart, freq, frameStart, frameEnd; 14 | ULONGLONG timeCount; 15 | 16 | // the cpu and gpu watcher 17 | CpuWatch *frameCpuWatcher, *secondCpuWatcher; 18 | GpuWatch *gpuWatcher; 19 | 20 | HANDLE processHandle; 21 | 22 | unsigned int frameIndex, secondIndex, frameCountInSecond; 23 | 24 | LightWeightRecorder * frameRecorder; 25 | LightWeightRecorder * secondRecorder; 26 | LightWeightRecorder * errorRecorder; 27 | 28 | bool frameStarted, secondStarted; 29 | 30 | public: 31 | InfoRecorder(char * prefix); 32 | ~InfoRecorder(); 33 | 34 | void flush(); 35 | bool onFrameEnd(); 36 | bool onSecondEnd(); 37 | 38 | void logError(char * foramt, ...); 39 | void logFrame(char * format, ...); 40 | void logSecond(char * format, ...); 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /HookD3D/inforecorder.cpp: -------------------------------------------------------------------------------- 1 | #include "inforecoder.h" 2 | 3 | // constructor and destructor 4 | InfoRecorder::InfoRecorder(char * prefix){ 5 | char recorderName[100]; 6 | 7 | // init he frame recorder 8 | sprintf(recorderName, "%s.frame.log", prefix); 9 | frameRecorder = new LightWeightRecorder(recorderName); 10 | memset(recorderName, 0, 100); 11 | sprintf(recorderName, "%s.second.log", prefix); 12 | secondRecorder = new LightWeightRecorder(recorderName); 13 | memset(recorderName, 0, 100); 14 | sprintf(recorderName, "%s.error.log", prefix); 15 | errorRecorder = new LightWeightRecorder(recorderName); 16 | 17 | // create all the watcher 18 | frameCpuWatcher = new CpuWatch(); 19 | secondCpuWatcher = new CpuWatch(); 20 | gpuWatcher = new GpuWatch(); 21 | 22 | processHandle = GetCurrentProcess(); 23 | if (processHandle == NULL){ 24 | MessageBox(NULL, "null process handle, get current process failed.", "Error", MB_OK); 25 | } 26 | 27 | 28 | timeCount = 0; 29 | QueryPerformanceFrequency(&freq); 30 | 31 | frameIndex = 0; 32 | secondIndex = 0; 33 | frameCountInSecond = 0; 34 | 35 | frameStarted = false; 36 | secondStarted = false; 37 | 38 | logFrame("FrameIndex FPS cpu gpu\n"); 39 | logSecond("SecondIndex FPS cpu gpu\n"); 40 | } 41 | 42 | InfoRecorder::~InfoRecorder(){ 43 | 44 | // flush first 45 | flush(); 46 | 47 | if (frameRecorder){ 48 | delete frameRecorder; 49 | frameRecorder = NULL; 50 | } 51 | if (secondRecorder){ 52 | delete secondRecorder; 53 | secondRecorder = NULL; 54 | } 55 | if (errorRecorder){ 56 | delete errorRecorder; 57 | errorRecorder = NULL; 58 | } 59 | 60 | if (frameCpuWatcher){ 61 | delete frameCpuWatcher; 62 | frameCpuWatcher = NULL; 63 | } 64 | if (secondCpuWatcher){ 65 | delete secondCpuWatcher; 66 | secondCpuWatcher = NULL; 67 | } 68 | if (gpuWatcher){ 69 | delete gpuWatcher; 70 | gpuWatcher = NULL; 71 | } 72 | } 73 | 74 | 75 | // functions 76 | void InfoRecorder::flush(){ 77 | this->frameRecorder->flush(true); 78 | this->secondRecorder->flush(true); 79 | this->errorRecorder->flush(true); 80 | } 81 | 82 | // get the cpu usage and gpu usage and the fps 83 | bool InfoRecorder::onFrameEnd(){ 84 | // compute the fps 85 | float curFps = 0.0f; 86 | double cpuUsage = 0.0f; 87 | double gpuUsage = 0.0f; 88 | // get the frame time 89 | QueryPerformanceCounter(&frameEnd); 90 | 91 | if (frameStarted){ 92 | #if 1 93 | cpuUsage = frameCpuWatcher->GetProcessCpuUtilization(processHandle); 94 | 95 | gpuUsage = gpuWatcher->GetGpuUsage(); 96 | 97 | curFps = this->freq.QuadPart / ((frameEnd.QuadPart - frameStart.QuadPart)); 98 | #endif 99 | 100 | frameCountInSecond++; 101 | 102 | timeCount += (frameEnd.QuadPart - frameStart.QuadPart); 103 | if (timeCount >= this->freq.QuadPart){ 104 | onSecondEnd(); 105 | timeCount = 0; 106 | } 107 | #if 1 108 | // do the log for frame. 109 | // the log format should be: [index] [fps] [cpuUsage] [gpuUsage] 110 | frameRecorder->log("%d %f %f %f\n", frameIndex, curFps, cpuUsage, gpuUsage); 111 | #endif 112 | } 113 | else{ 114 | frameStarted = true; 115 | } 116 | 117 | frameIndex++; 118 | QueryPerformanceCounter(&frameStart); 119 | return true; 120 | } 121 | // get the cpu and gpu usage and the fps 122 | bool InfoRecorder::onSecondEnd(){ 123 | QueryPerformanceCounter(&secondEnd); 124 | 125 | if (secondStarted){ 126 | // log the second counter 127 | float cpuUsage = 0.0f; 128 | float gpuUsage = 0.0f; 129 | float fpsInSecond = frameCountInSecond * this->freq.QuadPart / (secondEnd.QuadPart - secondStart.QuadPart); 130 | 131 | frameCountInSecond = 0; 132 | 133 | cpuUsage = secondCpuWatcher->GetProcessCpuUtilization(processHandle); 134 | gpuUsage = gpuWatcher->GetGpuUsage(); 135 | 136 | secondRecorder->log("%d %f %f %f\n", secondIndex, fpsInSecond, cpuUsage, gpuUsage); 137 | } 138 | else{ 139 | secondStarted = true; 140 | } 141 | secondIndex++; 142 | QueryPerformanceCounter(&secondStart); 143 | return true; 144 | } 145 | 146 | // log the error 147 | void InfoRecorder::logError(char * format, ...){ 148 | va_list ap; 149 | va_start(ap, format); 150 | errorRecorder->log(format, ap); 151 | va_end(ap); 152 | } 153 | 154 | void InfoRecorder::logFrame(char * format, ...){ 155 | va_list ap; 156 | va_start(ap, format); 157 | frameRecorder->log(format, ap); 158 | va_end(ap); 159 | } 160 | void InfoRecorder::logSecond(char * format, ...){ 161 | va_list ap; 162 | va_start(ap, format); 163 | secondRecorder->log(format, ap); 164 | va_end(ap); 165 | } -------------------------------------------------------------------------------- /HookD3D/lightweightrecoder.cpp: -------------------------------------------------------------------------------- 1 | #include "lightweightreocder.h" 2 | // this is for the high performance logger. 3 | 4 | // constructor and destructor 5 | 6 | LightWeightRecorder::LightWeightRecorder(char * prefix, int bufferSize){ 7 | this->bufferSize = bufferSize; 8 | logBuffer = NULL; 9 | curPoint = NULL; 10 | file = NULL; 11 | curLogSize = 0; 12 | 13 | temBuffer = NULL; 14 | 15 | if (!init(prefix)){ 16 | // error 17 | } 18 | } 19 | 20 | LightWeightRecorder::~LightWeightRecorder(){ 21 | if (file){ 22 | flush(true); 23 | close(); 24 | file = NULL; 25 | } 26 | if (logBuffer){ 27 | 28 | free(logBuffer); 29 | logBuffer = NULL; 30 | bufferSize = 0; 31 | curPoint = NULL; 32 | curLogSize = 0; 33 | } 34 | 35 | if (temBuffer){ 36 | free(temBuffer); 37 | temBuffer = NULL; 38 | } 39 | 40 | } 41 | 42 | bool LightWeightRecorder::init(char * prefix){ 43 | logBuffer = (char *)malloc(sizeof(char)* bufferSize); 44 | curPoint = logBuffer; 45 | 46 | temBuffer = (char *)malloc(sizeof(char)* 512); 47 | 48 | // format the log name 49 | char filename[128]; 50 | sprintf(filename, "%s.log", prefix); 51 | file = fopen(filename, "w"); 52 | if (file == NULL){ 53 | // error 54 | return false; 55 | } 56 | 57 | return true; 58 | 59 | } 60 | void LightWeightRecorder::log(char * format, ...){ 61 | va_list ap; 62 | va_start(ap, format); 63 | int n = vsprintf(temBuffer, format, ap); 64 | va_end(ap); 65 | 66 | if (this->curLogSize + n >= MAX_LOG_BUFFER_SIZE){ 67 | flush(true); 68 | } 69 | // copy the log 70 | strcpy(this->curPoint, temBuffer); 71 | 72 | this->curLogSize += n; 73 | this->curPoint += n; 74 | } 75 | bool LightWeightRecorder::close(){ 76 | if (file){ 77 | fclose(file); 78 | file = NULL; 79 | } 80 | return true; 81 | } 82 | bool LightWeightRecorder::flush(bool force){ 83 | if (force && curLogSize > 0){ 84 | fprintf(file, "%s", this->logBuffer); 85 | memset(logBuffer, 0, MAX_LOG_BUFFER_SIZE); 86 | curLogSize = 0; 87 | curPoint = logBuffer; 88 | } 89 | return true; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /HookD3D/lightweightreocder.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIGHTWEIGHTRECORDER_H__ 2 | #define __LIGHTWEIGHTRECORDER_H__ 3 | // this is for the high performance logger 4 | #include 5 | #include 6 | 7 | #define MAX_LOG_BUFFER_SIZE 8388608 8 | 9 | 10 | 11 | class LightWeightRecorder{ 12 | int bufferSize; 13 | 14 | int curLogSize; 15 | char * curPoint; 16 | char * logBuffer; 17 | char * temBuffer; 18 | FILE * file; 19 | 20 | 21 | public: 22 | LightWeightRecorder(char * prefix, int bufferSize = MAX_LOG_BUFFER_SIZE); 23 | ~LightWeightRecorder(); 24 | 25 | void log(char * format, ...); 26 | bool init(char * prefix); 27 | bool close(); 28 | bool flush(bool force); 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /HookD3D/nvapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3D/nvapi.lib -------------------------------------------------------------------------------- /HookD3D/videosource.h: -------------------------------------------------------------------------------- 1 | // this is for the video sources 2 | #ifndef __VIDEOSOURCE_H__ 3 | #define __VIDEOSOURCE_H__ 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | #endif -------------------------------------------------------------------------------- /HookD3D/windowsource.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3D/windowsource.cpp -------------------------------------------------------------------------------- /HookD3DAll/HookD3DAll.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 头文件 50 | 51 | 52 | 头文件 53 | 54 | 55 | 头文件 56 | 57 | 58 | 头文件 59 | 60 | 61 | 头文件 62 | 63 | 64 | 头文件 65 | 66 | 67 | 68 | 69 | 源文件 70 | 71 | 72 | 源文件 73 | 74 | 75 | 源文件 76 | 77 | 78 | 源文件 79 | 80 | 81 | 源文件 82 | 83 | 84 | 源文件 85 | 86 | 87 | 源文件 88 | 89 | 90 | 源文件 91 | 92 | 93 | 源文件 94 | 95 | 96 | 源文件 97 | 98 | 99 | 源文件 100 | 101 | 102 | 源文件 103 | 104 | 105 | 源文件 106 | 107 | 108 | 源文件 109 | 110 | 111 | 源文件 112 | 113 | 114 | 源文件 115 | 116 | 117 | 源文件 118 | 119 | 120 | 121 | 122 | 资源文件 123 | 124 | 125 | -------------------------------------------------------------------------------- /HookD3DAll/HookD3DAll.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /HookD3DAll/ReadMe.txt: -------------------------------------------------------------------------------- 1 | this project is to hook all the d3d api, count a game's instructions and the geometry data size 2 | and so on. -------------------------------------------------------------------------------- /HookD3DAll/detours/detours.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3DAll/detours/detours.lib -------------------------------------------------------------------------------- /HookD3DAll/detours/detours.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3DAll/detours/detours.pdb -------------------------------------------------------------------------------- /HookD3DAll/dll_entry.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include 3 | #include "recorder.h" 4 | #include "wrap_direct3d9.h" 5 | 6 | Recoder * gRecoder = NULL; // the global recoder 7 | 8 | IDirect3D9* (WINAPI* Direct3DCreate9Next)(UINT SDKVersion) = Direct3DCreate9; 9 | void (WINAPI* ExitProcessNext)(UINT uExitCode) = ExitProcess; 10 | 11 | IDirect3D9 * WINAPI Direct3DCreate9Callback(UINT SDKVersion){ 12 | gRecoder->logTrace("[INFO]: call the Direct3DCraete9.\n"); 13 | IDirect3D9 * base_d3d9 = Direct3DCreate9Next(SDKVersion); 14 | IDirect3D9 * pv = NULL; 15 | 16 | if (base_d3d9){ 17 | pv = dynamic_cast(new WrapperDirect3D9(base_d3d9, WrapperDirect3D9::ins_count++)); 18 | } 19 | 20 | return pv; 21 | } 22 | 23 | 24 | void WINAPI ExitProcessCallback(UINT uExitCode){ 25 | gRecoder->logError("[INFO]: call exit process.\n"); 26 | 27 | if (gRecoder){ 28 | gRecoder->FlushLog(true); 29 | delete gRecoder; 30 | gRecoder = NULL; 31 | } 32 | 33 | ExitProcessNext(uExitCode); 34 | } 35 | void StartHook() { 36 | gRecoder->logTrace("[INFO]: to start hook d3d.\n"); 37 | 38 | 39 | DetourTransactionBegin(); 40 | DetourUpdateThread(GetCurrentThread()); 41 | DetourAttach((PVOID*)&Direct3DCreate9Next, Direct3DCreate9Callback); 42 | DetourAttach(&(PVOID&)ExitProcessNext, ExitProcessCallback); 43 | LONG co = DetourTransactionCommit(); 44 | if( co== NO_ERROR){ 45 | gRecoder->logTrace("[INFO]: detour transaction commit succeeded.\n"); 46 | } 47 | else{ 48 | gRecoder->logTrace("[ERROR]: detour transaction commit failed with code:%d.\n", co); 49 | } 50 | } 51 | 52 | 53 | // read the cmdline to find whether to limit the fps 54 | char * getGameName(char * cmdline){ 55 | char * p = cmdline; 56 | char gameName[100] = { 0 }; 57 | while (*p){ 58 | if (*p == ' '){ 59 | // the white space is the seperator 60 | break; 61 | } 62 | p++; 63 | } 64 | if (p - cmdline > 0){ 65 | strncpy(gameName, cmdline, p - cmdline); 66 | return _strdup(gameName); 67 | } 68 | else{ 69 | return NULL; 70 | } 71 | 72 | } 73 | 74 | 75 | #if 0 76 | char * getSavePath(char * cmdLine){ 77 | char * p = cmdLine; 78 | char path[MAX_PATH] = {0}; 79 | char * lastSlash = NULL; 80 | while(*p){ 81 | if(*p == '\\' || *p == '/'){ 82 | lashSlash = p; 83 | } 84 | p++; 85 | } 86 | if(lastSlash - cmdLine >0){ 87 | strncpy(path, cmdLine, lastSlash - cmdLine); 88 | return _strdup(path); 89 | }else{ 90 | return _strdup(".\\"); 91 | } 92 | } 93 | #endif 94 | 95 | bool rateControl = false; 96 | int maxFps = 30; 97 | bool enableFrameLog = false; 98 | char path[MAX_PATH] = {0}; 99 | char outputFileName[MAX_PATH] = {0}; 100 | bool useOutput = false; 101 | 102 | int getFps(char * cmdline){ 103 | char * p = cmdline; 104 | char * pEnd = NULL; 105 | char fps[10] = { 0 }; 106 | 107 | while (*p){ 108 | if (*p == '-'){ 109 | p++; 110 | if (*p == 'f' || *p == 'F'){ 111 | // specific a FPS 112 | rateControl = true; 113 | p++; 114 | while (*p == ' '){ 115 | p++; 116 | } 117 | // the p is the start of fps 118 | pEnd = p; 119 | while (*pEnd){ 120 | if (!(*pEnd) || (*pEnd) == ' '){ 121 | break; 122 | } 123 | pEnd++; 124 | } 125 | strncpy(fps, p, pEnd - p); 126 | maxFps = atoi(fps); 127 | //return 1; 128 | p = pEnd; 129 | } 130 | else if(*p == 'L' || *p == 'l'){ 131 | // the log option 132 | p++; 133 | while(*p == ' ' ){ 134 | p++; 135 | } 136 | // the p is the start of the log option 137 | pEnd = p; 138 | while( *pEnd){ 139 | if(!(*pEnd) || (*pEnd) == ' '){ 140 | break; 141 | } 142 | pEnd++; 143 | } 144 | if(!strncmp("frame", p, pEnd - p)){ 145 | // frame log enabled. 146 | enableFrameLog = true; 147 | } 148 | p = pEnd; 149 | 150 | } 151 | else if(*p == 'S' || *p == 's'){ 152 | // the save directory 153 | p++; 154 | while(*p == ' '){ 155 | p++; 156 | } 157 | // the p is the start of the save directory 158 | pEnd = p; 159 | while(*pEnd){ 160 | if(!(*pEnd) || (*pEnd) == ' '){ 161 | break; 162 | } 163 | pEnd++; 164 | } 165 | strncpy(path, p, pEnd - p); 166 | p=pEnd; 167 | } 168 | else if(*p == 'O' || *p == 'o'){ 169 | // the output file name 170 | p++; 171 | while(*p == ' '){ 172 | p++; 173 | } 174 | pEnd = p; 175 | while(*pEnd){ 176 | if(!(*pEnd) || (*pEnd) == ' '){ 177 | break; 178 | } 179 | pEnd++; 180 | } 181 | strncpy(outputFileName, p, pEnd - p); 182 | p = pEnd; 183 | useOutput = true; 184 | } 185 | 186 | } 187 | p++; 188 | } 189 | return 0; 190 | } 191 | 192 | 193 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { 194 | 195 | char * cmdLine = GetCommandLine(); 196 | char * gameName = NULL; 197 | 198 | switch (ul_reason_for_call) 199 | { 200 | case DLL_PROCESS_ATTACH: 201 | // deal with the command line, get all the parameters 202 | gameName = getGameName(cmdLine); 203 | if (gameName == NULL){ 204 | MessageBox(NULL, "null game name", "ERROR", MB_OK); 205 | } 206 | 207 | getFps(cmdLine); 208 | 209 | // init the logger 210 | if (gRecoder == NULL){ 211 | if(useOutput == false){ 212 | gRecoder = new Recoder(path, gameName); 213 | } 214 | else{ 215 | gRecoder = new Recoder(path, gameName, outputFileName); 216 | } 217 | } 218 | 219 | //getFps(cmdLine); 220 | 221 | if (rateControl){ 222 | gRecoder->setLimitFps(true); 223 | gRecoder->setMaxFps(maxFps); 224 | } 225 | else{ 226 | gRecoder->logTrace("[INFO]: no limit to fps.\n"); 227 | } 228 | 229 | if(enableFrameLog){ 230 | gRecoder->setEnableFrameLog(true); 231 | } 232 | else{ 233 | gRecoder->logTrace("[INFO]: do not log frame.\n"); 234 | } 235 | 236 | // start the hook 237 | DisableThreadLibraryCalls(hModule); 238 | 239 | StartHook(); 240 | break; 241 | case DLL_THREAD_ATTACH: break; 242 | case DLL_THREAD_DETACH: break; 243 | case DLL_PROCESS_DETACH: 244 | 245 | //don't do anything here 246 | break; 247 | 248 | WM_ACTIVATE; 249 | } 250 | 251 | return TRUE; 252 | } -------------------------------------------------------------------------------- /HookD3DAll/hook_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOOK_COMMON_H__ 2 | 3 | #define __HOOK_COMMON_H__ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #pragma comment(lib, "d3d9.lib") 10 | #pragma comment(lib, "d3dx9.lib") 11 | #pragma comment(lib, "dxguid.lib") 12 | #pragma comment(lib, "comctl32.lib") 13 | 14 | #define COM_METHOD(TYPE, METHOD) TYPE STDMETHODCALLTYPE METHOD 15 | 16 | #include "detours\detours.h" 17 | #pragma comment(lib, "detours/detours.lib") 18 | #pragma comment(lib, "winmm.lib") 19 | #pragma comment(lib, "nvapi.lib") 20 | 21 | extern IDirect3D9* (WINAPI* Direct3DCreate9Next)(UINT SDKVersion); 22 | 23 | IDirect3D9* WINAPI Direct3DCreate9Callback(UINT SDKVersion); 24 | void WINAPI ExitProcessCallback(UINT uExitCode); 25 | 26 | //#define GETWRAPPERDEVICE 27 | 28 | #endif -------------------------------------------------------------------------------- /HookD3DAll/hookd3dall.def: -------------------------------------------------------------------------------- 1 | LIBRARY hookd3dall.dll 2 | EXPORTS 3 | StartHook -------------------------------------------------------------------------------- /HookD3DAll/nvapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/HookD3DAll/nvapi.lib -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3d9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3D9__ 2 | #define __WRAP_DIRECT3D9__ 3 | 4 | 5 | 6 | class WrapperDirect3D9 : public IDirect3D9 { 7 | private: 8 | IDirect3D9* m_d3d; 9 | int id; 10 | public: 11 | WrapperDirect3D9(IDirect3D9* m_ptr, int _id); 12 | #ifdef GETWRAPPERDEVICE 13 | static WrapperDirect3D9* GetWrapperD3D9(IDirect3D9* ptr); 14 | static HashSet m_list; 15 | #endif 16 | static int ins_count; 17 | inline int GetID(); 18 | inline void SetID(int id); 19 | 20 | public: 21 | COM_METHOD(HRESULT, QueryInterface)(THIS_ REFIID riid, void** ppvObj); 22 | COM_METHOD(ULONG, AddRef)(THIS); 23 | COM_METHOD(ULONG, Release)(THIS); 24 | 25 | /*** IDirect3D9 methods ***/ 26 | COM_METHOD(HRESULT, RegisterSoftwareDevice)(THIS_ void* pInitializeFunction); 27 | COM_METHOD(UINT, GetAdapterCount)(THIS); 28 | COM_METHOD(HRESULT, GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); 29 | COM_METHOD(UINT, GetAdapterModeCount)(THIS_ UINT Adapter,D3DFORMAT Format); 30 | COM_METHOD(HRESULT, EnumAdapterModes)(THIS_ UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); 31 | COM_METHOD(HRESULT, GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode); 32 | COM_METHOD(HRESULT, CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) ; 33 | COM_METHOD(HRESULT, CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) ; 34 | COM_METHOD(HRESULT, CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels) ; 35 | COM_METHOD(HRESULT, CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); 36 | COM_METHOD(HRESULT, CheckDeviceFormatConversion)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) ; 37 | COM_METHOD(HRESULT, GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) ; 38 | COM_METHOD(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) ; 39 | COM_METHOD(HRESULT, CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) ; 40 | }; 41 | 42 | #endif 43 | 44 | 45 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dcubetexture9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DBASETEXTURE9__ 2 | #define __WRAP_DIRECT3DBASETEXTURE9__ 3 | 4 | 5 | class WrapperDirect3DCubeTexture9 : public IDirect3DCubeTexture9 6 | { 7 | private: 8 | int id; 9 | IDirect3DCubeTexture9* m_cube_tex; 10 | 11 | public: 12 | 13 | UINT edgeLength, level; 14 | D3DFORMAT format; 15 | int getTextureSize(); 16 | static int ins_count; 17 | IDirect3DCubeTexture9* GetCubeTex9(); 18 | int GetID(); 19 | inline void SetID(int id); 20 | WrapperDirect3DCubeTexture9(IDirect3DCubeTexture9* ptr, int id); 21 | #ifdef GETWRAPPERDEVICE 22 | static WrapperDirect3DCubeTexture9* GetWrapperCubeTexture9(IDirect3DCubeTexture9* ptr); 23 | 24 | static HashSet m_list; 25 | #endif 26 | public: 27 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 28 | COM_METHOD(ULONG,AddRef)(THIS); 29 | COM_METHOD(ULONG,Release)(THIS); 30 | 31 | /*** IDirect3DBaseTexture9 methods ***/ 32 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 33 | COM_METHOD(HRESULT,SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 34 | COM_METHOD(HRESULT,GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 35 | COM_METHOD(HRESULT,FreePrivateData)(THIS_ REFGUID refguid); 36 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 37 | COM_METHOD(DWORD, GetPriority)(THIS); 38 | COM_METHOD(void, PreLoad)(THIS); 39 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 40 | COM_METHOD(DWORD, SetLOD)(THIS_ DWORD LODNew); 41 | COM_METHOD(DWORD, GetLOD)(THIS); 42 | COM_METHOD(DWORD, GetLevelCount)(THIS); 43 | STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType); 44 | COM_METHOD(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS); 45 | COM_METHOD(void, GenerateMipSubLevels)(THIS); 46 | COM_METHOD(HRESULT,GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc); 47 | COM_METHOD(HRESULT,GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); 48 | COM_METHOD(HRESULT,LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); 49 | COM_METHOD(HRESULT,UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level); 50 | COM_METHOD(HRESULT,AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect); 51 | }; 52 | 53 | #endif -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dindexbuffer9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DINDEXBUFFER9__ 2 | #define __WRAP_DIRECT3DINDEXBUFFER9__ 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | class WrapperDirect3DIndexBuffer9: public IDirect3DIndexBuffer9 9 | { 10 | private: 11 | int id; 12 | public: 13 | int ib_size; 14 | IDirect3DIndexBuffer9* m_ib; 15 | static int ins_count; 16 | 17 | WrapperDirect3DIndexBuffer9(IDirect3DIndexBuffer9* ptr, int _id); 18 | LPDIRECT3DINDEXBUFFER9 GetIB9(); 19 | inline void SetID(int id); 20 | inline int GetID(); 21 | #ifdef GETWRAPPERDEVICE 22 | static WrapperDirect3DIndexBuffer9* GetWrapperIndexedBuffer9(IDirect3DIndexBuffer9* base_indexed_buffer); 23 | static HashSet m_list; 24 | #endif 25 | 26 | public: 27 | /*** IUnknown methods ***/ 28 | COM_METHOD(HRESULT, QueryInterface)(THIS_ REFIID riid, void** ppvObj); 29 | COM_METHOD(ULONG,AddRef)(THIS); 30 | COM_METHOD(ULONG,Release)(THIS); 31 | 32 | /*** IDirect3DResource9 methods ***/ 33 | COM_METHOD(HRESULT, GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 34 | COM_METHOD(HRESULT, SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 35 | COM_METHOD(HRESULT, GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 36 | COM_METHOD(HRESULT, FreePrivateData)(THIS_ REFGUID refguid); 37 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 38 | COM_METHOD(DWORD, GetPriority)(THIS); 39 | COM_METHOD(void, PreLoad)(THIS); 40 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 41 | COM_METHOD(HRESULT, Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); 42 | COM_METHOD(HRESULT, Unlock)(THIS); 43 | COM_METHOD(HRESULT, GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dpixelshader9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | #include "wrap_direct3dpixelshader9.h" 4 | 5 | int WrapperDirect3DPixelShader9::ins_count = 0; 6 | HashSet WrapperDirect3DPixelShader9::m_list; 7 | 8 | WrapperDirect3DPixelShader9::WrapperDirect3DPixelShader9(IDirect3DPixelShader9* ptr, int _id): m_ps(ptr), id(_id) { 9 | 10 | m_list.AddMember(ptr, this); 11 | } 12 | 13 | inline void WrapperDirect3DPixelShader9::SetID(int id) { 14 | this->id = id; 15 | } 16 | 17 | inline int WrapperDirect3DPixelShader9::GetID() { 18 | return this->id; 19 | } 20 | 21 | IDirect3DPixelShader9* WrapperDirect3DPixelShader9::GetPS9() { 22 | return m_ps; 23 | } 24 | 25 | #ifdef GETWRAPPERDEVICE 26 | WrapperDirect3DPixelShader9* WrapperDirect3DPixelShader9::GetWrapperPixelShader(IDirect3DPixelShader9* ptr) { 27 | 28 | gRecoder->logTrace("[INFO]: PixelShader9 call GetWrapperPixelShader.\n"); 29 | WrapperDirect3DPixelShader9* ret = (WrapperDirect3DPixelShader9*)( m_list.GetDataPtr(ptr) ); 30 | if(ret == NULL) { 31 | ret = new WrapperDirect3DPixelShader9(ptr, ins_count++); 32 | } 33 | gRecoder->logTrace("[INFO]: PixelShader9 end GetWapperPixelShader.\n"); 34 | return ret; 35 | } 36 | #endif 37 | 38 | /*** IUnknown methods ***/ 39 | STDMETHODIMP WrapperDirect3DPixelShader9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 40 | gRecoder->logTrace("[INFO]: PixelShader9 call QueryInterface.\n"); 41 | HRESULT hr = m_ps->QueryInterface(riid, ppvObj); 42 | 43 | gRecoder->cmdCalled(sizeof(riid)+sizeof(void *)); 44 | 45 | *ppvObj = this; 46 | gRecoder->logTrace("[INFO]: PixelShader9 end QueryInterface.\n"); 47 | return hr; 48 | } 49 | STDMETHODIMP_(ULONG) WrapperDirect3DPixelShader9::AddRef(THIS) { 50 | gRecoder->logTrace("[INFO]: PixelShader9 call AddRef.\n"); 51 | gRecoder->cmdCalled(sizeof(ULONG)); 52 | ULONG hr = m_ps->AddRef(); 53 | gRecoder->logTrace("[INFO]: PixelShader9 end AddRef.\n"); 54 | return hr; 55 | } 56 | STDMETHODIMP_(ULONG) WrapperDirect3DPixelShader9::Release(THIS) { 57 | gRecoder->logTrace("[INFO]: PixelShader9 call Release.\n"); 58 | gRecoder->cmdCalled(sizeof(ULONG)); 59 | ULONG hr = m_ps->Release(); 60 | gRecoder->logTrace("[INFO]: PixelShader9 end Release.\n"); 61 | return hr; 62 | } 63 | 64 | /*** IDirect3DPixelShader9 methods ***/ 65 | STDMETHODIMP WrapperDirect3DPixelShader9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 66 | gRecoder->logTrace("[INFO]: PixelShader9 call GetDevice.\n"); 67 | gRecoder->cmdCalled(sizeof(void*)); 68 | HRESULT hr = m_ps->GetDevice(ppDevice); 69 | gRecoder->logTrace("[INFO]: PixelShader9 end GetDevice.\n"); 70 | return hr; 71 | } 72 | 73 | STDMETHODIMP WrapperDirect3DPixelShader9::GetFunction(THIS_ void* ptr,UINT* pSizeOfData) { 74 | gRecoder->logTrace("[INFO]: PixelShader9 call GetFunction.\n"); 75 | UINT sizeOfData = 0; 76 | HRESULT hr = m_ps->GetFunction(ptr, &sizeOfData); 77 | *pSizeOfData = sizeOfData; 78 | gRecoder->cmdCalled(sizeof(void *) * 2 + sizeOfData); 79 | gRecoder->logTrace("[INFO]: PixelShader9 end GetFunction.\n"); 80 | return hr; 81 | } -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dpixelshader9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DPIXELSHADER9__ 2 | #define __WRAP_DIRECT3DPIXELSHADER9__ 3 | 4 | 5 | class WrapperDirect3DPixelShader9: public IDirect3DPixelShader9 6 | { 7 | private: 8 | IDirect3DPixelShader9* m_ps; 9 | int id; 10 | public: 11 | 12 | int funcCount; // store the command count in the shader 13 | 14 | static int ins_count; 15 | WrapperDirect3DPixelShader9(IDirect3DPixelShader9* ptr, int _id); 16 | inline int GetID(); 17 | inline void SetID(int id); 18 | IDirect3DPixelShader9* GetPS9(); 19 | #ifdef GETWRAPPERDEVICE 20 | static WrapperDirect3DPixelShader9* GetWrapperPixelShader(IDirect3DPixelShader9* ptr); 21 | static HashSet m_list; 22 | #endif 23 | 24 | /*** IUnknown methods ***/ 25 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 26 | COM_METHOD(ULONG,AddRef)(THIS); 27 | COM_METHOD(ULONG,Release)(THIS); 28 | 29 | /*** IDirect3DPixelShader9 methods ***/ 30 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 31 | COM_METHOD(HRESULT,GetFunction)(THIS_ void*,UINT* pSizeOfData); 32 | 33 | }; 34 | 35 | #endif -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dstateblock9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | 4 | #include "wrap_direct3dstateblock9.h" 5 | #include "wrap_direct3ddevice9.h" 6 | int WrapperDirect3DStateBlock9::ins_count = 0; 7 | 8 | WrapperDirect3DStateBlock9::WrapperDirect3DStateBlock9(IDirect3DStateBlock9* _sb, int _id): m_sb(_sb), id(_id){ 9 | 10 | } 11 | 12 | inline int WrapperDirect3DStateBlock9::GetID() { 13 | return this->id; 14 | } 15 | 16 | inline void WrapperDirect3DStateBlock9::SetID(int id) { 17 | this->id = id; 18 | } 19 | 20 | inline IDirect3DStateBlock9* WrapperDirect3DStateBlock9::GetSB9() { 21 | return this->m_sb; 22 | } 23 | 24 | 25 | /*** IUnknown methods ***/ 26 | STDMETHODIMP WrapperDirect3DStateBlock9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 27 | gRecoder->logTrace("[INFO]: StateBlock9 call QueryInterface.\n"); 28 | gRecoder->cmdCalled(sizeof(riid)); 29 | HRESULT hr = m_sb->QueryInterface(riid, ppvObj); 30 | *ppvObj = this; 31 | gRecoder->logTrace("[INFO]: StateBlock9 end QueryInterface.\n"); 32 | return hr; 33 | } 34 | 35 | STDMETHODIMP_(ULONG) WrapperDirect3DStateBlock9::AddRef(THIS) { 36 | gRecoder->logTrace("[INFO]: StateBlock9 call AddRef.\n"); 37 | gRecoder->cmdCalled(sizeof(ULONG)); 38 | ULONG hr = m_sb->AddRef(); 39 | gRecoder->logTrace("[INFO]: StateBlock9 end AddRef.\n"); 40 | return hr; 41 | } 42 | 43 | STDMETHODIMP_(ULONG) WrapperDirect3DStateBlock9::Release(THIS) { 44 | gRecoder->logTrace("[INFO]: StateBlock9 call Release.\n"); 45 | gRecoder->cmdCalled(sizeof(ULONG)); 46 | ULONG hr = m_sb->Release(); 47 | gRecoder->logTrace("[INFO]: StateBlock9 end Release.\n"); 48 | return hr; 49 | } 50 | 51 | /*** IDirect3DStateBlock9 methods ***/ 52 | STDMETHODIMP WrapperDirect3DStateBlock9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 53 | gRecoder->logTrace("[INFO]: StateBlock9 call GetDevice.\n"); 54 | IDirect3DDevice9* base = NULL; 55 | HRESULT hr = this->m_sb->GetDevice(&base); 56 | 57 | gRecoder->cmdCalled(sizeof(void *)); 58 | WrapperDirect3DDevice9 * ret = NULL; 59 | //WrapperDirect3DDevice9::GetWrapperDevice9(base); 60 | #ifndef GETWRAPPERDEVICE 61 | if ( 62 | (*base) == typeid(IDirect3DDevice9)){ 63 | *ppDevice = base; 64 | } 65 | else if (typeid(*base) == typeid(WrapperDirect3DDevice9)){ 66 | gRecoder->logError("[ERROR]: State Block GetDevice got a WrapperDevice.\n"); 67 | *ppDevice = ((WrapperDirect3DDevice9 *)base)->GetIDirect3DDevice9(); 68 | } 69 | else{ 70 | gRecoder->logError("[ERROR]: State Block GetDevice got a Unknow type.\n"); 71 | *ppDevice = base; 72 | } 73 | #else 74 | ret = WrapperDirect3DDevice9::GetWrapperDevice9(base); 75 | gRecoder->cmdCalled(sizeof(void*)); 76 | *ppDevice = dynamic_cast(ret); 77 | #endif 78 | gRecoder->logTrace("[INFO]: StateBlock9 end GetDevice.\n"); 79 | return hr; 80 | } 81 | 82 | STDMETHODIMP WrapperDirect3DStateBlock9::Capture(THIS) { 83 | 84 | gRecoder->logTrace("[INFO]: StateBlock9 call Capture.\n"); 85 | gRecoder->cmdCalled(0); 86 | HRESULT hr = m_sb->Capture(); 87 | gRecoder->logTrace("[INFO]: StateBlock9 end Capture.\n"); 88 | return hr; 89 | } 90 | 91 | STDMETHODIMP WrapperDirect3DStateBlock9::Apply(THIS) { 92 | gRecoder->logTrace("[INFO]: StateBlock9 call Apply.\n"); 93 | gRecoder->cmdCalled(0); 94 | HRESULT hr = m_sb->Apply(); 95 | gRecoder->logTrace("[INFO]: StateBlock9 end Apply.\n"); 96 | return hr; 97 | } 98 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dstateblock9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DSTATEBLOCK9__ 2 | #define __WRAP_DIRECT3DSTATEBLOCK9__ 3 | 4 | 5 | class WrapperDirect3DStateBlock9 : public IDirect3DStateBlock9 { 6 | private: 7 | IDirect3DStateBlock9* m_sb; 8 | int id; 9 | 10 | public: 11 | 12 | static int ins_count; 13 | WrapperDirect3DStateBlock9(IDirect3DStateBlock9* _sb, int _id); 14 | inline int GetID(); 15 | inline void SetID(int id); 16 | inline IDirect3DStateBlock9* GetSB9(); 17 | 18 | public: 19 | /*** IUnknown methods ***/ 20 | COM_METHOD(HRESULT, QueryInterface)(THIS_ REFIID riid, void** ppvObj); 21 | COM_METHOD(ULONG,AddRef)(THIS); 22 | COM_METHOD(ULONG,Release)(THIS); 23 | 24 | /*** IDirect3DStateBlock9 methods ***/ 25 | COM_METHOD(HRESULT, GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 26 | COM_METHOD(HRESULT, Capture)(THIS); 27 | COM_METHOD(HRESULT, Apply)(THIS); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dsurface9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DSURFACE9__ 2 | #define __WRAP_DIRECT3DSURFACE9__ 3 | 4 | 5 | class WrapperDirect3DSurface9 : public IDirect3DSurface9 6 | { 7 | private: 8 | IDirect3DSurface9* m_surface; 9 | int size; 10 | int id; 11 | public: 12 | UINT width, height; 13 | D3DFORMAT format; 14 | 15 | //int getSurfaceSize(); 16 | 17 | static int ins_count; 18 | WrapperDirect3DSurface9(IDirect3DSurface9* ptr, int id); 19 | #ifdef GETWRAPPERDEVICE 20 | static WrapperDirect3DSurface9* GetWrapperSurface9(IDirect3DSurface9* ptr); 21 | static HashSet m_list; 22 | #endif 23 | inline int GetID(); 24 | inline void SetID(int id); 25 | IDirect3DSurface9* GetSurface9(); 26 | 27 | int getSurfaceSize(); 28 | 29 | /*** IUnknown methods ***/ 30 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 31 | COM_METHOD(ULONG,AddRef)(THIS); 32 | COM_METHOD(ULONG,Release)(THIS); 33 | 34 | /*** IDirect3DResource9 methods ***/ 35 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 36 | COM_METHOD(HRESULT,SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 37 | COM_METHOD(HRESULT,GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 38 | COM_METHOD(HRESULT,FreePrivateData)(THIS_ REFGUID refguid); 39 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 40 | COM_METHOD(DWORD, GetPriority)(THIS); 41 | COM_METHOD(void, PreLoad)(THIS); 42 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 43 | COM_METHOD(HRESULT,GetContainer)(THIS_ REFIID riid,void** ppContainer); 44 | COM_METHOD(HRESULT,GetDesc)(THIS_ D3DSURFACE_DESC *pDesc); 45 | COM_METHOD(HRESULT,LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); 46 | COM_METHOD(HRESULT,UnlockRect)(THIS); 47 | COM_METHOD(HRESULT,GetDC)(THIS_ HDC *phdc); 48 | COM_METHOD(HRESULT,ReleaseDC)(THIS_ HDC hdc); 49 | }; 50 | 51 | #endif -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dswapchain9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | 4 | #include "wrap_direct3dswapchain9.h" 5 | #include "wrap_direct3dsurface9.h" 6 | 7 | int WrapperDirect3DSwapChain9::ins_count = 0; 8 | HashSet WrapperDirect3DSwapChain9::m_list; 9 | 10 | WrapperDirect3DSwapChain9::WrapperDirect3DSwapChain9(IDirect3DSwapChain9* ptr, int _id): m_chain(ptr), id(_id) { 11 | m_list.AddMember(ptr, this); 12 | } 13 | 14 | inline int WrapperDirect3DSwapChain9::GetID() { 15 | return this->id; 16 | } 17 | 18 | inline void WrapperDirect3DSwapChain9::SetID(int id) { 19 | this->id = id; 20 | } 21 | 22 | #ifdef GETWRAPPERDEVICE 23 | 24 | WrapperDirect3DSwapChain9* WrapperDirect3DSwapChain9::GetWrapperSwapChain9(IDirect3DSwapChain9* ptr) { 25 | gRecoder->logTrace("[INFO]: SwapChain9 call GetWrapperSwapChain9.\n"); 26 | WrapperDirect3DSwapChain9* ret = (WrapperDirect3DSwapChain9*)( m_list.GetDataPtr(ptr) ); 27 | 28 | if(ret == NULL) { 29 | gRecoder->logTrace("[INFO]: create new swap chain, id = %d.\n", ins_count); 30 | ret = new WrapperDirect3DSwapChain9(ptr, ins_count++); 31 | } 32 | gRecoder->logTrace("[INFO]: SwapChain9 end GetWrapperSwapChain9.\n"); 33 | return ret; 34 | } 35 | #endif 36 | 37 | /*** IUnknown methods ***/ 38 | STDMETHODIMP WrapperDirect3DSwapChain9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 39 | gRecoder->logTrace("[INFO]: SwapChain9 call QueryInterface.\n"); 40 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 41 | HRESULT hr = m_chain->QueryInterface(riid, ppvObj); 42 | *ppvObj = this; 43 | gRecoder->logTrace("[INFO]: SwapChain9 end QueryInterface.\n"); 44 | return hr; 45 | } 46 | STDMETHODIMP_(ULONG) WrapperDirect3DSwapChain9::AddRef(THIS) { 47 | gRecoder->logTrace("[INFO]: SwapChain9 call AddRef.\n"); 48 | gRecoder->cmdCalled(sizeof(ULONG)); 49 | ULONG hr = m_chain->AddRef(); 50 | gRecoder->logTrace("[INFO]: SwapChain9 end AddRef.\n"); 51 | return hr; 52 | } 53 | STDMETHODIMP_(ULONG) WrapperDirect3DSwapChain9::Release(THIS) { 54 | gRecoder->logTrace("[INFO]: SwapChain9 call Release.\n"); 55 | gRecoder->cmdCalled(sizeof(ULONG)); 56 | ULONG hr = m_chain->Release(); 57 | gRecoder->logTrace("[INFO]: SwapChain9 end Release.\n"); 58 | return hr; 59 | } 60 | 61 | /*** IDirect3DSwapChain9 methods ***/ 62 | STDMETHODIMP WrapperDirect3DSwapChain9::Present(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags) { 63 | 64 | gRecoder->logTrace("[INFO]: SwapChain9 call Present.\n"); 65 | gRecoder->presentCalled(sizeof(void *) * 3 + sizeof(RECT) * 2 + sizeof(HWND) + sizeof(RGNDATA) + sizeof(DWORD)); 66 | 67 | HRESULT hr = m_chain->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); 68 | gRecoder->logTrace("[INFO]: SwapChain9 end Present.\n"); 69 | return hr; 70 | } 71 | 72 | STDMETHODIMP WrapperDirect3DSwapChain9::GetFrontBufferData(THIS_ IDirect3DSurface9* pDestSurface) { 73 | gRecoder->logTrace("[INFO]: SwapChain9 call GetFrontBufferData.\n"); 74 | gRecoder->cmdCalled(sizeof(void *)); 75 | HRESULT hr = m_chain->GetFrontBufferData(pDestSurface); 76 | gRecoder->logTrace("[INFO]: SwapChain9 end GetFrontBufferData.\n"); 77 | return hr; 78 | } 79 | 80 | STDMETHODIMP WrapperDirect3DSwapChain9::GetBackBuffer(THIS_ UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) { 81 | gRecoder->logTrace("[INFO]: SwapChain9 call GetBackBuffer.\n"); 82 | IDirect3DSurface9* base_surface = NULL; 83 | HRESULT hr = m_chain->GetBackBuffer(iBackBuffer, Type, &base_surface); 84 | WrapperDirect3DSurface9* surface = NULL; 85 | #ifndef GETWRAPPERDEVICE 86 | if (typeid(*base_surface) == typeid(WrapperDirect3DSurface9)){ 87 | *ppBackBuffer = surface; 88 | } 89 | else if (typeid(*base_surface) == typeid(IDirect3DSurface9)){ 90 | gRecoder->logError("[ERROR]: GetBackBuffer got a IDirect3DSurface9. create new!"); 91 | surface = new WrapperDirect3DSurface9(base_surface, WrapperDirect3DSurface9::ins_count++); 92 | *ppBackBuffer = surface; 93 | } 94 | else{ 95 | 96 | // error 97 | gRecoder->logError("[ERROR]: GetBackBuffer got an unknown type.\n"); 98 | *ppBackBuffer = NULL; 99 | } 100 | gRecoder->cmdSendAndCalled(sizeof(UINT) + sizeof(D3DBACKBUFFER_TYPE) + sizeof(void *)); 101 | 102 | #else 103 | surface = WrapperDirect3DSurface9::GetWrapperSurface9(base_surface); 104 | gRecoder->cmdSendAndCalled(sizeof(UINT)+sizeof(D3DBACKBUFFER_TYPE)+sizeof(void *)); 105 | *ppBackBuffer = dynamic_cast(surface); 106 | #endif 107 | gRecoder->logTrace("[INFO]: SwapChain9 end GetBackBuffer.\n"); 108 | return hr; 109 | } 110 | 111 | STDMETHODIMP WrapperDirect3DSwapChain9::GetRasterStatus(THIS_ D3DRASTER_STATUS* pRasterStatus) { 112 | gRecoder->logTrace("[INFO]: SwapChain9 call GetRasterStatus.\n"); 113 | gRecoder->cmdCalled(sizeof(void *) + sizeof(D3DRASTER_STATUS)); 114 | HRESULT hr = m_chain->GetRasterStatus(pRasterStatus); 115 | gRecoder->logTrace("[INFO]: SwapChain9 end GetRasterStatus.\n"); 116 | return hr; 117 | } 118 | 119 | STDMETHODIMP WrapperDirect3DSwapChain9::GetDisplayMode(THIS_ D3DDISPLAYMODE* pMode) { 120 | gRecoder->logTrace("[INFO]: SwapChain9 call GetDisplayMode.\n"); 121 | gRecoder->cmdCalled(sizeof(D3DDISPLAYMODE)); 122 | HRESULT hr =m_chain->GetDisplayMode(pMode); 123 | gRecoder->logTrace("[INFO]: SwapChain9 end GetDisplayMode.\n"); 124 | return hr; 125 | } 126 | 127 | STDMETHODIMP WrapperDirect3DSwapChain9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 128 | gRecoder->logTrace("[INFO]: SwapChain9 call GetDevice.\n"); 129 | gRecoder->cmdCalled(sizeof(void *)); 130 | HRESULT hr = m_chain->GetDevice(ppDevice); 131 | gRecoder->logTrace("[INFO]: SwapChain9 end GetDevice.\n"); 132 | return hr; 133 | } 134 | 135 | STDMETHODIMP WrapperDirect3DSwapChain9::GetPresentParameters(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) { 136 | gRecoder->logTrace("[INFO]: SwapChain9 call GetPresentParameters.\n"); 137 | gRecoder->cmdCalled(sizeof(void *) + sizeof(D3DPRESENT_PARAMETERS)); 138 | HRESULT hr = m_chain->GetPresentParameters(pPresentationParameters); 139 | gRecoder->logTrace("[INFO]: SwapChain9 end GetPresentParameters.\n"); 140 | return hr; 141 | } 142 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dswapchain9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DSWAPCHAIN9__ 2 | #define __WRAP_DIRECT3DSWAPCHAIN9__ 3 | 4 | 5 | class WrapperDirect3DSwapChain9 : public IDirect3DSwapChain9 6 | { 7 | private: 8 | IDirect3DSwapChain9* m_chain; 9 | int id; 10 | 11 | public: 12 | 13 | static int ins_count; 14 | inline void SetID(int id); 15 | inline int GetID(); 16 | WrapperDirect3DSwapChain9(IDirect3DSwapChain9* ptr, int _id); 17 | #ifdef GETWRAPPERDEVICE 18 | static WrapperDirect3DSwapChain9* GetWrapperSwapChain9(IDirect3DSwapChain9* ptr); 19 | static HashSet m_list; 20 | #endif 21 | public: 22 | /*** IUnknown methods ***/ 23 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 24 | COM_METHOD(ULONG,AddRef)(THIS); 25 | COM_METHOD(ULONG,Release)(THIS); 26 | 27 | /*** IDirect3DSwapChain9 methods ***/ 28 | COM_METHOD(HRESULT,Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags); 29 | COM_METHOD(HRESULT,GetFrontBufferData)(THIS_ IDirect3DSurface9* pDestSurface); 30 | COM_METHOD(HRESULT,GetBackBuffer)(THIS_ UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer); 31 | COM_METHOD(HRESULT,GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus); 32 | COM_METHOD(HRESULT,GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode); 33 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 34 | COM_METHOD(HRESULT,GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dtexture9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DTEXTURE9__ 2 | #define __WRAP_DIRECT3DTEXTURE9__ 3 | 4 | 5 | class WrapperDirect3DTexture9: public IDirect3DTexture9 6 | { 7 | private: 8 | IDirect3DTexture9* m_tex; 9 | int id; 10 | 11 | public: 12 | 13 | int height, width, level; 14 | D3DFORMAT foramt; 15 | 16 | inline int getTextureSize(); 17 | 18 | static int ins_count; 19 | WrapperDirect3DTexture9(IDirect3DTexture9* ptr, int _id); 20 | int GetID(); 21 | inline void SetID(int id); 22 | IDirect3DTexture9* GetTex9(); 23 | #ifdef GETWRAPPERDEVICE 24 | static WrapperDirect3DTexture9* GetWrapperTexture9(IDirect3DTexture9* ptr); 25 | static HashSet m_list; 26 | #endif 27 | /*** IUnknown methods ***/ 28 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 29 | COM_METHOD(ULONG,AddRef)(THIS); 30 | COM_METHOD(ULONG,Release)(THIS); 31 | 32 | /*** IDirect3DBaseTexture9 methods ***/ 33 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 34 | COM_METHOD(HRESULT,SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 35 | COM_METHOD(HRESULT,GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 36 | COM_METHOD(HRESULT,FreePrivateData)(THIS_ REFGUID refguid); 37 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 38 | COM_METHOD(DWORD, GetPriority)(THIS); 39 | COM_METHOD(void, PreLoad)(THIS); 40 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 41 | COM_METHOD(DWORD, SetLOD)(THIS_ DWORD LODNew); 42 | COM_METHOD(DWORD, GetLOD)(THIS); 43 | COM_METHOD(DWORD, GetLevelCount)(THIS); 44 | COM_METHOD(HRESULT,SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType); 45 | COM_METHOD(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS); 46 | COM_METHOD(void, GenerateMipSubLevels)(THIS); 47 | COM_METHOD(HRESULT,GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc); 48 | COM_METHOD(HRESULT,GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface9** ppSurfaceLevel); 49 | COM_METHOD(HRESULT,LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); 50 | COM_METHOD(HRESULT,UnlockRect)(THIS_ UINT Level); 51 | COM_METHOD(HRESULT,AddDirtyRect)(THIS_ CONST RECT* pDirtyRect); 52 | }; 53 | 54 | #endif -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexbuffer9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | #include "wrap_direct3dvertexbuffer9.h" 4 | 5 | 6 | int WrapperDirect3DVertexBuffer9::ins_count = 0; 7 | 8 | HashSet WrapperDirect3DVertexBuffer9::m_list; 9 | 10 | WrapperDirect3DVertexBuffer9::WrapperDirect3DVertexBuffer9(IDirect3DVertexBuffer9* ptr, int _id): m_vb(ptr), id(_id) { 11 | m_list.AddMember(ptr, this); 12 | } 13 | 14 | 15 | WrapperDirect3DVertexBuffer9 * WrapperDirect3DVertexBuffer9::GetWrapperVertexBuffer9(IDirect3DVertexBuffer9 * ptr){ 16 | gRecoder->logTrace("[INFO]: VertexBuffer9 Call GetWraperVertexBuffer9.\n"); 17 | WrapperDirect3DVertexBuffer9 * ret = (WrapperDirect3DVertexBuffer9 *)(m_list.GetDataPtr(ptr)); 18 | if (ret == NULL){ 19 | ret = new WrapperDirect3DVertexBuffer9(ptr, ins_count++); 20 | } 21 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetWrapperVertexBuffer9.\n"); 22 | return ret; 23 | } 24 | 25 | LPDIRECT3DVERTEXBUFFER9 WrapperDirect3DVertexBuffer9::GetVB9() { 26 | return m_vb; 27 | } 28 | 29 | inline void WrapperDirect3DVertexBuffer9::SetId(int id) { 30 | this->id = id; 31 | } 32 | 33 | inline int WrapperDirect3DVertexBuffer9::GetId() { 34 | return this->id; 35 | } 36 | /*** IUnknown methods ***/ 37 | STDMETHODIMP WrapperDirect3DVertexBuffer9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 38 | gRecoder->logTrace("[INFO]: VertexBuffer9 call QueryInterface.\n"); 39 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 40 | HRESULT hr = m_vb->QueryInterface(riid, ppvObj); 41 | *ppvObj = this; 42 | gRecoder->logTrace("[INFO]: VertexBuffer9 end QueryInterface.\n"); 43 | return hr; 44 | }; 45 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexBuffer9::AddRef(THIS) { 46 | gRecoder->logTrace("[INFO]: VertexBuffer9 call AddRef.\n"); 47 | gRecoder->cmdCalled(sizeof(ULONG)); 48 | ULONG hr = m_vb->AddRef(); 49 | gRecoder->logTrace("[INFO]: VertexBuffer9 end AddRef.\n"); 50 | return hr; 51 | } 52 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexBuffer9::Release(THIS) { 53 | gRecoder->logTrace("[INFO]: VertexBuffer9 call Release.\n"); 54 | gRecoder->cmdCalled(sizeof(ULONG)); 55 | ULONG hr = m_vb->Release(); 56 | gRecoder->logTrace("[INFO]: VertexBuffer9 end Release.\n"); 57 | return hr; 58 | } 59 | 60 | /*** IDirect3DResource9 methods ***/ 61 | STDMETHODIMP WrapperDirect3DVertexBuffer9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 62 | gRecoder->logTrace("[INFO]: VertexBuffer9 call GetDevice.\n"); 63 | gRecoder->cmdCalled(sizeof(void *)); 64 | HRESULT hr = m_vb->GetDevice(ppDevice); 65 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetDevice.\n"); 66 | return hr; 67 | } 68 | STDMETHODIMP WrapperDirect3DVertexBuffer9::SetPrivateData(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) { 69 | gRecoder->logTrace("[INFO]: VertexBuffer9 call SetPrivateData.\n"); 70 | gRecoder->cmdCalled(sizeof(refguid) + sizeof(void *) + sizeof(DWORD) * 2 + SizeOfData); 71 | HRESULT hr = m_vb->SetPrivateData(refguid, pData, SizeOfData, Flags); 72 | gRecoder->logTrace("[INFO]: VertexBuffer9 end SetPrivateData.\n"); 73 | return hr; 74 | } 75 | STDMETHODIMP WrapperDirect3DVertexBuffer9::GetPrivateData(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) { 76 | gRecoder->logTrace("[INFO]: VertexBuffer9 call GetPrivateData.\n"); 77 | DWORD sizeOfData = 0; 78 | HRESULT hr = m_vb->GetPrivateData(refguid, pData, &sizeOfData); 79 | *pSizeOfData = sizeOfData; 80 | gRecoder->cmdCalled(sizeof(refguid) + sizeof(void *) * 2 + sizeof(DWORD) + sizeOfData); 81 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetPrivateData.\n"); 82 | return hr; 83 | } 84 | 85 | STDMETHODIMP WrapperDirect3DVertexBuffer9::FreePrivateData(THIS_ REFGUID refguid) { 86 | gRecoder->logTrace("[INFO]: VertexBuffer9 call FreePrivateData.\n"); 87 | gRecoder->cmdCalled(sizeof(refguid)); 88 | HRESULT hr = m_vb->FreePrivateData(refguid); 89 | gRecoder->logTrace("[INFO]: VertexBuffer9 end FreePrivateData.\n"); 90 | return hr; 91 | } 92 | STDMETHODIMP_(DWORD) WrapperDirect3DVertexBuffer9::SetPriority(THIS_ DWORD PriorityNew) { 93 | gRecoder->logTrace("[INFO]: VertexBuffer9 call SetPriority.\n"); 94 | gRecoder->cmdCalled(sizeof(DWORD) * 2); 95 | 96 | DWORD hr = m_vb->SetPriority(PriorityNew); 97 | gRecoder->logTrace("[INFO]: VertexBuffer9 end SetPriority.\n"); 98 | return hr; 99 | } 100 | 101 | STDMETHODIMP_(DWORD) WrapperDirect3DVertexBuffer9::GetPriority(THIS) { 102 | gRecoder->logTrace("[INFO]: VertexBuffer9 call GetPriority.\n"); 103 | gRecoder->cmdCalled(sizeof(DWORD)); 104 | DWORD hr = m_vb->GetPriority(); 105 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetPriority.\n"); 106 | return hr; 107 | } 108 | STDMETHODIMP_(void) WrapperDirect3DVertexBuffer9::PreLoad(THIS) { 109 | gRecoder->logTrace("[INFO]: VertexBuffer9 call PreLoad.\n"); 110 | gRecoder->cmdCalled(0); 111 | m_vb->PreLoad(); 112 | gRecoder->logTrace("[INFO]: VertexBuffer9 end PreLoad.\n"); 113 | return; 114 | } 115 | STDMETHODIMP_(D3DRESOURCETYPE) WrapperDirect3DVertexBuffer9::GetType(THIS) { 116 | gRecoder->logTrace("[INFO]: VertexBuffer9 call GetType.\n"); 117 | gRecoder->cmdCalled(sizeof(D3DRESOURCETYPE)); 118 | D3DRESOURCETYPE hr = m_vb->GetType(); 119 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetType.\n"); 120 | return hr; 121 | } 122 | 123 | STDMETHODIMP WrapperDirect3DVertexBuffer9::Lock(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) { 124 | gRecoder->logTrace("[INFO]: VertexBuffer9 call Lock.\n"); 125 | gRecoder->vertexBufferLockCalled(sizeof(UINT) * 2 + sizeof(void *) + sizeof(DWORD), SizeToLock); 126 | 127 | HRESULT hr = m_vb->Lock(OffsetToLock, SizeToLock, ppbData, Flags); 128 | gRecoder->logTrace("[INFO]: VertexBuffer9 end Lock.\n"); 129 | return hr; 130 | } 131 | 132 | STDMETHODIMP WrapperDirect3DVertexBuffer9::Unlock(THIS) { 133 | gRecoder->logTrace("[INFO]: VertexBuffer9 call Unlock.\n"); 134 | gRecoder->cmdCalled(0); 135 | HRESULT hr = m_vb->Unlock(); 136 | gRecoder->logTrace("[INFO]: VertexBuffer9 end Unlock.\n"); 137 | return hr; 138 | } 139 | 140 | STDMETHODIMP WrapperDirect3DVertexBuffer9::GetDesc(THIS_ D3DVERTEXBUFFER_DESC *pDesc) { 141 | gRecoder->logTrace("[INFO]: VertexBuffer9 call GetDesc.\n"); 142 | gRecoder->cmdCalled(sizeof(D3DVERTEXBUFFER_DESC) + sizeof(void *)); 143 | HRESULT hr =m_vb->GetDesc(pDesc); 144 | gRecoder->logTrace("[INFO]: VertexBuffer9 end GetDesc.\n"); 145 | return hr; 146 | } 147 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexbuffer9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DVERTEXBUFFER9__ 2 | #define __WRAP_DIRECT3DVERTEXBUFFER9__ 3 | 4 | class WrapperDirect3DVertexBuffer9: public IDirect3DVertexBuffer9 5 | { 6 | private: 7 | IDirect3DVertexBuffer9* m_vb; 8 | int id; 9 | public: 10 | 11 | int vb_size; 12 | 13 | static int ins_count; 14 | WrapperDirect3DVertexBuffer9(IDirect3DVertexBuffer9* ptr, int _id); 15 | LPDIRECT3DVERTEXBUFFER9 GetVB9(); 16 | 17 | inline void SetId(int id); 18 | inline int GetId(); 19 | #ifdef GETWRAPPERDEVICE 20 | static WrapperDirect3DVertexBuffer9* GetWrapperVertexBuffer9(IDirect3DVertexBuffer9* ptr); 21 | static HashSet m_list; 22 | #endif 23 | public: 24 | /*** IUnknown methods ***/ 25 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 26 | COM_METHOD(ULONG,AddRef)(THIS); 27 | COM_METHOD(ULONG,Release)(THIS); 28 | 29 | /*** IDirect3DResource9 methods ***/ 30 | 31 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 32 | COM_METHOD(HRESULT,SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 33 | COM_METHOD(HRESULT,GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 34 | COM_METHOD(HRESULT,FreePrivateData)(THIS_ REFGUID refguid); 35 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 36 | COM_METHOD(DWORD, GetPriority)(THIS); 37 | COM_METHOD(void, PreLoad)(THIS); 38 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 39 | 40 | COM_METHOD(HRESULT,Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); 41 | COM_METHOD(HRESULT,Unlock)(THIS); 42 | COM_METHOD(HRESULT,GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc); 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexdeclaration9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | 4 | #include "wrap_direct3dvertexdeclaration9.h" 5 | 6 | int WrapperDirect3DVertexDeclaration9::ins_count = 0; 7 | HashSet WrapperDirect3DVertexDeclaration9::m_list;\ 8 | 9 | 10 | WrapperDirect3DVertexDeclaration9 * WrapperDirect3DVertexDeclaration9::GetWrapperDirect3DVertexDeclaration(IDirect3DVertexDeclaration9 * ptr){ 11 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call GetWrapperVertexDeclaration9.\n"); 12 | WrapperDirect3DVertexDeclaration9 * ret = (WrapperDirect3DVertexDeclaration9 *)(m_list.GetDataPtr(ptr)); 13 | if (ret == NULL){ 14 | ret = new WrapperDirect3DVertexDeclaration9(ptr, ins_count++); 15 | } 16 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end GetWrapperVertexDeclaration9.\n"); 17 | return ret; 18 | } 19 | 20 | 21 | int WrapperDirect3DVertexDeclaration9::getDeclarationSize(){ 22 | return sizeof(D3DVERTEXELEMENT9) * this->Count; 23 | } 24 | 25 | 26 | WrapperDirect3DVertexDeclaration9::WrapperDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9* ptr, int _id): m_vd(ptr), id(_id) { 27 | m_list.AddMember(ptr, this); 28 | } 29 | 30 | void WrapperDirect3DVertexDeclaration9::SetID(int id) { 31 | this->id = id; 32 | } 33 | 34 | int WrapperDirect3DVertexDeclaration9::GetID() { 35 | return this->id; 36 | } 37 | 38 | IDirect3DVertexDeclaration9* WrapperDirect3DVertexDeclaration9::GetVD9() { 39 | return m_vd; 40 | } 41 | 42 | /*** IUnknown methods ***/ 43 | STDMETHODIMP WrapperDirect3DVertexDeclaration9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 44 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call QueryInterface.\n"); 45 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 46 | HRESULT hr = m_vd->QueryInterface(riid, ppvObj); 47 | *ppvObj = this; 48 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end QueryInterface.\n"); 49 | return hr; 50 | } 51 | 52 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexDeclaration9::AddRef(THIS) { 53 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call AddRef.\n"); 54 | gRecoder->cmdCalled(sizeof(ULONG)); 55 | ULONG hr = m_vd->AddRef(); 56 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end AddRef.\n"); 57 | return hr; 58 | } 59 | 60 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexDeclaration9::Release(THIS) { 61 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call Release.\n"); 62 | gRecoder->cmdCalled(sizeof(ULONG)); 63 | ULONG hr = m_vd->Release(); 64 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end Release.\n"); 65 | return hr; 66 | } 67 | 68 | /*** IDirect3DVertexDeclaration9 methods ***/ 69 | STDMETHODIMP WrapperDirect3DVertexDeclaration9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 70 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call GetDevice.\n"); 71 | gRecoder->cmdCalled(sizeof(void *)); 72 | HRESULT hr = m_vd->GetDevice(ppDevice); 73 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end GetDevice.\n"); 74 | return hr; 75 | } 76 | 77 | STDMETHODIMP WrapperDirect3DVertexDeclaration9::GetDeclaration(THIS_ D3DVERTEXELEMENT9* pElement,UINT* pNumElements) { 78 | gRecoder->logTrace("[INFO]: VertexDeclaration9 call GetDeclaration.\n"); 79 | gRecoder->cmdCalled(sizeof(void *) * 2 + sizeof(D3DVERTEXELEMENT9) + sizeof(UINT)); 80 | HRESULT hr = m_vd->GetDeclaration(pElement, pNumElements); 81 | gRecoder->logTrace("[INFO]: VertexDeclaration9 end GetDeclaration.\n"); 82 | return hr; 83 | } -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexdeclaration9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DVERTEXDECLARATION9__ 2 | #define __WRAP_DIRECT3DVERTEXDECLARATION9__ 3 | 4 | 5 | class WrapperDirect3DVertexDeclaration9: public IDirect3DVertexDeclaration9 6 | { 7 | private: 8 | IDirect3DVertexDeclaration9* m_vd; 9 | int id; 10 | public: 11 | static HashSet m_list; 12 | static WrapperDirect3DVertexDeclaration9 * GetWrapperDirect3DVertexDeclaration(IDirect3DVertexDeclaration9 * ptr); 13 | int Count; 14 | int getDeclarationSize(); 15 | static int ins_count; 16 | WrapperDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9* ptr, int _id); 17 | IDirect3DVertexDeclaration9* GetVD9(); 18 | void SetID(int id); 19 | int GetID(); 20 | 21 | public: 22 | /*** IUnknown methods ***/ 23 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 24 | COM_METHOD(ULONG,AddRef)(THIS); 25 | COM_METHOD(ULONG,Release)(THIS); 26 | 27 | /*** IDirect3DVertexDeclaration9 methods ***/ 28 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 29 | COM_METHOD(HRESULT,GetDeclaration)(THIS_ D3DVERTEXELEMENT9* pElement,UINT* pNumElements); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexshader9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | 4 | #include "wrap_direct3dvertexshader9.h" 5 | 6 | 7 | int WrapperDirect3DVertexShader9::ins_count = 0; 8 | HashSet WrapperDirect3DVertexShader9::m_list; 9 | 10 | int WrapperDirect3DVertexShader9::getShaderSize(){ 11 | #ifdef TEST_VERTEX_SHADER_SIZE 12 | 13 | UINT size =0; 14 | this->m_vs->GetFunction(NULL, &size); 15 | gRecoder->logError("[INFO]: VertexShader get shader size:%d, funcCount * sizeof(DWORD) = %d.\n", size, sizeof(DWORD) * this->funcCount); 16 | 17 | #endif 18 | return sizeof(DWORD) * this->funcCount; 19 | 20 | } 21 | 22 | WrapperDirect3DVertexShader9::WrapperDirect3DVertexShader9(IDirect3DVertexShader9* ptr, int _id): m_vs(ptr), id(_id) { 23 | m_list.AddMember(ptr, this); 24 | } 25 | 26 | inline int WrapperDirect3DVertexShader9::GetID() { 27 | return this->id; 28 | } 29 | 30 | inline void WrapperDirect3DVertexShader9::SetID(int id) { 31 | this->id = id; 32 | } 33 | 34 | IDirect3DVertexShader9* WrapperDirect3DVertexShader9::GetVS9() { 35 | return m_vs; 36 | } 37 | 38 | #ifdef GETWRAPPERDEVICE 39 | WrapperDirect3DVertexShader9* WrapperDirect3DVertexShader9::GetWrapperVertexShader(IDirect3DVertexShader9* ptr) { 40 | gRecoder->logTrace("[INFO]: VertexShader9 call GetWrapperVertexShader.\n"); 41 | WrapperDirect3DVertexShader9* ret = (WrapperDirect3DVertexShader9*)( m_list.GetDataPtr(ptr) ); 42 | if(ret == NULL) { 43 | 44 | ret = new WrapperDirect3DVertexShader9(ptr, ins_count++); 45 | } 46 | gRecoder->logTrace("[INFO]: VertexShader9 end GetWrapperVertexShader.\n"); 47 | return ret; 48 | } 49 | #endif 50 | /*** IUnknown methods ***/ 51 | STDMETHODIMP WrapperDirect3DVertexShader9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { 52 | gRecoder->logTrace("[INFO]: VertexShader9 call QueryInterface.\n"); 53 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 54 | HRESULT hr = m_vs->QueryInterface(riid, ppvObj); 55 | *ppvObj = this; 56 | gRecoder->logTrace("[INFO]: VertexShader9 end QueryInterface.\n"); 57 | return hr; 58 | } 59 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexShader9::AddRef(THIS) { 60 | gRecoder->logTrace("[INFO]: VertexShader9 call AddRef.\n"); 61 | gRecoder->cmdCalled(sizeof(ULONG)); 62 | ULONG hr = m_vs->AddRef(); 63 | gRecoder->logTrace("[INFO]: VertexShader9 end AddRef.\n"); 64 | return hr; 65 | } 66 | STDMETHODIMP_(ULONG) WrapperDirect3DVertexShader9::Release(THIS) { 67 | gRecoder->logTrace("[INFO]: VertexShader9 call Release.\n"); 68 | gRecoder->cmdCalled(sizeof(ULONG)); 69 | ULONG hr = m_vs->Release(); 70 | gRecoder->logTrace("[INFO]: VertexShader9 end Release.\n"); 71 | return hr; 72 | } 73 | 74 | /*** IDirect3DVertexShader9 methods ***/ 75 | STDMETHODIMP WrapperDirect3DVertexShader9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { 76 | gRecoder->logTrace("[INFO]: VertexShader9 call GetDevice.\n"); 77 | gRecoder->cmdCalled(sizeof(void *)); 78 | HRESULT hr = m_vs->GetDevice(ppDevice); 79 | gRecoder->logTrace("[INFO]: VertexShader9 end GetDevice.\n"); 80 | return hr; 81 | } 82 | STDMETHODIMP WrapperDirect3DVertexShader9::GetFunction(THIS_ void* ptr,UINT* pSizeOfData) { 83 | gRecoder->logTrace("[INFO]: VertexShader9 call GetFunction.\n"); 84 | UINT sizeOfData = 0; 85 | HRESULT hr = m_vs->GetFunction(ptr, &sizeOfData); 86 | gRecoder->cmdCalled(sizeof(void *) * 2 + sizeOfData); 87 | gRecoder->logTrace("[INFO]: VertexShader9 end GetFunction.\n"); 88 | return hr; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvertexshader9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DVERTEXSHADER9__ 2 | #define __WRAP_DIRECT3DVERTEXSHADER9__ 3 | 4 | //#define TEST_VERTEX_SHADER_SIZE 5 | 6 | class WrapperDirect3DVertexShader9: public IDirect3DVertexShader9 7 | { 8 | private: 9 | IDirect3DVertexShader9* m_vs; 10 | int id; 11 | public: 12 | 13 | int funcCount; // stores the shader's command count 14 | int getShaderSize(); 15 | static int ins_count; 16 | WrapperDirect3DVertexShader9(IDirect3DVertexShader9* ptr, int _id); 17 | inline int GetID(); 18 | inline void SetID(int id); 19 | IDirect3DVertexShader9* GetVS9(); 20 | #ifdef GETWRAPPERDEVICE 21 | static WrapperDirect3DVertexShader9* GetWrapperVertexShader(IDirect3DVertexShader9* ptr); 22 | static HashSet m_list; 23 | #endif 24 | public: 25 | 26 | /*** IUnknown methods ***/ 27 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 28 | COM_METHOD(ULONG,AddRef)(THIS); 29 | COM_METHOD(ULONG,Release)(THIS); 30 | 31 | /*** IDirect3DVertexShader9 methods ***/ 32 | COM_METHOD(HRESULT,GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 33 | COM_METHOD(HRESULT,GetFunction)(THIS_ void*,UINT* pSizeOfData); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvolume9.cpp: -------------------------------------------------------------------------------- 1 | #include "hook_common.h" 2 | #include "recorder.h" 3 | 4 | #include "wrap_direct3dvolume9.h" 5 | #include "wrap_direct3ddevice9.h" 6 | int WrapperDirect3DVolume9::ins_count = 0; 7 | HashSet WrapperDirect3DVolume9::m_list; 8 | 9 | int WrapperDirect3DVolume9::getVolumeSize(){ 10 | 11 | D3DVOLUME_DESC vdesc; 12 | this->m_d3dvolume->GetDesc(&vdesc); 13 | return vdesc.Width * vdesc.Height * vdesc.Depth * 4; 14 | 15 | } 16 | 17 | WrapperDirect3DVolume9::WrapperDirect3DVolume9(IDirect3DVolume9 *ptr, int _id):m_d3dvolume(ptr),id(_id){ 18 | m_list.AddMember(ptr, this); 19 | } 20 | 21 | inline int WrapperDirect3DVolume9::GetID(){ 22 | return this->id; 23 | } 24 | inline void WrapperDirect3DVolume9::SetID(int id){ 25 | this->id =id; 26 | } 27 | #ifdef GETWRAPPERDEVICE 28 | WrapperDirect3DVolume9 * WrapperDirect3DVolume9::GetWrapperDirect3DVolume9(IDirect3DVolume9 *ptr){ 29 | gRecoder->logTrace("[INFO]: Volume9 call GetWrapperDirect3DVolume9.\n"); 30 | WrapperDirect3DVolume9 * ret = NULL; 31 | ret = (WrapperDirect3DVolume9 *)m_list.GetDataPtr(ptr); 32 | if(ret == NULL){ 33 | } 34 | gRecoder->logTrace("[INFO]: Volume9 end GetWrapperDirect3DVolume9.\n"); 35 | return ret; 36 | } 37 | #endif 38 | IDirect3DVolume9 * WrapperDirect3DVolume9::GetIDirect3DVolume9(){ 39 | return this->m_d3dvolume; 40 | } 41 | 42 | /********************** IUnknown Methods *************/ 43 | STDMETHODIMP WrapperDirect3DVolume9::QueryInterface(THIS_ REFIID riid, void **ppvObj){ 44 | gRecoder->logTrace("[INFO]: Volume9 call QueryInterface.\n"); 45 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 46 | HRESULT hr =this->m_d3dvolume->QueryInterface(riid, ppvObj); 47 | *ppvObj = this; 48 | gRecoder->logTrace("[INFO]: Volume9 end QueryInterface.\n"); 49 | return hr; 50 | } 51 | STDMETHODIMP_(ULONG) WrapperDirect3DVolume9::AddRef(THIS){ 52 | gRecoder->logTrace("[INFO]: Volume9 call AddRef.\n"); 53 | gRecoder->cmdCalled(sizeof(ULONG)); 54 | ULONG hr = this->m_d3dvolume->AddRef(); 55 | gRecoder->logTrace("[INFO]: Volume9 end AddRef.\n"); 56 | return hr; 57 | } 58 | 59 | STDMETHODIMP_(ULONG) WrapperDirect3DVolume9::Release(THIS){ 60 | gRecoder->logTrace("[INFO]: Volume9 call Release.\n"); 61 | gRecoder->cmdCalled(sizeof(ULONG)); 62 | ULONG hr = this->m_d3dvolume->Release(); 63 | gRecoder->logTrace("[INFO]: Volume9 end Release.\n"); 64 | return hr; 65 | } 66 | 67 | /*************** Methods *************************/ 68 | STDMETHODIMP WrapperDirect3DVolume9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) 69 | { 70 | gRecoder->logTrace("[INFO]: Volume9 call GetDevice.\n"); 71 | gRecoder->cmdCalled(sizeof(void *)); 72 | IDirect3DDevice9* base_device = NULL; 73 | HRESULT hr = this->m_d3dvolume->GetDevice(&base_device); 74 | #ifndef GETWRAPPERDEVICE 75 | if (typeid(*base_device) == typeid(IDirect3DDevice9)){ 76 | *ppDevice = base_device; 77 | } 78 | else if (typeid(*base_device) == typeid(WrapperDirect3DDevice9)){ 79 | *ppDevice = ((WrapperDirect3DDevice9*)base_device)->GetIDirect3DDevice9(); 80 | } 81 | else{ 82 | // error type 83 | *ppDevice = base_device; 84 | } 85 | #else 86 | #if 1 87 | *ppDevice = dynamic_cast(WrapperDirect3DDevice9::GetWrapperDevice9(base_device)); 88 | #else 89 | *ppDevice = ((WrapperDirect3DDevice9*)base_device)->GetIDirect3DDevice9(); 90 | #endif 91 | gRecoder->cmdCalled(sizeof(void *)); 92 | #endif 93 | gRecoder->logTrace("[INFO]: Volume9 end GetDevice.\n"); 94 | return hr; 95 | } 96 | STDMETHODIMP WrapperDirect3DVolume9::SetPrivateData(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) 97 | { 98 | gRecoder->logTrace("[INFO]: Volume9 call SetPrivateData.\n"); 99 | gRecoder->cmdCalled(sizeof(refguid) + sizeof(void *) + sizeof(DWORD) * 2 + SizeOfData); 100 | HRESULT hr =this->m_d3dvolume->SetPrivateData(refguid, pData, SizeOfData, Flags); 101 | gRecoder->logTrace("[INFO]: Volume9 end SetPrivateData.\n"); 102 | return hr; 103 | } 104 | STDMETHODIMP WrapperDirect3DVolume9::GetPrivateData(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) 105 | { 106 | gRecoder->logTrace("[INFO]: Volume9 call GetPrivateData.\n"); 107 | DWORD sizeOfData = 0; 108 | HRESULT hr =this->m_d3dvolume->GetPrivateData(refguid, pData, &sizeOfData); 109 | *pSizeOfData = sizeOfData; 110 | gRecoder->cmdCalled(sizeof(refguid) + sizeof(void *) * 2 + sizeof(DWORD) + sizeOfData); 111 | gRecoder->logTrace("[INFO]: Volume9 end GetPrivateData.\n"); 112 | return hr; 113 | } 114 | STDMETHODIMP WrapperDirect3DVolume9::FreePrivateData(THIS_ REFGUID refguid) 115 | { 116 | gRecoder->logTrace("[INFO]: Volume9 call FreePrivateData.\n"); 117 | gRecoder->cmdCalled(sizeof(refguid)); 118 | 119 | HRESULT hr =this->m_d3dvolume->FreePrivateData(refguid); 120 | gRecoder->logTrace("[INFO]: Volume9 end FreePrivateData.\n"); 121 | return hr; 122 | } 123 | STDMETHODIMP WrapperDirect3DVolume9::GetContainer(THIS_ REFIID riid,void** ppContainer) 124 | { 125 | gRecoder->logTrace("[INFO]: Volume9 call GetContainer.\n"); 126 | gRecoder->cmdCalled(sizeof(riid) + sizeof(void *)); 127 | HRESULT hr =this->m_d3dvolume->GetContainer(riid, ppContainer); 128 | gRecoder->logTrace("[INFO]: Volume9 end GetContainer.\n"); 129 | return hr; 130 | } 131 | STDMETHODIMP WrapperDirect3DVolume9::GetDesc(THIS_ D3DVOLUME_DESC *pDesc) 132 | { 133 | gRecoder->logTrace("[INFO]: Volume9 call GetDesc.\n"); 134 | gRecoder->cmdCalled(sizeof(void *) + sizeof(D3DVOLUME_DESC)); 135 | HRESULT hr =this->m_d3dvolume->GetDesc(pDesc); 136 | gRecoder->logTrace("[INFO]: Volume9 end GetDesc.\n"); 137 | return hr; 138 | } 139 | STDMETHODIMP WrapperDirect3DVolume9::LockBox(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) 140 | { 141 | gRecoder->logTrace("[INFO]: Volume9 call LockBox.\n"); 142 | gRecoder->cmdCalled(sizeof(D3DLOCKED_BOX) + sizeof(D3DBOX) + sizeof(DWORD) + sizeof(void *) * 2); 143 | HRESULT hr =this->m_d3dvolume->LockBox(pLockedVolume, pBox, Flags); 144 | gRecoder->logTrace("[INFO]: Volume9 end LockBox.\n"); 145 | return hr; 146 | } 147 | STDMETHODIMP WrapperDirect3DVolume9::UnlockBox(THIS) 148 | { 149 | gRecoder->logTrace("[INFO]: Volume9 call UnlockBox.\n"); 150 | gRecoder->cmdCalled(0); 151 | HRESULT hr =this->m_d3dvolume->UnlockBox(); 152 | gRecoder->logTrace("[INFO]: Volume9 end UnlockBox.\n"); 153 | return hr; 154 | } 155 | -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvolume9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DVOLUME9__ 2 | #define __WRAP_DIRECT3DVOLUME9__ 3 | 4 | class WrapperDirect3DVolume9 : public IDirect3DVolume9 5 | { 6 | private: 7 | IDirect3DVolume9 * m_d3dvolume; 8 | int id; 9 | 10 | public: 11 | static int ins_count; 12 | int getVolumeSize(); 13 | 14 | WrapperDirect3DVolume9(IDirect3DVolume9 *ptr, int _id); 15 | inline int GetID(); 16 | inline void SetID(int id); 17 | #ifdef GETWRAPPERDEVICE 18 | static WrapperDirect3DVolume9* GetWrapperDirect3DVolume9(IDirect3DVolume9 *ptr); 19 | static HashSet m_list; 20 | #endif 21 | IDirect3DVolume9 * GetIDirect3DVolume9(); 22 | 23 | /*** IUnknown methods ***/ 24 | COM_METHOD(HRESULT, QueryInterface)(THIS_ REFIID riid, void** ppvObj); 25 | COM_METHOD(ULONG,AddRef)(THIS); 26 | COM_METHOD(ULONG,Release)(THIS); 27 | 28 | /*** IDirect3DVolume9 methods ***/ 29 | COM_METHOD(HRESULT, GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 30 | COM_METHOD(HRESULT, SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 31 | COM_METHOD(HRESULT, GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 32 | COM_METHOD(HRESULT, FreePrivateData)(THIS_ REFGUID refguid); 33 | COM_METHOD(HRESULT, GetContainer)(THIS_ REFIID riid,void** ppContainer); 34 | COM_METHOD(HRESULT, GetDesc)(THIS_ D3DVOLUME_DESC *pDesc); 35 | COM_METHOD(HRESULT, LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); 36 | COM_METHOD(HRESULT, UnlockBox)(THIS); 37 | 38 | }; 39 | 40 | #endif -------------------------------------------------------------------------------- /HookD3DAll/wrap_direct3dvolumetexture9.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAP_DIRECT3DVOLUMETEXTURE9__ 2 | #define __WRAP_DIRECT3DVOLUMETEXTURE9__ 3 | 4 | class WrapperDirect3DVolumeTexture9: public IDirect3DVolumeTexture9 5 | { 6 | private: 7 | IDirect3DVolumeTexture9* m_tex; 8 | int id; 9 | 10 | public: 11 | int width, height, depth, level; 12 | D3DFORMAT format; 13 | 14 | inline int getTextureSize(); // get the size of the whole texture 15 | 16 | static int ins_count; 17 | WrapperDirect3DVolumeTexture9(IDirect3DVolumeTexture9* ptr, int _id); 18 | inline int GetID(); 19 | inline void SetID(int id); 20 | IDirect3DVolumeTexture9* GetVolumeTex9(); 21 | 22 | #ifdef GETWRAPPERDEVICE 23 | static WrapperDirect3DVolumeTexture9* GetWrapperTexture9(IDirect3DVolumeTexture9* ptr); 24 | static HashSet m_list; 25 | #endif 26 | 27 | /*** IUnknown methods ***/ 28 | COM_METHOD(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObj); 29 | COM_METHOD(ULONG,AddRef)(THIS); 30 | COM_METHOD(ULONG,Release)(THIS); 31 | 32 | COM_METHOD(HRESULT, GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 33 | COM_METHOD(HRESULT, SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); 34 | COM_METHOD(HRESULT, GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData); 35 | COM_METHOD(HRESULT, FreePrivateData)(THIS_ REFGUID refguid); 36 | COM_METHOD(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 37 | COM_METHOD(DWORD, GetPriority)(THIS); 38 | COM_METHOD(void, PreLoad)(THIS); 39 | COM_METHOD(D3DRESOURCETYPE, GetType)(THIS); 40 | COM_METHOD(DWORD, SetLOD)(THIS_ DWORD LODNew); 41 | COM_METHOD(DWORD, GetLOD)(THIS); 42 | COM_METHOD(DWORD, GetLevelCount)(THIS); 43 | COM_METHOD(HRESULT, SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType); 44 | COM_METHOD(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS); 45 | COM_METHOD(void, GenerateMipSubLevels)(THIS); 46 | COM_METHOD(HRESULT, GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc); 47 | COM_METHOD(HRESULT, GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume9** ppVolumeLevel); 48 | COM_METHOD(HRESULT, LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); 49 | COM_METHOD(HRESULT, UnlockBox)(THIS_ UINT Level); 50 | COM_METHOD(HRESULT, AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox); 51 | }; 52 | 53 | #endif -------------------------------------------------------------------------------- /NetChart/chartdir.lic: -------------------------------------------------------------------------------- 1 | SXZVFNRN9MZ9L8LGA0E2B1BB -------------------------------------------------------------------------------- /NetChart/netchartdir_cp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/NetChart/netchartdir_cp.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AutoProfilingToolTrunk 2 | ====================== 3 | 4 | Profiling tool for analysising the games, get all the characteristic by hook d3d. 5 | 6 | To compile this tool, you should use Visual Stdio 2010, the form is in C# and the d3d hook part is c++. 7 | -------------------------------------------------------------------------------- /Release/AutoProfilingTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/AutoProfilingTool.exe -------------------------------------------------------------------------------- /Release/AutoProfilingTool.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/AutoProfilingTool.pdb -------------------------------------------------------------------------------- /Release/HookD3D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3D.dll -------------------------------------------------------------------------------- /Release/HookD3D.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3D.exp -------------------------------------------------------------------------------- /Release/HookD3D.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3D.lib -------------------------------------------------------------------------------- /Release/HookD3D.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3D.pdb -------------------------------------------------------------------------------- /Release/HookD3DAll.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3DAll.dll -------------------------------------------------------------------------------- /Release/HookD3DAll.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3DAll.exp -------------------------------------------------------------------------------- /Release/HookD3DAll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3DAll.lib -------------------------------------------------------------------------------- /Release/HookD3DAll.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/HookD3DAll.pdb -------------------------------------------------------------------------------- /Release/Utility.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Release/Utility.lib -------------------------------------------------------------------------------- /Utility/CpuWatch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/CpuWatch.cpp -------------------------------------------------------------------------------- /Utility/CpuWatch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/CpuWatch.h -------------------------------------------------------------------------------- /Utility/GpuWatch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/GpuWatch.cpp -------------------------------------------------------------------------------- /Utility/GpuWatch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/GpuWatch.h -------------------------------------------------------------------------------- /Utility/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:Utility 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 Utility 库项目。 6 | 7 | 没有为此项目创建源文件。 8 | 9 | 10 | Utility.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件, 12 | 其中包含生成该文件的 Visual C++ 13 | 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 14 | 15 | Utility.vcxproj.filters 16 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。 17 | 它包含有关项目文件与筛选器之间的关联信息。 在 IDE 18 | 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。 19 | 例如,“.cpp”文件与“源文件”筛选器关联。 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | 其他注释: 23 | 24 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | -------------------------------------------------------------------------------- /Utility/Utility.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {D16EB61C-DA30-4174-BC6F-45324E72EAFB} 15 | Win32Proj 16 | Utility 17 | 18 | 19 | 20 | StaticLibrary 21 | true 22 | MultiByte 23 | 24 | 25 | StaticLibrary 26 | false 27 | true 28 | MultiByte 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Level3 46 | Disabled 47 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 48 | 49 | 50 | Windows 51 | true 52 | 53 | 54 | 55 | 56 | Level3 57 | 58 | 59 | MaxSpeed 60 | true 61 | true 62 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 63 | 64 | 65 | Windows 66 | true 67 | true 68 | true 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Utility/Utility.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | 源文件 49 | 50 | 51 | 源文件 52 | 53 | 54 | 源文件 55 | 56 | 57 | -------------------------------------------------------------------------------- /Utility/Utility.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Utility/adl_sdk/adl_sdk.h: -------------------------------------------------------------------------------- 1 | /// 2 | /// Copyright (c) 2008 - 2013 Advanced Micro Devices, Inc. 3 | 4 | /// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 5 | /// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 6 | /// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 7 | 8 | /// \file adl_sdk.h 9 | /// \brief Contains the definition of the Memory Allocation Callback.\n Included in ADL SDK 10 | /// 11 | /// \n\n 12 | /// This file contains the definition of the Memory Allocation Callback.\n 13 | /// It also includes definitions of the respective structures and constants.\n 14 | /// This is the only header file to be included in a C/C++ project using ADL 15 | 16 | #ifndef ADL_SDK_H_ 17 | #define ADL_SDK_H_ 18 | 19 | #include "adl_structures.h" 20 | 21 | #if defined (LINUX) 22 | #define __stdcall 23 | #endif /* (LINUX) */ 24 | 25 | /// Memory Allocation Call back 26 | typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int ); 27 | 28 | 29 | #endif /* ADL_SDK_H_ */ 30 | -------------------------------------------------------------------------------- /Utility/hash.cpp: -------------------------------------------------------------------------------- 1 | #include "utility.h" 2 | 3 | namespace CacheMgr { 4 | 5 | UINT hash(const char* data, size_t n, UINT seed) { 6 | const UINT m = 0x6a4a793; 7 | const UINT r = 24; 8 | const char* limit = data + n; 9 | UINT h = seed ^ (n * m); 10 | 11 | while(data + 4 < limit) { 12 | UINT w = *((UINT*)data); 13 | data += 4; 14 | h += w; 15 | h *= m; 16 | h ^= (h >> 16); 17 | } 18 | 19 | switch(limit - data) { 20 | case 3: 21 | h += data[2] << 16; 22 | //fall through 23 | case 2: 24 | h += data[1] << 8; 25 | //fall through 26 | case 1: 27 | h += data[0]; 28 | h *= m; 29 | h ^= (h >> r); 30 | break; 31 | } 32 | return h; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /Utility/hash_set.cpp: -------------------------------------------------------------------------------- 1 | #include "utility.h" 2 | #include "hash_set.h" 3 | 4 | HashSet::HashSet() { 5 | for(int i=0; iid == id) { 14 | return pThis->pData; 15 | } 16 | pThis = pThis->pNext; 17 | } 18 | return NULL; 19 | } 20 | 21 | PVOID HashSet::GetDataPtr(PVOID pKey) { 22 | HashLinkedList* pThis = m_pHead[GetHash(pKey)]; 23 | while(pThis) 24 | { 25 | if(pThis->pKey == pKey) 26 | { 27 | return pThis->pData; 28 | } 29 | pThis = pThis->pNext; 30 | } 31 | return NULL; 32 | } 33 | 34 | bool HashSet::AddMember(int id, PVOID pData) { 35 | UINT hash = GetHash(id); 36 | HashLinkedList* pThis = new HashLinkedList; 37 | if(pThis == NULL) { 38 | return false; 39 | } 40 | pThis->pData = pData; 41 | pThis->id = id; 42 | pThis->pNext = m_pHead[hash]; 43 | m_pHead[hash] = pThis; 44 | 45 | return true; 46 | } 47 | 48 | bool HashSet::AddMember(PVOID pKey, PVOID pData) 49 | { 50 | UINT Hash = GetHash(pKey); 51 | HashLinkedList* pThis = new HashLinkedList; 52 | if(pThis == NULL) 53 | { 54 | return false; 55 | } 56 | 57 | pThis->pNext = m_pHead[Hash]; 58 | pThis->pKey = pKey; 59 | pThis->pData = pData; 60 | m_pHead[Hash] = pThis; 61 | return true; 62 | } 63 | 64 | bool HashSet::DeleteMember(int id) { 65 | UINT hash = GetHash(id); 66 | HashLinkedList* pThis = m_pHead[hash]; 67 | HashLinkedList* pLast = 0L; 68 | 69 | if(m_pHead[hash]->id == id) { 70 | m_pHead[hash] = pThis->pNext; 71 | delete pThis; 72 | return true; 73 | } 74 | else { 75 | pLast = pThis; 76 | pThis = pThis->pNext; 77 | } 78 | 79 | while(pThis) { 80 | if(pThis->id == id) { 81 | pLast->pNext = pThis->pNext; 82 | delete pThis; 83 | return true; 84 | } 85 | pLast = pThis; 86 | pThis = pThis->pNext; 87 | } 88 | return false; 89 | } 90 | 91 | 92 | bool HashSet::DeleteMember(PVOID pKey) 93 | { 94 | UINT Hash = GetHash(pKey); 95 | HashLinkedList* pThis = m_pHead[Hash]; 96 | HashLinkedList* pLast = 0L; 97 | 98 | if( m_pHead[Hash]->pKey == pKey ) 99 | { 100 | m_pHead[Hash] = pThis->pNext; 101 | delete pThis; 102 | return true; 103 | } 104 | else 105 | { 106 | pLast = pThis; 107 | pThis = pThis->pNext; 108 | } 109 | 110 | while( pThis ) 111 | { 112 | if( pThis->pKey == pKey ) 113 | { 114 | pLast->pNext = pThis->pNext; 115 | delete pThis; 116 | return true; 117 | } 118 | pLast = pThis; 119 | pThis = pThis->pNext; 120 | } 121 | return false; 122 | } 123 | 124 | 125 | -------------------------------------------------------------------------------- /Utility/hash_set.h: -------------------------------------------------------------------------------- 1 | #ifndef __HASH_SET__ 2 | #define __HASH_SET__ 3 | 4 | #include "utility.h" 5 | 6 | #define HASHSETSIZE 128 7 | #define HASHSETMASK 127 8 | 9 | struct HashLinkedList { 10 | int id; 11 | PVOID pKey; 12 | PVOID pData; 13 | HashLinkedList* pNext; 14 | }; 15 | 16 | class HashSet { 17 | public: 18 | HashSet(); 19 | PVOID GetDataPtr(int id); 20 | PVOID GetDataPtr(PVOID pKey); 21 | bool AddMember(int id, PVOID pData); 22 | bool AddMember(PVOID pKey, PVOID pData); 23 | bool DeleteMember(PVOID pKey); 24 | bool DeleteMember(int id); 25 | __forceinline UINT GetHash(PVOID pKey) { 26 | DWORD Key = (DWORD)pKey; 27 | return (( Key >> 3 ^ Key >> 7 ^ Key >> 11 ^ Key >> 17 ) & HASHSETMASK); 28 | } 29 | __forceinline UINT GetHash(int id) { 30 | return (( id >> 3 ^ id >> 7 ^ id >> 11 ^ id >> 17 ) & HASHSETMASK); 31 | } 32 | private: 33 | HashLinkedList* m_pHead[HASHSETSIZE]; 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /Utility/log.cpp: -------------------------------------------------------------------------------- 1 | #include "log.h" 2 | #include 3 | #include 4 | 5 | #define MAX_CHAR 512 6 | 7 | Log::Log(const char *filename){ 8 | init(filename); 9 | 10 | } 11 | Log::~Log(){ 12 | close(); 13 | 14 | } 15 | 16 | 17 | // this is for the log component 18 | void Log::init(const char * filename){ 19 | strcpy(fname_, filename); 20 | fs_.open(fname_, ios::out); 21 | 22 | log("Log::init(), filename = %s.\n", fname_); 23 | 24 | } 25 | 26 | void Log::close(){ 27 | log("Log::close() called.\n"); 28 | fs_.close(); 29 | } 30 | 31 | void Log::log(const char * text, ...){ 32 | //if (!is_init_) init("fuck.log"); 33 | char buffer[MAX_CHAR]; 34 | char timestr[30]; 35 | 36 | tv = time(0); 37 | tm* ltime = localtime(&tv); 38 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 39 | 40 | va_list ap; 41 | va_start(ap, text); 42 | vsprintf(buffer, text, ap); 43 | va_end(ap); 44 | DWORD thread = GetCurrentThreadId(); 45 | fs_ << timestr << ": " << " [tid: " << thread << "]" << buffer; 46 | fs_.flush(); 47 | } 48 | 49 | void Log::slog(const char* text, ...) { 50 | char buffer[MAX_CHAR]; 51 | 52 | char timestr[30]; 53 | 54 | tv = time(0); 55 | tm* ltime = localtime(&tv); 56 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 57 | 58 | va_list ap; 59 | va_start(ap, text); 60 | vsprintf(buffer, text, ap); 61 | va_end(ap); 62 | DWORD thread = GetCurrentThreadId(); 63 | fs_ << timestr << ": " << " [tid: " << thread << "]" << buffer; 64 | fs_.flush(); 65 | } 66 | 67 | void Log::logscreen(const char * text, ...){ 68 | char buffer[MAX_CHAR]; 69 | char timestr[30]; 70 | 71 | tv = time(0); 72 | tm * ltime = localtime(&tv); 73 | strftime(timestr, sizeof(timestr), "%H:%M:%S", ltime); 74 | 75 | va_list ap; 76 | va_start(ap, text); 77 | vsprintf(buffer, text, ap); 78 | va_end(ap); 79 | 80 | cerr << timestr << ": " << buffer; 81 | cerr.flush(); 82 | } -------------------------------------------------------------------------------- /Utility/log.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOG_H__ 2 | #define __LOG_H__ 3 | // this for the log system for the project 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | 13 | class Log { 14 | time_t tv; 15 | public: 16 | void init(const char* fname); 17 | void log(const char* text, ...); 18 | void slog(const char* text, ...); 19 | void logscreen(const char * text, ...); 20 | void close(); 21 | 22 | Log(const char * filename); 23 | ~Log(); 24 | 25 | private: 26 | char fname_[100]; 27 | ofstream fs_; 28 | }; 29 | 30 | #endif -------------------------------------------------------------------------------- /Utility/nvapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/nvapi.lib -------------------------------------------------------------------------------- /Utility/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/stdafx.h -------------------------------------------------------------------------------- /Utility/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/targetver.h -------------------------------------------------------------------------------- /Utility/utility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanzw/AutoProfilingToolTrunk/92ac4d71eae5aa28d815a3bedb947a945b35991a/Utility/utility.h --------------------------------------------------------------------------------