








format MS COFF

R1 fix eax
R2 fix ebx
R3 fix ecx
R4 fix edx
R5 fix edi
R6 fix esi
R7 fix ebp
RSP fix esp
BITS fix 32
dv fix dd
vword fix dword







;
;
;
;
;
;
;





macro display [args]
{
	forward
	if args eqtype 'a'
		display args
	else if args = 10
		display args
	else if args = 13
		display args
	else
		c_intCurrent = args
		c_intNew = 0
		c_cRepeats = 0
		repeat 10
			if c_intCurrent > 0
				c_intNew = (c_intNew * 10) + (c_intCurrent mod 10)
				c_intCurrent = c_intCurrent / 10
				c_cRepeats = c_cRepeats + 1
			end if			
		end repeat
		if c_intNew = 0
			display '0'
		else
			repeat c_cRepeats
					display '0' + (c_intNew mod 10)
					c_intNew = c_intNew / 10
			end repeat			
		end if			
	end if
}




;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
	
	
	
macro AddDataList a_strClass, a_strLabel , a_strType, [a_astrValues]{
common
	struc a_strClass \{
		. a_strClass
		a_strLabel a_strType a_astrValues
	\}
}
macro AddDataLabel a_strClass , a_strLabel , a_strObjType {
common
	struc a_strClass \{
		. a_strClass
		ObjectLabel a_strClass, a_strLabel
	\}
}

macro ObjectLabel a_strClass , a_strLabel{
	a_strLabel :
}

macro displaylist [a_astrList]{
forward
	display `a_astrList , ' , '
common
	display 13 , 10
}

macro InitBaseProc a_strClass , a_strProc{
	a_strClass#_FUNCLIST equ a_strProc
}

macro AddBaseProc a_strClass , a_strProc{
	match t_astrList , a_strClass#_FUNCLIST\{
		restore a_strClass#_FUNCLIST
		a_strClass#_FUNCLIST equ t_astrList , a_strProc
		restore t_astrPrev
		a_strClass#_ADDRESS.#a_strProc equ ?#a_strProc#@#a_strClass
	\}
}

macro InitDerivProcAddr a_strClass, a_strBase, a_strStart , [a_astrFuncs]{
forward
		a_strClass#_ADDRESS.#a_astrFuncs equ a_strBase#_ADDRESS.#a_astrFuncs 
}

macro InitDerivedProc a_strClass , a_strBase {
	match t_astrList , a_strBase#_FUNCLIST\{
		a_strClass#_FUNCLIST equ t_astrList
		InitDerivProcAddr a_strClass , a_strBase,  t_astrList
	\}	
}

macro AddDerivedProc a_strClass , a_strBase , a_strProc{
	match =a_strClass#_ADDRESS.#a_strProc , a_strClass#_ADDRESS.#a_strProc \{
		match t_astrList , a_strClass#_FUNCLIST \\{
			t_astrPrev equ t_astrList
			restore a_strClass#_FUNCLIST
			a_strClass#_FUNCLIST equ t_astrPrev , a_strProc
			restore t_astrPrev
		\\}
	\}
	restore a_strClass#_ADDRESS.#a_strProc
	a_strClass#_ADDRESS.#a_strProc equ ?#a_strProc#@#a_strClass
}

macro CreateProcTable a_strClass , a_strStart , [a_astrFuncs]{
common
	virtual at 0
		a_strClass#_FUNCOFFSET:
forward
			.#a_astrFuncs dv ?
common
	end virtual
}

macro InitVirtualTableLst a_strClass , a_strStart , [a_astrFuncs]{
common
	a_strClass#PVTBLPRIMEVAL :
display 'InitVirtualTableLst ', `a_strClass , 13 , 10	
forward
		match =a_strStart , a_astrFuncs \{
			a_strClass#_PVTABLE :
		\}
		match a_strAddress , ?\#a_astrFuncs\#@#a_strClass\{
			dv a_strAddress
		\}
}

macro InitVirtualTable a_strClass{
display 'Inicializando VirtualTable para ', `a_strClass , 13 , 10
	match t_astrList , a_strClass#_FUNCLIST \{
		InitVirtualTableLst a_strClass , t_astrList
	\}
}

macro CreateSingleExtern a_strClass , a_strProc , a_strAddress {
	match =a_strAddress , a_strClass#_ADDRESS.#a_strProc\{
		if defined a_strClass#PVTBLPRIMEVAL
			public a_strAddress
		else
			extrn a_strAddress
		end if		
	\}
}

macro CreateExternsList a_strClass , a_strStart, [a_astrFuncs] {
common
	if defined a_strClass#PVTBLPRIMEVAL
display 'Defining symbol as public', 13 , 10	
		public a_strClass#_PVTABLE
	else
display 'Defining symbol as extrn', 13 , 10	
		extrn a_strClass#_PVTABLE
	end if		
forward
	match x , a_astrFuncs#@#a_strClass \{
		CreateSingleExtern a_strClass , a_astrFuncs , x
	\}
}

macro CreateExterns a_strClass {

	match x , a_strClass#_FUNCLIST \{
		CreateExternsList a_strClass , x
	\}
}



macro BaseClass a_strClass{
	\macro ClassStartData \{
		struc dq [val] \\{ \\common AddDataList a_strClass , . , dq , val \\}
		struc dp [val] \\{ \\common AddDataList a_strClass , . , dp , val \\}
		struc dd [val] \\{ \\common AddDataList a_strClass , . , dd , val \\}
		struc dw [val] \\{ \\common AddDataList a_strClass , . , dw , val \\}
		struc db [val] \\{ \\common AddDataList a_strClass , . , db , val \\}
		macro ObjectLabel a_strObjClass, a_strLabel \\{ AddDataLabel a_strClass , a_strLabel , a_strObjClass \\}
		\\macro ObjectAggregate a_strObjClass, a_strLabel \\{ AddDataLabel a_strClass , a_strLabel , a_strObjClass \\}
		
		\\struc a_strClass \\{
			\\\match =MAINCLASS , MAINCLASS \\\{
				MAINCLASS \\\equ a_strClass
			\\\}
			
			.m_pvFuncTable dv 0
		\\}
	\}
	macro ClassEndData \{
		\\struc a_strClass \\{
			. a_strClass
			\\match =a_strClass , MAINCLASS \\\{
				ObjectLabel a_strClass , .sizeof
				restore MAINCLASS
			\\\}
		\\}
		restruc dq
		restruc dp
		restruc dd
		restruc dw
		restruc db
		purge ObjectLabel
		purge ObjectAggregate
		\\virtual at 0
			a_strClass a_strClass
		\\end virtual
	\}
	macro ClassStartProc a_strStart \{
		InitBaseProc a_strClass , a_strStart
		\macro Proc a_strProc \\{
			AddBaseProc a_strClass , a_strProc			
		\\}
	\}		
	macro ClassEndProc \{
		match t_astrList , a_strClass#_FUNCLIST \\{
			CreateProcTable a_strClass , t_astrList				
		\\}
		purge Proc
	\}
	
	\macro ClassEnd\{
		purge ClassStartData
		purge ClassEndData
		purge ClassStartProc
		purge ClassEndProc
		
		CreateExterns a_strClass
	\}		
}

macro DerivedClass a_strClass , a_strBase{
	\macro ClassStartData \{
		\\struc dq [val] \\{ \\common AddDataList a_strClass , . , dq , val \\}
		\\struc dp [val] \\{ \\common AddDataList a_strClass , . , dp , val \\}
		\\struc dd [val] \\{ \\common AddDataList a_strClass , . , dd , val \\}
		\\struc dw [val] \\{ \\common AddDataList a_strClass , . , dw , val \\}
		\\struc db [val] \\{ \\common AddDataList a_strClass , . , db , val \\}
		\\macro ObjectLabel a_strObjClass, a_strLabel \\{ AddDataLabel a_strClass , a_strLabel , a_strObjClass \\}
		\\macro ObjectAggregate a_strObjClass, a_strLabel \\{ AddDataLabel a_strClass , a_strLabel , a_strObjClass \\}
		
		\\struc a_strClass \\{
			\\\match =MAINCLASS , MAINCLASS \\\{
				MAINCLASS \\\equ a_strClass
			\\\}
			. a_strBase
		\\}			
	\}
	macro ClassEndData \{
		\\struc a_strClass \\{
			. a_strClass
			\\match =a_strClass , MAINCLASS \\\{
				ObjectLabel a_strClass , .sizeof
				restore MAINCLASS
			\\\}
		\\}
		restruc dq
		restruc dp
		restruc dd
		restruc dw
		restruc db
		purge ObjectLabel
		purge ObjectAggregate
		\virtual at 0
			a_strClass a_strClass
		\end virtual
	\}
	macro ClassStartProc a_strStart \{
		InitDerivedProc a_strClass , a_strBase
		\macro Proc a_strProc \\{
			AddDerivedProc a_strClass , a_strBase , a_strProc
		\\}
	\}		
	macro ClassEndProc \{
		match t_astrList , a_strClass#_FUNCLIST\\{
			CreateProcTable a_strClass , t_astrList
		\\}
		purge Proc
	\}
	
	\macro ClassEnd\{
		purge ClassStartData
		purge ClassEndData
		purge ClassStartProc
		purge ClassEndProc
	\}
}

macro Class a_strClass , a_strBase{
	match x , a_strBase \{
		DerivedClass a_strClass , a_strBase
	\}
	match , a_strBase \{
		BaseClass a_strClass
	\}
}

macro VIRTUALCALL a_strClass , a_strProc , a_strObj , [a_astrParams]{
t_cOffset = (BITS / 8)
reverse
	match a_strParam , a_astrParams\{
		mov [RSP - t_cOffset] , a_strParam
		t_cOffset = t_cOffset + (BITS / 8)
	\}
common
	sub RSP , t_cOffset
	mov R1 , [a_strObj + a_strClass#.#m_pvFuncTable ]
	mov [RSP] , a_strObj	
	call vword [R1 + a_strClass#_FUNCOFFSET.#a_strProc]	
}







PROCDATA_ID fix 0x10213243

ExceptionContinueExecution	fix 0
ExceptionContinueSearch		fix 1
ExceptionNestedException	fix 2
ExceptionCollidedUnwind		fix 3

DEBUG_LEVEL fix DEBUGLEVEL_INSTR

struc TIB
{
.m_pexrExceptionList		dd ?
.m_pvStackBase				dd ?
.m_pvStackLimit				dd ?
	.m_pvSubSystemTib:				;WINNT
	.m_pvTDB:				dw ?	;WIN95
	.m_pvThunkSS:			dw ?	;WIN95

	.m_pvFiberDataOrVersion:		;WINNT
	.m_dwUnknown			dd ?	;WIN95

.m_pvArbitraryUserPointer	dd ?
.m_pntbSelf					dd ?

	.m_dwUnknown1:					;WINNT
	.m_wTIBFlags			dw ?	;WIN95
	.m_wWin16MutexCount		dw ?	;WIN95

	.m_dwProcessID:					;WINNT
	.m_dwDebugContext		dd ?	;WIN95

	.m_dwThreadID:					;WINNT
	.m_pCurrentPriority		dd ?	;WIN95
	
	.m_dwUnknown2			dd ?	;WINNT
	.m_pvQueue				dd ?	;WIN95

.m_pvTLSArray				dd ?
	
	.m_pProcess				dd ?	;WIN95
}

virtual at 0
TIB TIB
end virtual


EXCEPTION_MAXIMUM_PARAMETERS	fix 15

struc EXCEPTION_RECORD
{
	.m_dwExceptionCode		dd ?
	.m_dwExceptionFlags		dd ?
	.m_percExceptionRecord	dd ?
	.m_pvExceptionAddress	dd ?
	.m_cParams				dd ?
	.m_ExceptionInformation:
	rept EXCEPTION_MAXIMUM_PARAMETERS
	\{
		dd ?
	\}
}

virtual at 0
	EXCEPTION_RECORD EXCEPTION_RECORD
end virtual

SIZE_OF_80387_REGISTERS fix 80

struc FLOATING_SAVE_AREA
{
	.m_dwControlWord	dd ?
	.m_dwStatusWord		dd ?
	.m_dwTagWord		dd ?
	.m_dwErrorOffset	dd ?
	.m_dwErrorSelector	dd ?
	.m_dwDataOffset		dd ?
	.m_dwDataSelector	dd ?
	.m_adblRegisterArea:
		repeat SIZE_OF_80387_REGISTERS
			db ?
		end repeat
	.m_dwCr0NpxState	dd ?
	.sizeof:
}

struc CONTEXT
{
.m_dwContextFlags	dd ?
.m_dwDr0			dd ?
.m_dwDr1			dd ?
.m_dwDr2			dd ?
.m_dwDr3			dd ?
.m_dwDr6			dd ?
.m_dwDr7			dd ?

.m_flsFloatSave	FLOATING_SAVE_AREA

.m_dwSegGs			dd ?
.m_dwSegFs			dd ?
.m_dwSegEs			dd ?
.m_dwSegDs			dd ?

.m_edi			dd ?
.m_esi			dd ?
.m_ebx			dd ?
.m_edx			dd ?
.m_ecx			dd ?
.m_eax			dd ?
.m_ebp			dd ?
.m_eip			dd ?
.m_dwSegCs		dd ?
.m_dwEFlags		dd ?
.m_esp			dd ?
.m_dwSegSs		dd ?

.m_dwExtendedRegisters: rept 512 \{ db ? \}
}

virtual at 0
	CONTEXT CONTEXT
end virtual

struc PROCDATA
{
	.m_pexrPrevious		dd ?
	.m_pfncHandler		dd ?
	.m_dwID				dd ?
	.m_pvContinue		dd ?
	.m_pvPrevHandler	dd ?
	.m_dwdLine			dd ?
	.m_strFile			dd ?
	.m_strProc			dd ?
	.m_pvProc			dd ?
	.m_dwStack			dd ?
	
	.m_ebx dd ?
	.m_esi dd ?
	.m_edi dd ?
	.m_ebp dd ?
	
	.m_eax dd ?
	.m_ecx dd ?
	.m_edx dd ?
	
	.m_pvObjList dd ?
	
	.sizeof :
}

virtual at 0
PROCDATA PROCDATA
end virtual








S_OK equ 0
S_FALSE equ 1
E_NOINTERFACE equ 0x80004002

E_NOTIMPL equ 0x80004001
E_OUTOFMEMORY equ 0x8007000E
E_INVALIDARG equ 0x80070057
CONNECT_E_NOCONNECTION	equ 0x80040200
CONNECT_E_ADVISELIMIT   equ 0x80040201
CONNECT_E_CANNOTCONNECT equ 0x80040202
CONNECT_E_OVERRIDDEN	equ 0x80040203



struc GUID x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11
{
	.dwd1	dd x1
	.wrd1	dw x2
	.wrd2	dw x3
	.byt1	db x4
	.byt2	db x5
	.byt3	db x6
	.byt4	db x7
	.byt5	db x8
	.byt6	db x9
	.byt7	db x10
	.byt8	db x11
}

macro DefineUUID a_pvGUID , x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11
{
common
	match =1,INSTGUID \{
		a_pvGUID GUID x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11 
		public a_pvGUID
	\}
	match =INSTGUID,INSTGUID \{
		extrn a_pvGUID
	\}
}


macro LocateGUID a_puidSource,[a_puidConst,a_pvJumpTo]
{
forward
	cmp a_puidSource , a_puidConst
	je a_pvJumpTo
}



DefineUUID IID_IUnknown				, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46

DefineUUID IID_IDispatch			, 0x00020400, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46

DefineUUID IIDBase					, 0xb36b6969, 0x630d, 0x46f9, 0xb3, 0x39, 0x96, 0x85, 0xe2, 0x98, 0x3a, 0x0c

DefineUUID IIDMemory				, 0x6d178f84, 0xa1d3, 0x46a4, 0x9a, 0x09, 0xcb, 0x9a, 0x43, 0xed, 0x03, 0x55

DefineUUID IIDArray					, 0x8a1bed0a, 0x7802, 0x4296, 0x8c, 0x9f, 0x81, 0x57, 0xe1, 0x8b, 0x85, 0x04

DefineUUID IIDString				, 0x72ecefb8, 0xb558, 0x4b8f, 0xaf, 0xc5, 0x0d, 0x9d, 0xe9, 0xeb, 0x96, 0x7f

DefineUUID IIDArrayNotes			, 0x90838063, 0x06d0, 0x4a77, 0x85, 0x5b, 0x67, 0xe2, 0x8d, 0x33, 0x47, 0xe3

DefineUUID IIDNotesDataInterface	, 0x2bc7b165, 0x8960, 0x4d55, 0x87, 0x8c, 0x73, 0xbb, 0xbd, 0x00, 0x35, 0xb7

DefineUUID IIDStringNotes			, 0xffbf1f40, 0x73e2, 0x4787, 0xae, 0xca, 0xe6, 0xaf, 0x70, 0x7d, 0xf3, 0x99

DefineUUID IID_IConnectionPointContainer , 0xB196B284, 0xBAB4, 0x101A, 0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07

DefineUUID IID_IConnectionPoint		, 0xB196B286, 0xBAB4, 0x101A, 0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07

DefineUUID IID_IEnumConnectionPoints, 0xB196B285, 0xBAB4, 0x101A, 0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07

DefineUUID IIDThreadEvent			, 0x889e066a, 0xf7d3, 0x45d9, 0x87, 0x9f, 0x63, 0xb1, 0x14, 0x38, 0x08, 0xe8

DefineUUID IIDFileThreadEvents		, 0xb5865d4f, 0x63e0, 0x4e8e, 0x8c, 0x58, 0x4e, 0xbf, 0x4c, 0x26, 0xe5, 0x57

DefineUUID IIDOutputStream			, 0xf04961b9, 0x2fa1, 0x4c24, 0x95, 0xe5, 0x58, 0xc6, 0x01, 0x97, 0xf5, 0x4c

DefineUUID IIDThread				, 0x91017952, 0xb8af, 0x4eb9, 0x8c, 0xc2, 0x70, 0xd2, 0x7f, 0x94, 0x6f, 0x22

DefineUUID IIDNotesDocument			, 0x4f6ae48b, 0xc9cc, 0x419c, 0x99, 0x85, 0xc6, 0xed, 0xd2, 0x70, 0x4a, 0x4e

DefineUUID IIDNotesDocumentLocator	, 0x26bdf296, 0xd92b, 0x469e, 0xb1, 0xba, 0x94, 0xc8, 0x1a, 0xb8, 0x25, 0x30

DefineUUID IIDNotesExec				, 0xa2901984, 0xa411, 0x427d, 0x9d, 0xbc, 0x4b, 0xb2, 0x39, 0x82, 0x3d, 0x14

DefineUUID IIDRichTextOS			, 0x11c33370, 0xe835, 0x4c88, 0x84, 0xba, 0xb8, 0x67, 0xc0, 0x42, 0x86, 0x05

DefineUUID IIDNotesViewColumn		, 0x5babc417, 0x23ae, 0x4f7d, 0x93, 0xb2, 0x75, 0x84, 0xef, 0x16, 0x2f, 0x3f

DefineUUID IIDNotesErrPost			, 0xd1733a4d, 0xe0c8, 0x438d, 0x84, 0xac, 0xf1, 0x59, 0xd8, 0x1b, 0xee, 0x0b

DefineUUID IIDNotesInit				, 0x6198e31e, 0xaf23, 0x4d1e, 0x95, 0xef, 0x58, 0x68, 0x7e, 0xc1, 0x47, 0x69

DefineUUID IIDNotesDocumentDesign	, 0xaa437be9, 0xc4be, 0x4d5d, 0xbe, 0x33, 0x0c, 0xfc, 0xe4, 0xd4, 0x7a, 0x28

DefineUUID IIDNotesDesignLocator	, 0xee6d3025, 0xd372, 0x4894, 0xb8, 0xb4, 0x29, 0x2f, 0xf7, 0x62, 0xa0, 0x99

DefineUUID IIDNotesArrayViewColumn	, 0x32328f1e, 0xca5d, 0x4e61, 0xad, 0x88, 0x47, 0x60, 0x03, 0x4d, 0xfe, 0x46

DefineUUID IIDNotesView				, 0xca76aa5a, 0xb6f8, 0x46c2, 0x85, 0x97, 0x53, 0x36, 0x63, 0x25, 0x6c, 0xbc

DefineUUID IIDNotesFormula			, 0x2f10f8af, 0xf78b, 0x4d88, 0xb9, 0x6e, 0x90, 0xa9, 0xf5, 0xab, 0xde, 0x71

DefineUUID IIDFile					, 0x2f10f8b0, 0xf78b, 0x4d88, 0xb9, 0x6e, 0x90, 0xa9, 0xf5, 0xab, 0xde, 0x72

DefineUUID IIDInputStreamFile		, 0x2f10f8b1, 0xf78b, 0x4d88, 0xb9, 0x6e, 0x90, 0xa9, 0xf5, 0xab, 0xde, 0x70

DefineUUID IIDOutputStreamFile		, 0x2f10f8b2, 0xf78c, 0x4d89, 0xb9, 0x6e, 0x90, 0xa9, 0xf5, 0xab, 0xde, 0x60

DefineUUID IIDTime					, 0x0c717cba, 0x5ec9, 0x4976, 0xa4, 0x7c, 0x08, 0x79, 0xac, 0x24, 0x64, 0xbc

DefineUUID IIDNotesFont				, 0x83a74dc1, 0x13e4, 0x458a, 0x94, 0x70, 0xf5, 0x5c, 0x07, 0x8c, 0x02, 0xe3

DefineUUID IIDNotesIndexDescritor	, 0x39aee88a, 0x7f9c, 0x4a66, 0x86, 0x25, 0x4e, 0x69, 0x5c, 0xa9, 0xbe, 0xdc

DefineUUID IIDNotesIndex			, 0xdde07b79, 0xcf91, 0x4791, 0xae, 0xb9, 0x95, 0xf1, 0xc4, 0xd7, 0x9c, 0x2e








macro _DECLARE_PROC a_strProc{
	public a_strProc
	a_strProc :
	PROCNAME equ a_strProc
}

macro AddParamValue a_strProc, a_strName , a_strType , [val] {
	local ..ParamLabel
	..ParamLabel a_strType ?
	a_strName equ [PROCDATA_ADDR + ..ParamLabel + 4]
}

macro AddParamLabel a_strProc , a_strName, a_strType {
	local ..ParamLabel
	..ParamLabel :
	a_strName equ [PROCDATA_ADDR + ..ParamLabel + 4]
}

macro PARAMLIST2 a_strProc {
	struc dq [val] \{ \common AddParamValue a_strProc , . , dq , val \}
	struc dp [val] \{ \common AddParamValue a_strProc , . , dp , val \}
	struc dd [val] \{ \common AddParamValue a_strProc , . , dd , val \}
	struc dw [val] \{ \common AddParamValue a_strProc , . , dw , val \}
	struc db [val] \{ \common AddParamValue a_strProc , . , db , val \}
	macro ObjectLabel a_strObjClass, a_strLabel \{ AddParamLabel a_strClass , a_strLabel , a_strObjClass \}
	macro ObjectAggregate a_strObjClass, a_strLabel \{ AddDataLabel a_strClass , a_strLabel , a_strObjClass \}
	virtual at 0
}
macro PARAMLISTEND2 a_strProc {
		local ..ParamLabel
		..ParamLabel :
		PARAMSIZE equ ..ParamLabel
	end virtual

	restruc dq
	restruc dp
	restruc dd
	restruc dw
	restruc db
	purge ObjectLabel
}

macro ClassStartCode a_strClass{
	macro PROCOBJ a_strProc , [a_astrFlags] \{
		common
		ebx equ VALOR_NAO_SALVO
		edi equ VALOR_NAO_SALVO
		esi equ VALOR_NAO_SALVO
		ebp equ VALOR_NAO_SALVO		

		STACKFRAMETYPE	equ ESP
		PARAMSIZE	equ 0
		LOCALSIZE	equ PROCDATA.sizeof
		
		_DECLARE_PROC ?\#a_strProc\#@#a_strClass

;
		lea edx , [esp + PROCDATA - PROCDATA.sizeof]
		mov eax , [fs:TIB.m_pexrExceptionList]
		mov [edx + PROCDATA.m_pfncHandler] , dword .ErrorHandler
		mov [fs:TIB.m_pexrExceptionList] , edx
		mov [edx + PROCDATA.m_pexrPrevious] , eax
		mov [edx + PROCDATA.m_dwID] , dword 0x14233241
		mov [edx + PROCDATA.m_pvProc] , dword PROCNAME
		mov [edx + PROCDATA.m_pvObjList] , dword 0
		mov [edx + PROCDATA.m_dwdLine] , dword $
		\forward
			\match =EBXSAVE,flags \\{
				restore ebx
				mov [edx + PROCDATA.m_ebx] , ebx
				ebx_flg equ PROCED
			\\}
			\match =EBPSAVE,flags \\{
				restore ebp
				mov dword [edx + PROCDATA.m_ebp] , ebp
				ebp_flg equ PROCED
			\\}
			\match =EDISAVE,flags \\{
				restore edi
				mov [edx + PROCDATA.m_edi] , edi
				edi_flg equ PROCED
			\\}
			\match =ESISAVE,flags \\{
				restore esi
				mov [edx + PROCDATA.m_esi] , esi
				esi_flg equ PROCED
			\\}
			
			\match =C_CALL,flags \\{
				C_CALL_FLG equ PROCED
			\\}
			
		\forward
			match =EBPSTACK,flags \\{
				lea ebp , [esp - PROCDATA.sizeof]
				restore STACKFRAMETYPE
				STACKFRAMETYPE equ EBP			
			\\}			
		\common
					
			match =ESP,STACKFRAMETYPE \\{ PROCDATA_ADDR equ esp + LOCALSIZE \\}
			match =EBP,STACKFRAMETYPE \\{ PROCDATA_ADDR equ ebp \\}
			
			lea esp , [esp + PROCDATA - PROCDATA.sizeof]
			
			\macro PARAMLIST \\{
				match t_strProcPRL , PROCNAME \\\{
					PARAMLIST2 t_strProcPRL					
				\\\}		
			\\}
					
			\macro PARAMLISTEND \\{
				match t_strProcPRL , PROCNAME \\\{
					PARAMLISTEND2 PROCNAME			
				\\\}	
			\\}					
			
			
			
			\macro PROCOBJEND \\{
			.ret:
public .ret			
;
		match =EBP,STACKFRAMETYPE \\\{
			lea esp , [ebp + PROCDATA.sizeof]
			restore PROCDATA_ADDR
			PROCDATA_ADDR equ esp + LOCALSIZE
		\\\}
		
;
		mov [PROCDATA_ADDR + PROCDATA.m_edx] , edx

;

		match =ebp , ebp \\\{ mov ebp , [PROCDATA_ADDR + PROCDATA.m_ebp] \\\}
		match =edi , edi \\\{ mov edi , [PROCDATA_ADDR + PROCDATA.m_edi] \\\}
		match =esi , esi \\\{ mov esi , [PROCDATA_ADDR + PROCDATA.m_esi] \\\}
		match =ebx , ebx \\\{ mov ebx , [PROCDATA_ADDR + PROCDATA.m_ebx] \\\}
			
;

		mov edx , [PROCDATA_ADDR + PROCDATA.m_pexrPrevious]
		mov [fs:TIB.m_pexrExceptionList] , edx

;
		mov edx , [PROCDATA_ADDR + PROCDATA.m_edx]
		
;
			add esp , LOCALSIZE + PROCDATA.sizeof


				
			match =PROCED , C_CALL_FLG \\\{
				ret
			\\\}
			match =C_CALL_FLG , C_CALL_FLG \\\{
				ret PARAMSIZE
			\\\}
			.ErrorHandler:
				purge PARAMLIST
				purge PARAMLISTEND
				
				restore ebx_flg
				restore edi_flg
				restore esi_flg
				restore ebp_flg
				
				restore ebx
				restore edi
				restore esi
				restore ebp
				restore this
				restore this
				
				restore EBXSAVE
				restore EBPSAVE
				restore EDISAVE
				restore ESISAVE
				restore EDXTHIS
				restore EBXTHIS
				restore EBPTHIS
				restore EBPSTACK
				
				
				restore STACKFRAMETYPE
				restore PARAMSIZE
				restore PARAMSIZE
				restore PARAMSIZE
				restore LOCALSIZE
			\\}
		
	\}
	macro ClassEndCode\{
		InitVirtualTable a_strClass
	\}
}




Class JRBBase
	ClassStartData
		.m_pvMain	dd ?
		.m_cRefs	dd ?
	ClassEndData
	ClassStartProc QueryInterface
		Proc Constructor
		Proc Destructor
		Proc QueryInterface
		Proc AddRef
		Proc Release
	ClassEndProc
ClassEnd

macro JRBBase_Destructor a_pvThis { VIRTUALCALL JRBBase, Destructor , a_pvThis }
macro JRBBase_QueryInterface a_pvThis , a_ridIID, a_pvRet { VIRTUALCALL JRBBase, QueryInterface, a_pvThis, a_ridIID, a_pvRet }
macro JRBBase_AddRef a_pvThis { VIRTUALCALL JRBBase_AddRef , a_pvThis }
macro JRBBase_Release a_pvThis { VIRTUALCALL JRBBase_Release , a_pvThis }

match x , JRBBase.sizeof{
	display 'Offset para x:', x , 13 , 10
}




if ~defined Teste
	display 'Not defined', 13 , 10
else
	display 'Defined' , 13 , 10
end if
Teste dd 5


ClassStartCode JRBBase
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCOBJ Constructor
	PARAMLIST
		this dd ?
	PARAMLISTEND
	mov eax , this
	mov [eax + JRBBase.m_pvMain], dword 0
	mov [eax + JRBBase.m_cRefs] , dword 1
PROCOBJEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCOBJ Destructor
	PARAMLIST
		this dd ?
	PARAMLISTEND
PROCOBJEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCOBJ QueryInterface
	PARAMLIST
		this		dd ?
		a_ridIID	dd ?
		a_pvObjRet	dd ?
	PARAMLISTEND
	mov edx , this
	mov eax , a_ridIID
	mov ecx , [edx + JRBBase.m_pvMain]
	test ecx , ecx
	jz .NoMain
		mov edx , a_pvObjRet
		JRBBase_QueryInterface ecx , eax , edx
		jmp .ret
.NoMain: 
	LocateGUID eax , IID_IUnknown , .FoundThis , IIDBase , .FoundThis
		mov [edx] , dword 0
		mov eax , E_NOINTERFACE
		jmp .ret
.FoundThis:
	mov ecx , a_pvObjRet
	inc dword [edx + JRBBase.m_cRefs]
	mov eax , 0		
	mov [ecx] , edx
	
PROCOBJEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCOBJ AddRef
	PARAMLIST
		this dd ?
	PARAMLISTEND
	mov edx , this
	mov eax , [edx + JRBBase.m_cRefs]
	inc eax
	mov [edx + JRBBase.m_cRefs] , eax
PROCOBJEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCOBJ Release
	PARAMLIST
		this dd ?
	PARAMLISTEND
	mov edx , this
	dec dword [edx + JRBBase.m_cRefs]
	mov eax , [edx + JRBBase.m_cRefs]
	jnz .ret
		JRBBase_Destructor edx
		xor eax , eax
PROCOBJEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ClassEndCode
