13
13
CREATE_LIST_STRUCT (WinRuntimeObject )
14
14
15
15
// @todo: hard-coding this may cause random program failures due to ASLR etc.
16
+ // @todo: need smarter way of setting up IAT regions that don't conflict b/w
17
+ // exes & libs
16
18
#define IAT_BASE_START 0x7d7e0000
19
+ #define IAT_INCREMENT 0x10000
17
20
18
21
struct WinRuntimeObject runtime_exe ;
19
22
struct RuntimeObject * lib_ntdll ;
@@ -403,7 +406,7 @@ static bool initialize_lib_ntdll(struct RuntimeObject *lib_ntdll_object) {
403
406
404
407
tiny_c_close (ntdll_file );
405
408
406
- // @todo: computed not initialized
409
+ // @todo: bss, computed not initialized?
407
410
uint8_t * bss = 0 ;
408
411
size_t bss_len = 0 ;
409
412
const struct SectionHeader * bss_section_header = find_section_header (
@@ -579,8 +582,21 @@ static bool initialize_dynamic_data(
579
582
& iat_runtime_base
580
583
);
581
584
size_t iat_runtime_offset = current_iat_offset ;
582
- current_iat_base += 0x1000 ;
583
- current_iat_offset += 0x1000 ;
585
+ current_iat_base += IAT_INCREMENT ;
586
+ current_iat_offset += IAT_INCREMENT ;
587
+
588
+ /* Init .bss */
589
+
590
+ // @todo: lib bss
591
+
592
+ // const struct WinSectionHeader *bss_header = find_win_section_header(
593
+ // pe_exe.section_headers, pe_exe.section_headers_len, ".bss"
594
+ // );
595
+ // if (bss_header != NULL) {
596
+ // uint8_t *bss_region =
597
+ // (uint8_t *)(image_base + bss_header->base_address);
598
+ // memset(bss_region, 0, bss_header->virtual_size);
599
+ // }
584
600
585
601
struct WinRuntimeObject shared_lib = {
586
602
.name = dir_entry -> lib_name ,
@@ -669,8 +685,8 @@ int main(int argc, char **argv) {
669
685
(size_t )dynamic_callback_windows ,
670
686
& iat_runtime_base
671
687
);
672
- current_iat_base += 0x1000 ;
673
- current_iat_offset += 0x1000 ;
688
+ current_iat_base += IAT_INCREMENT ;
689
+ current_iat_offset += IAT_INCREMENT ;
674
690
675
691
/* Load libntdll.so */
676
692
@@ -679,6 +695,17 @@ int main(int argc, char **argv) {
679
695
EXIT ("initialize_lib_ntdll failed\n" );
680
696
}
681
697
698
+ /* Init .bss */
699
+
700
+ const struct WinSectionHeader * bss_header = find_win_section_header (
701
+ pe_exe .section_headers , pe_exe .section_headers_len , ".bss"
702
+ );
703
+ if (bss_header != NULL ) {
704
+ uint8_t * bss_region =
705
+ (uint8_t * )(image_base + bss_header -> base_address );
706
+ memset (bss_region , 0 , bss_header -> virtual_size );
707
+ }
708
+
682
709
/* Load dlls */
683
710
684
711
shared_libraries = (WinRuntimeObjectList ){
0 commit comments