Hossa,

im working on a basic playerfinder for a popular multiplayergame.

can you test if it work on nt or win2k and can you take a look at the code and show me a better way to find a word inside a text ?

since its basic i use wolffinder to do the search work....

Thanks

ps: its packed with winrar ,remove ".zip" to entpack.
sorry i have no zip program.

for the one dont like to download:

.386
.MODEL FLAT,STDCALL

UNICODE=0
include resources\w32.inc

extrn lstrcat : proc
extrn lstrcpy :Proc
extrn lstrcatA :Proc
extrn lstrcmpi :Proc
extrn FindWindowExA :Proc
extrn inet_addr : proc
extrn WSAGetLastError : proc

;**************************************** DATA *************************************************
.DATA

WSACleanup PROTO
WSAStartup PROTO :DWORD,:DWORD
htons PROTO :DWORD
recv PROTO :DWORD,:DWORD,:DWORD,:DWORD
socket PROTO :DWORD, :DWORD, :DWORD
WSAAsyncSelect PROTO :DWORD,:DWORD,:DWORD,:DWORD
closesocket PROTO :DWORD
accept PROTO :DWORD,:DWORD,:DWORD
bind PROTO :DWORD,:DWORD,:DWORD
listen PROTO :DWORD,:DWORD
connect PROTO :DWORD,:DWORD,:DWORD
send PROTO :DWORD,:DWORD,:DWORD,:DWORD
ioctlsocket PROTO :DWORD,:DWORD,:DWORD
setsockopt PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
gethostbyname PROTO :DWORD


WSABASEERR equ 10000
WSAEINTR equ WSABASEERR+4
WSAEBADF equ WSABASEERR+9
WSAEACCES equ WSABASEERR+13
WSAEFAULT equ WSABASEERR+14
WSAEINVAL equ WSABASEERR+22
WSAEMFILE equ WSABASEERR+24
WSAEWOULDBLOCK equ WSABASEERR + 35
WSAEINPROGRESS equ WSABASEERR + 36
WSAEALREADY equ WSABASEERR + 37
WSAENOTSOCK equ WSABASEERR + 38
WSAEDESTADDRREQ equ WSABASEERR + 39
WSAEMSGSIZE equ WSABASEERR + 40
WSAEPROTOTYPE equ WSABASEERR + 41
WSAENOPROTOOPT equ WSABASEERR + 42
WSAEPROTONOSUPPORT equ WSABASEERR + 43
WSAESOCKTNOSUPPORT equ WSABASEERR + 44
WSAEOPNOTSUPP equ WSABASEERR + 45
WSAEPFNOSUPPORT equ WSABASEERR + 46
WSAEAFNOSUPPORT equ WSABASEERR + 47
WSAEADDRINUSE equ WSABASEERR + 48
WSAEADDRNOTAVAIL equ WSABASEERR + 49
WSAENETDOWN equ WSABASEERR + 50
WSAENETUNREACH equ WSABASEERR + 51
WSAENETRESET equ WSABASEERR + 52
WSAECONNABORTED equ WSABASEERR + 53
WSAECONNRESET equ WSABASEERR + 54
WSAENOBUFS equ WSABASEERR + 55
WSAEISCONN equ WSABASEERR + 56
WSAENOTCONN equ WSABASEERR + 57
WSAESHUTDOWN equ WSABASEERR + 58
WSAETOOMANYREFS equ WSABASEERR + 59
WSAETIMEDOUT equ WSABASEERR + 60
WSAECONNREFUSED equ WSABASEERR + 61
WSAELOOP equ WSABASEERR + 62
WSAENAMETOOLONG equ WSABASEERR + 63
WSAEHOSTDOWN equ WSABASEERR + 64
WSAEHOSTUNREACH equ WSABASEERR + 65
WSAENOTEMPTY equ WSABASEERR + 66
WSAEPROCLIM equ WSABASEERR + 67
WSAEUSERS equ WSABASEERR + 68
WSAEDQUOT equ WSABASEERR + 69
WSAESTALE equ WSABASEERR + 70
WSAEREMOTE equ WSABASEERR + 71
WSASYSNOTREADY equ WSABASEERR+91
WSAVERNOTSUPPORTED equ WSABASEERR+92
WSANOTINITIALISED equ WSABASEERR+93
WSAHOST_NOT_FOUND equ WSABASEERR + 1001
HOST_NOT_FOUND equ WSAHOST_NOT_FOUND
SOCKET_ERROR equ -1

;These are the dialog elements as found in the .rc file
DLG1 equ 100
ICON1 equ 101

IDB_BTN1 equ 105

IDE_WORD equ 500
IDE_FOUND equ 510

IDL_TIME equ 600
IDL_SER equ 610
IDL_PLA equ 620
IDL_UPD equ 630
IDL_NAME equ 640
IDE_STATUS equ 700
;**********************************

SOCK_STREAM equ 1
AF_INET equ 2
BuffSize equ 1024


WSAdata STRUCT
wVersion dw ?
wHighVersion dw ?
szDescription db 257 dup (?)
szSystemStatus db 129 dup (?)
iMaxSockets dw ?
iMaxUdpDg dw ?
lpVendorInfo dd ?
WSAdata ENDS

sockaddr_in STRUCT
sin_family dw ?
sin_port dw ?
sin_addr dd ?
sin_zero db 8 dup (0)
sockaddr_in ENDS

wsadata WSAdata <?>
sock DD ?
Len DD ?

wsa2 WSAdata ?
conn_socket dd 0
data_socket dd 0
server sockaddr_in <0,0,0,0>

wsa WSAdata <?>
hStatic dd ?
hFont dd ?
;**********************************

hInstance dd 0
seekdb dd 0
seekinc dd 0
seekcount dd 0
loopcount dd 0
foundstr dd 0
hicon dd 0
hinst_ dd 0

ipsrting db 'gowolf.pl',0

d01 db 'ERROR OPEN CONNECTION',0
d02 db 'WSAENETDOWN',0
d03 db 'WSAENETUNREACH',0
d04 db 'WSAECONNABORTED',0
d05 db 'WSAECONNRESET',0
d06 db 'WSAENOTCONN',0
d07 db 'WSAEHOSTDOWN',0
d08 db 'WSAEHOSTUNREACH',0
d09 db 'WSAVERNOTSUPPORTED',0

errorsocket DB 'SOCKET ERROR' ,0
errorsend DB 'SEND ERROR' ,0
errorIP DB 'IP ERROR' ,0
errorMiss DB 'PLAYER NAME MISSING' ,0

buff db BuffSize dup (00h)

;---- wolffinder cgi strings

wolffinderip db '216.99.207.98',2 dup (0)
start01 db 'GET /index.php?',0
seek1 db 'sname=',0
language1 db '&submit=',0
language2 db 'click',0
end db ' HTTP/1.0',0
eol db 13,10,13,10,13,10,0
db 20 dup (0)
;**************************************** DATA ? *************************************************
.data?
errordummy db 70 DUP (?)
buffer db 24 dup (?)
buffer2 db 128 dup (?)
username01 db 24 dup (?)
htmlbuffer db 1024 dup (?)
htmlbuffer1 db 9000 dup (?)
htmlbuffer2 db 256000 dup (?)
htmlbuffer3 db 256000 dup (?)
htmlbuffer4 db 256000 dup (?)
htmlbuffer5 db 256000 dup (?)
htmlbuffer6 db 256000 dup (?)
htmlbuffer7 db 256000 dup (?)
txtbuffer db 256 dup (?)
seekbuffer db 256 dup (?)
seekbuffer2 db 256 dup (?)
;**************************************** CODE *************************************************
.CODE
main:
call GetModuleHandleA, 0
test eax, eax
jne gmhok
call ExitProcess,0

gmhok:
mov hinst_, eax
call DialogBoxParamA, hinst_, DLG1, 0, offset DlgProcedure, 0
call ExitProcess,0
;********************************************************************************
PUBLIC DlgProcedure
DlgProcedure PROC STDCALL, hwnd_:DWORD, wmsg:DWORD, wparam_:DWORD, lparam_:DWORD
USES ebx, edi, esi

.IF wmsg==WM_DESTROY || wmsg==WM_CLOSE
jmp wmdestroy

.ELSEIF wmsg==WM_COMMAND
jmp wmcommand

.ELSEIF wmsg==WM_INITDIALOG
jmp dlginit

.ENDIF
RET

wmdestroy:
call EndDialog, hwnd_, 0
call ExitProcess,0

wmcommand :
.IF word ptr ==IDB_BTN1
call GetDlgItem,hwnd_,IDB_BTN1
call ShowWindow,eax,0
call SendSearch

.ENDIF
RET
;******************************************** DLG INIT ******************************************
dlginit:
call LoadIconA, hinst_, ICON1 ; load icon
call SendMessageA, hwnd_, WM_SETICON, ICON1, eax ; show icon

SockedInitialize:
call WSAStartup ,101h ,offset wsa2
cmp eax ,SOCKET_ERROR
jnz InitOk
Exit_if_cant_open:
jmp wmdestroy
InitOk:
RET
DlgProcedure EndP
;***************************************** SEND SEARCH *****************************************
SendSearch proc
call SendDlgItemMessageA,hwnd_,IDL_NAME,LB_RESETCONTENT,0,0 ;-- empty listbox

call GetDlgItemText,hwnd_,IDE_WORD,offset txtbuffer,256
call lstrlen,offset txtbuffer
cmp eax,0
je Error_Missing

call socket ,AF_INET ,SOCK_STREAM ,0
cmp eax ,SOCKET_ERROR
jz Error_Socket
mov conn_socket ,eax
call htons ,80 ; HTTP-Service
mov ,AF_INET
mov ,ax

call inet_addr ,offset wolffinderip ;--searchengine ip
cmp eax ,SOCKET_ERROR
jz Error_IP

mov ,eax
call connect ,conn_socket,offset server,16

call ClearBuff
mov buff,0
;----------------------
call lstrcpy ,offset buff ,offset start01 ;---cgi script
call lstrcat ,offset buff ,offset seek1

call lstrcat ,offset buff ,offset txtbuffer ;-- edit value

call lstrcat ,offset buff ,offset language1
call lstrcat ,offset buff ,offset language2
;----------------------
call lstrcat ,offset buff ,offset end ;-- cgi http
call lstrcat ,offset buff ,offset eol ;-- cgi end
call lstrlen ,offset buff

call send ,conn_socket ,offset buff ,eax ,0
cmp eax,SOCKET_ERROR
je SOCK_ERROR_MSG

mov htmlbuffer1,0
call recv,conn_socket ,offset htmlbuffer1,9000,0 ; Read the data from the socket
call SetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer1

call closesocket ,conn_socket
call closesocket ,data_socket
call Sleep,150
call searchinfos ;--- start search for word in text
ret
;**************************************************************************
; SOCKET ERRORS
;**************************************************************************
SOCK_ERROR_MSG:
call WSAGetLastError
.if eax!=WSAEWOULDBLOCK
call lstrcpy,offset errordummy,offset d01
.elseif eax!=WSAENETDOWN
call lstrcpy,offset errordummy,offset d02
.elseif eax!=WSAENETUNREACH
call lstrcpy,offset errordummy,offset d03
.elseif eax!=WSAECONNABORTED
call lstrcpy,offset errordummy,offset d04
.elseif eax!=WSAECONNRESET
call lstrcpy,offset errordummy,offset d05
.elseif eax!=WSAENOTCONN
call lstrcpy,offset errordummy,offset d06
.elseif eax!=WSAEHOSTDOWN
call lstrcpy,offset errordummy,offset d07
.elseif eax!=WSAEHOSTUNREACH
call lstrcpy,offset errordummy,offset d08
.elseif eax!=WSAVERNOTSUPPORTED
call lstrcpy,offset errordummy,offset d09
.endif
call SetDlgItemText,hwnd_,IDE_STATUS,offset errordummy
jmp endloop

Error_Socket:
call SetDlgItemText,hwnd_,IDE_STATUS,offset errorsocket
jmp endloop
Error_IP:
call SetDlgItemText,hwnd_,IDE_STATUS,offset errorIP
jmp endloop
Error_Send_Notify:
call SetDlgItemText,hwnd_,IDE_STATUS,offset errorsend
jmp endloop
Error_Missing:
call SetDlgItemText,hwnd_,IDE_STATUS,offset errorMiss
jmp endloop
SendSearch endp
;**************************************************************************
; CLEAR BUFFER
;**************************************************************************
ClearBuff Proc Near
mov edi ,offset buff
mov ecx ,BuffSize shr 2
xor eax ,eax
rep stosd
ret
ClearBuff EndP
;**************************************************************************
; SEARCH
;**************************************************************************
searchinfos Proc
call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer1-23,55
call SetDlgItemText,hwnd_,IDL_TIME,offset htmlbuffer1

call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer2-786,790
call SetDlgItemText,hwnd_,IDL_SER,offset htmlbuffer2

call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer3-905,910
call SetDlgItemText,hwnd_,IDL_PLA,offset htmlbuffer3

call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer4-1017,1042
call SetDlgItemText,hwnd_,IDL_UPD,offset htmlbuffer4
;---
mov loopcount,0
mov seekcount,0
mov foundstr,0
call SendDlgItemMessageA,hwnd_,IDL_NAME,LB_RESETCONTENT,0,0

call GetDlgItemText,hwnd_,IDE_WORD,offset seekbuffer,256
call lstrlen,offset seekbuffer
inc eax
mov seekdb,eax

call GetDlgItemText,hwnd_,IDE_FOUND,offset seekbuffer2,seekdb

loopseek:
.if foundstr==0
mov edi, offset seekbuffer
mov esi, offset seekbuffer2
mov ecx, 5
repz cmpsb
jnz Notfound
mov foundstr,1
jmp Notfound
.elseif foundstr==1
mov edi, offset ipsrting
mov esi, offset seekbuffer2
mov ecx, 5
repz cmpsb
jnz Notfound
call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer4-10,50
call SendDlgItemMessageA,hwnd_,IDL_NAME,LB_ADDSTRING,0,offset htmlbuffer4
mov foundstr,0
.endif

Notfound:
inc loopcount
cmp loopcount,9000
je endloop

inc seekdb
call GetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer4-1,256000
call SetDlgItemText,hwnd_,IDE_FOUND,offset htmlbuffer4

call GetDlgItemText,hwnd_,IDE_FOUND,offset seekbuffer2,seekdb
jmp loopseek
endloop:

call GetDlgItem,hwnd_,IDB_BTN1
call ShowWindow,eax,1
ret
searchinfos EndP
;************************** END ******************************
ends
end main
Posted on 2002-04-26 02:52:04 by Max
OS: WinXP
CPU-usage: 97%
Screenshot:
Posted on 2002-04-26 06:57:45 by Delight
Thanks for the help :-)

i change the way i create the dialog and hope now it work on XP.
i would happy if you have the time to test the new version.

tomorow i remove the html strings ,so dont wonder.

i post a screenshot to show how it should look :-)
Posted on 2002-04-26 18:43:42 by Max
Screenshot:
Posted on 2002-04-26 18:45:37 by Max
Not better I'm afraid :(

CPU-usage: 99%
Screenshot:
Posted on 2002-04-27 05:32:04 by Delight
i've a problem on a prog some weeks ago that should be your problem, on Win98 the dialog shows ok, but in WinXP it shows like that window (Delight). Check the return value of all WM_*
:alright:

cu

Coder7345 / jEAN
Posted on 2002-04-27 07:57:53 by coder