Quelltext /~heha/hs/fakedate.zip/Version2/src/Fakehelp.c

/* Modifikation des Datums für einen Prozess,
 * 07/04 h#s
 */

#include "iwatchsu.h"
#include "detours.h"
#include "FakeHelp.h"

MYDATE MyDate;

DETOUR_TRAMPOLINE(VOID WINAPI oGetSystemTime(LPSYSTEMTIME st), GetSystemTime);
DETOUR_TRAMPOLINE(VOID WINAPI oGetLocalTime (LPSYSTEMTIME st), GetLocalTime);
 
VOID WINAPI MyGetSystemTime(LPSYSTEMTIME st) {
 oGetSystemTime(st);
 st->wYear=MyDate.year;
 st->wMonth=MyDate.month;
 st->wDay=MyDate.day;
}

VOID WINAPI MyGetLocalTime(LPSYSTEMTIME st) {
 oGetLocalTime(st);
 st->wYear=MyDate.year;
 st->wMonth=MyDate.month;
 st->wDay=MyDate.day;
}
#if 0
VOID WINAPI MyGetSystemTimeAsFileTime(LPFILETIME ft) {
 SYSTEMTIME st;
 MyGetSystemTime(&st);
 SystemTimeToFileTime(&st,ft);
}

BOOL WINAPI MyIsDebuggerPresent(VOID) {
 return FALSE;
}
#endif

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) {
 switch(fdwReason) {
  case DLL_PROCESS_ATTACH: {
   TCHAR buf[MAX_PATH],profile[MAX_PATH];
   DisableThreadLibraryCalls(hinstDLL);
   GetModuleFileName(0,buf,elemof(buf));
   GetModuleFileName(hinstDLL,profile,elemof(profile));
   lstrcpy(GetFileNameExt(profile),T(".INI"));
   MyDate.all=GetPrivateProfileInt(T("Apps"),buf,0,profile);
//   MyDate.day=7; MyDate.month=7; MyDate.year=2004;
   if (MyDate.all) {
    DetourFunctionWithTrampoline((PBYTE)oGetSystemTime,(PBYTE)MyGetSystemTime);
    DetourFunctionWithTrampoline((PBYTE)oGetLocalTime, (PBYTE)MyGetLocalTime);
   }
  }break;
  case DLL_PROCESS_DETACH: if (MyDate.all) {
   DetourRemove((PBYTE)oGetLocalTime, (PBYTE)MyGetLocalTime);
   DetourRemove((PBYTE)oGetSystemTime,(PBYTE)MyGetSystemTime);
  }break;
 }
 return TRUE;
}
Vorgefundene Kodierung: UTF-80