@@ -20,6 +20,7 @@ use crate::{
2020use crate :: { get_bit, kuser_shared, set_bit, structures, winapi:: winapi32, winapi:: winapi64} ;
2121
2222use fast_log:: appender:: { Command , FastLogRecord , RecordFormat } ;
23+ use crate :: maps:: heap_allocation:: O1Heap ;
2324
2425pub struct CustomLogFormat ;
2526impl RecordFormat for CustomLogFormat {
@@ -94,6 +95,7 @@ impl Emu {
9495 definitions : HashMap :: new ( ) ,
9596 stored_contexts : HashMap :: new ( ) ,
9697 entropy : 0.0 ,
98+ heap_management : None ,
9799 }
98100 }
99101
@@ -353,15 +355,18 @@ impl Emu {
353355 if dyn_link {
354356 //heap.set_base(0x555555579000);
355357 } else {
356- let heap_sz = 0x4d8000 - 0x4b5000 ;
358+ // here we are allocating 4MB of heap memory
359+ let heap_sz = 0x885900 - 0x4b5000 ;
357360 self . heap_addr = self . maps . alloc ( heap_sz) . expect ( "cannot allocate heap" ) ;
358361 let heap = self
359362 . maps
360- . create_map ( "heap" , self . heap_addr , heap_sz, Permission :: READ_WRITE ) //.create_map("heap", 0x4b5b00, 0x4d8000 - 0x4b5000)
363+ . create_map ( ". heap" , self . heap_addr , heap_sz, Permission :: READ_WRITE ) //.create_map("heap", 0x4b5b00, 0x4d8000 - 0x4b5000)
361364 . expect ( "cannot create heap map" ) ;
362365 heap. load ( "heap.bin" ) ;
363- }
364366
367+ self . heap_management = Some ( Box :: new ( O1Heap :: new ( self . heap_addr , heap_sz as u32 ) . expect ( "Expect new heap_management but failed" ) ) ) ;
368+ }
369+
365370 self . regs_mut ( ) . rbp = 0 ;
366371
367372 self . fs_mut ( ) . insert ( 0xffffffffffffffc8 , 0 ) ; //0x4b6c50
@@ -521,5 +526,14 @@ impl Emu {
521526 let stack_size = 0x100000 ;
522527 teb. nt_tib . stack_limit = self . cfg . stack_addr + stack_size + 0x2000 ;
523528 teb. save ( teb_map) ;
529+
530+ let heap_sz = 0x885900 - 0x4b5000 ;
531+ self . heap_addr = self . maps . alloc ( heap_sz) . expect ( "cannot allocate heap" ) ;
532+ let heap = self
533+ . maps
534+ . create_map ( ".heap" , self . heap_addr , heap_sz, Permission :: READ_WRITE )
535+ . expect ( "cannot create heap map" ) ;
536+
537+ self . heap_management = Some ( Box :: new ( O1Heap :: new ( self . heap_addr , heap_sz as u32 ) . expect ( "Expect new heap_management but failed" ) ) ) ;
524538 }
525539}
0 commit comments