mirror of
https://github.com/snowie2000/mactype.git
synced 2025-01-05 10:17:02 +08:00
add the macloader project
launch application from macloader using the standard detour API.
This commit is contained in:
parent
2e6e118f7c
commit
165011e8de
70
gdiexe.rc
70
gdiexe.rc
@ -1,70 +0,0 @@
|
||||
#pragma code_page(65001)
|
||||
#ifdef RC_INVOKED
|
||||
#include <winresrc.h>
|
||||
#endif
|
||||
|
||||
#define IDS_USAGE 1
|
||||
#define IDS_DLL 2
|
||||
#define IDC_EXEC 3
|
||||
|
||||
#ifdef RC_INVOKED
|
||||
|
||||
#define GDIPP_EXE
|
||||
#include "gdidll.rc"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_NUMBER
|
||||
PRODUCTVERSION VER_NUMBER
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "041104B0"
|
||||
{
|
||||
VALUE "CompanyName", "2ch"
|
||||
VALUE "FileDescription", "GDI++ Font Rasterizer Driver"
|
||||
VALUE "FileVersion", VER_STRING
|
||||
VALUE "InternalName", "gdi++"
|
||||
VALUE "LegalCopyright", "(C) 仧0x0D/0x20I, 460. All rights reserved."
|
||||
VALUE "OriginalFilename", "gdi++.exe"
|
||||
VALUE "ProductVersion", VER_STRING
|
||||
VALUE "URL", "http://drwatson.nobody.jp/gdi++/"
|
||||
}
|
||||
}
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x0411 0x04B0
|
||||
}
|
||||
}
|
||||
|
||||
1 24 DISCARDABLE
|
||||
{
|
||||
"<?xml version=""1.0"" standalone=""yes""?>\n"
|
||||
"<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0""><dependency><dependentAssembly><assemblyIdentity type=""win32"" name=""Microsoft.Windows.Common-Controls"" version=""6.0.0.0"" processorArchitecture=""X86"" publicKeyToken=""6595b64144ccf1df"" language=""*"" /></dependentAssembly></dependency></assembly>"
|
||||
}
|
||||
|
||||
//じゃぱにーず
|
||||
STRINGTABLE DISCARDABLE
|
||||
{
|
||||
IDS_USAGE "gdi++.exe <file> argument ...\n\nEXE, またはショートカットなどをドロップしてください."
|
||||
IDS_DLL "error: 0x%08x\nDLLが見つかりません."
|
||||
IDC_EXEC "error: 0x%08x\n実行できません."
|
||||
}
|
||||
|
||||
//えーご(適当)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
{
|
||||
IDS_USAGE "gdi++.exe <file> argument ...\n\nPlease drag and drop executable files or shortcut files."
|
||||
IDS_DLL "error: 0x%08x\nCannot find a DLL."
|
||||
IDC_EXEC "error: 0x%08x\nCannot execute."
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#include "Please modify with a text editor instead of Visual Studio."
|
||||
#endif
|
30
gdipp.sln
30
gdipp.sln
@ -4,6 +4,8 @@ VisualStudioVersion = 17.4.33103.184
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MacType", "gdipp.vcxproj", "{15C33FD9-0811-4981-B08F-E0BAD74A3028}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "macloader", "macloader.vcxproj", "{6D6AC860-BA16-4BE7-9169-21787F21CB6F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug Infinality|Win32 = Debug Infinality|Win32
|
||||
@ -50,6 +52,34 @@ Global
|
||||
{15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release+StaticHook|Win32.Build.0 = Release+StaticHook|Win32
|
||||
{15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release+StaticHook|x64.ActiveCfg = Release+StaticHook|x64
|
||||
{15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release+StaticHook|x64.Build.0 = Release+StaticHook|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug Infinality|Win32.ActiveCfg = Debug|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug Infinality|Win32.Build.0 = Debug|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug Infinality|x64.ActiveCfg = Debug|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug Infinality|x64.Build.0 = Debug|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Debug|x64.Build.0 = Debug|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Detours|Win32.ActiveCfg = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Detours|Win32.Build.0 = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Detours|x64.ActiveCfg = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Detours|x64.Build.0 = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Trace|Win32.ActiveCfg = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Trace|Win32.Build.0 = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Trace|x64.ActiveCfg = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Rel+Trace|x64.Build.0 = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release Infinality|Win32.ActiveCfg = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release Infinality|Win32.Build.0 = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release Infinality|x64.ActiveCfg = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release Infinality|x64.Build.0 = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release|Win32.Build.0 = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release|x64.ActiveCfg = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release|x64.Build.0 = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release+StaticHook|Win32.ActiveCfg = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release+StaticHook|Win32.Build.0 = Release|Win32
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release+StaticHook|x64.ActiveCfg = Release|x64
|
||||
{6D6AC860-BA16-4BE7-9169-21787F21CB6F}.Release+StaticHook|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -17,6 +17,14 @@
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="EXE|Win32">
|
||||
<Configuration>EXE</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="EXE|x64">
|
||||
<Configuration>EXE</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Rel+Detours|Win32">
|
||||
<Configuration>Rel+Detours</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
@ -67,7 +75,7 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
@ -146,6 +154,12 @@
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='EXE|Win32'">
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='EXE|x64'">
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
@ -443,7 +457,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;EASYHOOK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_EXE;EASYHOOK;STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
|
BIN
macloader.rc
Normal file
BIN
macloader.rc
Normal file
Binary file not shown.
147
macloader.vcxproj
Normal file
147
macloader.vcxproj
Normal file
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="run.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="macloader.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{6d6ac860-ba16-4be7-9169-21787f21cb6f}</ProjectGuid>
|
||||
<RootNamespace>macloader</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>$(ProjectName)64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>$(ProjectName)64</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;USE_DETOURS;_GDIPP_EXE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>Default</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;USE_DETOURS;_GDIPP_EXE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>Default</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;USE_DETOURS;_GDIPP_EXE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>Default</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;USE_DETOURS;_GDIPP_EXE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>Default</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
14
resource.h
14
resource.h
@ -1424,3 +1424,17 @@
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Resource.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
249
run.cpp
249
run.cpp
@ -1,4 +1,4 @@
|
||||
// dll injection
|
||||
// dll injection
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#define WINVER 0x500
|
||||
#define _WIN32_WINNT 0x500
|
||||
@ -14,7 +14,6 @@
|
||||
#include <tchar.h>
|
||||
#include "array.h"
|
||||
#include <strsafe.h>
|
||||
#include "gdiexe.rc"
|
||||
|
||||
// _vsnwprintf用
|
||||
#include <wchar.h>
|
||||
@ -37,13 +36,21 @@
|
||||
#pragma comment(lib, "ShLwApi.lib")
|
||||
#pragma comment(lib, "Ole32.lib")
|
||||
|
||||
#define IDS_USAGE 101
|
||||
#define IDS_DLL 102
|
||||
#define IDC_EXEC 103
|
||||
|
||||
static void showmsg(LPCSTR msg) {
|
||||
MessageBoxA(NULL, msg, "MacType ERROR", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
|
||||
static void errmsg(UINT id, DWORD code)
|
||||
{
|
||||
char buffer [512];
|
||||
char format [128];
|
||||
char buffer[512];
|
||||
char format[128];
|
||||
LoadStringA(GetModuleHandleA(NULL), id, format, 128);
|
||||
wnsprintfA(buffer, 512, format, code);
|
||||
MessageBoxA(NULL, buffer, "MacType ERROR", MB_OK|MB_ICONSTOP);
|
||||
showmsg(buffer);
|
||||
}
|
||||
|
||||
inline HRESULT HresultFromLastError()
|
||||
@ -53,7 +60,17 @@ inline HRESULT HresultFromLastError()
|
||||
}
|
||||
|
||||
|
||||
//#include <detours.h>
|
||||
#include "detours.h"
|
||||
#ifdef _M_IX86
|
||||
#pragma comment (lib, "detours.lib")
|
||||
const auto MacTypeDll = L"MacType.dll";
|
||||
const auto MacTypeDllA = "MacType.dll";
|
||||
#else
|
||||
#pragma comment (lib, "detours64.lib")
|
||||
const auto MacTypeDll = L"MacType64.dll";
|
||||
const auto MacTypeDllA = "MacType64.dll";
|
||||
#endif
|
||||
|
||||
|
||||
HINSTANCE hinstDLL;
|
||||
|
||||
@ -62,53 +79,44 @@ HINSTANCE hinstDLL;
|
||||
|
||||
#define _GDIPP_EXE
|
||||
#define _GDIPP_RUN_CPP
|
||||
#include "supinfo.h"
|
||||
|
||||
static BOOL (WINAPI * ORIG_CreateProcessW)(LPCWSTR lpApp, LPWSTR lpCmd, LPSECURITY_ATTRIBUTES pa, LPSECURITY_ATTRIBUTES ta, BOOL bInherit, DWORD dwFlags, LPVOID lpEnv, LPCWSTR lpDir, LPSTARTUPINFOW psi, LPPROCESS_INFORMATION ppi)
|
||||
= CreateProcessW;
|
||||
|
||||
static BOOL WINAPI IMPL_CreateProcessW(LPCWSTR lpApp, LPWSTR lpCmd, LPSECURITY_ATTRIBUTES pa, LPSECURITY_ATTRIBUTES ta, BOOL bInherit, DWORD dwFlags, LPVOID lpEnv, LPCWSTR lpDir, LPSTARTUPINFOW psi, LPPROCESS_INFORMATION ppi)
|
||||
{
|
||||
return _CreateProcessAorW(lpApp, lpCmd, pa, ta, bInherit, dwFlags, lpEnv, lpDir, psi, ppi, ORIG_CreateProcessW);
|
||||
}
|
||||
|
||||
//#include "supinfo.h"
|
||||
|
||||
//#define OLD_PSDK
|
||||
|
||||
#ifdef OLD_PSDK
|
||||
extern "C" {
|
||||
HRESULT WINAPI _SHILCreateFromPath(LPCWSTR pszPath, LPITEMIDLIST *ppidl, DWORD *rgflnOut)
|
||||
{
|
||||
if (!pszPath || !ppidl) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
HRESULT WINAPI _SHILCreateFromPath(LPCWSTR pszPath, LPITEMIDLIST* ppidl, DWORD* rgflnOut)
|
||||
{
|
||||
if (!pszPath || !ppidl) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
LPSHELLFOLDER psf;
|
||||
HRESULT hr = ::SHGetDesktopFolder(&psf);
|
||||
if (hr != NOERROR) {
|
||||
LPSHELLFOLDER psf;
|
||||
HRESULT hr = ::SHGetDesktopFolder(&psf);
|
||||
if (hr != NOERROR) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
ULONG chEaten;
|
||||
LPOLESTR lpszDisplayName = ::StrDupW(pszPath);
|
||||
hr = psf->ParseDisplayName(NULL, NULL, lpszDisplayName, &chEaten, ppidl, rgflnOut);
|
||||
::LocalFree(lpszDisplayName);
|
||||
psf->Release();
|
||||
return hr;
|
||||
}
|
||||
|
||||
ULONG chEaten;
|
||||
LPOLESTR lpszDisplayName = ::StrDupW(pszPath);
|
||||
hr = psf->ParseDisplayName(NULL, NULL, lpszDisplayName, &chEaten, ppidl, rgflnOut);
|
||||
::LocalFree(lpszDisplayName);
|
||||
psf->Release();
|
||||
return hr;
|
||||
}
|
||||
void WINAPI _SHFree(void* pv)
|
||||
{
|
||||
if (!pv) {
|
||||
return;
|
||||
}
|
||||
|
||||
void WINAPI _SHFree(void *pv)
|
||||
{
|
||||
if (!pv) {
|
||||
return;
|
||||
LPMALLOC pMalloc = NULL;
|
||||
if (::SHGetMalloc(&pMalloc) == NOERROR) {
|
||||
pMalloc->Free(pv);
|
||||
pMalloc->Release();
|
||||
}
|
||||
}
|
||||
|
||||
LPMALLOC pMalloc = NULL;
|
||||
if (::SHGetMalloc(&pMalloc) == NOERROR) {
|
||||
pMalloc->Free(pv);
|
||||
pMalloc->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define _SHILCreateFromPath SHILCreateFromPath
|
||||
@ -116,6 +124,52 @@ void WINAPI _SHFree(void *pv)
|
||||
#endif
|
||||
|
||||
|
||||
bool isX64PE(const TCHAR* file_path) {
|
||||
HANDLE hFile = CreateFile(file_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
showmsg("Error opening file");
|
||||
return false;
|
||||
}
|
||||
|
||||
IMAGE_DOS_HEADER dosHeader;
|
||||
DWORD bytesRead;
|
||||
if (!ReadFile(hFile, &dosHeader, sizeof(IMAGE_DOS_HEADER), &bytesRead, NULL)) {
|
||||
showmsg("Error reading file");
|
||||
CloseHandle(hFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if it's a PE file
|
||||
if (dosHeader.e_magic != IMAGE_DOS_SIGNATURE) {
|
||||
showmsg("Not a PE file");
|
||||
CloseHandle(hFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
IMAGE_NT_HEADERS ntHeaders;
|
||||
// Seek to the PE header offset
|
||||
SetFilePointer(hFile, dosHeader.e_lfanew, NULL, FILE_BEGIN);
|
||||
if (!ReadFile(hFile, &ntHeaders, sizeof(IMAGE_NT_HEADERS), &bytesRead, NULL)) {
|
||||
showmsg("Error reading PE header");
|
||||
CloseHandle(hFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ntHeaders.FileHeader.Machine == IMAGE_FILE_MACHINE_I386) {
|
||||
CloseHandle(hFile);
|
||||
return false;
|
||||
}
|
||||
else if (ntHeaders.FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64) {
|
||||
CloseHandle(hFile);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
CloseHandle(hFile);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 1つ目の引数だけファイルとして扱い、実行する。
|
||||
//
|
||||
// コマンドは こんな感じで連結されます。
|
||||
@ -125,34 +179,35 @@ static HRESULT HookAndExecute(int show)
|
||||
{
|
||||
int argc = 0;
|
||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if(!argv) {
|
||||
if (!argv) {
|
||||
return HresultFromLastError();
|
||||
}
|
||||
if(argc <= 1) {
|
||||
char buffer [256];
|
||||
if (argc <= 1) {
|
||||
char buffer[256];
|
||||
LoadStringA(GetModuleHandleA(NULL), IDS_USAGE, buffer, 256);
|
||||
MessageBoxA(NULL,
|
||||
buffer
|
||||
,"MacType", MB_OK|MB_ICONINFORMATION);
|
||||
, "MacType", MB_OK | MB_ICONINFORMATION);
|
||||
LocalFree(argv);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
size_t length = 1;
|
||||
for(i=2; i<argc; i++) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
length += wcslen(argv[i]) + 3;
|
||||
}
|
||||
|
||||
LPWSTR cmdline = (WCHAR*)calloc(sizeof(WCHAR), length);
|
||||
if(!cmdline) {
|
||||
if (!cmdline) {
|
||||
LocalFree(argv);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
LPWSTR p = cmdline;
|
||||
*p = L'\0';
|
||||
for(i=2; i<argc; i++) {
|
||||
for (i = 1; i < argc; i++) {
|
||||
const bool dq = !!wcschr(argv[i], L' ');
|
||||
if (dq) {
|
||||
*p++ = '"';
|
||||
@ -169,12 +224,26 @@ static HRESULT HookAndExecute(int show)
|
||||
|
||||
*CharPrevW(cmdline, p) = L'\0';
|
||||
|
||||
// now we got the full cmdline for external exetuble. let's check if we can hook into it
|
||||
#ifdef _M_IX86
|
||||
if (isX64PE(argv[1])) {
|
||||
ShellExecute(NULL, NULL, L"macloader64.exe", cmdline, NULL, SW_SHOW);
|
||||
return S_OK;
|
||||
}
|
||||
#else
|
||||
if (!isX64PE(argv[1])) {
|
||||
ShellExecute(NULL, NULL, L"macloader.exe", cmdline, NULL, SW_SHOW);
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
WCHAR file[MAX_PATH], dir[MAX_PATH];
|
||||
GetCurrentDirectoryW(_countof(dir), dir);
|
||||
StringCchCopyW(file, _countof(file), argv[1]);
|
||||
if(PathIsRelativeW(file)) {
|
||||
if (PathIsRelativeW(file)) {
|
||||
PathCombineW(file, dir, file);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
WCHAR gdippDir[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, gdippDir, _countof(gdippDir));
|
||||
PathRemoveFileSpec(gdippDir);
|
||||
@ -189,86 +258,58 @@ static HRESULT HookAndExecute(int show)
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(argv);
|
||||
argv = NULL;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if((GetAsyncKeyState(VK_CONTROL) & 0x8000)
|
||||
&& MessageBoxW(NULL, cmdline, NULL, MB_YESNO) != IDYES) {
|
||||
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)
|
||||
&& MessageBoxW(NULL, cmdline, NULL, MB_YESNO) != IDYES) {
|
||||
free(cmdline);
|
||||
return NOERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
LPITEMIDLIST pidl = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
//fileのアイテムIDリストを取得
|
||||
hr = _SHILCreateFromPath(file, &pidl, NULL);
|
||||
if(SUCCEEDED(hr) && pidl) {
|
||||
//SEE_MASK_INVOKEIDLISTを使うと
|
||||
//explorerでクリックして起動したのと同じ動作になる
|
||||
SHELLEXECUTEINFOW sei = { sizeof(SHELLEXECUTEINFOW) };
|
||||
sei.fMask = SEE_MASK_INVOKEIDLIST
|
||||
| SEE_MASK_CONNECTNETDRV
|
||||
| SEE_MASK_FLAG_DDEWAIT
|
||||
| SEE_MASK_DOENVSUBST
|
||||
| SEE_MASK_WAITFORINPUTIDLE;
|
||||
sei.hwnd = GetDesktopWindow();
|
||||
sei.lpParameters = cmdline;
|
||||
sei.lpDirectory = dir;
|
||||
sei.nShow = show;
|
||||
sei.lpIDList = pidl;
|
||||
PROCESS_INFORMATION processInfo;
|
||||
STARTUPINFO startupInfo = { 0 };
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
|
||||
//ShellExecuteExWが内部で呼び出すCreateProcessWをフックして
|
||||
//HookChildProcesses相当の処理を行う
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID&)ORIG_CreateProcessW, IMPL_CreateProcessW);
|
||||
hr = DetourTransactionCommit();
|
||||
|
||||
if(hr == NOERROR) {
|
||||
if(ShellExecuteExW(&sei)) {
|
||||
hr = S_OK;
|
||||
} else {
|
||||
hr = HresultFromLastError();
|
||||
}
|
||||
}
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(&(PVOID&)ORIG_CreateProcessW, IMPL_CreateProcessW);
|
||||
DetourTransactionCommit();
|
||||
// get current directory and append mactype dll
|
||||
char path[MAX_PATH] = { 0 };
|
||||
if (GetModuleFileNameA(NULL, path, _countof(path))) {
|
||||
PathRemoveFileSpecA(path);
|
||||
strcat(path, "\\");
|
||||
}
|
||||
strcat(path, MacTypeDllA);
|
||||
|
||||
auto ret = DetourCreateProcessWithDllEx(NULL, cmdline, NULL, NULL, false, 0, NULL, dir, &startupInfo, &processInfo, path, NULL);
|
||||
|
||||
if(pidl)
|
||||
_SHFree(pidl);
|
||||
free(cmdline);
|
||||
return hr;
|
||||
LocalFree(argv);
|
||||
argv = NULL;
|
||||
return ret ? S_OK : E_ACCESSDENIED;
|
||||
}
|
||||
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE ins, HINSTANCE prev, LPWSTR cmd, int show)
|
||||
{
|
||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
OleInitialize(NULL);
|
||||
|
||||
WCHAR path [MAX_PATH];
|
||||
if(GetModuleFileNameW(NULL, path, _countof(path))) {
|
||||
PathRenameExtensionW(path, L".dll");
|
||||
WCHAR path[MAX_PATH];
|
||||
if (GetModuleFileNameW(NULL, path, _countof(path))) {
|
||||
PathRemoveFileSpec(path);
|
||||
wcscat(path, L"\\");
|
||||
wcscat(path, MacTypeDll);
|
||||
//DONT_RESOLVE_DLL_REFERENCESを指定すると依存関係の解決や
|
||||
//DllMainの呼び出しが行われない
|
||||
hinstDLL = LoadLibraryExW(path, NULL, DONT_RESOLVE_DLL_REFERENCES);
|
||||
}
|
||||
if(!hinstDLL) {
|
||||
if (!hinstDLL) {
|
||||
errmsg(IDS_DLL, HresultFromLastError());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
PathRemoveFileSpecW(path);
|
||||
SetCurrentDirectoryW(path);
|
||||
|
||||
HRESULT hr = HookAndExecute(show);
|
||||
if(hr != S_OK) {
|
||||
if (hr != S_OK) {
|
||||
errmsg(IDC_EXEC, hr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user