1

How find address of loaded specific driver on memory by C language in windows os

enter image description here

thanks

3
/**
    \todo Get system info in loop. If the list grows between the first & 2nd call the allocd ammount may be too low
*/
BOOL GetKernelInformation(PSYSTEM_MODULE_INFORMATION* pModuleList)
{
    NTSTATUS status = STATUS_SUCCESS;
    ULONG neededSize = 0;

    NtQuerySystemInformation(
        SystemModuleInformation,
        &neededSize,
        0,
        &neededSize
        );

    *pModuleList = (PSYSTEM_MODULE_INFORMATION)malloc(neededSize);
    if(*pModuleList == NULL)
    {
        return FALSE;
    }

    status = NtQuerySystemInformation(SystemModuleInformation,
        *pModuleList,
        neededSize,
        0
        );

    return NT_SUCCESS(status);
}

int main()
{
    PSYSTEM_MODULE_INFORMATION pModuleList = NULL;

    if(!GetKernelInformation(&pModuleList))
        goto CLEANUP;

    for(ULONG i = 0; i < pModuleList->uCount; i++)
    {
        PSYSTEM_MODULE mod = &pModuleList->aSM[i];
        printf("%s @ %p\n", mod->ImageName, mod->Base);
    }


CLEANUP:
    if(pModuleList)
        free(pModuleList);
    return EXIT_SUCCESS;
}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.