Yves how you manages to make it works fully ?
I´m stuck on something and i cannot find what a hell i´m doing wrong. I changed my code so many times, and then i reproduces what you did and yet...Nothing.
Some stupid "this file maybe corrupt" shows ups,while on yours, the same file is converted completelly.
This is yours routine
;################################################################
Importe_File PROC pdll:DWORD, pfile:DWORD
Local ghszFile:DWORD,ghszClass[50]:BYTE,gardesp:DWORD,ghClass
Local modulefilename[MAX_PATH]:BYTE,outputfile[MAX_PATH]:BYTE
Local retour:DWORD
mov retour,1
invoke convert_SearchAdresse,pdll
.if eax == 0
jmp FindeImporte_File
.endif
mov retour,1
invoke GetModuleFileName,NULL,addr modulefilename,sizeof modulefilename
invoke lstrcpy,addr outputfile,addr modulefilename
invoke lstrlen,addr outputfile
lea edx,outputfile
add edx,eax
@@:
.if byte ptr [edx]!= "\"
dec edx
jmp @B
.endif
inc edx
invoke lstrcpy,edx,TXT("test.rtf")
mov edx,output.Hwnd
invoke InitConverter32,0,addr modulefilename
;invoke InitConverter32,NULL,NULL
.if eax != 0
;écriture de l'import
invoke CreateFile,addr outputfile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,\
FILE_FLAG_SEQUENTIAL_SCAN, NULL
mov Converted_File,eax
mov ghClass,Fr(GlobalAlloc,GHND,4096)
invoke StringToGlobal,pfile ;addr parametre ;TXT("C:\Documents and Settings\Luce\Bureau\sansnom1.htm")
mov ghszFile,eax
mov ghBuf,Fr(GlobalAlloc,GHND, 4096)
;pas de istorage ,ghszClass retourne la classe
;verifie
invoke IsFormatCorrect32,ghszFile,ghClass
invoke GlobalToString,ghClass,addr ghszClass
;mov ghszClass,0
invoke MessageBox,NULL,addr ghszClass,TXT("format correct"),MB_OK
;---------------------------------------------------------------------
;--------------------------------------------------------------------
invoke ForeignToRtf32,ghszFile, NULL, ghBuf,ghClass, NULL,WriteCallback
;--------------------------------------------------------------------
.if eax == 0
invoke MessageBox,NULL,TXT("reussite"),addr ghszClass,MB_OK
.else
invoke MessageBox,NULL,TXT("Failed"),addr ghszClass,MB_OK
.endif
invoke CloseHandle,Converted_File
invoke GlobalFree,ghszFile
invoke GlobalFree,ghBuf
invoke UninitConverter
.endif
invoke convert_FreeLibrary
FindeImporte_File:
mov eax,retour
ret
Importe_File endp
Mine is:
Proc DoConvert::
Arguments @DocFileStruct, @lpszFileName, @FileLen
Local @hMem, @ghClass
Uses esi, edi, ecx, ebx
call RegisterApp &NULL, &NULL
On eax = 0, ExitP
mov esi D@DocFileStruct
mov eax D@FileLen | shl eax 8
call VMemAlloc MemConvertedBuff, eax | mov D$CConverter.m_hBuff eax | mov D@hMem eax
call 'kernel32.GlobalAlloc' &GHND, 4096 | mov D@ghClass eax
call StringtoHGlobal D@lpszFileName | mov D$ghszFile eax
call 'kernel32.GlobalAlloc' &GHND, 4096 | mov D$ghBuf eax
; here should be isformatcorrect32 ?
call StringtoHGlobal D$esi+DocType.pszClassNameDis | mov D@ghClass eax
call D$CConverter.m_ForeignToRtf D$ghszFile, &NULL, D$ghBuf, D@ghClass, &NULL, WriteOut
call 'kernel32.GlobalFree' D$ghszFile
call 'kernel32.GlobalFree' D$ghBuf
call 'kernel32.GlobalFree' D@ghclass
mov eax D@hMem
EndP
Proc WriteOut:
Arguments @cch, @nPercentComplete
Local @size, @pMem
mov eax D$CConverter.m_nPercent
If eax <> D@nPercentComplete
; do something to print the percentage
move D$CConverter.m_nPercent D@nPercentComplete
End_If
;..If D@nPercentComplete <> 0
;move D$CConverter.m_nPercent D@nPercentComplete
.If D@cch <> 0
call 'KERNEL32.GlobalLock' D$ghBuf | mov D@pMem eax
call StrCpyEx eax, D$CConverter.m_hBuff, D@cch
mov eax D@cch
add D$CConverter.m_hBuff eax
If D$CConverter.m_nPercent = 100
mov eax eax ; do something latwer. After fix this crap
End_If
call 'KERNEL32.GlobalUnlock' D$ghBuf
mov eax 0
;.Else;_If eax = 0400
.End_If
mov eax 0
;..End_If
EndP
I have no more clues why it is refusing to translate completelly.
I´m uploading the file i´m using. The source code is embeded on it. You may open the file in rosasm to see the source code.
Btw: The registerapp makes no difference on the error, neither also the VirtualMemory allocation for the exports (Instead making it export directly, i intended to the rtf shows on the richtextbox, but the error message shows before the VirtualMemory is used - if i remove the VirtualMemoryit won´t change anything. The problem is somewhere else in the ghClass for example. Isn´t ghClass, in fact, part of a structure ?
What i noticed is that on mine callback, the percentage goes directly to 82 (or something), meaning that the converter idn´t parsed 100% of the file, while on yours, it goes from 0 to 2 4 6 8 .... 100
When you open/save a file you will see their classes and extensions and the path. (I´ll remove from the opendialog filter the path later. I was just leave there to make sure it was using the correct converter