<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Whizit - Hard Wired</title>
	<atom:link href="https://www.hardwired.dev/author/whizit/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.hardwired.dev</link>
	<description></description>
	<lastBuildDate>Sun, 28 Dec 2025 05:17:51 +0000</lastBuildDate>
	<language>cs</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.hardwired.dev/wp-content/uploads/2022/10/android-chrome-256x256-1-150x150.png</url>
	<title>Whizit - Hard Wired</title>
	<link>https://www.hardwired.dev</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Portable Executable (PE) Format</title>
		<link>https://www.hardwired.dev/2025/12/01/portable-executable/</link>
		
		<dc:creator><![CDATA[Whizit]]></dc:creator>
		<pubDate>Mon, 01 Dec 2025 17:00:42 +0000</pubDate>
				<category><![CDATA[Cyber Security]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Různé]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[binary analysis]]></category>
		<category><![CDATA[code analysis]]></category>
		<category><![CDATA[COFF]]></category>
		<category><![CDATA[cybersecurity]]></category>
		<category><![CDATA[digital forensics]]></category>
		<category><![CDATA[dll files]]></category>
		<category><![CDATA[DOS header]]></category>
		<category><![CDATA[exe files]]></category>
		<category><![CDATA[executable files]]></category>
		<category><![CDATA[file headers]]></category>
		<category><![CDATA[file structure]]></category>
		<category><![CDATA[malware analysis]]></category>
		<category><![CDATA[Malware Development Essentials]]></category>
		<category><![CDATA[NT headers]]></category>
		<category><![CDATA[PE format]]></category>
		<category><![CDATA[PE-bear]]></category>
		<category><![CDATA[Portable Executable]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[security-research]]></category>
		<category><![CDATA[threat analysis]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows OS]]></category>
		<guid isPermaLink="false">https://www.hardwired.dev/?p=2890</guid>

					<description><![CDATA[<p>Portable Executable is file format which is used in Windows OS for executable files like .exe, .dll, .cpl etc. It &#62;&#62;&#62;</p>
<p>The post <a href="https://www.hardwired.dev/2025/12/01/portable-executable/">Portable Executable (PE) Format</a> first appeared on <a href="https://www.hardwired.dev">Hard Wired</a>.</p>]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p><strong>Portable Executable</strong> is file format which is used in Windows OS for executable files like <em>.exe, .dll, .cpl etc</em>. It is based on <strong>COFF</strong> (<strong>Common Object File Format</strong>).</p>
<p>A PE file is a data structure that holds information necessary for OS loader to load that executable into memory and execute it.</p>
<p>This article serves as basic overview of PE structure, understanding of which is useful for reverse engineering and understanding not just malware binaries.</p>
<h2>Note</h2>
<p>Examples provided in this article will be taken from random executable file, opened using analytics tool named <a href="https://github.com/hasherezade/pe-bear/releases" title="PE-bear">PE-bear</a>.</p>
<p>Code examples are from winnt.h WinAPI file. You can download these files as part of Visual Studio.</p>
<h2>Structure</h2>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2025/11/PEStructure-207x300.avif" alt="" /></p>
<h3>DOS Header</h3>
<p>Is represented by first 64 bytes of every PE file. Following parts are the most important:<br />
<strong>e_magic</strong> - Every PE File starts with 2 byte magic number <em>0x5A4D</em>. It is used to verify if it is valid executable. The value can be seen in reverse order in screenshot below, due to <em>Windows using little endian encoding</em><br />
<strong>e_lfanew</strong> - These 4 bytes contain the offset of PE header. When the program needs to be loaded by Windows loader, it looks for this value to skip the DOS Stub and go directly to NT headers.</p>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2025/12/DOSHeader-300x87.avif" alt="" /></p>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2025/12/DOSHeader_WinApi-PNG-300x176.avif" alt="" /></p>
<h3>DOS Stub</h3>
<p>Usually contains message <strong>&quot;This program cannot be run in DOS mode&quot;</strong>. It is used as fallback for older DOS systems that cannot process PE files.<br />
<img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2025/12/DOSStub-300x39.avif" alt="" /></p>
<h3>NT Headers</h3>
<p>Are accesssed from address in <em>e_lfanew</em></p>
<p><strong>Signature</strong> - Serves for checking validity of the structure, has value of <em>Ox4550</em> (PE)<br />
<strong>File Headers</strong> - Contains information about structure of the whole file, such as the machine type of the executable code, a time stamp, a pointer to symbol table and various flags. Value in machine type can help you determine whether the executable is 32(value 0x4c) or 64 bit (value 0x64)<br />
<strong>Optional Headers</strong> - Unlike name suggests, this header is not actually optional. It contains additional important information to <em>File Headers</em>, another magic number that determines whether file is 32/64bit, information about running subsystem, Preffered base address and security flags. Another important part is import,export, resource tables etc. which contain used APIs, imported functions, string and other static resources.<br />
<img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2025/12/32bitSignature-300x79.avif" alt="" /></p>
<h3>Section Header</h3>
<p>Is an array that contains memory locations for each section.</p>
<h3>Sections</h3>
<p><strong>.text</strong> - Contains the executable code. This section includes all compiled instructions that the processor will execute. The section is typically marked as executable and read-only for security purposes.</p>
<p><strong>.data</strong> - Contains initialized global data. This includes variables with initial values that the program requires during execution. The section is marked as readable and writable.</p>
<p><strong>.rdata</strong> - Contains read-only data, including import and export tables. It stores constant data, string literals, and critical tables that support dynamic linking functionality.</p>
<p><strong>.rsrc</strong> - Contains resources such as icons, images, and strings. This section organizes resources in a hierarchical structure that applications can access during runtime.</p>
<p><strong>.reloc</strong> - Contains relocation table that is used by loader for recalculating addresses in case the executable is not loaded at base address.</p>
<p><strong>.tls</strong>(Thread Local Storage)- is a special storage  class that contains thread specific data.</p>
<p><em>This list of sections is not exhaustive, just explains the most common ones.</em></p>
<p>When analyzing PE file, <em>malicious executables can have unusually small or large headers or sections</em>. Unusually large header can be a <em>sign of obfuscation</em> and for example small or empty import table can be sign of <em>dynamic loading</em> of libraries which is common for malware.</p>

<div class="twitter-share"><a href="https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.hardwired.dev%2F2025%2F12%2F01%2Fportable-executable%2F&#038;via=hessevalentino" class="twitter-share-button">Tweet</a></div><p>The post <a href="https://www.hardwired.dev/2025/12/01/portable-executable/">Portable Executable (PE) Format</a> first appeared on <a href="https://www.hardwired.dev">Hard Wired</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Windows Architecture &#038; WinAPI</title>
		<link>https://www.hardwired.dev/2024/04/23/windows-architecture-winapi/</link>
		
		<dc:creator><![CDATA[Whizit]]></dc:creator>
		<pubDate>Tue, 23 Apr 2024 21:45:08 +0000</pubDate>
				<category><![CDATA[Cyber Security]]></category>
		<category><![CDATA[Různé]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Malware Development Essentials]]></category>
		<category><![CDATA[Memory Management]]></category>
		<category><![CDATA[WinAPI]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">https://www.hardwired.dev/?p=2172</guid>

					<description><![CDATA[<p>Windows Architecture Windows architecture follows layered design with two main components: User Mode This mode is made of system processes, &#62;&#62;&#62;</p>
<p>The post <a href="https://www.hardwired.dev/2024/04/23/windows-architecture-winapi/">Windows Architecture & WinAPI</a> first appeared on <a href="https://www.hardwired.dev">Hard Wired</a>.</p>]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><h1>Windows Architecture</h1>
<p>Windows architecture follows layered design with two main components:</p>
<h3>User Mode</h3>
<p>This mode is made of  system processes, services, application and environments running on the system. All of these components have limited access to hardware and rely on <strong>kernel mode</strong> for hardware interaction.<br />
Interface between user mode and kernel functions is called environment subsystem.<br />
Each of these implement different API sets.<br />
Three main environment subsystems exist:<br />
1.Win32<br />
2.OS/2<br />
3.POSIX</p>
<h3>Security subsystem</h3>
<p>Deals with security tokens, manages access to resources based on permissions, handles authentication. Manages <strong>Active Directory</strong></p>
<h3>Kernel Mode</h3>
<p>Has full access to system hardware and resources and runs code in Protected Memory. Kernel mode handles memory management, device drivers, process management, thread prioritization etc.</p>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2024/04/WinArchitecture-232x300.png" alt="" /></p>
<h3>System Call</h3>
<p>When user mode program needs access to any restricted resource or hardware, it makes system call. This call is processed by kernel mode.</p>
<h3>Hardware Abstraction Layer</h3>
<p>Acts as a bridge between kernel mode and hardware. Translates generic kernel instructions to specific instructions for given hardware.</p>
<h1>Memory Management</h1>
<p>Windows has sophisticated memory management system for physical(RAM) and virtual(RAM and Disk) memory utilization.</p>
<p><strong>Virtual Address Space</strong> - is set of virtual memory that process can use. This memory is private and cannot be accessed by other processes unless shared.<br />
Virtual address does not represent physical location in memory. System maintains internal data structure <em>Page Table</em> for each process. Every time thread references virtual address, system translates it to physical one.<br />
<em>Virtual address space</em> is divided into two <em>partitions - system and process</em>.</p>
<h3>Memory Types</h3>
<ul>
<li><strong>User mode/Kernel mode</strong>:<br />
Memory allocations are segregated based on mode to ensure security</li>
<li><strong>x86/x64</strong>:<br />
Represent addressable memory space for different CPU architectures. Every 32-bit(<em>x86</em>) app has up to <em>4GB</em> of virtual memory space, while 64-bit (<em>x64</em>) has up to 8TB.</li>
<li><strong>Paged Pool</strong>:<br />
Dynamically allocated memory that can be swapped between RAM and paging file on disk. This serves as memory usage optimization, or when RAM memory is full.</li>
<li><strong>Non-paged pool</strong>:<br />
Hold critical kernel mode data that must be always accessible in RAM as long as corresponding objects are allocated. This data is not paged to disk.</li>
</ul>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2024/04/WinMemoryManagement.png" alt="" /></p>
<h3>Page States</h3>
<ul>
<li><strong>Free</strong>: The page is available to be reserved, committed, or simultaneously reserved and committed</li>
<li><strong>Reserved</strong>: The page is reserved for future use, but it does <em>not have any physical storage associated</em> with it. Reserved memory cannot be used by other functions</li>
<li><strong>Committed</strong>: Memory have been allocated in RAM/paging file(s) on disk. Page is accessible and access is controlled by <strong>Memory Protection Constants</strong></li>
</ul>
<h3>Memory Protection Constants</h3>
<p>These constants specify permissions, which define operations that can be done on specified memory region. There is many of them, so I will list just a few that are probably most common, the rest can be found in <a href="https://learn.microsoft.com/en-us/windows/win32/memory/memory-protection-constants" title="Microsoft Documentation">Microsoft Documentation</a>.</p>
<ul>
<li><strong>PAGE_EXECUTE_READWRITE</strong> - Enables execute, read-only, or read/write access to the committed region of pages</li>
<li><strong>PAGE_READWRITE</strong> - Enables read-only or read/write access to the committed region of pages</li>
<li><strong>PAGE_READONLY</strong> - Enables read-only access to the committed region of pages<br />
...</li>
</ul>
<h3>C++ Code Example</h3>
<p>Let's apply previous information to allocate memory in a process.</p>
<pre><code>LPVOID memBlock = VirtualAllocEx(hProcess, NULL, sizeof(payload), (MEM_RESERVE | MEM_COMMIT), PAGE_EXECUTE_READWRITE);</code></pre>
<p>Here, we allocate variable 'memBlock' of 'LPVOID' type, assigning it result of 'VirtualAllocEx'(memoryapi.h) function. LPVOID represents address of any type.<br />
Executing this function commits memory to which we can write data later.<br />
Parameters:</p>
<ol>
<li>hProcess is handle to process in which virtual address space the memory will be allocated</li>
<li>This parameter specifies starting address. NULL means function will determine where to allocate the region</li>
<li>Size of memory region to allocate in bytes</li>
<li>Set page state, multiple can be used with bitwise '|' operator </li>
<li>Requires memory protection constant</li>
</ol>
<h2>Data Execution Prevention (DEP)</h2>
<p>Is a security technology, that makes some pages in memory non-executable. This prevents potential attackers from executing malicious code in these regions of memory using exploits like buffer overflow.</p>
<h2>Address Space Layout Randomization (ASLR)</h2>
<p>Is a security technique that randomizes base addresses of processes, DLL's and critical data structures like <em>stack and heap</em>. This prevents the attacker from hardcoding memory locations, which are like to be changed on each application restart. It also makes mistakes expensive, since writing to wrong address leads to application crash.<br />
Effectiveness of this technique can be significantly diminished by reducing entropy.</p>
<p><img decoding="async" src="https://www.hardwired.dev/wp-content/uploads/2024/04/ASLR-300x87.png" alt="" /></p>
<h2>WinAPI</h2>
<p>WinAPI is a collection of functions, divided between many DLL's, that allow applications to interact with underlying Windows functionalities through code.<br />
Many of these functions are documented in <a href="https://learn.microsoft.com/en-us/windows/win32/api/" title="Win32 API MSDN">Win32 API MSDN</a>.</p>
<h3>Important Windows DLL's</h3>
<ul>
<li>kernel32.dll - Exposes functions for memory management, file system access and console I/O, thread creation...</li>
<li>user32.dll - Provides functions for managing windows, menus, controls and handling user input</li>
<li>ntdll.dll - Many user mode API's rely on ntdll, as it exposes Native API</li>
<li>ws2_32.dll - Implements Windows Websocket API, it is crutial for network programming</li>
<li>advapi32.dll - Provides security features like authentication, access control and registry manipulation</li>
</ul>

<div class="twitter-share"><a href="https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.hardwired.dev%2F2024%2F04%2F23%2Fwindows-architecture-winapi%2F&#038;via=hessevalentino" class="twitter-share-button">Tweet</a></div><p>The post <a href="https://www.hardwired.dev/2024/04/23/windows-architecture-winapi/">Windows Architecture & WinAPI</a> first appeared on <a href="https://www.hardwired.dev">Hard Wired</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
