-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
56 lines (49 loc) · 1.32 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <Windows.h>
#include <wincrypt.h>
#include <stdlib.h>
#include <detours.h>
using fnCertVerifyTimeValidity = decltype(CertVerifyTimeValidity);
using fnGetLocalTime = decltype(GetLocalTime);
fnCertVerifyTimeValidity *m_pfnCertVerifyTimeValidity = NULL;
fnGetLocalTime *m_pfnGetLocalTime = NULL;
LONG WINAPI NewCertVerifyTimeValidity(
LPFILETIME pTimeToVerify,
PCERT_INFO pCertInfo
)
{
return 0;
}
VOID WINAPI NewGetLocalTime(
_Out_ LPSYSTEMTIME lpSystemTime
)
{
auto p = strstr(GetCommandLineA(), "-fuckyear ");
if (p)
{
auto year = atoi(p);
if (year >= 1900 && year <= 2100)
{
m_pfnGetLocalTime(lpSystemTime);
lpSystemTime->wYear = year;
return;
}
}
m_pfnGetLocalTime(lpSystemTime);
}
extern "C" __declspec(dllexport) int test()
{
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
m_pfnCertVerifyTimeValidity = (fnCertVerifyTimeValidity *)GetProcAddress(LoadLibraryW(L"crypt32.dll"), "CertVerifyTimeValidity");
m_pfnGetLocalTime = (fnGetLocalTime *)GetProcAddress(LoadLibraryW(L"kernel32.dll"), "GetLocalTime");
DetourTransactionBegin();
DetourAttach(&(void *&)m_pfnCertVerifyTimeValidity, NewCertVerifyTimeValidity);
DetourAttach(&(void *&)m_pfnGetLocalTime, NewGetLocalTime);
DetourTransactionCommit();
}
return 1;
}