Module: D:\SOURCE\WORK\HOSTS\find.cpp Group: 'DGROUP' CONST,CONST2,_DATA,_BSS Segment: find_TEXT WORD 0000012a bytes #include "hostsrvs.hpp" #include #include #include #include extern "C" int CALLBACK LocateHostServices(LPSTR location) { char buf[256]; //try the directory where winsock.dll is located 0000 LOCATEHOSTSERVICES: 0000 1e push ds 0001 58 pop ax 0002 90 nop 0003 45 inc bp 0004 55 push bp 0005 89 e5 mov bp,sp 0007 1e push ds 0008 8e d8 mov ds,ax 000a 56 push si 000b 57 push di 000c 81 ec 96 01 sub sp,0196H 0010 8b 76 08 mov si,+8H[bp] HINSTANCE hinst=LoadLibrary("winsock.dll"); 0013 68 00 00 push seg L3 0016 68 00 00 push offset L3 0019 9a 00 00 00 00 call far LOADLIBRARY 001e 89 c7 mov di,ax if(hinst>HINSTANCE_ERROR) { char drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT]; 0020 3d 20 00 cmp ax,0020H 0023 0f 86 8b 00 jbe L1 GetModuleFileName(hinst,buf,256); 0027 50 push ax 0028 8d 96 64 fe lea dx,-19cH[bp] 002c 16 push ss 002d 52 push dx 002e 68 00 01 push 0100H 0031 9a 00 00 00 00 call far GETMODULEFILENAME FreeLibrary(hinst); 0036 57 push di 0037 9a 00 00 00 00 call far FREELIBRARY _splitpath(buf,drive,dir,fname,ext); 003c 8d 56 f0 lea dx,-10H[bp] 003f 16 push ss 0040 52 push dx 0041 8d 56 e6 lea dx,-1aH[bp] 0044 16 push ss 0045 52 push dx 0046 8d 96 64 ff lea dx,-9cH[bp] 004a 16 push ss 004b 52 push dx 004c 8c d1 mov cx,ss 004e 8d 5e f6 lea bx,-0aH[bp] 0051 8c d2 mov dx,ss 0053 8d 86 64 fe lea ax,-19cH[bp] 0057 9a 00 00 00 00 call far _splitpath_ _makepath(buf,drive,dir,"hosts",""); 005c 68 00 00 push seg L3 005f 68 0c 00 push offset L4 0062 68 00 00 push seg L3 0065 68 0d 00 push offset L5 0068 8d 96 64 ff lea dx,-9cH[bp] 006c 16 push ss 006d 52 push dx 006e 8c d1 mov cx,ss 0070 8d 5e f6 lea bx,-0aH[bp] 0073 8c d2 mov dx,ss 0075 8d 86 64 fe lea ax,-19cH[bp] 0079 9a 00 00 00 00 call far _makepath_ if(access(buf,F_OK)==0) { 007e 31 db xor bx,bx 0080 8c d2 mov dx,ss 0082 8d 86 64 fe lea ax,-19cH[bp] 0086 9a 00 00 00 00 call far access_ 008b 85 c0 test ax,ax 008d 75 23 jne L1 strcpy(location,drive); 008f 8c d1 mov cx,ss 0091 8d 5e f6 lea bx,-0aH[bp] 0094 8b 46 06 mov ax,+6H[bp] 0097 89 f2 mov dx,si 0099 9a 00 00 00 00 call far strcpy_ strcat(location,dir); 009e 8c d1 mov cx,ss 00a0 8d 9e 64 ff lea bx,-9cH[bp] 00a4 8b 46 06 mov ax,+6H[bp] 00a7 89 f2 mov dx,si 00a9 9a 00 00 00 00 call far strcat_ return 0; } } //try Windows directory 00ae 31 c0 xor ax,ax 00b0 eb 6d jmp L2 GetWindowsDirectory(location,144); 00b2 56 L1 push si 00b3 ff 76 06 push +6H[bp] 00b6 68 90 00 push 0090H 00b9 9a 00 00 00 00 call far GETWINDOWSDIRECTORY wsprintf(buf,"%s\\hosts",location); 00be 56 push si 00bf ff 76 06 push +6H[bp] 00c2 68 00 00 push seg L3 00c5 68 13 00 push offset L6 00c8 8d 96 64 fe lea dx,-19cH[bp] 00cc 16 push ss 00cd 52 push dx 00ce 9a 00 00 00 00 call far _wsprintf 00d3 83 c4 0c add sp,000cH if(access(buf,F_OK)==0) { return 0; } //try Windows system directory 00d6 31 db xor bx,bx 00d8 8c d2 mov dx,ss 00da 8d 86 64 fe lea ax,-19cH[bp] 00de 9a 00 00 00 00 call far access_ 00e3 85 c0 test ax,ax 00e5 74 38 je L2 GetSystemDirectory(location,144); 00e7 56 push si 00e8 ff 76 06 push +6H[bp] 00eb 68 90 00 push 0090H 00ee 9a 00 00 00 00 call far GETSYSTEMDIRECTORY wsprintf(buf,"%s\\hosts",location); 00f3 56 push si 00f4 ff 76 06 push +6H[bp] 00f7 68 00 00 push seg L3 00fa 68 1c 00 push offset L7 00fd 8d 96 64 fe lea dx,-19cH[bp] 0101 16 push ss 0102 52 push dx 0103 9a 00 00 00 00 call far _wsprintf 0108 83 c4 0c add sp,000cH if(access(buf,F_OK)==0) { return 0; } 010b 31 db xor bx,bx 010d 8c d2 mov dx,ss 010f 8d 86 64 fe lea ax,-19cH[bp] 0113 9a 00 00 00 00 call far access_ 0118 85 c0 test ax,ax 011a 74 03 je L2 return -1; 011c b8 ff ff mov ax,0ffffH } 011f 8d 66 fa L2 lea sp,-6H[bp] 0122 5f pop di 0123 5e pop si 0124 1f pop ds 0125 5d pop bp 0126 4d dec bp 0127 ca 04 00 retf 0004H No disassembly errors ------------------------------------------------------------ Segment: find_TEXT WORD 00000025 bytes 0000 77 69 6e 73 L3 DB 77H,69H,6eH,73H 0004 6f 63 6b 2e DB 6fH,63H,6bH,2eH 0008 64 6c 6c 00 DB 64H,6cH,6cH,00H 000c 00 L4 DB 00H 000d 68 6f 73 74 L5 DB 68H,6fH,73H,74H 0011 73 00 DB 73H,00H 0013 25 73 5c 68 L6 DB 25H,73H,5cH,68H 0017 6f 73 74 73 DB 6fH,73H,74H,73H 001b 00 DB 00H 001c 25 73 5c 68 L7 DB 25H,73H,5cH,68H 0020 6f 73 74 73 DB 6fH,73H,74H,73H 0024 00 DB 00H No disassembly errors ------------------------------------------------------------