#pragma option dll
#pragma option lst
#pragma option wbss
#pragma option wsi
#jumptomain NONE


#define _WINBASE_ TRUE
#define _COMMCTRL_ TRUE
#define _COMMDLG_ TRUE
#include "windows.h--"

extern WINAPI "IMAGEHLP.DLL"{
  dword ImageNtHeader(dword);
}

dword dllinst;
char title[MAX_PATH];//="JumpFIX by Den Po [GEN_JFIX.DLL]";
byte upcasetbl[MAX_PATH];
char fname[MAX_PATH];

_export int winampGetGeneralPurposePlugin(){return #dll;}

byte magic[]={
  0x8A,0x01,0x3C,0x41,0x7C,0x08,0x3C,0x5A,0x7F,
  0x04,0x04,0x20,0x88,0x01,0x41,0x80,0x39,0x00,
  0x75,0xEC
};


int main(dword hinstDLL,fdwReason,reserved)
{
  dllinst=hinstDLL;
  return 1;
}

cdecl int mycompare(int filename,findstring){
  $push ESI,EDI,ECX;
  while(){
    EDI=filename;
    EAX=DSBYTE[EDI];
    IF(!EAX)BREAK;
    ESI=findstring;
    do{
      EAX=upcasetbl[DSBYTE[ESI ]];
      IF(!EAX){EAX++;GOTO OK;}
      ECX=upcasetbl[DSBYTE[EDI ]];
      ESI++;
      EDI++;
    }while(ECX==EAX);
    filename++;
  }
  OK:
  $pop ECX,EDI,ESI;
}

int init()
{
  int old;

  $pushad;
  EDI=#upcasetbl;
  GetModuleFileName(dllinst,EDI,sizeof(upcasetbl));
  GetFileTitle(EDI,#fname,sizeof(fname));

  $cld;AL=0;do{$stosb;AL++;}while(!ZEROFLAG);
  CharUpperBuff(#upcasetbl,sizeof(upcasetbl)+sizeof(fname));

  wsprintf(#title,"JumpFIX v1.1 by Den Po [%s]",#fname);

  ESI=GetModuleHandle(0);
  EDX=ImageNtHeader(ESI);DH++;
  EBX=DSDWORD[EDX];
  EDX=DSDWORD[EDX+4]+ESI;
//---------------------------------------------------
  loop(EBX){
    ESI=#magic;
    ECX=sizeof(magic);
    EDI=EDX;
    $cld;
    $rep;$cmpsb;
    IF(ZEROFLAG){
      EDX&=!3;
      WHILE(DSDWORD[EDX]!=0x81EC8B55)EDX-=4;
      $push EBX,EDX
      VirtualProtect(EDX,5,PAGE_EXECUTE_READWRITE,#old);
      $pop EDX,EBX
      DSBYTE[EDX]=0xE9;DSDWORD[EDX+1]=#mycompare-5-EDX;// "JMP mycompare"
      VirtualProtect(EDX,5,old,0);
      BREAK;
    }
    EDX++;
  }
  $popad;
  return 0;
}

done(){return;}

char info="JumpFIX by Den Po/DaMage

Исправление диалога 'Jump to file'
для поддержки русского языка

fido:\t2:5066/68.19
e-mail:\tden_po@chat.ru"o;

byte cfgdlg=0;
cfg()
{

  IF(!cfgdlg){
    cfgdlg++;
    MessageBoxA(0,#info,"about",MB_OK);
    cfgdlg--;
  }
}

#aligncode 4
dword dll={
  0x10
 ,#title
 ,#init
 ,#cfg
 ,#done
};
