News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

XML Parser/Edit library

Started by ragdog, February 05, 2017, 09:46:05 PM

Previous topic - Next topic

HSE

Equations in Assembly: SmplMath

fearless

https://dl.dropboxusercontent.com/u/17077376/mxml-2.10.zip

ragdog

Thank you

Yes it crash in mxmlLoadFile

004011F6  MOV EDI,[ARG.1]
004011F9   PUSH EDI                                 ; /stream
004011FA  CALL <JMP.&MSVCR120.getc>                ; \getc

I must use a newer Msvcrt.lib from \Microsoft Visual Studio 12.0\VC\lib\
And it works.

fearless

I managed to trace into the getc as far as a lock function and then the exception was thrown. (I compiled static lib with debug /Zi setting in it, recompiled the mxmltree with debug settings and then used x64dbg to trace as far as the internal getc lock function)

Here is my radasm v2 project options for debug:
3,O,$B\ML.EXE /c /coff /Cp /Zi /Zd /nologo /I"$I",2
5,O,$B\LINK.EXE /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"$18" /VERSION:4.0 /LIBPATH:"$L" /OUT:"$5",3,4


I dont seem to have a vc12 lib folder for some reason, maybe you can recompile the static on your system and upload that msvcrt.lib as well so i can try it out

ragdog


Here is this msvcrt.lib from "\Microsoft Visual Studio 12.0\VC\lib\msvcrt.lib"

https://www.sendspace.com/file/ts239p

Copy this in your project folder rename it to msvcrt_.lib
and include this

include msvcrt.inc
includelib msvcrt_.lib
include mxml.inc
includelib mxml.lib


Here is my working code


invoke crt_fopen ,chr$ ("test.xml"), chr$ ("r");
.if eax!=0
mov FilePointer,eax
invoke mxmlLoadFile,NULL,FilePointer,MXML_NO_CALLBACK
.endif


fearless

Ok that seems to work, i was using standard CreateFile api call to open and passing the handle to mxmlLoadFile which doesnt seem to work for some reason - must be a c runtime thing. Anyhow at least we know why and now there is a couple of ways of handling the xml files.

ragdog

I have rebuild this static library and use a older Msvcrt.lib from Xp
Now works it fine without MSVCR1xx  Runtimes. etc


please test it

fearless

That crashed for me using mxmlFileOpen - the one i have seems to work ok for me.

ragdog

My static lib what i have attach Crash in mxmlFileOpen ?


fearless

yes - but it could be that they are still calling msvrt routines as bundled in dll's on our different systems.

ragdog

My static lib use not MSVCR1xxx runtimes, i use a older from xp

Correction.
your last static lib with MSVCR100 and the older MSVCR120 crash too.
This is if i use the msvcrt.lib from Masm32 package.

for run fine must i use msvcrt from sdk

My static lib use without MSVCR1xxx


.686
.model flat,stdcall
option casemap:none

include Console.inc

include msvcrt.inc
includelib msvcrt.lib
include mxml.inc
includelib mxml_ragdog.lib;mxml.lib

.data?
FilePointer dd ?
pTree dd ?
node dd ?
.code
start:

;#########################################################################
invoke crt_fopen ,chr$ ("test.xml"), chr$ ("r");
.if (eax)
mov FilePointer,eax
invoke mxmlLoadFile,NULL,FilePointer,MXML_NO_CALLBACK
.if (eax)
mov pTree,eax
invoke mxmlFindElement,pTree ,pTree, chr$ ("note"),NULL, NULL,MXML_DESCEND
.if (eax)
mov node,eax
invoke mxmlElementGetAttr,node,chr$ ("year")
invoke crt_printf,chr$ (" year:%s" ,CR,LF),eax

invoke mxmlElementGetAttr,node,chr$ ("date")
invoke crt_printf,chr$ (" date:%s" ,CR,LF),eax
.else
invoke crt_puts ,chr$ ("Unable to find first <choice> element in XML tree.")
.endif
.endif
.endif
;#########################################################################

invoke wait_key
@exit:
    invoke ExitProcess, 0


end start




output

year:55
date:33


See in my attach.
https://www.sendspace.com/file/ax91c7

HSE

@ragdog:
  working :t

@fearless:
  there is a problem with debug32. I disabled. Try that.

Equations in Assembly: SmplMath

fearless

Debug32 uses msvcrt i think anyhow. I commented out the DEBUG32 EQU 1 line when i want to exclude debug32 etc. Seems to work fine with that lib and the standard msvcrt.lib found in the masm32 lib folder.

Anyhow hopefully its useful stuff for others.

ragdog

Thank you both for the test, and Fear for translate the header and the project files.

QuoteDebug32 uses msvcrt i think anyhow. I commented out the DEBUG32 EQU 1 line when i want to exclude debug32 etc. Seems to work fine with that lib and the standard msvcrt.lib found in the masm32 lib folder.

It works fine with Debug32 stuff and msvcrt.lib from Masm32 folder :t


include msvcrt.inc  ;<<< From Masm32 folder
includelib msvcrt.lib   ;<<< From Masm32 folder
include mxml.inc
includelib mxml_ragdog.lib;mxml.lib

DEBUG32 EQU 1

IFDEF DEBUG32
    includelib \Masm32\lib\Debug32.lib
    DBG32LIB equ 1
    DEBUGEXE textequ <'\Masm32\DbgWin.exe'>
    include \Masm32\include\debug32.inc
ENDIF


The problem was only the original MiniXml project by compile it with Vs it include the MSVCRxxx runtimes
In other Cpp projects have i add a Tinycrt or a older Msvcrt.lib from Windows XP sdk to remove this MSVCRxxx runtimes.

HSE

@fearless:
You can define NODEBUGTOOLS equ 0, and that disabled the calls to debug system (you don't need all those IFDEF DEBUG32) .

Still there is some problem with Debug32 here, perhaps a macro with same name. There is not  serious consequences because usually I use OA32 DebugCenter, a more complex VKdebug descendent, but perhaps it's a problem to follow some projects that used it.

A year ago I downloaded several alternatives for Xml, but after some days none of them worked. Now I put to work these examples of Mini-MXML ( wich library I can't compile  :biggrin:), asm-xml1.4, XML_parser from Nemeth_G and IoEXML Writer-Parser (I forgot that was working, it's a nightmare COM thing). 

Thanks   
Equations in Assembly: SmplMath