Author Topic: HTML to RTF  (Read 78284 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #15 on: June 10, 2013, 02:14:20 AM »

Made a copy (clipboard) of an html page.Run the prog,the menu will not be the same.
Fa is a musical note to play with CL

jj2007

  • Member
  • *****
  • Posts: 13300
  • Assembly is fun ;-)
    • MasmBasic
Re: HTML to RTF
« Reply #16 on: June 10, 2013, 02:37:15 AM »

Made a copy (clipboard) of an html page.Run the prog,the menu will not be the same.

That's true. It will show "RTF as text", and when you paste it e.g. in MS Word, you'll get the HTML codes. A truly intelligent solution but not to our problem.

guga

  • Moderator
  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: HTML to RTF
« Reply #17 on: June 10, 2013, 05:09:43 AM »
CPPFrance is an excelent site. I frequently have some convertionsand ideas done from this site, but, the clipboard viewer is not the solution yet.

I strongly believe that the solution is understanding how the encapsulation of a HTML to RTFworks and use this dll (or simply, build an app able to make full encapsulations) will do the job. But, since there is a lack of information about this encapsulation technique im not sure if we can be able to encapsulate images on the RTF (or even, is a richedit viewer will understand what is a css or js file encapsulated as well).
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #18 on: June 10, 2013, 03:15:27 PM »
Quote
im not sure if we can be able to encapsulate images on the RTF
I am sure it is possible ,it is done by the sample for wich i have given a link.
I use this feature in my IDE to use title in image (wordart or free open office).
It use OLE and do not use all of his features.

The lazy method is to find a tool who made it and search the dll who made the job.
That's true.You will surely find this dll on free download on internet.
Free office do that and you have surely here the good path to have a fast soluce.

******** windbg can give you great knowledge ***********
Fa is a musical note to play with CL

guga

  • Moderator
  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: HTML to RTF
« Reply #19 on: June 10, 2013, 05:11:00 PM »
WinXp already provide this Dll.It is called cdosys.dll. It is inside windows/system directory. It seems that there is a Ole IID for acessing it Probably IID_IMAPIProp), but i´m not sure what it is, since there is a lack of information about it.

Here are some functions existent inside that dll, that makes me think that it is possible to use this windows dll to do the encapsulations without having to program one completelly.

It uses mapi library as defined here: http://www.codeproject.com/Articles/19139/Bridging-the-gap-between-NET-and-Extended-MAPI

Code: [Select]

; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

; public: virtual long __stdcall HTMLRTF::QueryInterface(struct _GUID const &, void * *)
?QueryInterface@HTMLRTF@@UAGJABU_GUID@@PAPAX@Z proc near
; DATA XREF: .text:const HTMLRTF::`vftable'o
; .text:const RTFHTML::`vftable'o ...

arg_0 = dword ptr  8
arg_4 = dword ptr  0Ch
arg_8 = dword ptr  10h

mov edi, edi
push ebp
mov ebp, esp
push esi
mov esi, [ebp+arg_4]
push edi
push 4
pop ecx
mov edi, offset __GUID_00000000_0000_0000_c000_000000000046
xor eax, eax
repe cmpsd
jz short loc_4766EB9D
mov esi, [ebp+arg_4]
push 4
pop ecx
mov edi, offset _IID_IMAPIProp
xor eax, eax
repe cmpsd
jz short loc_4766EB9D
mov eax, [ebp+arg_8]
and dword ptr [eax], 0
mov eax, 80004002h
jmp short loc_4766EBAD
; ---------------------------------------------------------------------------

loc_4766EB9D: ; CODE XREF: HTMLRTF::QueryInterface(_GUID const &,void * *)+16j
; HTMLRTF::QueryInterface(_GUID const &,void * *)+27j
mov eax, [ebp+arg_0]
mov ecx, [ebp+arg_8]
mov [ecx], eax
mov ecx, [eax]
push eax
call dword ptr [ecx+4]
xor eax, eax

loc_4766EBAD: ; CODE XREF: HTMLRTF::QueryInterface(_GUID const &,void * *)+34j
pop edi
pop esi
pop ebp
retn 0Ch
?QueryInterface@HTMLRTF@@UAGJABU_GUID@@PAPAX@Z endp

; ---------------------------------------------------------------------------


Code: [Select]
; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

; protected: long __thiscall HTMLRTF::ScEncapsulateTag(class HTMLTOKEN *, unsigned long)
?ScEncapsulateTag@HTMLRTF@@IAEJPAVHTMLTOKEN@@K@Z proc near
; CODE XREF: HTMLRTF::ScNInterpret(TOKEN *,ulong)+897p
; HTMLRTF::ScNInterpret(TOKEN *,ulong)+B76p

var_460 = dword ptr -460h
var_45C = dword ptr -45Ch
var_458 = dword ptr -458h
var_454 = byte ptr -454h
var_450 = dword ptr -450h
var_44C = dword ptr -44Ch
CodePage = dword ptr -448h
var_444 = dword ptr -444h
var_440 = dword ptr -440h
var_43C = dword ptr -43Ch
var_438 = dword ptr -438h
var_434 = dword ptr -434h
var_430 = dword ptr -430h
var_42C = dword ptr -42Ch
var_428 = dword ptr -428h
var_424 = dword ptr -424h
var_420 = dword ptr -420h
Dst = byte ptr -41Ch
var_1C = dword ptr -1Ch
ms_exc = CPPEH_RECORD ptr -18h
arg_0 = dword ptr  8
arg_4 = dword ptr  0Ch

push 450h
push offset stru_47611C00
call __SEH_prolog
mov eax, ___security_cookie
mov [ebp+var_1C], eax
mov [ebp+var_424], ecx
mov edi, [ebp+arg_0]
xor edx, edx
mov [ebp+var_420], edx
mov [ebp+var_42C], edx
mov [ebp+var_444], edx
or ebx, 0FFFFFFFFh
mov [ebp+var_430], edx
mov [ebp+var_428], edx
mov [ebp+var_450], 1
mov [ebp+var_44C], 3713001Eh
mov [ebp+ms_exc.disabled], edx
test byte ptr [edi+0Dh], 1
jz loc_476664DF
mov ecx, [ebp+arg_4]
mov eax, 0C00h
and ecx, eax
cmp ecx, eax
jnz loc_476664DF
xor ecx, ecx

loc_47665F75: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+562j
mov [ebp+var_43C], ecx
cmp ecx, [edi+14h]
jnb loc_47666464
lea eax, [ecx+ecx*2]
mov eax, [edi+eax*4+20h]
imul eax, 1Ch
add eax, offset ?rgHTMLTag@@3QBU_htmltag@@B ; _htmltag const * const rgHTMLTag
mov [ebp+var_460], eax
test byte ptr [eax+5], 80h
jz loc_47666456
mov [ebp+var_438], 400h
push edx
lea eax, [ebp+CodePage]
push eax
lea eax, [ebp+var_438]
push eax
lea eax, [ebp+Dst]
push eax
push ecx
push edi
mov ecx, [ebp+var_424]
call ?ScGetParamText@HTMLPARSE@@QAEJPAVHTMLTOKEN@@KPAEPAK2H@Z ; HTMLPARSE::ScGetParamText(HTMLTOKEN *,ulong,uchar *,ulong *,ulong *,int)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
push offset Control ; " \t\n\r"
lea eax, [ebp+Dst]
push eax ; Str
call ds:__imp__strspn
pop ecx
pop ecx
mov [ebp+var_440], eax
test eax, eax
jbe short loc_47666024
sub [ebp+var_438], eax
mov ecx, [ebp+var_438]
inc ecx
push ecx ; Size
lea eax, [ebp+eax+Dst]
push eax ; Src
lea eax, [ebp+Dst]
push eax ; Dst
call ds:__imp__memmove
add esp, 0Ch

loc_47666024: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+FFj
cmp [ebp+var_438], 0
jz loc_47666456
and [ebp+var_434], 0
cmp [ebp+Dst], 23h
jz loc_47666456
cmp [ebp+Dst], 3Fh
jz loc_47666153
cmp [ebp+Dst], 3Bh
jz loc_47666153
mov esi, 8004010Fh
mov [ebp+var_420], esi
mov eax, [ebp+var_424]
mov eax, [eax+15BCh]
test eax, 400000h
jz short loc_476660F2
test eax, 800000h
jz short loc_476660F2
push offset a?_1 ; "#?;"
lea eax, [ebp+Dst]
push eax ; Str
call ds:__imp__strcspn
pop ecx
pop ecx
lea eax, [ebp+eax+Dst]
mov [ebp+var_434], eax
movsx ecx, byte ptr [eax]
mov [ebp+var_444], ecx
test ecx, ecx
jz short loc_476660B7
mov byte ptr [eax], 0
jmp short loc_476660BE
; ---------------------------------------------------------------------------

loc_476660B7: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+1B3j
and [ebp+var_434], 0

loc_476660BE: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+1B8j
mov eax, [ebp+var_424]
mov ecx, [eax+1010h]
mov edx, [ecx]
lea esi, [ebp+var_430]
push esi
push 0FFFFFFFFh
push 400h
push dword ptr [eax+1590h]
lea eax, [ebp+Dst]
push eax
call dword ptr [edx+34h]
mov esi, eax
mov [ebp+var_420], esi

loc_476660F2: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+17Ej
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+185j
cmp esi, 8004010Fh
jnz loc_47666269
and [ebp+var_420], 0
and [ebp+var_440], 0
lea eax, [ebp+var_440]
push eax
push offset aAZaZ_N ; "%*[a-zA-Z.+-]:%n"
lea eax, [ebp+Dst]
push eax ; Src
call ds:__imp__sscanf
add esp, 0Ch
cmp [ebp+var_440], 1
ja loc_47666456
cmp [ebp+var_434], 0
jz short loc_47666153
mov al, byte ptr [ebp+var_444]
mov ecx, [ebp+var_434]
mov [ecx], al
and [ebp+var_434], 0

loc_47666153: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+14Fj
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+15Cj ...
push 400h ; int
lea eax, [ebp+Dst]
push eax ; MaxCount
mov eax, [ebp+var_424]
push dword ptr [eax+1590h] ; Buf
lea eax, [ebp+Dst]
push eax ; Src
call ?MdURLCombine@@YGJPAD00K@Z ; MdURLCombine(char *,char *,char *,ulong)
mov [ebp+var_458], eax
cmp eax, 1000h
jnz loc_47666456

loc_47666188: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+374j
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+380j
mov eax, [ebp+var_430]
test eax, eax
jz loc_47666228
and [ebp+var_428], 0
mov ecx, [eax]
lea edx, [ebp+var_428]
push edx
lea edx, [ebp+var_454]
push edx
push 0
lea edx, [ebp+var_450]
push edx
push eax
call dword ptr [ecx+14h]
mov esi, eax
mov [ebp+var_420], esi
cmp esi, 80040105h
jz loc_47666282
cmp esi, 800CCE06h
jz loc_47666282
test esi, esi
jl loc_4766650B
mov eax, [ebp+var_428]
mov eax, [eax]
and eax, 0FFFFh
cmp eax, 0Ah
jz loc_47666282
test esi, esi
jz short loc_47666202
mov [ebp+var_42C], esi

loc_47666202: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+2FDj
mov eax, [ebp+var_430]
mov ecx, [eax]
push 8
push eax
call dword ptr [ecx+10h]
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
jz short loc_47666228
mov [ebp+var_42C], esi

loc_47666228: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+293j
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+323j
test ebx, ebx
jge loc_476662C2
mov eax, [ebp+arg_4]
and eax, 0FFFFF7BFh
or eax, 180h
push eax ; int
mov ecx, [ebp+var_424]
push dword ptr [ecx+114Ch] ; CodePage
mov eax, [ebp+var_43C]
lea eax, [eax+eax*2+6]
push dword ptr [edi+eax*4] ; int
push dword ptr [edi+4] ; int
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov ebx, 9000h
jmp loc_47666307
; ---------------------------------------------------------------------------

loc_47666269: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+1FBj
test esi, esi
jl loc_4766650B
jz loc_47666188
mov [ebp+var_42C], esi
jmp loc_47666188
; ---------------------------------------------------------------------------

loc_47666282: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+2CBj
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+2D7j ...
xor esi, esi
cmp [ebp+var_428], esi
jz short loc_476662A5
mov ecx, [ebp+var_430]
mov eax, [ecx]
push [ebp+var_428]
push 1
call dword ptr [eax+38h]
mov [ebp+var_428], esi

loc_476662A5: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+38Dj
mov eax, [ebp+var_430]
mov ecx, [eax]
push eax
call dword ptr [ecx+8]
mov [ebp+var_430], esi
mov [ebp+var_420], esi
jmp loc_47666456
; ---------------------------------------------------------------------------

loc_476662C2: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+32Dj
lea eax, [ebx+ebx*2+6]
mov ecx, [edi+eax*4]
lea eax, [ebx+ebx*2]
mov edx, [edi+eax*4+1Ch]
mov ebx, 9000h
push ebx ; int
mov eax, [ebp+var_424]
push dword ptr [eax+114Ch] ; CodePage
mov eax, [ebp+var_43C]
lea eax, [eax+eax*2+6]
mov eax, [edi+eax*4]
sub eax, edx
sub eax, ecx
push eax ; int
mov eax, [edi+4]
add eax, edx
add eax, ecx
push eax ; int
mov ecx, [ebp+var_424]
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)

loc_47666307: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+367j
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
jz short loc_4766631F
mov [ebp+var_42C], esi

loc_4766631F: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+41Aj
mov ecx, [ebp+var_424]
cmp [ebp+var_428], 0
jz loc_4766641D
push 9001h ; int
push 0 ; CodePage
push 0FFFFFFFFh ; int
push offset aHtmlbase ; "{\\htmlbase "
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
jz short loc_4766635D
mov [ebp+var_42C], esi

loc_4766635D: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+458j
push ebx ; int
push 0 ; CodePage
push 0FFFFFFFFh ; int
mov eax, [ebp+var_428]
push dword ptr [eax+8] ; int
mov ecx, [ebp+var_424]
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
jz short loc_4766638E
mov [ebp+var_42C], esi

loc_4766638E: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+489j
push 9001h ; int
push 0 ; CodePage
push 1 ; int
push offset asc_47611B4C ; "}"
mov ecx, [ebp+var_424]
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl loc_4766650B
jz short loc_476663BF
mov [ebp+var_42C], esi

loc_476663BF: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+4BAj
mov eax, [ebp+var_434]
test eax, eax
jz short loc_476663EE
mov cl, byte ptr [ebp+var_444]
mov [eax], cl
push ebx ; int
push [ebp+CodePage] ; CodePage
push 0FFFFFFFFh ; int
push eax ; int
mov ecx, [ebp+var_424]
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi

loc_476663EE: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+4CAj
mov ecx, [ebp+var_430]
mov eax, [ecx]
push [ebp+var_428]
push 1
call dword ptr [eax+38h]
and [ebp+var_428], 0
mov eax, [ebp+var_430]
mov ecx, [eax]
push eax
call dword ptr [ecx+8]
and [ebp+var_430], 0
jmp short loc_4766643A
; ---------------------------------------------------------------------------

loc_4766641D: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+42Fj
push ebx ; int
push [ebp+CodePage] ; CodePage
push 0FFFFFFFFh ; int
lea eax, [ebp+Dst]
push eax ; int
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi

loc_4766643A: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+51Ej
test esi, esi
jl loc_4766650B
jz short loc_4766644A
mov [ebp+var_42C], esi

loc_4766644A: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+545j
mov ebx, [ebp+var_43C]
mov [ebp+var_45C], ebx

loc_47666456: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+A0j
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+12Ej ...
mov ecx, [ebp+var_43C]
inc ecx
xor edx, edx
jmp loc_47665F75
; ---------------------------------------------------------------------------

loc_47666464: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+81j
cmp ebx, edx
jl short loc_476664DF
lea eax, [ebx+ebx*2+6]
mov eax, [edi+eax*4]
lea ecx, [ebx+ebx*2]
mov ecx, [edi+ecx*4+1Ch]
push 9000h ; int
mov edx, [ebp+var_424]
push dword ptr [edx+114Ch] ; CodePage
mov esi, [edi+8]
sub esi, ecx
sub esi, eax
push esi ; int
mov esi, [edi+4]
add esi, ecx
add esi, eax
push esi ; int
mov ecx, edx
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl short loc_4766650B
jz short loc_476664B2
mov [ebp+var_42C], esi

loc_476664B2: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+5ADj
push 9001h ; int
push 0 ; CodePage
push 2 ; int
push offset asc_47611B50 ; ">}"
mov ecx, [ebp+var_424]
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi
test esi, esi
jl short loc_4766650B
jz short loc_476664DF
mov [ebp+var_42C], esi

loc_476664DF: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+5Ej
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+70j ...
mov eax, [ebp+arg_4]
test ebx, ebx
jl short loc_476664EB
or eax, 100h

loc_476664EB: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+5E7j
push eax ; int
mov ecx, [ebp+var_424]
push dword ptr [ecx+114Ch] ; CodePage
push dword ptr [edi+8] ; int
push dword ptr [edi+4] ; int
call ?ScWriteBodyText@HTMLRTF@@QAEJPAEKKK@Z ; HTMLRTF::ScWriteBodyText(uchar *,ulong,ulong,ulong)
mov esi, eax
mov [ebp+var_420], esi

loc_4766650B: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+DDj
; HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+2DFj ...
or [ebp+ms_exc.disabled], 0FFFFFFFFh
call sub_47666536
test esi, esi
mov eax, esi
jnz short loc_47666520
mov eax, [ebp+var_42C]

loc_47666520: ; CODE XREF: HTMLRTF::ScEncapsulateTag(HTMLTOKEN *,ulong)+61Bj
mov ecx, [ebp+var_1C]
call @__security_check_cookie@4 ; __security_check_cookie(x)
call __SEH_epilog
retn 8
?ScEncapsulateTag@HTMLRTF@@IAEJPAVHTMLTOKEN@@K@Z endp

Code: [Select]

; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

; protected: long __thiscall HTMLRTF::ScOutputRTFString(unsigned char *, unsigned long, unsigned long)
?ScOutputRTFString@HTMLRTF@@IAEJPAEKK@Z proc near
; CODE XREF: HTMLRTF::ScWriteRTFHeader(void)+78p
; HTMLRTF::ScWriteRTFHeader(void)+1E6p ...

arg_0 = dword ptr  8
arg_4 = dword ptr  0Ch
arg_8 = dword ptr  10h

mov edi, edi
push ebp
mov ebp, esp
push esi
push edi
xor edi, edi
cmp [ebp+arg_8], edi
mov esi, ecx
jz short loc_4766317B
push [ebp+arg_8]
mov ecx, [esi+15FCh]
call ?ScSetCpid@OUTSTM@@QAEJK@Z ; OUTSTM::ScSetCpid(ulong)
test eax, eax
jl short loc_47663195
jz short loc_4766317B
mov edi, eax

loc_4766317B: ; CODE XREF: HTMLRTF::ScOutputRTFString(uchar *,ulong,ulong)+Ej
; HTMLRTF::ScOutputRTFString(uchar *,ulong,ulong)+22j
push [ebp+arg_8]
mov ecx, [esi+15FCh]
push [ebp+arg_4]
mov eax, [ecx]
push [ebp+arg_0]
call dword ptr [eax+0Ch]
test eax, eax
jnz short loc_47663195
mov eax, edi

loc_47663195: ; CODE XREF: HTMLRTF::ScOutputRTFString(uchar *,ulong,ulong)+20j
; HTMLRTF::ScOutputRTFString(uchar *,ulong,ulong)+3Cj
pop edi
pop esi
pop ebp
retn 0Ch
?ScOutputRTFString@HTMLRTF@@IAEJPAEKK@Z endp

; ---------------------------------------------------------------------------


The same coding shows here:
http://www.astim.si/patch/zarafa-1250.diff
http://www.wischik.com/lu/programmer/mapi_utils.html
http://download.zarafa.com/community/final/7.1/7.1.4-41394/sourcecode/

So, for what i understood, MAPI objects already have inside a way to convert HTML toRTF and vice-versa. but, how to acess these this functions without having to use messages from outlook is another story :(

The goal is to have acess to mapi interface and use only the needed functions responsable for the conversion.
« Last Edit: June 10, 2013, 06:30:12 PM by guga »
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #20 on: June 10, 2013, 06:16:07 PM »

What you say cdosys.dll ?
And after a few seconds i get his typelib,you win.
Download my translator,he wil give you all the needed way to extract all declarations needed by masm.
you need midl (windows sdk) also to do that.
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #21 on: June 10, 2013, 06:36:49 PM »

The idl file need msado15.dll
just replace it by it's full path:
C:\Program Files\Fichiers communs\System\ado\msado15.dll
Verify it.

Next order the declarations in the idl file,structures,enum, constants ..must be  on top of file.If not,you got errors like this
Quote
.\cdosys.idl(671) : error MIDL2025 : syntax error : expecting a constant expression near "<"
.\cdosys.idl(671) : error MIDL2035 : constant expression expected
.\cdosys.idl(671) : error MIDL2025 : syntax error : expecting ) near "IDispatch"
.\cdosys.idl(672) : error MIDL2025 : syntax error : expecting a type specification near "ConnectModeEnum"
.\cdosys.idl(673) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #22 on: June 10, 2013, 07:09:37 PM »

It's a good day for you.
It's like a game for me now to do that,here the result.
All can be missed now is the full sdk translate.Download it from the "windows include" subforum.
Fa is a musical note to play with CL

guga

  • Moderator
  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: HTML to RTF
« Reply #23 on: June 10, 2013, 10:09:45 PM »
Good work, ToutEnMasm

Btw, i just suceeded to initialize that crappy mapi stuff. Now will ty to acess the Com data in order to convert the rtftohtml

here is the code i made:
Code: [Select]

;;
References:
http://www.outlookcode.com/archive0/d/mapi.htm
http://msdn.microsoft.com/en-us/library/office/cc963763%28v=office.12%29.aspx
http://msdn.microsoft.com/en-us/library/office/dd181963%28v=office.12%29.aspx
http://msdn.microsoft.com/en-us/library/office/cc815369%28v=office.12%29.aspx
http://www.wischik.com/lu/programmer/mapi_utils.html
http://www.clydesdalesoftware.com/Blog/05-05-15/Building_Outlook_Add-ins_with_ATL_C.aspx
https://www.google.com.br/search?q=rtf%20encapsulated&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=np&source=hp
http://msdn.microsoft.com/en-us/library/ee159984%28v=exchg.80%29.aspx
http://msdn.microsoft.com/en-us/library/ee158614%28v=exchg.80%29.aspx
http://msdn.microsoft.com/en-us/library/ee217484%28v=exchg.80%29.aspx
http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/bd852fb5-159d-4250-aaa5-3e2a32be0fcb
http://msdn.microsoft.com/en-us/library/office/dd162409%28v=office.12%29.aspx

;;

[szMAPIDLL: B$ 0 #&MAX_PATH]
[pfnMAPIInitialize: D$ 0]
[pfnMAPIUninitialize: D$ 0]
[Sz_MapiError1: B$ "The application could not access an Exchange Server 2010 server.
Try installing the hotfix 2685289 for it as described in:
http://support.microsoft.com/kb/2674185
http://support.microsoft.com/kb/2685289
http://support.microsoft.com/kb/892231/pt-br

If it also fails, it means that you don´t have uou probably don´t have
'Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1'
installed on your machine, as describe in:
http://support.backup-connect.com/2010/01/21/insufficient-permissions-for-mailbox-backup

Error= Mapi_E_call_failed Detail= Unspecified error:
How to solve error: Error= Mapi_E_call_failed Detail= Unspecified error:
 
When configurating or performing a maillevel backup on a server 2003/2008, the following error can occur:
logonSession 'ERROR= MAPI_E_CALL_FAILED Detail= Unspecified error'
This problem is caused by the MAPI Files that are stored on the system. This is often caused by a previous used backup software.

* To resolve the issue, please verify if the Mapisp32.exe file does exist on the system (C:\WINDOWS\system32\mapisp32.exe).
  In some cases, the Mapisp32.exe file may have been removed or renamed by anti-virus software.
  You can restore this by reinstalling the Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 (ExchangeMAPICdo.exe).
  Make sure you uninstall the old version first. Then run Mapisp32.exe.

* Disable old back-up software (i.e. backup exec), and make sure outlook, outlook express or windows mail are not installed on the server.

____________________________________________________________
To install, download it at:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=1004
or
http://download.microsoft.com/download/A/2/4/A24BD8F5-4475-4C3B-B051-7A264B660E90/ExchangeMapiCdo.EXE", 0]

Proc MapiWorks:
    Local @hMapiDLL

    call InitializeMapiFunctions szMAPIDLL, pfnMAPIInitialize, pfnMAPIUninitialize
    On eax = 0, ExitP
    mov D@hMapiDLL eax
    ; Initialize the MAPI subsystem
    call D$pfnMAPIInitialize &NULL
    ; &MAPI_E_INVALID_PARAMETER &MAPI_E_UNKNOWN_FLAGS &MAPI_E_NOT_ENOUGH_RESOURCES &MAPI_E_CALL_FAILED <---- DAMN IT ! &MAPI_E_NOT_INITIALIZED
    ; &MAPI_E_CALL_FAILED = need to install an update http://support.microsoft.com/kb/2674185 http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=892231&kbln=pt-br
    ; http://support.backup-connect.com/2010/01/21/insufficient-permissions-for-mailbox-backup/
    ; http://www.microsoft.com/en-us/download/confirmation.aspx?id=1004
    ..If eax <> &S_OK
        .If eax = &MAPI_E_CALL_FAILED
            call 'USER32.MessageBoxA' 0, Sz_MapiError1, {'Error: Mapi Failed (MAPI_E_CALL_FAILED)', 0},  &MB_OK__&MB_ICONWARNING__&MB_SYSTEMMODAL
        .End_If
        call 'KERNEL32.FreeLibrary' D@hMapiDLL
        xor eax eax
        ExitP ; something wrong at initilization
    ..End_If

    ; Here’s where you make calls to other MAPI APIs


    ; Uninitialize the MAPI subsystem
    call D$pfnMAPIUninitialize
    call 'KERNEL32.FreeLibrary' D@hMapiDLL
EndP

Code: [Select]

[s_szMSIApplicationLCID: B$ "Microsoft\\Office\\9.0\\Outlook\0LastUILanguage\0", 0]
[s_szMSIOfficeLCID: B$ "Microsoft\\Office\\9.0\\Common\\LanguageResources\0UILanguage\0InstallLanguage\0", 0]

[s_szMSIOfficeLCID2: B$ "Microsoft\Office\12.0\Common\LanguageResources\0InstalledUIs\0", 0]

Proc InitializeMapiFunctions:
    Arguments @szMAPIDir, @pMapiInit, @pMapiDeInit
    Local @hinstStub, @pfnFGetComponentPath
    Uses edi, ecx, ebx, edx, esi

    mov D@hinstStub 0
    mov D@pfnFGetComponentPath 0
    call 'KERNEL32.LoadLibraryA' {B$ "mapistub.dll", 0}
    If eax = 0
        call 'KERNEL32.LoadLibraryA' {B$ "mapi32.dll", 0} | On eax = 0, ExitP
    End_If
    mov D@hinstStub eax

    call 'KERNEL32.GetProcAddress' eax, {B$ "FGetComponentPath", 0} | mov D@pfnFGetComponentPath eax
    ...If eax <> 0
        mov edi D@szMAPIDir
        call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIApplicationLCID, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
        call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIOfficeLCID, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
        call D@pfnFGetComponentPath {B$ "FF1D0740-D227-11D1-A4B0-006008AF820E", 0}, s_szMSIOfficeLCID2, edi, &MAX_PATH, &TRUE | on eax <> 0, jmp L1>
        call D@pfnFGetComponentPath {B$ "473FF9A0-D659-11D1-A4B2-006008AF820E", 0}, &NULL, edi, &MAX_PATH, &TRUE
        If eax = 0
            call 'KERNEL32.FreeLibrary' D@hinstStub | xor eax eax | ExitP
        End_If
        L1:
            If B$edi = '\'
                mov B$edi 0
                inc edi
            End_If
    ...End_If
    call 'KERNEL32.GetProcAddress' D@hinstStub, {B$ "MAPIInitialize", 0}
    If eax <> 0
        mov esi D@pMapiInit
        mov D$esi eax
    End_If
    call 'KERNEL32.GetProcAddress' D@hinstStub, {B$ "MAPIUninitialize", 0}
    If eax <> 0
        mov esi D@pMapiDeInit
        mov D$esi eax
    End_If
    mov eax D@hinstStub

EndP


If the error shows up,follows the instructions and install the last hotfixor the "Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1" at: http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

I was having that crappy error and had no idea,untill i found the solution and install this thing



Of course, all the above code can be simply replaced by a call to the initialize function as:

Code: [Select]
call 'mapi32.MAPIInitialize' &NULL
But,since i was following M$ instructions, it lead me to that code  :greensml:
At least now i know why i was not being able to initialize the Mapi library.

Now is a matter of see the relationship between mapi32.dll and cdosys.dll, in order to achieve the proper convertion functions.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #24 on: June 10, 2013, 10:47:43 PM »

To begin by update your system don't seem to be the good way.Try to make it work as it is.
The header files i have posted don't need any update,try to follow the same path.
The dependances are clear.It is the msado15.dll perhaps another one on your system.If you update ,it could change.


Fa is a musical note to play with CL

jj2007

  • Member
  • *****
  • Posts: 13300
  • Assembly is fun ;-)
    • MasmBasic
Re: HTML to RTF
« Reply #25 on: June 11, 2013, 01:12:41 AM »
Hi Guga,

I tried the other road, so far with success, at least on Win7. Here is the most important line:

           push ForeignToRtf32(srcfile$, 0, SrcBuf, Chr$(0), 0, offset cbRead)

I'm afraid it requires a well-known library ;-)

P.S.: Test it by dragging whatever.htm over the executable. Note that pages saved from Masm32 sometimes choke during conversion (but try the samples attached); in contrast, a plain Google.com gets converted but you may have to scroll down 20 pages to get past the css and javascript crap.

The archive contains a second sample, a MS Works doc called MASM32_SDK.wps
Conversion quality is much better...

EDIT: Version b attached, with improved commandline handling (test_tmp.rtf will be now created in the folder of the htm source). Test opening the RTF in MS Word, it looks pretty OK.
« Last Edit: June 11, 2013, 08:09:32 AM by jj2007 »

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #26 on: June 11, 2013, 04:33:33 AM »

first step with :
Code: [Select]
invoke CoCreateInstance,addr CLSID_Message, NULL,CLSCTX_ALL,\
addr IID_IMessage,\
addr ppvIMessage ;ppv out
;eax S_OK réussite
.if ppvIMessage != 0 ;réussite
IMessage  Release
.else
;voir erreurs com
.endif
http://msdn.microsoft.com/en-us/library/ms526451(v=exchg.10).aspx

Fa is a musical note to play with CL

guga

  • Moderator
  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: HTML to RTF
« Reply #27 on: June 11, 2013, 11:25:22 AM »
Good work guys

toutenasm here goes the msado15 classes and enumerations:

It links to the msado interface that will then call the  cdosys.dll


Also, see here to connect to this thing:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms677563%28v=vs.85%29.aspx



JJ. Excelent work, but it uses office to perform the convertion, right ? I was thinking in something more direct from the OS, and perhaps this encapsulation is the answer, since it seems to convert correctly RTF to HTML and vice-versa preserving the formattings
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

  • Member
  • *****
  • Posts: 13300
  • Assembly is fun ;-)
    • MasmBasic
Re: HTML to RTF
« Reply #28 on: June 11, 2013, 03:20:15 PM »
JJ. Excelent work, but it uses office to perform the convertion, right ?

Not really. Html.iec is part of the OS:
Quote
html.iec........(Microsoft HTML Converter). Needed to be able to copy text from a Webpage and paste it to Wordpad

And it works remarkably well, see new attachment in reply #25.
The "embedded" strategy might work in some cases, but it implies that you have a fake RTF file with html containers. Test if that works with a simple RichEd control - I doubt it...

TouEnMasm

  • Member
  • *****
  • Posts: 1762
    • EditMasm
Re: HTML to RTF
« Reply #29 on: June 11, 2013, 04:07:36 PM »

To jj,i have free office who is launched by your application.
I give better results when i run it myself.
Fa is a musical note to play with CL