Skip to content

when dll memory loadlibrary dll will be crash! #13

Open

Description

@warsark

1.the test.exe memload a.dll
2.a.dll compile with memorymodulepp.lib
3.in a.dll dllmain DLL_PROCESS_ATTACH memload b.dll

if use test.exe memlod b.dll it's ok!
but use test.exe memload a.dll,in a.dll memload b.dll will crash in test.exe call a.dllmain

I comment //static const BOOL MmpStaticInitializer = MmpInitialize();
then call MmpInitialize before LdrLoadDllMemoryExW
the a.dll load successful, but a.dll call MmpInitialize crash
auto tls = CONTAINING_RECORD(NtCurrentTeb()->ThreadLocalStoragePointer, TLS_VECTOR, TLS_VECTOR::ModuleTlsData);
if (tls && tls->Length > MMP_START_TLS_INDEX) {
RtlRaiseStatus(STATUS_NOT_SUPPORTED);-->crash here
return FALSE;
}

Activity

  1. bb107 commented on Sep 7, 2022

    @bb107
    Owner

    Hi. MMP maintains a private TLS list internally to support TLS without locating the LdrpHandleTlsData routine by signature. The MMP will take over the TlsVector for all threads in the process, so it can only be initialized once. If you must link statically in a different module, use the previous version of MMP that did not handle TLS.
    A good practice is to always link the MMP in the exe file and expose the MMP API as a function pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions