portable-executable

how to build an executable without import table in c/c++?

浪子不回头ぞ 提交于 2019-12-01 08:20:50
I found a tool to repair import table here , but how are PE executable without import table built in the first place in c/c++? Just don't use CRT, and don't use any imported functions. #pragma comment(linker, "/entry:start") int start() { return 42; } To use WinAPI functions, find kernel32 base, parse it's export directory and find LoadLibrary() function (you should already have something like GetProcAddress() to find LoadLibrary()) This may looks like this: // compile as console application, "release" configuration with /MT /GS- #include <Windows.h> #pragma comment(linker, "/entry:start")

Size of exe file vs available memory

北战南征 提交于 2019-12-01 05:50:23
I have gone through How does a PE file get mapped into memory? , this is not what i am asking for. I want to know which sections (data, text, code, ...) of a PE file are always completely loaded into memory by the loader no matter whatever the condition is? As per my understanding, none of the sections (code,data,resources,text,...) are always loaded completely, they are loaded as and when needed, page by page. If few pages of code (in the middle or at the end), are not required to process user's request then these pages will not always get loaded. I have tried making exe files with lots of

Microsoft's ASLR is weird

此生再无相见时 提交于 2019-12-01 05:10:12
问题 I watched a ASLRed dll images's based address for 32bit Process. It's not a fully randomization. It just randomizated 1/2 probability. For example, once I load a dll then the image is loaded on 0x12345678 . And I load the image again, the image is loaded on 0x23456789 .(Base address is changed!) But I load the image again 0x12345678 0x23456789 0x12345678 0x23456789 ... Why they did implement like this? Is it for a crash report's frequency?(For getting same crash addresses of re-deployed dlls)

Binary Reproducibility in Visual C++

爱⌒轻易说出口 提交于 2019-12-01 02:23:42
问题 Is there a way to force the same code to produce the same binary in Visual C++? Turn off the timestamp in the PE or force the timestamp in the PE to be some fixed value, in other words? 回答1: It's not only a timestamp - there's an embedded GUID used for PDB matching - as John Robbins explains. Even beyond that, there's just no way to force the compiler to generate consistent results, as Jim Griesmer explains - compiler writers are far more interested in generating correctly functioning code

About ImageBase of .EXE in windows

被刻印的时光 ゝ 提交于 2019-12-01 00:52:08
I just learned ImageBase is specified in PE format,and OS will load it to the exact position for .EXE , then comes the question: what if two .EXE is requiring the same ImageBase location? st0le Incase of 2 EXE's, they have Completely Different Address Spaces...Every Executable has its own space. This means, every time you execute an EXE, it is assigned its own independent 4GB (on 32bit systems, although the process can use just part of it, the rest goes the kernel.) worth address space. It's Virtual Address Space . It's different from your Physical Memory. So there's no conflict. Technically,

Writing a Cross-Platform (32-bit and 64-bit compatible) Program for Windows (like AnyCPU in .NET)

£可爱£侵袭症+ 提交于 2019-12-01 00:31:53
问题 It's been baffling me how the "AnyCPU" feature in .NET works: It loads the executable as native 32-bit if the system is 32-bit, and as 64-bit if the system is 64-bit (which you can easily confirm with Task Manager). So obviously, this isn't impossible. The question is, how exactly did Microsoft do this? Windows originally didn't know about the .NET framework, so the Windows PE Loader can't possibly look for any extra features in PE headers for the CLR header; this feature must have been added

So most of the binary is composed of reloc table?

心已入冬 提交于 2019-12-01 00:26:09
I just used objdump -x ... to check the sections of a PE file. There's about 90,000 lines of reloc entries: reloc 92 offset bc0 [524bc0] HIGHLOW reloc 93 offset bc4 [524bc4] HIGHLOW .... Does it hold true that the majority space of most PE files are composed of the reloc entries like above? What are those entries for? UPDATE Anyone can explain how the relocation entries work like above? Relocations are needed when there is a base conflict in the memory. If a dynamic-link-library wants to load its code section in a certain memory space but when it has already been accupied by another module, it

How do I determine if an EXE (or DLL) participate in ASLR, i.e. is relocatable?

余生长醉 提交于 2019-11-30 23:18:34
How do I determine if an EXE (or DLL) participate in ASLR, i.e. is relocatable? I want to check some EXE's on my system whether they are relocatable and participate in ASLR. I know the default behavior of the linker is to strip base relocations, so that the EXE is not relocatable? How do I see from a tool like FileAlyzer whether the image participate in ASLR? miguel A relocatable module (exe or dll) doesn't necessarily need to have ASLR enabled but a module that has ASLR enabled needs to be relocatable. A module that is ASLR-enabled (using the /DYNAMICBASE linker switch) will be loaded at a

Questions Regarding DLL Loading in a Process Address Space

百般思念 提交于 2019-11-30 16:19:32
问题 Well, I read several of Matt Pietrek's articles on Portable Executable (PE) files, like: An In-Depth Look into the Win32 Portable Executable File Format, Part 1 and Part 2 MSJ article on linkers MSJ article on COFF format In addition, I have read a few other sources on the subject. It is either me overlooking some parts, or the questions aren't answered there. So, here are the questions: It is known that, when loading an EXE, the Windows Loader reads the list of imported DLL's from the

Questions Regarding DLL Loading in a Process Address Space

橙三吉。 提交于 2019-11-30 15:52:16
Well, I read several of Matt Pietrek's articles on Portable Executable (PE) files, like: An In-Depth Look into the Win32 Portable Executable File Format, Part 1 and Part 2 MSJ article on linkers MSJ article on COFF format In addition, I have read a few other sources on the subject. It is either me overlooking some parts, or the questions aren't answered there. So, here are the questions: It is known that, when loading an EXE, the Windows Loader reads the list of imported DLL's from the Importa Address Table (IAT), and loads them into the process address space. The process address space is a