From 29b8110cb69974da01bc25e9232ce91e5a02b339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20Mat=C4=9Bjka?= Date: Wed, 11 Oct 2017 11:01:24 +0200 Subject: [PATCH] x64 --- README.md | 1 + clrinject-cli/cli.cpp | 6 ++- clrinject-cli/clrinject-cli.vcxproj | 66 ++++++++++++++++++++++++ clrinject-cli/clrinject-cli.vcxproj.user | 8 +++ clrinject.sln | 18 +++++++ clrinject/clrinject.cpp | 10 +++- clrinject/clrinject.vcxproj | 59 +++++++++++++++++++++ invader/invader.csproj | 20 +++++++ victim/victim.csproj | 20 +++++++ 9 files changed, 206 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8fcfc64..fbda497 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,4 @@ Opens process with id `` or name ``, inject ` #include #include +#ifndef _WIN64 #pragma comment(lib, "clrinject.lib") +#else +#pragma comment(lib, "clrinject64.lib") +#endif #include DWORD GetProcessIdByName(const char * processName) { @@ -158,7 +162,7 @@ int main(int argc, char** argv) { } if (!options.enumerate) - printf("Injection successful, return value: %0x08X\n", result.retVal); + printf("Injection successful, return value: 0x%08X\n", result.retVal); return 0; } diff --git a/clrinject-cli/clrinject-cli.vcxproj b/clrinject-cli/clrinject-cli.vcxproj index b07298d..60eac87 100644 --- a/clrinject-cli/clrinject-cli.vcxproj +++ b/clrinject-cli/clrinject-cli.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + @@ -25,6 +33,12 @@ v140 MultiByte + + Application + true + v140 + MultiByte + Application false @@ -32,6 +46,13 @@ MultiByte true + + Application + false + v140 + MultiByte + true + @@ -40,9 +61,15 @@ + + + + + + bin\$(Configuration)\ @@ -50,12 +77,26 @@ $(SolutionDir)clrinject;$(IncludePath) $(SolutionDir)clrinject\bin\$(Configuration);$(LibraryPath) + + $(SolutionDir)clrinject;$(IncludePath) + $(SolutionDir)clrinject\bin\$(Configuration);$(LibraryPath) + bin\$(Configuration)\ + obj\$(Configuration)\ + $(ProjectName)64 + bin\$(Configuration)\ obj\$(Configuration)\ $(SolutionDir)clrinject;$(IncludePath) $(SolutionDir)clrinject\bin\$(Configuration);$(LibraryPath) + + $(SolutionDir)clrinject;$(IncludePath) + $(SolutionDir)clrinject\bin\$(Configuration);$(LibraryPath) + bin\$(Configuration)\ + obj\$(Configuration)\ + $(ProjectName)64 + Level3 @@ -63,6 +104,13 @@ + + + Level3 + true + + + Level3 @@ -81,6 +129,24 @@ true + + + Level3 + Full + true + true + true + + + + + + true + + + true + + diff --git a/clrinject-cli/clrinject-cli.vcxproj.user b/clrinject-cli/clrinject-cli.vcxproj.user index aadd913..3dc3941 100644 --- a/clrinject-cli/clrinject-cli.vcxproj.user +++ b/clrinject-cli/clrinject-cli.vcxproj.user @@ -4,8 +4,16 @@ -p victim.exe -a "$(SolutionDir)invader\bin\$(Configuration)\invader.exe" -d 1 -i Invader.Invader WindowsLocalDebugger + + -p victim.exe -a "$(SolutionDir)invader\bin\x64\$(Configuration)\invader.exe" -d 1 -i Invader.Invader + WindowsLocalDebugger + -p victim.exe -a "$(SolutionDir)invader\bin\$(Configuration)\invader.exe" -d 1 -i Invader.Invader WindowsLocalDebugger + + -p victim.exe -a "$(SolutionDir)invader\bin\x64\$(Configuration)\invader.exe" -d 1 -i Invader.Invader + WindowsLocalDebugger + \ No newline at end of file diff --git a/clrinject.sln b/clrinject.sln index 81d06c5..6d213ff 100644 --- a/clrinject.sln +++ b/clrinject.sln @@ -15,24 +15,42 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clrinject-cli", "clrinject- EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4FA32C01-2B57-4D78-A079-905295575CAD}.Debug|x64.ActiveCfg = Debug|x64 + {4FA32C01-2B57-4D78-A079-905295575CAD}.Debug|x64.Build.0 = Debug|x64 {4FA32C01-2B57-4D78-A079-905295575CAD}.Debug|x86.ActiveCfg = Debug|Win32 {4FA32C01-2B57-4D78-A079-905295575CAD}.Debug|x86.Build.0 = Debug|Win32 + {4FA32C01-2B57-4D78-A079-905295575CAD}.Release|x64.ActiveCfg = Release|x64 + {4FA32C01-2B57-4D78-A079-905295575CAD}.Release|x64.Build.0 = Release|x64 {4FA32C01-2B57-4D78-A079-905295575CAD}.Release|x86.ActiveCfg = Release|Win32 {4FA32C01-2B57-4D78-A079-905295575CAD}.Release|x86.Build.0 = Release|Win32 + {14EC8B28-633C-451B-864D-829D1D0D02A5}.Debug|x64.ActiveCfg = Debug|Any CPU + {14EC8B28-633C-451B-864D-829D1D0D02A5}.Debug|x64.Build.0 = Debug|Any CPU {14EC8B28-633C-451B-864D-829D1D0D02A5}.Debug|x86.ActiveCfg = Debug|Any CPU {14EC8B28-633C-451B-864D-829D1D0D02A5}.Debug|x86.Build.0 = Debug|Any CPU + {14EC8B28-633C-451B-864D-829D1D0D02A5}.Release|x64.ActiveCfg = Release|x64 + {14EC8B28-633C-451B-864D-829D1D0D02A5}.Release|x64.Build.0 = Release|x64 {14EC8B28-633C-451B-864D-829D1D0D02A5}.Release|x86.ActiveCfg = Release|Any CPU {14EC8B28-633C-451B-864D-829D1D0D02A5}.Release|x86.Build.0 = Release|Any CPU + {20974E0D-C43C-46E7-8F34-1457613024BD}.Debug|x64.ActiveCfg = Debug|Any CPU + {20974E0D-C43C-46E7-8F34-1457613024BD}.Debug|x64.Build.0 = Debug|Any CPU {20974E0D-C43C-46E7-8F34-1457613024BD}.Debug|x86.ActiveCfg = Debug|Any CPU {20974E0D-C43C-46E7-8F34-1457613024BD}.Debug|x86.Build.0 = Debug|Any CPU + {20974E0D-C43C-46E7-8F34-1457613024BD}.Release|x64.ActiveCfg = Release|x64 + {20974E0D-C43C-46E7-8F34-1457613024BD}.Release|x64.Build.0 = Release|x64 {20974E0D-C43C-46E7-8F34-1457613024BD}.Release|x86.ActiveCfg = Release|Any CPU {20974E0D-C43C-46E7-8F34-1457613024BD}.Release|x86.Build.0 = Release|Any CPU + {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Debug|x64.ActiveCfg = Debug|x64 + {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Debug|x64.Build.0 = Debug|x64 {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Debug|x86.ActiveCfg = Debug|Win32 {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Debug|x86.Build.0 = Debug|Win32 + {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Release|x64.ActiveCfg = Release|x64 + {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Release|x64.Build.0 = Release|x64 {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Release|x86.ActiveCfg = Release|Win32 {6A9CF653-0969-492F-AB03-B6C01CD8AA3F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection diff --git a/clrinject/clrinject.cpp b/clrinject/clrinject.cpp index 731bdc9..72de253 100644 --- a/clrinject/clrinject.cpp +++ b/clrinject/clrinject.cpp @@ -9,7 +9,9 @@ } struct RemoteDataStruct { - int relocation; +#ifndef _WIN64 + INT relocation; +#endif HMODULE(WINAPI *GetModuleHandleA)(LPCSTR); FARPROC(WINAPI *GetProcAddress)(HMODULE, LPCSTR); HANDLE(WINAPI *GetCurrentProcess)(); @@ -35,10 +37,14 @@ struct RemoteDataStruct { #include #import raw_interfaces_only auto_rename +#ifndef _WIN64 #define CT(constant, type) ((type)((const byte *)constant + (RELOCATION))) #define CA(constant) CT(constant, decltype(constant)) #define CC(constant) (*CA(&constant)) #define RELOCATION localData->relocation +#else +#define CC(constant) (constant) +#endif #define REMOTE_ERROR_RET(cleanupLevel, message, returnValue) do {\ result.status = localData->GetLastError();\ @@ -259,7 +265,9 @@ int Inject(const InjectionOptions * options, InjectionResult * result) { INJECT_ERROR(2, "WriteProcessMemory for remote procedure code failed!"); RemoteDataStruct localData; +#ifndef _WIN64 localData.relocation = (byte*)remoteSectionAddr - (byte*)remoteSection; +#endif localData.GetModuleHandleA = GetModuleHandleA; localData.GetProcAddress = GetProcAddress; localData.GetCurrentProcess = GetCurrentProcess; diff --git a/clrinject/clrinject.vcxproj b/clrinject/clrinject.vcxproj index acf46a3..0b8455c 100644 --- a/clrinject/clrinject.vcxproj +++ b/clrinject/clrinject.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {4FA32C01-2B57-4D78-A079-905295575CAD} @@ -23,6 +31,12 @@ v140 MultiByte + + StaticLibrary + true + v140 + MultiByte + StaticLibrary false @@ -30,6 +44,13 @@ MultiByte true + + StaticLibrary + false + v140 + MultiByte + true + @@ -38,18 +59,34 @@ + + + + + + bin\$(Configuration)\ obj\$(Configuration)\ + + bin\$(Configuration)\ + obj\$(Configuration)\ + $(ProjectName)64 + bin\$(Configuration)\ obj\$(Configuration)\ + + bin\$(Configuration)\ + obj\$(Configuration)\ + $(ProjectName)64 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -58,6 +95,14 @@ + + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + Level3 + + + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -71,6 +116,20 @@ + + + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EditAndContinue + Full + true + true + false + + + + + + diff --git a/invader/invader.csproj b/invader/invader.csproj index 9c00192..08221a8 100644 --- a/invader/invader.csproj +++ b/invader/invader.csproj @@ -35,6 +35,26 @@ + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + diff --git a/victim/victim.csproj b/victim/victim.csproj index b03ce4f..48d05fa 100644 --- a/victim/victim.csproj +++ b/victim/victim.csproj @@ -32,6 +32,26 @@ prompt 4 + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true +