Преглед изворни кода

新增Console解决方案,以控制台运行方便调试。

sat23 пре 3 година
родитељ
комит
45b9f0cdd1

+ 3 - 0
DLLInjection/RegistryInjection/InjectionDLL/InjectionDLL.sln

@@ -5,10 +5,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InjectionDLL", "InjectionDL
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Console|Win32 = Console|Win32
 		Debug|Win32 = Debug|Win32
 		Release|Win32 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4AB6061F-754B-4ABD-9F91-8C5AA04E69D4}.Console|Win32.ActiveCfg = Console|Win32
+		{4AB6061F-754B-4ABD-9F91-8C5AA04E69D4}.Console|Win32.Build.0 = Console|Win32
 		{4AB6061F-754B-4ABD-9F91-8C5AA04E69D4}.Debug|Win32.ActiveCfg = Debug|Win32
 		{4AB6061F-754B-4ABD-9F91-8C5AA04E69D4}.Debug|Win32.Build.0 = Debug|Win32
 		{4AB6061F-754B-4ABD-9F91-8C5AA04E69D4}.Release|Win32.ActiveCfg = Release|Win32

+ 90 - 0
DLLInjection/RegistryInjection/InjectionDLL/InjectionDLL/InjectionDLL.vcproj

@@ -165,6 +165,79 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="Console|Win32"
+			OutputDirectory="..\..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			UseOfMFC="0"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				UACExecutionLevel="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -195,6 +268,15 @@
 						CompileAsManaged="0"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Console|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+						CompileAsManaged="0"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath=".\InjectionDLL.cpp"
@@ -223,6 +305,14 @@
 						UsePrecompiledHeader="1"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Console|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath=".\Utility.cpp"

+ 20 - 2
DLLInjection/RegistryInjection/InjectionDLL/InjectionDLL/dllmain.cpp

@@ -48,7 +48,7 @@ HWND GetMainWnd()
 
 DWORD WINAPI WorkThreadProc(LPVOID lParam)
 {
-#ifdef _DEBUG
+#if defined _DEBUG & !defined _CONSOLE
 	Sleep(15000);
 #endif
 	TCHAR szLog[MAX_PATH] = {0};
@@ -87,7 +87,7 @@ DWORD WINAPI WorkThreadProc(LPVOID lParam)
 	return 0;
 }
 
-
+#ifndef _CONSOLE
 BOOL APIENTRY DllMain( HMODULE hModule,DWORD  ul_reason_for_call,LPVOID lpReserved)
 {
 	switch (ul_reason_for_call)
@@ -109,4 +109,22 @@ BOOL APIENTRY DllMain( HMODULE hModule,DWORD  ul_reason_for_call,LPVOID lpReserv
 	}
 	return TRUE;
 }
+#else
+int main(int argc, char **argv)
+{
+    Utility::g_hDLLModule = GetModuleHandle(NULL);
+    Utility::GetConfigContent();
+
+    Utility::dprintf(_T("¹ÜµÀÃû³Æ=%s, ´°¿ÚÃû³Æ=%s, ´°¿Ú½ø³ÌÃû³Æ=%s"), Utility::g_cfgCtx.szPipeName, Utility::g_cfgCtx.szWindowTitel, Utility::g_cfgCtx.szWndProcessName);
 
+    if ( Utility::g_pPipeClient == NULL )
+    {
+        Utility::g_pPipeClient = new CPipeClient(Utility::g_cfgCtx.szPipeName);
+        Utility::g_pPipeClient->StartWork();
+    }
+
+    system("pause");
+
+    return 0;
+}
+#endif