News:

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

Main Menu

Really Bizarre Question

Started by Zen, July 13, 2013, 03:40:36 AM

Previous topic - Next topic

Zen

Warning: This is an actual question,...not a ridiculous joke.

I stumbled upon this article over at CodeProject: Test TCP/IP Connectivity Through aspx Page,...which seemed like a pretty cool idea.
And, so,...I was wondering,...can you write an automated program in assembly that would generate ASP.NET web pages ???
...I'm initially assuming that it is possible, but,...so horrendously error-prone and time-consuming that no one actually does it that way.

Anyone here ever done any ASP.NET (or, even, NET Framework) programming ????

Zen

I remember about a year ago,...someone was asking if you could use a NET Framework member function from within an assembly language program. No one seemed to know the answer. I have programmed with the NET Framework,...but, it's silly,...you are basically calling an interface that then calls the underlying Windows API that assembly programers normally invoke from an assembly program.

jj2007

What exactly do you mean with "an automated program in assembly that would generate ASP.NET web pages"?

hutch--

It sounds like a variant of conventional CGI. Instead of creating ordinary HTML, it would be a generator of .NET style pages.

Zen

JOCHEN,   
Quote from: JOCHENWhat exactly do you mean with "an automated program in assembly that would generate ASP.NET web pages"?
Yeah,...excellent question. I hadn't really thought it all the way through. But, I'm assuming that to invoke NET Framework objects and their member functions from an assembly program, you would have to have a version of the NET Framework library residing on your computer,...and, then, you'd have to write some kind of header or include file that would prototype these routines correctly. My initial concept was to use Dumpbin to determine the names of the exported NET interfaces, and then, LoadLibrary, and GetProcAddress to return an address, that could be used with the assembler call syntax.
At that point, I was just going to wing it,...
...It was actually more of a hypothetical question than anything else. The main concept was to see if a NET Framework member function could actually be called from a compiled assembly language program. My operating assumption is that it is possible, but, would be so inconvenient that everyone would simply use a NET Framework compiler.
I read somewhere, years ago, that NET Framework objects are actually implemented as COM interfaces,...so, the invoke or call technique would be somewhat similar.

jj2007

Ok, so you want to mimic functionality of the page, not generate the page itself (the latter sounded too simple to be true).

Sounds difficult. This is badly documented stuff...

Zen

When the NET Framework was first released (I think 2002), I purchased a book by the title of: .NET and COM: The Complete Interoperability Guide, by Adam Nathan. Incredible book, but the syntax for COM interop from NET Framework executables was very tedious and unpleasant.
I was thinking that the NET Framework member functions could be used in much the same way as JAPHETH does with his COM interfaces COM and Assembly, essentially by addressing the COM Virtual Table, using simple addressing.
Here is a blog post from Raymond Chen: The Layout of a COM Object

Quote from: JJOCHENSounds difficult. This is badly documented stuff...
...Yeah,...I don't think it's documented anywhere,... :dazzled:

GoneFishing

#7
Hi,
I have  very basic understanding of Net framework but I  think that working with NET through ASM is  very sophisticated task.
If we look into the import section of NET executables we will see the only entry:
_CorExeMain or _CorDllMain (mscoree.dll)
Here is a small portion of info on how  CLR is initialised and managed module is executed. It may be useful to explore mscoree.tlb (from Microsoft.Net\framework\x.x...) in Visual Studio Object Browser and mscoree.h /mscoree.idl files (from Windows SDK includes) in editor .
NET  debuggers and ILDASM are good tools to dig into NET internals.

P.S. : About runtime hosting

HTH





Zen

#8
Clearly, I need to do alot more research.
Anyway, here is a link to the MSDN section: Developing Web Applications with ASP.NET
From the introduction: ASP.NET Web Pages is a framework that you can use to create dynamic web pages. And, you need a computer that is running Windows 7, Windows Vista SP2, Windows XP SP3, Windows Server 2003 SP2, Windows Server 2008, or Windows Server 2008 R2. They recommend that you should be familiar with both HTML and CSS.

EDIT: Added July 17,...I started a thread over at CodeProject in the NET Framework Forum and asked if: a NET Framework interface can be Invoked from MASM Assembly Language. (Derek Tortonian is one of Baltoro's many aliases.)
MSDN states: Unmanaged applications can also benefit from hosting the common language runtime. (A MASM Assembly Language Program would be considered an unmamaged application.)
Also, MSDN provides this overview of: Hosting Overview (for .NET Framework version 4.5)

Finally,...here's an article from CodeProject on: Injecting .Net Assemblies Into Unmanaged Processes

GoneFishing

#9
...

GoneFishing

#10
...

Zen

VERTOGRAD,
Quote from: VERTOGRADThe time has come to code MASM version of this tricky stuff.  ;)

You are right,...unfortunately, my computer died about two years ago.
...Think of it as a "Classic Thought Experiment",... :icon_eek:

GoneFishing

Oh, I see ...

Are there any chances  to repair your computer or to buy a new (or used) one not-too-expensive?
Anyway keep feeding your brain with MASM.
I'll  post some code here soon  ;)

                   

GoneFishing

#13
Finally I did it ...
Here's a very small application which enumerates installed .NET Framework runtimes.
It uses hosting API to interact with CLR.

NB: It requires  .NET Framework 4  to run / build it! .
You may run the following line* in the command prompt to check what runtimes are present on your computer:
dir  /b  /ad  c:\windows\Microsoft.NET\Framework\v*
*assuming that c:\ is your system root
or
check the version of mscoree.dll in system32 directory.

You will need mscoree.lib(it's not included in masm32 package) to build it ( don't forget to change the path in the includelib section)

P.S. more coming soon ...

Zen

VERTOGRAD,
Very impressive initial attempt. I quickly scanned your code; it's simple and elegant.
...I even ran the app,...but, I am on a public terminal (public library in California, running Windows XP),...and, I got the error message (which I expected).
It is entirely possible that you are the first programmer in the galaxy to actually compile a MASM app that correctly queries the installed NET Framework version (if any).