News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Masm32Ref

Started by mabdelouahab, January 14, 2016, 09:56:41 AM

Previous topic - Next topic

GoneFishing

HELLO ZEN ,

I want to share with you my secret knowledge
First , please, read about   #import Directive (C++)

Now create a new project with your version of MS VS ( I assume you already have it installed )  with this code:


// TLBimports.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" raw_interfaces_only
#import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscoree.tlb" raw_interfaces_only

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}


ATTENTION : In the  sample above I hardcoded the paths to the typelibs of .NET Framework v2

You may need to change it or write just typelib name without path to use the default runtime

Build the project and open its folder in explorer . Look for files with .tlh extension .

Here's the trick . You've got all interfaces defined. Convert them to MASM includes and you'll become extremly dangerous coder.
;-)

In a day or two I'll  polish one simple project  and possibly ( if you don't mind ) post it here . 

mabdelouahab

ZEN
When we are dealing with the Common Language Runtime, I think the first thing to do is to understand well what does it mean an managed Object instance in memory, and how it is converted from managed to unmanaged code (Marshaling)
this is an managed Object in memory (x86)
You can not figure out the order of Methods because that order varies

This is an excerpt from this document (Default Marshaling for Objects) that explains how to exposed an object to COM as an interface (What we are dealing with it)
Quote
Marshaling Object to Interface
When an object is exposed to COM as an interface, that interface is the class interface for the managed type Object (the _Object interface). This interface is typed as an IDispatch (UnmanagedType.IDispatch) or an IUnknown (UnmanagedType.IUnknown) in the resulting type library. COM clients can dynamically invoke the members of the managed class or any members implemented by its derived classes through the _Object interface. The client can also call QueryInterface to obtain any other interface explicitly implemented by the managed type.

ZEN
Did you know that the best way to deal with .Net objects are using reflection(System.Reflection), And this is the method used in Masm32Ref
QuoteThe classes in the System.Reflection namespace, together with System::Type, enable you to obtain information about loaded assemblies and the types defined within them, such as classes, interfaces, and value types. You can also use reflection to create type instances at run time, and to invoke and access them

See:
Reflection in the .NET Framework
Dynamic Programming in the .NET Framework

Remark: I reiterate my apology from my English bad

Zen

Excellent Intel, MABDELOUAHAB,...thanks,...I'll read up on everything,...:bgrin:
Undoubtedly, Il Spy uses reflection to produce its output (all the code that implements the methods of whatever object or class you're interested in),...

...And,...VERTOGRAD/GONEFISHING,...good to see you here again. :bgrin:
Quote from: VERTOGRAD...Here's the trick . You've got all interfaces defined. Convert them to MASM includes and you'll become extremly dangerous coder,...
I'm already the undisputed champion 'most annoying coder in the MASM Forum',...so, yes,...the yellow brick road to world domination extends out on my horizon. :bgrin: Thanks for the tip,...but, I don't have Visual Studio on my computer anymore,...but, I think I can figure out how to do it in MASM, if necessary,...
By the way,...this MASM32Ref Project of  MABDELOUAHAB's is really a great concept,...and, with just a few minor errors, it works well,...
Zen

Zen

Hi, again,...MABDELOUAHAB,
I have another problem,...in fact,...I'm completely stuck.

I'm going through the code in __GetDefaultDomain,...and, I'm trying to make sense out of the purpose of both functions, __ForEachAssemblyInIAppDomain and CallBackFunction_GetMsCorLibAssembly. I think I understand what is supposed to happen in __ForEachAssemblyInIAppDomain (the code iterates through all loaded assemblies in the AppDomain, calling CallBackFunction_GetMsCorLibAssembly for each one). But,...what is supposed to happen in CallBackFunction_GetMsCorLibAssembly ??? Specifically, I have absolutely no idea what this block of code is supposed to be doing:
     ;     (from procedure, CallBackFunction_GetMsCorLibAssembly)     
     .IF __Asm    ;    __Asm is a pointer to the data returned in SAFEARRAY (returned from _APPDomain:GetAssemblies).   
     LEA ECX,__lpstrname
     PUSH ECX
     MOV EDX, __Asm
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+28]    ;    What the HECK are we calling here ??? GetType, or, GetName ???


...Right after the code calls: CALL DWORD PTR [EDX+28],...the code then immediately calls: CompareStringW (which does NOT return CSTR_EQUAL), so the CallBackFunction_GetMsCorLibAssembly function returns TRUE (meaning WHAT ???),...only that __ForEachAssemblyInIAppDomain then returns.
Returning then, to __GetDefaultDomain there is a long block of code that doesn't execute (which I assume is supposed to execute, or it wouldn't be there):
     .IF MsCorLib
     MOV EDX,BSTR$("System.AppDomain")    ;    If this block of code were executing the application would crash at the BSTR$ Macro. 
     LEA ECX,tAppDomain
     PUSH ECX
     PUSH EDX
     MOV EDX, MsCorLib
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+68]
     .IF !EAX
     LEA ECX,aProperties
     PUSH ECX
     MOV EDX, tAppDomain
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+308] 
     .IF !EAX
     MOV ECX,aProperties
     MOV EDX,[ECX].SAFEARRAY.rgsabound.cElements
     MOV ESI,[ECX].SAFEARRAY.pvData
     XOR ECX,ECX
     MOV CurrentDomainProperty,ECX
SPr__:
     CMP ECX,EDX
     JE EPr__
     PUSH ECX
     PUSH EDX
     MOV EAX,[ESI]
     LEA ECX,__lpstrname
     PUSH ECX
     MOV EDX, EAX
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+48]
     .IF !EAX
     invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, __lpstrname,-1,BSTR$("CurrentDomain"),13
     .IF EAX == CSTR_EQUAL
     invoke SysFreeString,__lpstrname
     MOV EAX,[ESI]
     MOV CurrentDomainProperty,EAX
     POP  EDX
     POP  ECX
     jmp EPr__
     .ENDIF
     invoke SysFreeString,__lpstrname
     .ENDIF
     POP  EDX
     POP  ECX
     INC  ECX
     ADD  ESI,4
     JMP SPr__
EPr__:
     .IF CurrentDomainProperty
     LEA ECX,vtDefaultDomain
     PUSH ECX
     PUSH 0
     PUSH 0
     PUSH 0
     PUSH 0
     PUSH 0
     MOV EDX, CurrentDomainProperty
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+76]
     .IF !EAX
     MOV DefaultDomain ,offset vtDefaultDomain
     MOV EAX,DefaultDomain
     RET
     .ELSE
     __ExeptionMsg BSTR$("CurrentDomain.GetValue FAIL")
     MOV EAX,FALSE
     .ENDIF
     .ELSE
     __ExeptionMsg BSTR$("CurrentDomainProperty FAIL ")
     MOV EAX,FALSE
     .ENDIF
     .ELSE
     MOV EAX,FALSE
     .ENDIF
     .ELSE
     MOV EAX,FALSE
     .ENDIF
     .ENDIF


Also, if the above block of code does NOT execute, then __Private_GetBasicMethods doesn't execute,...:icon_eek:
Arrgh !!! I'm so confused here, that I'm not even sure I'm expressing the situation correctly,...:icon_eek:

...So,...I launched ProcessExplorer to see what DLLs were being loaded by the version 4 CLR when calling __GetDefaultDomain, and, weirdly enough, the DLL: mscorlib.ni.dll is loaded into the process address space.
...And,...so,...finally,...what is supposed to be happening here ???
Zen

mabdelouahab

Hi ZEN again,
please send me the full code and I will explain to you what is the problem

Quote from: Zen on June 28, 2016, 08:40:43 AM
...So,...I launched ProcessExplorer to see what DLLs were being loaded by the version 4 CLR when calling __GetDefaultDomain, and, weirdly enough, the DLL: mscorlib.ni.dll is loaded into the process address space.
...And,...so,...finally,...what is supposed to be happening here ???

.NI.Dll ( Native Image) it is just a Dll that contains the compiled code of an assembly

Zen

Good news,...MABDELOUAHAB,
I am now UNSTUCK. The procedure CallBackFunction_GetMsCorLibAssembly is clearly just there to confirm that Mscorlib was loaded by the version 4 CLR. I modified the code slightly, tested the code, and it works.
I added some code to your DotNetHelper.inc file so I could figure out what the COM interface method, CALL DWORD PTR [EDX+28] does. The Unicode string that is returned is: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. So, the reason that CompareStringW was NOT returning CSTR_EQUAL is simple. You wrote this in the original DotNetHelper.inc:
     invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, __lpstrname,9,BSTR$("mscorlib,"),9   

I changed that by just substituting a BSTR pointer to the Unicode string, "mscorlib.ni.dll" for the string "mscorlib" in the BSTR$ Macro, and changed the number of characters in each string to be compared from 9 to 8. Like this:
     invoke CompareStringW, LOCALE_USER_DEFAULT, NORM_IGNORECASE, __lpstrname, 8, bstmscorlibni, 8    ;    Modified from original ("mscorlib.ni.dll")

The CompareStringW function now works (returning  CSTR_EQUAL) without having to change anything else. And, almost everything else in the .IF MsCorLib block (noted above) works after substituting BSTR strings for the BSTR$ Macro.
I'm almost done, and, then I will post the entire test app. I've modified the code in numerous places (just minor rearrangements, for the most part). I wanted it all to work correctly before posting it.
Zen

mabdelouahab

ZEN what is happening with you? you sed that:
Quote from: Zen on June 30, 2016, 05:09:18 AM
... The Unicode string that is returned is: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. So, the reason that CompareStringW was NOT returning CSTR_EQUAL is simple. You wrote this in the original DotNetHelper.inc:
     invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, __lpstrname,9,BSTR$("mscorlib,"),9   

..
What are the first nine letters of :"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Of course, it is "mscorlib,"
Why not work with you ??????
Why do you use first 8 letters of "mscorlib.ni.dll"
Do "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" equal "mscorlib.ni.dll" ?????
I do not understand you

With different versions of CLR, sometimes it is loaded 2 assembly with each other:
Quote"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
"mscorlib.resources"
What is the difference between the two strings  when we use CompareStringW, is that the 9 letters of the first is "mscorlib," and the 9 letters of the secend is "mscorlib."

ZEN
I have designed for you wStrings.inc, because you have a problem with BSTR$ Macro, Have you tried the new version of the DotNetHelper.inc, which does not contain BSTR$ macro?


Zen

Sorry, MABDELOUAHAB,
...But, that string "mscorlib" looked like it had a period at the end (yes, I've changed a few things in DotNetHelper.inc). And, I had no idea what type of string CompareStringW was comparing "mscorlib,"to (I naturally assumed that the string returned from CALL DWORD PTR [EDX+28] was, "mscorlib.dll", or some variant of that). Anyway, you could call CompareStringW twice, once comparing to "mscorlib" and, then comparing to "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". This might produce better results especially if you have run MASM32Ref against a version four component assembly. Just an idea.

But, really, this is a minor issue, easily modified. What I'm REALLY interested in is what the COM interface method calls are for lines of code like:
     LEA ECX,__lpstrname
     PUSH ECX
     MOV EDX, __Asm    ;     __Asm must be a pointer, but, to what ???
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+28]    ;    Unknown COM method call. 

...from, CallBackFunction_GetMsCorLibAssembly.   

...Or, these three, from __GetDefaultDomain:
     MOV EDX, MsCorLib
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+68]    ;    Unknown COM method call.   


     MOV EDX, tAppDomain
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+308]    ;    Unknown COM method call.     


     LEA ECX,__lpstrname
     PUSH ECX
     MOV EDX, EAX
     PUSH EDX   
     MOV EDX,[EDX]   
     CALL DWORD PTR [EDX+48]    ;    Unknown COM method call.     


...__Private_GetBasicMethods also contains a number of Unknown COM interface method calls,...

I realize that all my posts must seem annoying to you,...but, that is not my intent. I think that the difference in the native language that we each speak is making it unnecessarily difficult to communicate with each other. I'm just interested in understanding in great detail, how your source code works.
Zen

GoneFishing

HELLO GUYS,

Here's my little example I was talking about in my previous post .
It was written as an answer to this question
I use QWORD's METHOD macro to call methods of managed interfaces implemented as structures in CLRDEFS.INC :



... 

;   struct __declspec(uuid("05f696dc-2b29-3663-ad8b-c4389cf2a713"))
_AppDomain STRUCT
    IUnknown                            <>
    METHOD(GetTypeInfoCount ,          _this:LPVOID, pcTInfo:LPVOID )
    METHOD(GetTypeInfo ,               _this:LPVOID, iTInfo:UINT, lcid:LCID, ppTInfo:LPVOID )
    METHOD(GetIDsOfNames ,             _this:LPVOID, riid:LPVOID, rgszNames:LPOLESTR, cNames:UINT,lcid:LCID, rgDispId:LPVOID )
    METHOD(_Invoke ,                   _this:LPVOID, dispIdMember:DWORD, riid:LPVOID,lcid:LCID, wFlags:DWORD, pDispParams:LPVOID, pVarResult:LPVOID, pExcepInfo:LPVOID, puArgErr:LPVOID )
    METHOD(get_ToString ,              _this:LPVOID, pRetVal:BSTR  )
    METHOD(Equals ,                    _this:LPVOID, other:VARIANT, pRetVal:VARIANT_BOOL  )
    METHOD(GetHashCode ,               _this:LPVOID, pRetVal:LPVOID )
    METHOD(GetType ,                   _this:LPVOID, pRetVal: ptr _Type  )
    METHOD(InitializeLifetimeService , _this:LPVOID, pRetVal:VARIANT )
    METHOD(GetLifetimeService ,        _this:LPVOID, pRetVal:VARIANT )
    METHOD(get_Evidence ,              _this:LPVOID, pRetVal:ptr _Evidence )
    METHOD(add_DomainUnload ,          _this:LPVOID, value:ptr _EventHandler  )
    METHOD(remove_DomainUnload ,       _this:LPVOID, value:ptr _EventHandler  )
    METHOD(add_AssemblyLoad ,          _this:LPVOID, value:ptr _AssemblyLoadEventHandler  )
    METHOD(remove_AssemblyLoad ,       _this:LPVOID, value:ptr _AssemblyLoadEventHandler  )
    METHOD(add_ProcessExit ,           _this:LPVOID, value:ptr _EventHandler  )
    METHOD(remove_ProcessExit ,        _this:LPVOID, value:ptr _EventHandler  )
    METHOD(add_TypeResolve ,           _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(remove_TypeResolve ,        _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(add_ResourceResolve ,       _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(remove_ResourceResolve ,    _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(add_AssemblyResolve ,       _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(remove_AssemblyResolve ,    _this:LPVOID, value:ptr _ResolveEventHandler )
    METHOD(add_UnhandledException ,    _this:LPVOID, value:ptr _UnhandledExceptionEventHandler  )
    METHOD(remove_UnhandledException , _this:LPVOID, value:ptr _UnhandledExceptionEventHandler  )
    METHOD(DefineDynamicAssembly ,     _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_2 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , dir:BSTR , pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_3 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , Evidence:ptr _Evidence , pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_4 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , requiredPermissions:ptr _PermissionSet, optionalPermissions:ptr _PermissionSet , refusedPermissions:ptr _PermissionSet, pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_5 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , dir:BSTR, Evidence:ptr _Evidence , pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_6 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , dir:BSTR, requiredPermissions:ptr _PermissionSet, optionalPermissions:ptr _PermissionSet , refusedPermissions:ptr _PermissionSet, pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_7 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , Evidence:ptr _Evidence , requiredPermissions:ptr _PermissionSet, optionalPermissions:ptr _PermissionSet , refusedPermissions:ptr _PermissionSet, pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_8 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , dir:BSTR, Evidence:ptr _Evidence , requiredPermissions:ptr _PermissionSet, optionalPermissions:ptr _PermissionSet , refusedPermissions:ptr _PermissionSet, pRetVal:ptr _AssemblyBuilder  )
    METHOD(DefineDynamicAssembly_9 ,   _this:LPVOID, _name:ptr _AssemblyName , access:AssemblyBuilderAccess , dir:BSTR, Evidence:ptr _Evidence , requiredPermissions:ptr _PermissionSet, optionalPermissions:ptr _PermissionSet , refusedPermissions:ptr _PermissionSet, IsSynchronized:VARIANT_BOOL , pRetVal:ptr _AssemblyBuilder  )
    METHOD(CreateInstance ,            _this:LPVOID, AssemblyName:BSTR, typeName:BSTR ,pRetVal:ptr  _ObjectHandle  )
    METHOD(CreateInstanceFrom ,        _this:LPVOID, assemblyFile:BSTR, typeName:BSTR ,pRetVal:ptr  _ObjectHandle  )
    METHOD(CreateInstance_2 ,          _this:LPVOID, AssemblyName:BSTR, typeName:BSTR , activationAttributes:SAFEARRAY,pRetVal:ptr  _ObjectHandle  )
    METHOD(CreateInstanceFrom_2 ,      _this:LPVOID, assemblyFile:BSTR, typeName:BSTR , activationAttributes:SAFEARRAY,pRetVal:ptr  _ObjectHandle  )
    METHOD(CreateInstance_3 ,          _this:LPVOID, AssemblyName:BSTR, typeName:BSTR , ignoreCase:VARIANT_BOOL,  bindingAttr:BindingFlags , Binder:ptr _Binder , args:SAFEARRAY , culture:ptr _CultureInfo, activationAttributes:SAFEARRAY,securityAttributes:ptr  _Evidence ,pRetVal:ptr  _ObjectHandle  )
    METHOD(CreateInstanceFrom_3 ,      _this:LPVOID, assemblyFile:BSTR, typeName:BSTR , ignoreCase:VARIANT_BOOL,  bindingAttr:BindingFlags , Binder:ptr _Binder , args:SAFEARRAY , culture:ptr _CultureInfo, activationAttributes:SAFEARRAY,securityAttributes:ptr  _Evidence ,pRetVal:ptr  _ObjectHandle  )
    METHOD(Load ,                      _this:LPVOID, assemblyRef:ptr _AssemblyName, pRetVal:ptr _Assembly  )
    METHOD(Load_2 ,                    _this:LPVOID, assemblyString:BSTR, pRetVal:ptr _Assembly  )
    METHOD(Load_3 ,                    _this:LPVOID, rawAssembly:SAFEARRAY , pRetVal:ptr _Assembly  )
    METHOD(Load_4 ,                    _this:LPVOID, rawAssembly:SAFEARRAY , rawSymbolStore:SAFEARRAY , pRetVal:ptr _Assembly  )
    METHOD(Load_5 ,                    _this:LPVOID, rawAssembly:SAFEARRAY , rawSymbolStore:SAFEARRAY , securityEvidence:ptr _Evidence , pRetVal:ptr _Assembly  )
    METHOD(Load_6 ,                    _this:LPVOID, assemblyRef:ptr _AssemblyName, assemblySecurity:ptr _Evidence , pRetVal:ptr _Assembly  )
    METHOD(Load_7 ,                    _this:LPVOID, assemblyString:BSTR, assemblySecurity:ptr _Evidence , pRetVal:ptr _Assembly  )
    METHOD(ExecuteAssembly ,           _this:LPVOID, assemblyFile:BSTR, assemblySecurity:ptr _Evidence , pRetVal:LPVOID )
    METHOD(ExecuteAssembly_2 ,         _this:LPVOID, assemblyFile:BSTR, pRetVal:LPVOID )
    METHOD(ExecuteAssembly_3 ,         _this:LPVOID, assemblyFile:BSTR, assemblySecurity:ptr _Evidence , args:SAFEARRAY , pRetVal:LPVOID )
    METHOD(get_FriendlyName ,          _this:LPVOID, pRetVal:BSTR  )
    METHOD(get_BaseDirectory ,         _this:LPVOID, pRetVal:BSTR  )
    METHOD(get_RelativeSearchPath ,    _this:LPVOID, pRetVal:BSTR  )
    METHOD(get_ShadowCopyFiles ,       _this:LPVOID, pRetVal:VARIANT_BOOL  )
    METHOD(GetAssemblies ,             _this:LPVOID, pRetVal:SAFEARRAY  )
    METHOD(AppendPrivatePath ,         _this:LPVOID, Path:BSTR )
    METHOD(ClearPrivatePath ,          _this:LPVOID)
    METHOD(SetShadowCopyPath ,         _this:LPVOID, s:BSTR )
    METHOD(ClearShadowCopyPath ,       _this:LPVOID)
    METHOD(SetCachePath ,              _this:LPVOID, s:BSTR )
    METHOD(SetData ,                   _this:LPVOID, _name:BSTR, data:VARIANT )
    METHOD(GetData ,                   _this:LPVOID, _name:BSTR, pRetVal:VARIANT)
    METHOD(SetAppDomainPolicy ,        _this:LPVOID, domainPolicy:ptr _PolicyLevel )
    METHOD(SetThreadPrincipal ,        _this:LPVOID, principal:ptr IPrincipal )
    METHOD(SetPrincipalPolicy ,        _this:LPVOID, policy:PrincipalPolicy )
    METHOD(DoCallBack ,                _this:LPVOID, theDelegate:ptr _CrossAppDomainDelegate )
    METHOD(get_DynamicDirectory ,      _this:LPVOID, pRetVal:BSTR  )
_AppDomain ENDS

....





GoneFishing

ZENEXIT or ZEXIT  :(
or even better ZeNxit which sounds like a  dangerous disease  :dazzled:

*** WHISH YOU WERE HERE ***

HSE

This subject is like tennis. I have not played in the last 30 years, but is funny to see in the TV. Now defiant favorite to contest ".NET-cup" surrender.  :(


          I vote for ZenIn !!!!
Equations in Assembly: SmplMath

Zen

Well, I've been working on an independent .NET Framework Hosting Application. It basically uses the same techniques that MABDELOUAHAB uses in MASM32Ref, but it doesn't use any of the output files from MASM32Ref or, the procedures in DotNetHelper.inc. I've been doing this just to find out how difficult it is to create an unmanaged application in MASM assembly language that accesses .NET Framework classes and methods correctly.
It requires a RIDICULOUS amount of code,...and, you'd have to be COMPLETELY INSANE to write it,...but, it does work,...
If anyone is interested, I can post the source code, along with a tutorial. :bgrin:
I suspect that only MABDELOUAHAB will be interested in this. But, I have converted a number of MsCorLib.dll COM interface (IDL) files to MASM-compatible (COM) STRUCT include files, that might be useful and more convenient to use in second generation MASM32Ref (if there ever is one). For example: the _AppDomain Interface, MSDN, the _Assembly Interface, MSDN, the _Type Interface, NSDN, and, the _MethodInfo Interface, MSDN

I also have a second application that I was working on which is the test app for the DotNetHelper.inc routines. I haven't been through all of MABDELOUAHAB's code,...but, it all seems to work pretty well (he definitely has the correct approach). This application is unfinished (I've kind of lost interest in it). But, I can also post the source code, if anyone is interested. Structurally, I haven't really changed much, but, I've altered the format extensively,...and added a Log File, which records the status of all of the routines tested, so that you can easily determine why the code is failing (if it does so). ...And, it can easily be extended.

There are some fairly significant problems inherent in this type of development. The most significant is the number of different .NET Framework Class Library Versions that are installed by default on the different Windows Operating System Versions. You can read all the gory details here: NET Framework Versions and Dependencies, MSDN. Also, there is not a debugger (on this planet) that can follow the code execution in both native Win32 code and .NET Framework MSIL execution,...so, if you have an unresolved error,...it will, in all probability, stay unsolved for all eternity. And, the big mystery that I could not solve is capturing (or exporting) .NET Framework Exceptions (there are many types of them) to unmanaged MASM COM HRESULT program code (although in most cases, the .NET Framework does this for you). So,...unfortunately,  what you see are a lot of application crashes when things go wrong. This can be very annoying. :dazzled:

Below,...is a zip file containing a listing of all the types contained in MsCorLib.dll (the main .NET Framework assembly that the Common Language Runtime loads when it is started),...and, the System Assembly (Version Four):
Zen

HSE

Hi COM masters!
I'm a follower of "the ZEN adventures" just for fun. If someday I grow up, I will try seriously to use the XML reader, and not so seriously before that :biggrin:
Thanks for show these funny meanderings. :t
Equations in Assembly: SmplMath

Zen

#73
...Ah,...HAH !!!

...Just as I suspected,...nobody's really interested in this COM Interop .NET Framework stuff,...except, malcontents, and, the deranged,...:bgrin:
Zen