Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transmission parameter through MapImage #83

Closed
Qazwar opened this issue Jun 3, 2016 · 1 comment
Closed

transmission parameter through MapImage #83

Qazwar opened this issue Jun 3, 2016 · 1 comment

Comments

@Qazwar
Copy link

Qazwar commented Jun 3, 2016

using "mmap().MapImage()" how to pass a parameter to lpvReserved In DllMain

targetProcess.mmap().MapImage(L"TestDll.dll",blackbone::NoFlags, nullptr,nullptr/*,CustomArgs_t*/);
BOOL WINAPI DllMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        if((INT)lpvReserved== 123456)
            MessageBox(0, L"ATTACH", L"TestDll", 0);
        return TRUE;
@DarthTon
Copy link
Owner

DarthTon commented Jun 4, 2016

In loader

struct DllArgs
{
    char fmt[80];
    char cval[16];
    int ival;
    float fval;
    bool bval;
} dll_args;

strcpy_s( dll_args.fmt, "DllArgs received. cval: %s, ival: %d, fval: %0.3f, bval: %i\r\n" );
strcpy_s( dll_args.cval, "Some text" );
dll_args.ival = 12345;
dll_args.fval = 7.567f;
dll_args.bval = true;

CustomArgs_t cargs( &dll_args );

targetProcess.mmap().MapImage( path, flags, nullptr, nullptr, &cargs );

In DLL

struct ArgsBase
{
    long long size;
};

struct CustomArgs : ArgsBase
{
    char fmt[80];
    char cval[16];
    int ival;
    float fval;
    bool bval;
};


BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )
{
    auto pArgs = (CustomArgs*)lpReserved;
    printf( pArgs->fmt, pArgs->cval, pArgs->ival, pArgs->fval, pArgs->bval );
    ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants