@@ -14,27 +14,27 @@ using namespace peconv;
1414namespace peconv {
1515 BYTE* load_no_sec_pe (BYTE* dllRawData, size_t r_size, OUT size_t &v_size, bool executable)
1616 {
17- ULONGLONG desired_base = 0 ;
17+ ULONG_PTR desired_base = 0 ;
1818 size_t out_size = (r_size < PAGE_SIZE) ? PAGE_SIZE : r_size;
1919 if (executable) {
2020 desired_base = get_image_base (dllRawData);
2121 out_size = peconv::get_image_size (dllRawData);
2222 }
2323 DWORD protect = (executable) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
24- BYTE* mappedPE = peconv::alloc_pe_buffer (out_size, protect, desired_base);
24+ BYTE* mappedPE = peconv::alloc_pe_buffer (out_size, protect, reinterpret_cast < void *>( desired_base) );
2525 if (!mappedPE) {
26- return NULL ;
26+ return nullptr ;
2727 }
2828 memcpy (mappedPE, dllRawData, r_size);
2929 v_size = out_size;
3030 return mappedPE;
3131 }
3232};
3333
34- BYTE* peconv::load_pe_module (BYTE* dllRawData, size_t r_size, OUT size_t &v_size, bool executable, bool relocate, ULONGLONG desired_base)
34+ BYTE* peconv::load_pe_module (BYTE* dllRawData, size_t r_size, OUT size_t &v_size, bool executable, bool relocate, ULONG_PTR desired_base)
3535{
3636 if (!peconv::get_nt_hdrs (dllRawData, r_size)) {
37- return NULL ;
37+ return nullptr ;
3838 }
3939 if (peconv::get_sections_count (dllRawData, r_size) == 0 ) {
4040 return load_no_sec_pe (dllRawData, r_size, v_size, executable);
@@ -53,35 +53,35 @@ BYTE* peconv::load_pe_module(BYTE* dllRawData, size_t r_size, OUT size_t &v_size
5353 // relocating was required, but it failed - thus, the full PE image is useless
5454 std::cerr << " [!] Could not relocate the module!\n " ;
5555 free_pe_buffer (mappedDLL, v_size);
56- mappedDLL = NULL ;
56+ mappedDLL = nullptr ;
5757 }
5858 } else {
5959 std::cerr << " [!] Could not allocate memory at the desired base!\n " ;
6060 }
6161 return mappedDLL;
6262}
6363
64- BYTE* peconv::load_pe_module (LPCTSTR filename, OUT size_t &v_size, bool executable, bool relocate, ULONGLONG desired_base)
64+ BYTE* peconv::load_pe_module (LPCTSTR filename, OUT size_t &v_size, bool executable, bool relocate, ULONG_PTR desired_base)
6565{
6666 size_t r_size = 0 ;
6767 BYTE *dllRawData = load_file (filename, r_size);
6868 if (!dllRawData) {
6969#ifdef _DEBUG
7070 std::cerr << " Cannot load the file: " << filename << std::endl;
7171#endif
72- return NULL ;
72+ return nullptr ;
7373 }
7474 BYTE* mappedPE = load_pe_module (dllRawData, r_size, v_size, executable, relocate, desired_base);
7575 free_file (dllRawData);
7676 return mappedPE;
7777}
7878
79- BYTE* peconv::load_pe_executable (BYTE* dllRawData, size_t r_size, OUT size_t &v_size, t_function_resolver* import_resolver, ULONGLONG desired_base)
79+ BYTE* peconv::load_pe_executable (BYTE* dllRawData, size_t r_size, OUT size_t &v_size, t_function_resolver* import_resolver, ULONG_PTR desired_base)
8080{
8181 BYTE* loaded_pe = load_pe_module (dllRawData, r_size, v_size, true , true , desired_base);
8282 if (!loaded_pe) {
8383 std::cerr << " [-] Loading failed!\n " ;
84- return NULL ;
84+ return nullptr ;
8585 }
8686#if _DEBUG
8787 printf (" Loaded at: %p\n " , loaded_pe);
@@ -116,7 +116,7 @@ BYTE* peconv::load_pe_executable(LPCTSTR my_path, OUT size_t &v_size, t_function
116116 if (!load_imports (loaded_pe, import_resolver)) {
117117 printf (" [-] Loading imports failed!" );
118118 free_pe_buffer (loaded_pe, v_size);
119- return NULL ;
119+ return nullptr ;
120120 }
121121 return loaded_pe;
122122}
0 commit comments