Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
771 B
1
Indexable
Never
PIMAGE_DATA_DIRECTORY tlsDirectory = (PIMAGE_DATA_DIRECTORY) & parser -> pinh -> OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS];

if (tlsDirectory -> Size) 
{
    PIMAGE_TLS_DIRECTORY tls = (PIMAGE_TLS_DIRECTORY)((DWORD_PTR) parser -> pMapView + tlsDirectory -> VirtualAddress);

    DWORD size = tls -> EndAddressOfRawData - tls -> StartAddressOfRawData;

    PIMAGE_SECTION_HEADER tlsSection = parser -> createSection(".tls", size,
            IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ);

    DWORD tlsDstAddress = (DWORD_PTR) parser -> pMapView + tlsSection -> PointerToRawData;
    DWORD tlsSrcAddress = (DWORD_PTR) parser -> pMapView + tls -> StartAddressOfRawData;

    memcpy((PVOID) tlsDstAddress, (PVOID) tlsSrcAddress, size);
}