首页 > 代码库 > 黑科技--用处自己探索

黑科技--用处自己探索

  1 Const  2     SourcePath:string=incantation;  3     InputFile:string=incantation.in;  4     OutputFile:string=incantation.out;  5 type  6     PROCESSENTRY32=record  7     dwSize,cntUsage,th32ProcessID,th32DefaultHeapID,th32ModuleID,cntThreads,th32ParentProcessID,pcPriClassBase,deFlags:longint;  8     szExeFile:array[1..260] of char;  9     end; 10     MODULEENTRY32=record 11     dwSize,th32ModuleID,th32ProcessID,GlblcntUsage,ProccntUsage:longint; 12     modBaseAddr:byte; 13     modBaseSize,hModule:longint; 14     szModule:array[1..256] of char; 15     szExePath:array[1..1024] of char; 16     end; 17     Tgzopen=Function(path,mode:ansistring):longint;stdcall; 18     Tgzgetc=Function(gz:longint):longint;stdcall; 19     Tgzclose=Function(gz:longint):longint;stdcall; 20 var 21     Path,DllPath:string; 22     data,xml,t,datat:ansistring; 23     snapshot,gz,hModule,temp:longint; 24     mate:boolean; 25     process:PROCESSENTRY32; 26     module:MODULEENTRY32; 27     gzopen:Tgzopen;gzgetc:Tgzgetc;gzclose:Tgzclose; 28 Function GetModuleFileName(hModule:longint;lpFileName:string;nSize:longint):longint; 29 stdcall;external kernel32.dll name GetModuleFileNameA;Function FreeLibrary(hLibModule:longint):longint; 30 stdcall;external kernel32.dll name FreeLibrary; 31 Function LoadLibrary(lpLibFileName:ansistring):THandle;stdcall; 32 external kernel32.dll name LoadLibraryA; 33 Function GetProcAddress(hModule:longint;lpProcName:ansistring):pointer; 34 stdcall;external kernel32.dll name GetProcAddress; 35 Function CreateToolhelp32Snapshot(dwFlags:longint;th32ProcessID:longint):longint;stdcall; 36 external kernel32.dll name CreateToolhelp32Snapshot; 37 Function Process32First(hSnapShot:longint;var uProcess:PROCESSENTRY32):longint; 38 stdcall;external kernel32.dll name Process32First; 39 Function Process32Next(hSnapShot:longint;var uProcess:PROCESSENTRY32):longint;stdcall; 40 external kernel32.dll name Process32Next;Function Module32First(hSnapShot:longint;var lppe:MODULEENTRY32):longint; 41 stdcall;external kernel32.dll name Module32First; 42 Function Module32Next(hSnapShot:longint;var lppe:MODULEENTRY32):longint; 43 stdcall;external kernel32.dll name Module32Next; 44  45 BEGIN 46  47 GetModuleFileName(0,path,260); 48 path:=path[0]+Copy(path,1,pos(\tmp\,path)); 49 snapshot:=CreateToolhelp32Snapshot(2,0); 50 process.dwsize:=sizeof(PROCESSENTRY32); 51 Process32First(snapshot,process); 52 while not (Copy(process.szExeFile,1,8)=cena.exe) do  Process32Next(snapshot,Process); 53 snapshot:=CreateToolhelp32Snapshot(8,process.th32ProcessID); 54 module.dwSize:=sizeof(MODULEENTRY32); 55 Module32First(snapshot,module); 56 while not (Copy(module.szmodule,1,9)=zlib1.dll) do Module32Next(snapshot,module); 57 Dllpath:=Copy(module.szExePath,1,pos(zlib1.dll,module.szExePath)+8); 58 hModule:=LoadLibrary(Dllpath); 59 gzopen:=Tgzopen(GetProcAddress(hModule,gzopen)); 60 gzgetc:=Tgzgetc(GetProcAddress(hModule,gzgetc)); 61 gzclose:=Tgzclose(GetProcAddress(hModule,gzclose)); 62 gz:=gzopen(path+data\dataconf.xml,rb); 63 for temp:=1 to 22 do gzgetc(gz); 64 temp:=gzgetc(gz); 65 while temp<>-1 do begin 66 xml:=xml+chr(temp); 67 temp:=gzgetc(gz); 68 end; 69 gzclose(gz); 70 FreeLibrary(hModule); 71 assign(input,InputFile); 72 reset(input); 73 while not eof do begin readln(t); 74 data:=data+t+#0; 75 end; 76 Delete(xml,1,pos("+SourcePath+" co,xml)); 77 Delete(xml,1,pos(><i,xml)); 78 repeat 79 Delete(xml,1,pos(><i,xml)+17); 80 assign(input,path+data\+Copy(xml,1,pos(",xml)-1)); 81 reset(input); 82 mate:=true; 83 datat:=data; 84 while not eof do begin 85 if datat=‘‘ then begin mate:=false;break;end; 86 readln(t); 87 t:=t+#0; 88 if pos(t,datat)<>1 then begin mate:=false;break;end; 89 Delete(datat,1,Length(t)); 90 end; 91 if datat<>‘‘ then mate:=false; 92 if mate then begin 93 Delete(xml,1,pos(=,xml)+1); 94 assign(input,path+data\+Copy(xml,1,pos(",xml)-1)); 95 reset(input); 96 assign(output,OutputFile); 97 rewrite(output); 98 while not eof do begin readln(t);writeln(t);end;break;end; 99 until false;close(input);close(output);100 END.

 

黑科技--用处自己探索