Skip to content

Instantly share code, notes, and snippets.

@ntddk
Created July 5, 2014 17:33
Show Gist options
  • Save ntddk/cbcf704b4e3262e2d937 to your computer and use it in GitHub Desktop.
Save ntddk/cbcf704b4e3262e2d937 to your computer and use it in GitHub Desktop.
昔のAPI hook
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <detours.h>
DETOUR_TRAMPOLINE(DWORD WINAPI RealGT(LPTIME_ZONE_INFORMATION lpTimeZone), GetTimeZoneInformation);
DETOUR_TRAMPOLINE(void WINAPI RealSysTime(LPSYSTEMTIME time), GetSystemTime);
DWORD WINAPI DetourGTZI(LPTIME_ZONE_INFORMATION lpTimeZone)
{
DWORD ret = RealGT(lpTimeZone);
lpTimeZone->Bias = -480;
return ret;
}
void WINAPI DetourSysTime(LPSYSTEMTIME time)
{
RealSysTime(time);
time->wDay = 14;
time->wDayOfWeek = 3;
time->wYear = 2012;
time->wMonth = 11;
}
__declspec(dllexport) BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
DetourFunctionWithTrampoline((PBYTE)RealGT, (PBYTE)DetourGTZI);
DetourFunctionWithTrampoline((PBYTE)RealSysTime, (PBYTE)DetourSysTime);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment