portable-executable

How do I make space for my code cave in a Windows PE 32bit executable

大城市里の小女人 提交于 2019-11-30 14:28:32
问题 So I want to make a space for my code caves in minesweeper.exe (typical Windows XP minesweeper game, link: Minesweeper). So I modified the PE header of the file via CFF Explorer to increase size of the .text section. I tried increasing raw size of .text segment by 1000h (new size was 3B58), but Windows was unable to locate the entry point and the game failed to launch. Then I tried increasing the size of the .rsrc section, adding a new section, increasing the image size, but none of those

Parsing plain Win32 PE File (Exe/DLL) in .NET

六月ゝ 毕业季﹏ 提交于 2019-11-30 13:09:13
I need to parse plain Win32 DLL/Exe and get all imports and exports from it to show on console or GUI (i.e. Win Forms). Is it possible to parse Win32 DLL/Exe in C#.NET by reading its export/import tables and get managed types from it? As it's unmanaged PE, .NET doesn't allows you to convert unmanaged PE files to managed .NET assemblies, it only generates COM managed assemblies. How can I parse these tables and take all of its methods (signatures) in managed form. (e.g. if char* as argument, it should display as IntPtr). Stephen Cleary Parsing PE files is possible using the Microsoft Portable

How do I make space for my code cave in a Windows PE 32bit executable

感情迁移 提交于 2019-11-30 10:18:32
So I want to make a space for my code caves in minesweeper.exe (typical Windows XP minesweeper game, link: Minesweeper ). So I modified the PE header of the file via CFF Explorer to increase size of the .text section. I tried increasing raw size of .text segment by 1000h (new size was 3B58), but Windows was unable to locate the entry point and the game failed to launch. Then I tried increasing the size of the .rsrc section, adding a new section, increasing the image size, but none of those attempts were successful, Windows was saying that "This is not x32 executable". So here is the question:

Fill in DLL import table manually: IMAGE_IMPORT_DESCRIPTOR's Name field stores 0x0000FFFF

和自甴很熟 提交于 2019-11-30 10:01:26
问题 My goal is to fill in Dll's import table manually in order to hook internal LoadLibrary calls (when you load library it may load another library inside its DllMain). Here is my code which fill in Import table recursively for each dll in dependecies hierarchy and it works fine except some dlls ( api-ms-win-crt-locale-l1-1-0.dll in this case). void PEUtility::fillImportTable(HMODULE loadedModule, FillImportFlag flag, std::function<void(HMODULE&)> callback) { std::stack<HMODULE> modules; modules

Thunk table in import address table?

两盒软妹~` 提交于 2019-11-30 07:15:00
问题 What is a thunk table in relation to the import address table that's used in EXE files to import functions used in external DLLs? Is this thunk table just a table containing 'Thunks' to other functions? 回答1: Thunks are a part of the Import table ( IMAGE_DIRECTORY_ENTRY_IMPORT ) and Delay Import Table ( IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT ). They are described http://msdn.microsoft.com/en-us/library/ms809762.aspx. I'll look at my old source code and will post later a working code which dump

How to programatically read native DLL imports in C#?

▼魔方 西西 提交于 2019-11-30 05:32:39
How can I programatically analyze a native DLL to read its imports? [EDIT: my original question looked like the following, along with a huge chunk of defective code. Please see answers below for more correct code.] The C# code located at this link is intended to print the imports of a native DLL. I find that when I run the sample code with the original example's target, MSCOREE.DLL, it prints all the imports fine. But when I use other dlls like GDI32.DLL or WSOCK32.DLL the imports do not get printed. What's missing from this code that would let it print all the imports as, for example, DUMPBIN

How can I validate digital signatures for Microsoft's Portable Executable format in portable code? [closed]

我的梦境 提交于 2019-11-30 05:01:26
I am looking for sample code (or libraries) that can help me validate digital signatures for Windows PE files (.exe, .dll, .cab, .etc) on non-Windows platforms using C++. I am looking for a platform-independent approach. Thanks! You could check at WINE's WinVerifyTrust implementation for a full programmatic way. And, actually, here is a good link How to verify executable digital signatures under Linux? that complains about WINE implementation (that was back in 2008), and thus, explains the process in a quite "portable" way, provided you have something similar to OpenSSL available in your

Parsing plain Win32 PE File (Exe/DLL) in .NET

家住魔仙堡 提交于 2019-11-29 18:41:01
问题 I need to parse plain Win32 DLL/Exe and get all imports and exports from it to show on console or GUI (i.e. Win Forms). Is it possible to parse Win32 DLL/Exe in C#.NET by reading its export/import tables and get managed types from it? As it's unmanaged PE, .NET doesn't allows you to convert unmanaged PE files to managed .NET assemblies, it only generates COM managed assemblies. How can I parse these tables and take all of its methods (signatures) in managed form. (e.g. if char* as argument,

Fill in DLL import table manually: IMAGE_IMPORT_DESCRIPTOR's Name field stores 0x0000FFFF

a 夏天 提交于 2019-11-29 18:17:25
My goal is to fill in Dll's import table manually in order to hook internal LoadLibrary calls (when you load library it may load another library inside its DllMain). Here is my code which fill in Import table recursively for each dll in dependecies hierarchy and it works fine except some dlls ( api-ms-win-crt-locale-l1-1-0.dll in this case). void PEUtility::fillImportTable(HMODULE loadedModule, FillImportFlag flag, std::function<void(HMODULE&)> callback) { std::stack<HMODULE> modules; modules.push(loadedModule); while (modules.size()) { auto module = modules.top(); modules.pop(); auto

what is the maximum size of a PE file on 64-bit Windows?

冷暖自知 提交于 2019-11-29 17:46:54
问题 It seems to me it's always going to be 4GB, because it uses the same size datatype (A DWORD)? Isn't a DWORD for the SizeOfImage always going to be 32-bits? Or am I mistaken about this limitation? Answer 4GB does indeed to seem to be the hard limit of ALL Portable Executable's (32-bit and 64-bit PE+). 回答1: According to the spec it is 32-bit unsigned value for a PE32+ image just like a PE32 image. However, in my testing with both 32-bit and 64-bit applications (PE32/PE32+ files) on Windows 7