Hello,
There is a little problem when there is multiple callers.The h2viewer window is closed by the first caller who close itself .The countdll don't work because each loadlibrary made new data for the caller.
The soluce is.
Add a new exported fonction to the dll.
Quote
;################################################################
ReleaseIh2vmain PROC
Local retour:DWORD
mov retour,1
.if ppvIh2vmain != 0
Ih2vmain Release
.endif
FindeReleaseIh2vmain:
mov eax,retour
ret
ReleaseIh2vmain endp
;################################################################
When a caller want to close,he need to count the number of callers,with.
Quote
;################################################################
IsrunningEditmasm PROC
Local pe:PROCESSENTRY32
Local osinfo:OSVERSIONINFO
Local count:DWORD,hSnapshot
Local retour:DWORD
ZEROLOCALES retour
;---------------------------------------------------
invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
mov hSnapshot,eax
mov pe.dwSize,sizeof PROCESSENTRY32
invoke Process32First,hSnapshot,addr pe
.while(eax)
invoke lstrlen,addr pe.szExeFile
.if eax == strsize(editmasm.exe) ;m
invoke lstrcmpi,addr pe.szExeFile,addr szeditmasmexe ;text compare
.if eax == 0 ;identique
inc retour
.endif
.endif
invoke Process32Next,hSnapshot,addr pe
.endw
invoke CloseHandle,hSnapshot
FindeIsrunningEditmasm:
mov eax,retour
ret
IsrunningEditmasm endp
and here is how to use it:
Quote
invoke IsrunningEditmasm
.if eax > 1
invoke ReleaseIh2vmain
.else
invoke EndH2viewer
.endif
Then ,all is OK.The last caller close the h2viewer,others just free the library and release the interface.