1- namespace ConquerLoader . Models
1+ namespace CLCore
22{
33 #region References
44
@@ -46,15 +46,15 @@ public static class Injector
4646 private const uint WAIT_TIMEOUT = 0x00000102 ;
4747 private const uint WAIT_FAILED = 0xFFFFFFFF ;
4848 #endregion
49+ public static InjectionStatus LastStatus { get ; set ; }
4950
5051 /// <summary>
5152 /// Function to inject a Dll
5253 /// </summary>
5354 /// <param name="DllName">Name of dll for inject.</param>
5455 /// <param name="ProcessName">Nombre del proceso en el que sera injectada la Dll.</param>
55- public static bool StartInjection ( string DllName , uint ProcessID , System . ComponentModel . BackgroundWorker Worker )
56+ public static InjectionStatus StartInjection ( string DllName , uint ProcessID , System . ComponentModel . BackgroundWorker Worker )
5657 {
57- bool Injected = false ;
5858 try
5959 {
6060 IntPtr hProcess = new IntPtr ( 0 ) ; //openprocess
@@ -84,36 +84,43 @@ public static bool StartInjection(string DllName, uint ProcessID, System.Compone
8484 {
8585 Worker . ReportProgress ( 50 ) ;
8686 uint Result = WaitForSingleObject ( hThread , 10 * 1000 ) ;
87- if ( Result != WAIT_FAILED || Result != WAIT_ABANDONED
88- || Result != WAIT_OBJECT_0 || Result != WAIT_TIMEOUT )
89- {
87+ if ( Result != WAIT_FAILED && Result != WAIT_ABANDONED && Result != WAIT_TIMEOUT ) {
9088 if ( VirtualFreeEx ( hProcess , hModule , 0 , MEM_RELEASE ) )
9189 {
9290 if ( hThread != IntPtr . Zero )
9391 {
9492 Worker . ReportProgress ( 99 ) ;
9593 CloseHandle ( hThread ) ;
96- Injected = true ;
97- return Injected ;
94+ return ReturnInjectionStatus ( true , "Injection success" ) ;
9895 }
99- else Core . LogWritter . Write ( "Bad thread handle ... injection failed" ) ;
96+ else ReturnInjectionStatus ( false , "Bad thread handle ... Injection failed" ) ;
10097 }
101- else Core . LogWritter . Write ( "Memory free problem ... injection failed" ) ;
98+ else ReturnInjectionStatus ( false , "Memory free problem ... Injection failed" ) ;
10299 }
103- else Core . LogWritter . Write ( "WaitForSingle failed: " + Result . ToString ( ) + "...injection failed" ) ;
100+ else ReturnInjectionStatus ( false , "WaitForSingle failed: " + Result . ToString ( ) + "... Injection failed" ) ;
104101 }
105- else Core . LogWritter . Write ( "Problem when starting the thread ... injection failed" ) ;
102+ else ReturnInjectionStatus ( false , "Problem when starting the thread ... Injection failed" ) ;
106103 }
107- else Core . LogWritter . Write ( "LoadLibraryA address not found ... injection failed" ) ;
104+ else ReturnInjectionStatus ( false , "LoadLibraryA address not found ... Injection failed" ) ;
108105 }
109- else Core . LogWritter . Write ( "Write error in process ... injection failed" ) ;
106+ else ReturnInjectionStatus ( false , "Write error in process ... Injection failed" ) ;
110107 }
111- else Core . LogWritter . Write ( "Unallocated memory ... injection failed" ) ;
108+ else ReturnInjectionStatus ( false , "Unallocated memory ... Injection failed" ) ;
112109 }
113- else Core . LogWritter . Write ( "Unopened process ... injection failed" ) ;
110+ else return ReturnInjectionStatus ( false , "Unopened process ... Injection failed" ) ;
114111 }
115- catch ( Exception Exc ) { Core . LogWritter . Write ( "Injection Error: " + Exc . ToString ( ) ) ; }
116- return Injected ;
112+ catch ( Exception Exc ) { return ReturnInjectionStatus ( false , "Injection Error: " + Exc . ToString ( ) ) ; }
113+ return ReturnInjectionStatus ( false , "Unhandled reason... Injection failed" ) ;
117114 }
115+ public static InjectionStatus ReturnInjectionStatus ( bool Injected , string ResultMessage )
116+ {
117+ LastStatus = new InjectionStatus ( ) { Injected = Injected , ResultMessage = ResultMessage } ;
118+ return LastStatus ;
119+ }
120+ }
121+ public class InjectionStatus
122+ {
123+ public bool Injected { get ; set ; }
124+ public string ResultMessage { get ; set ; }
118125 }
119126}
0 commit comments