Skip to content

Instantly share code, notes, and snippets.

@hasherezade
Created January 11, 2015 10:08
Show Gist options
  • Save hasherezade/f2240292924f46f39f90 to your computer and use it in GitHub Desktop.
Save hasherezade/f2240292924f46f39f90 to your computer and use it in GitHub Desktop.
Hook example - time
#include <ctime>
#include <iostream>
using namespace std;
int main() {
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
int year = now->tm_year + 1900;
int month = now->tm_mon + 1;
int day = now->tm_mday;
if ( month == 12 && day == 24) {
cout << "The pass is: XmassTree" <<endl;
return 0;
}
cout << "Today is: " << year << '-'
<< month << '-'
<< day
<< ", wait for Christmass Eve to get the password!" <<endl;
#ifdef _WINDOWS
system("pause");
#endif
return 0;
}
.686
.model flat,c
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
AppName db "DLL Skeleton",0
HelloMsg db "Hello, you're calling a function in this DLL",0
LoadMsg db "The DLL is loaded",0
UnloadMsg db "The DLL is unloaded",0
ThreadCreated db "A thread is created in this process",0
ThreadDestroyed db "A thread is destroyed in this process",0
.code
DllEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
.if reason==DLL_PROCESS_ATTACH
invoke MessageBox,NULL,addr LoadMsg,addr AppName,MB_OK
.elseif reason==DLL_PROCESS_DETACH
invoke MessageBox,NULL,addr UnloadMsg,addr AppName,MB_OK
.elseif reason==DLL_THREAD_ATTACH
invoke MessageBox,NULL,addr ThreadCreated,addr AppName,MB_OK
.else ; DLL_THREAD_DETACH
invoke MessageBox,NULL,addr ThreadDestroyed,addr AppName,MB_OK
.endif
mov eax,TRUE
ret
DllEntry Endp
_repeat proc param1:DWORD
mov eax, 549AD8F4h
ret
_repeat endp
End DllEntry
LIBRARY parrot
EXPORTS _repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment