1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-05-18 22:02:23 +02:00
OJ 4ffe127f04
Begin removing the delay-load dependency
The 'common' library has been removed. The only project that actually
used it was metsrv, so the code that metsrv required from common is now
directly compiled in as part of that project.

The common folder now contains files that are importanta cross all of
the projects, with a primary focus on the new "API" style function. What
this means is that MetSrv has an API that it exposes through a function
pointer that is passed to the extension when it's initialised. This
pointer references a structure with all the API functions wired in. This
means that:

* Extensions don't need to know anything about metsrv at compile time.
* The delay loading code can be removed, which was one of the last
  instances of "metsrv.dll" as a string.
* Metsrv.dll no longer exports any functions.

More to come.
2020-04-22 13:06:40 +10:00

62 lines
1.3 KiB
C

#include "precomp.h"
#include "common_metapi.h"
/*
#ifdef _WIN64
// sf: for the x64 build we dont need to redifine this
#else
typedef struct tagLASTINPUTINFO {
UINT cbSize;
DWORD dwTime;
} LASTINPUTINFO, *PLASTINPUTINFO;
#endif
*/
/*
* Returns the number of seconds the local user has been idle
*/
DWORD request_ui_get_idle_time(Remote *remote, Packet *request)
{
LASTINPUTINFO info;
HMODULE user32 = NULL;
Packet *response = met_api->packet.create_response(request);
DWORD result = ERROR_SUCCESS;
BOOL (WINAPI *getLastInputInfo)(PLASTINPUTINFO) = NULL;
do
{
// Load user32
if (!(user32 = LoadLibrary("user32")))
{
result = GetLastError();
break;
}
// Resolve the address of GetLastInputInfo (Windows 2000+)
if (!(getLastInputInfo = (BOOL (WINAPI *)(PLASTINPUTINFO))GetProcAddress(
user32, "GetLastInputInfo")))
{
result = GetLastError();
break;
}
info.cbSize = sizeof(info);
if (getLastInputInfo(&info))
met_api->packet.add_tlv_uint(response, TLV_TYPE_IDLE_TIME,
(GetTickCount() - info.dwTime) / 1000);
else
result = GetLastError();
} while (0);
// Unload the library
if (user32)
FreeLibrary(user32);
// Transmit the response packet
met_api->packet.transmit_response(result, remote, response);
return ERROR_SUCCESS;
}