#pragma option w32c
#jumptomain NONE
#include "win.hmm"

#include "rsrc.RC"


int f;
main(){
  if(f=CreateFile("\\\\.\\DPKBHOOK.VXD",0,0,0,OPEN_EXISTING,FILE_FLAG_DELETE_ON_CLOSE,0)==-1)
    MessageBox(0,"cant load vxd",":(",MB_OK);
  else
  {
    LoadLibrary("riched32.dll");
    EAX=0;
    DialogBoxParam(EAX,IDD_FORMVIEW,EAX,#DlgProc,EAX);

    CloseHandle(f);
  }
}


dword dlgrich;

dword temp[64];
byte string[256];

void cdecl printrich(){
  static byte tmpstring[256];

  $pop EDI;
  $pop temp[20];
  EBX=dlgrich;
  wsprintf(#tmpstring);
  SendMessage(EBX,EM_SETSEL,-1,-1);
  temp=60;
//  $push 0x40;$pop temp[7];//temp[4]=0x40000000;
  DSBYTE[#temp+7]=0x40;
  //temp[8]=0;
  SendMessage(EBX,WM_USER + 68,1,#temp);
  SendMessage(EBX,EM_REPLACESEL,0,#tmpstring);
  SendMessage(EBX,WM_VSCROLL,SB_THUMBPOSITION|0x70000000,0);
  $push EAX
  goto EDI;
}

dword oldkey;
dword oldtime;
char temps[MAX_PATH];
dword dlg;
DlgProc(dword hwnd,wmsg,wpar,lpar)
uses EBX,EDI
{
  switch(wmsg)
  {
    case WM_INITDIALOG:
                dlg=hwnd;
                dlgrich=GetDlgItem(hwnd,IDC_RICHEDIT1);
                DeviceIoControl(f,1,#dlg,sizeof(dlg),0,0,ESP,0);
                printrich(0,"press ctrl+alt+del =)\n");
                break;
    case WM_USER:
                if(lpar!=oldkey)
                {
                  if(GetTickCount()-oldtime>100)printrich(0,"\n");
                  printrich(0,"%X ",lpar);
                  oldtime=GetTickCount();
                }
                oldkey=lpar;
                break;
    case WM_CLOSE:
                QUITPROGRAM:
                EndDialog(hwnd,0); break;
    case WM_COMMAND:
                SWITCH(wpar){
                        CASE IDD_OK:

                        case IDCANCEL:
                        CASE IDD_CLOSE:   goto QUITPROGRAM;
                                break;
                }
                break;
  }
  return 0;
}