@@ -174,27 +174,41 @@ fn rewind() -> PyResult<()> {
174174fn execute_uninitialized ( ) -> PyResult < ( ) > {
175175 let mut vm = Icicle :: new (
176176 "x86_64" . to_string ( ) ,
177- false ,
177+ true ,
178178 true ,
179179 false ,
180180 true ,
181181 true , // NOTE: setting this to true is not properly supported
182182 true ,
183183 false ,
184- true ,
184+ false ,
185185 ) ?;
186186
187187 // \x48\x8d\x05\x01\x00\x00\x00\x90\x8a\x18\x90
188188
189189 vm. mem_map ( 0x100 , 0x20 , MemoryProtection :: ExecuteOnly ) ?;
190- vm. mem_write ( 0x100 , b"\xFF \xC0 " . to_vec ( ) ) ?; // inc eax
190+ vm. mem_write ( 0x100 , b"\x90 \ xFF\xC0 " . to_vec ( ) ) ?; // inc eax
191191 vm. reg_write ( "rip" , 0x100 ) ?;
192- let status = vm. step ( 1 ) ;
193- // NOTE: the real reason is that INIT is not set
194- println ! ( "run status : {:?}" , status) ;
195- println ! ( "exception code : {:?}" , vm. get_exception_code( ) ) ;
196- println ! ( "exception value : {:#x}" , vm. get_exception_value( ) ) ;
197- println ! ( "rax : {:#x}" , vm. reg_read( "rax" ) ?) ;
192+ {
193+ println ! ( "[pre1] icount: {}" , vm. get_icount( ) ) ;
194+ let status = vm. step ( 2 ) ;
195+ // NOTE: the real reason is that INIT is not set
196+ println ! ( "run status : {:?}" , status) ;
197+ println ! ( "exception code : {:?}" , vm. get_exception_code( ) ) ;
198+ println ! ( "exception value : {:#x}" , vm. get_exception_value( ) ) ;
199+ println ! ( "rax : {:#x}" , vm. reg_read( "rax" ) ?) ;
200+ }
201+
202+ {
203+ println ! ( "[pre2] icount: {}" , vm. get_icount( ) ) ;
204+ let status = vm. step ( 1 ) ;
205+ // NOTE: the real reason is that INIT is not set
206+ println ! ( "run status : {:?}" , status) ;
207+ println ! ( "exception code : {:?}" , vm. get_exception_code( ) ) ;
208+ println ! ( "exception value : {:#x}" , vm. get_exception_value( ) ) ;
209+ println ! ( "rax : {:#x}" , vm. reg_read( "rax" ) ?) ;
210+ println ! ( "[post] icount: {}" , vm. get_icount( ) ) ;
211+ }
198212
199213 // TODO: status is now UnhandledException, should be InstructionLimit
200214 // on the next stpe it should be UnhandledException -> ExecViolation
@@ -229,8 +243,14 @@ fn execute_only() -> PyResult<()> {
229243 Ok ( ( ) )
230244}
231245
246+ fn self_modifying ( ) -> PyResult < ( ) > {
247+ // TODO: add a self-modifying code check (where the previously-executed code is written to)
248+
249+ Ok ( ( ) )
250+ }
251+
232252fn step_modify_rip ( ) -> PyResult < ( ) > {
233- let mut vm = new_trace_vm ( false ) ?;
253+ let mut vm = new_vm ( false ) ?;
234254 vm. mem_map ( 0x100 , 0x20 , MemoryProtection :: ExecuteRead ) ?;
235255
236256 // 0x100: 48 01 d8 add rax,rbx
@@ -346,16 +366,16 @@ fn main() {
346366 }
347367
348368 let tests: Vec < ( & str , fn ( ) -> PyResult < ( ) > ) > = vec ! [
349- ( "NX (block start)" , nx_start) ,
350- ( "NX (block middle)" , nx_middle) ,
351- ( "Invalid instruction (block start)" , inv_start) ,
352- ( "Invalid instruction (block middle)" , inv_middle) ,
353- ( "Block optimization bug" , block_optimization) ,
354- ( "Rewind" , rewind) ,
355- ( "Execute only" , execute_only) ,
369+ // ("NX (block start)", nx_start),
370+ // ("NX (block middle)", nx_middle),
371+ // ("Invalid instruction (block start)", inv_start),
372+ // ("Invalid instruction (block middle)", inv_middle),
373+ // ("Block optimization bug", block_optimization),
374+ // ("Rewind", rewind),
375+ // ("Execute only", execute_only),
356376 ( "Execute uninitialized" , execute_uninitialized) ,
357- ( "Step modify rip" , step_modify_rip) ,
358- ( "EFlags reconstruction" , eflags_reconstruction) ,
377+ // ("Step modify rip", step_modify_rip),
378+ // ("EFlags reconstruction", eflags_reconstruction),
359379 ] ;
360380
361381 let mut success = 0 ;
0 commit comments