C
C
csar2016-09-19 23:33:53
Qt
csar, 2016-09-19 23:33:53

How to include a library in Qt?

Good day everyone.
I'm trying to work with the mhook library in Qt 5.
The code:

#include <windows.h>
#include <iostream>
#include "mhook-lib\mhook.h"


NTSTATUS (NTAPI * CurRtlQueryElevationFlags)(DWORD* pFlags) = NULL;

NTSTATUS NTAPI TimedRtlQueryElevationFlags(DWORD* pFlag)
{
    NTSTATUS ret = CurRtlQueryElevationFlags(pFlag);
    *pFlag = 0;
    return ret;
}

int main(int argc, char* argv[])
{
    CurRtlQueryElevationFlags = (NTSTATUS (NTAPI * )(DWORD* ))GetProcAddress(GetModuleHandle(L"ntdll.dll"), "RtlQueryElevationFlags");
    <b>if (Mhook_SetHook((PVOID*)&CurRtlQueryElevationFlags, (PVOID)TimedRtlQueryElevationFlags))</b>
        MessageBeep(MB_OK);

    if ((INT)ShellExecuteW(NULL, L"open", L"regedit.exe", NULL, NULL, SW_SHOWNORMAL) > 32)
    {
        printf("Success\n");
        return 0;
    }

    return 0;
}

The compiler swears - Undefined reference to "MHook_SetHook(void**,void*);
What's wrong? Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rou1997, 2016-09-19
@csar

except for the headers, nothing was connected.

And you need to include * .CPP too, so that they are compiled, or compiled into a library.

V
Vladimir Martyanov, 2016-09-19
@vilgeforce

The error is that you didn't include the library itself, but only its headers. There are, of course, times when this is sufficient. But judging by the error - not in your case.

C
csar, 2016-09-19
@csar

There are no compiled libraries in mhook, only h and cpp. I copied the code from the example where the project was compiled, except for the headers, nothing was connected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question