Skip to content

Commit 1913022

Browse files
committed
Initial commit
1 parent 58d93b0 commit 1913022

28 files changed

+1444
-0
lines changed

Captain Hook.sln

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31205.134
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Captain Hook", "Captain Hook\Captain Hook.vcxproj", "{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841} = {DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}
9+
EndProjectSection
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Smee", "Smee\Smee.vcxproj", "{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}"
12+
EndProject
13+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DetoursDll", "DetoursDll\DetoursDll.vcxproj", "{D2A84A08-792D-43E4-B907-642A276F9A3B}"
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|x64 = Release|x64
20+
Release|x86 = Release|x86
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Debug|x64.ActiveCfg = Debug|x64
24+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Debug|x64.Build.0 = Debug|x64
25+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Debug|x86.ActiveCfg = Debug|Win32
26+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Debug|x86.Build.0 = Debug|Win32
27+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Release|x64.ActiveCfg = Release|x64
28+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Release|x64.Build.0 = Release|x64
29+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Release|x86.ActiveCfg = Release|Win32
30+
{845E10A0-8B82-4E34-9B37-DC6F3FF02B4E}.Release|x86.Build.0 = Release|Win32
31+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Debug|x64.ActiveCfg = Debug|x64
32+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Debug|x64.Build.0 = Debug|x64
33+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Debug|x86.ActiveCfg = Debug|Win32
34+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Debug|x86.Build.0 = Debug|Win32
35+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Release|x64.ActiveCfg = Release|x64
36+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Release|x64.Build.0 = Release|x64
37+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Release|x86.ActiveCfg = Release|Win32
38+
{DA6FE44A-10D6-435E-A1EE-8CE8E9D5B841}.Release|x86.Build.0 = Release|Win32
39+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Debug|x64.ActiveCfg = Debug|x64
40+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Debug|x64.Build.0 = Debug|x64
41+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Debug|x86.ActiveCfg = Debug|Win32
42+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Debug|x86.Build.0 = Debug|Win32
43+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Release|x64.ActiveCfg = Release|x64
44+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Release|x64.Build.0 = Release|x64
45+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Release|x86.ActiveCfg = Release|Win32
46+
{D2A84A08-792D-43E4-B907-642A276F9A3B}.Release|x86.Build.0 = Release|Win32
47+
EndGlobalSection
48+
GlobalSection(SolutionProperties) = preSolution
49+
HideSolutionNode = FALSE
50+
EndGlobalSection
51+
GlobalSection(ExtensibilityGlobals) = postSolution
52+
SolutionGuid = {54061084-D497-4FCD-90C5-5E92B33F55A5}
53+
EndGlobalSection
54+
EndGlobal

Captain Hook/Captain Hook.cpp

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#include <iostream>
2+
#include <windows.h>
3+
#include <detours.h>
4+
#include <string>
5+
#include <Atlconv.h>
6+
#include <string>
7+
#include <stringapiset.h>
8+
#include <commctrl.h>
9+
#pragma warning(push)
10+
#if _MSC_VER > 1400
11+
#pragma warning(disable:6102 6103) // /analyze warnings
12+
#endif
13+
#include <strsafe.h>
14+
#pragma warning(pop)
15+
16+
17+
std::wstring ConvertStringToWstring(const std::string& str) { // https://stackoverflow.com/a/44777607
18+
if (str.empty()) {
19+
return std::wstring();
20+
}
21+
int num_chars = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str.c_str(), str.length(), NULL, 0);
22+
std::wstring wstrTo;
23+
if (num_chars) {
24+
wstrTo.resize(num_chars);
25+
if (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str.c_str(), str.length(), &wstrTo[0], num_chars)) {
26+
return wstrTo;
27+
}
28+
}
29+
return std::wstring();
30+
}
31+
32+
std::string GetCurrentDirectory() {
33+
char buffer[MAX_PATH];
34+
GetModuleFileNameA(NULL, buffer, MAX_PATH);
35+
std::string::size_type pos = std::string(buffer).find_last_of("\\/");
36+
37+
return std::string(buffer).substr(0, pos);
38+
}
39+
40+
int CDECL main(int argc, char* argv[])
41+
{
42+
if (argc == 0)
43+
{
44+
std::cout << "Usage: Captain Hook.exe [executable]" << std::endl;
45+
return 0;
46+
}
47+
48+
USES_CONVERSION;
49+
USES_CONVERSION_EX;
50+
51+
52+
STARTUPINFOW si;
53+
PROCESS_INFORMATION pi;
54+
55+
ZeroMemory(&si, sizeof(si));
56+
ZeroMemory(&pi, sizeof(pi));
57+
si.cb = sizeof(si);
58+
59+
std::wstring arguments = L"";
60+
for (int i = 1; i < argc; i++) {
61+
arguments.append(ConvertStringToWstring(argv[i]));
62+
arguments.append(L" ");
63+
}
64+
65+
66+
#ifdef _WIN64
67+
std::string dllPath = GetCurrentDirectory() + "\\Smeex64.dll";
68+
#else
69+
std::string dllPath = GetCurrentDirectory() + "\\Smee.dll";
70+
#endif
71+
72+
73+
BOOL status = DetourCreateProcessWithDllExW(NULL, // lpApplicationName
74+
const_cast<LPWSTR>(arguments.c_str()), // lpCommandLine
75+
NULL, //lpProcessAttributes
76+
NULL, //lpThreadAttributes
77+
TRUE, //bInheritHandles
78+
CREATE_DEFAULT_ERROR_MODE, //dwCreationFlags
79+
NULL, //lpEnvironment
80+
NULL, //lpCurrentDirectory
81+
&si, //lpStartupInfo
82+
&pi, //lpProcessInformation
83+
dllPath.c_str(), //lpDllName
84+
NULL); // pfCreateProcessW
85+
86+
87+
88+
if (status) {
89+
OutputDebugString(L"Process started successfully\r\n");
90+
std::cout << "Process started successfully!" << std::endl;
91+
std::cout << "Press enter to close...";
92+
93+
std::cin.get();
94+
} else {
95+
OutputDebugString(L"Process errored!\r\n");
96+
std::cout << "Process errored!\r\nCommand line: ";
97+
std::wcout << arguments << std::endl;
98+
std::cout << "Press enter to close...";
99+
100+
std::cin.get();
101+
return 1;
102+
103+
}
104+
105+
return 0;
106+
107+
}
108+

Captain Hook/Captain Hook.rc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Microsoft Visual C++ generated resource script.
2+
//
3+
4+
#include "resource.h"
5+
6+
#define APSTUDIO_READONLY_SYMBOLS
7+
/////////////////////////////////////////////////////////////////////////////
8+
//
9+
// Generated from the TEXTINCLUDE 2 resource.
10+
//
11+
#include "winres.h"
12+
13+
/////////////////////////////////////////////////////////////////////////////
14+
#undef APSTUDIO_READONLY_SYMBOLS
15+
16+
/////////////////////////////////////////////////////////////////////////////
17+
// English (United States) resources
18+
19+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20+
LANGUAGE 9, 1
21+
22+
#ifdef APSTUDIO_INVOKED
23+
/////////////////////////////////////////////////////////////////////////////
24+
//
25+
// TEXTINCLUDE
26+
//
27+
28+
1 TEXTINCLUDE
29+
BEGIN
30+
"resource.h\0"
31+
END
32+
33+
2 TEXTINCLUDE
34+
BEGIN
35+
"#include ""winres.h""\r\n"
36+
"\0"
37+
END
38+
39+
3 TEXTINCLUDE
40+
BEGIN
41+
"\r\n"
42+
"\0"
43+
END
44+
45+
#endif // APSTUDIO_INVOKED
46+
47+
#endif // English (United States) resources
48+
/////////////////////////////////////////////////////////////////////////////
49+
50+
51+
52+
#ifndef APSTUDIO_INVOKED
53+
/////////////////////////////////////////////////////////////////////////////
54+
//
55+
// Generated from the TEXTINCLUDE 3 resource.
56+
//
57+
58+
59+
/////////////////////////////////////////////////////////////////////////////
60+
#endif // not APSTUDIO_INVOKED
61+
62+
63+
MAINICON ICON "captain hook.ico"

Captain Hook/Captain Hook.vcxproj

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{845e10a0-8b82-4e34-9b37-dc6f3ff02b4e}</ProjectGuid>
25+
<RootNamespace>CaptainHook</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v142</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v142</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v142</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v142</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
</PropertyGroup>
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
77+
<LinkIncremental>false</LinkIncremental>
78+
</PropertyGroup>
79+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80+
<LinkIncremental>true</LinkIncremental>
81+
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
83+
<LinkIncremental>false</LinkIncremental>
84+
</PropertyGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<SDLCheck>true</SDLCheck>
89+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
90+
<ConformanceMode>true</ConformanceMode>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Console</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
<OutputFile>$(OutDir)$(TargetName)$(PlatformShortName)$(TargetExt)</OutputFile>
96+
</Link>
97+
</ItemDefinitionGroup>
98+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
99+
<ClCompile>
100+
<WarningLevel>Level3</WarningLevel>
101+
<FunctionLevelLinking>true</FunctionLevelLinking>
102+
<IntrinsicFunctions>true</IntrinsicFunctions>
103+
<SDLCheck>true</SDLCheck>
104+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;CINTERFACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105+
<ConformanceMode>true</ConformanceMode>
106+
</ClCompile>
107+
<Link>
108+
<SubSystem>Console</SubSystem>
109+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
110+
<OptimizeReferences>true</OptimizeReferences>
111+
<GenerateDebugInformation>true</GenerateDebugInformation>
112+
</Link>
113+
</ItemDefinitionGroup>
114+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
115+
<ClCompile>
116+
<WarningLevel>Level3</WarningLevel>
117+
<SDLCheck>true</SDLCheck>
118+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119+
<ConformanceMode>true</ConformanceMode>
120+
</ClCompile>
121+
<Link>
122+
<SubSystem>Console</SubSystem>
123+
<GenerateDebugInformation>true</GenerateDebugInformation>
124+
<OutputFile>$(OutDir)$(TargetName)$(PlatformShortName)$(TargetExt)</OutputFile>
125+
</Link>
126+
</ItemDefinitionGroup>
127+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
128+
<ClCompile>
129+
<WarningLevel>Level3</WarningLevel>
130+
<FunctionLevelLinking>true</FunctionLevelLinking>
131+
<IntrinsicFunctions>true</IntrinsicFunctions>
132+
<SDLCheck>true</SDLCheck>
133+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
134+
<ConformanceMode>true</ConformanceMode>
135+
</ClCompile>
136+
<Link>
137+
<SubSystem>Console</SubSystem>
138+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
139+
<OptimizeReferences>true</OptimizeReferences>
140+
<GenerateDebugInformation>true</GenerateDebugInformation>
141+
</Link>
142+
</ItemDefinitionGroup>
143+
<ItemGroup>
144+
<ClCompile Include="Captain Hook.cpp" />
145+
</ItemGroup>
146+
<ItemGroup>
147+
<None Include="packages.config" />
148+
</ItemGroup>
149+
<ItemGroup>
150+
<ClInclude Include="resource.h" />
151+
</ItemGroup>
152+
<ItemGroup>
153+
<ResourceCompile Include="Captain Hook.rc" />
154+
</ItemGroup>
155+
<ItemGroup>
156+
<Image Include="..\..\..\..\Pictures\heh\rand\captain hook.ico" />
157+
<Image Include="..\..\..\..\Pictures\heh\rand\captain hook.png" />
158+
</ItemGroup>
159+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
160+
<ImportGroup Label="ExtensionTargets">
161+
<Import Project="..\packages\Detours.4.0.1\build\native\Detours.targets" Condition="Exists('..\packages\Detours.4.0.1\build\native\Detours.targets')" />
162+
</ImportGroup>
163+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
164+
<PropertyGroup>
165+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
166+
</PropertyGroup>
167+
<Error Condition="!Exists('..\packages\Detours.4.0.1\build\native\Detours.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Detours.4.0.1\build\native\Detours.targets'))" />
168+
</Target>
169+
</Project>

0 commit comments

Comments
 (0)