News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using H2viewer with an application

Started by ToutEnMasm, March 10, 2009, 05:25:25 PM

Previous topic - Next topic

ToutEnMasm


All the com stuff is in the dll and allow multiple callers.
The interface functions of the h2viewer are exported by the dll adding DLL... to the function,see the source for that.
Three functions are here for start end and control the h2viewer.
Exported are also all  interface functions of dexplore,but they are not used in the sample.
Take care that the dll must be found by the exe.


[attachment deleted by admin]

ToutEnMasm

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.