|
-
Nov 22nd, 2008, 01:22 PM
#1
Thread Starter
New Member
[2008] How do I compile a project into native code?
I can't find the option for compiling a project into native code. Where is it?
Thank you in advance.
-
Nov 22nd, 2008, 01:53 PM
#2
Re: [2008] How do I compile a project into native code?
What do you mean by that? I expect that you are misunderstanding something about how .NET works, but exactly what, I am not sure.
My usual boring signature: Nothing
 
-
Nov 22nd, 2008, 02:26 PM
#3
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
I mean I need to compile a project into native code (x86 machine code).
Just to make everything clear, disassembled native code looks like this:
Code:
mov edi, [ebp+8]
mov eax, edi
and eax, 1
mov [ebp-4], eax
and edi, 0FFFFFFFEh
push edi
mov [ebp+8], edi
mov ecx, [edi]
call dword ptr [ecx+4]
and disassembled .NET code looks like this:
Code:
ldloc.0
callvirt T0xA000062
callvirt int32 [System.Windows.Forms]System.Windows.Forms.ComboBox/ObjectCollection::Add(class System.Object)
pop
ldloc.0
ldc.i4.1
add.ovf
stloc.0
Do I have to switch to 6.0 to do that?
Last edited by moomoocow; Nov 22nd, 2008 at 02:29 PM.
-
Nov 22nd, 2008, 04:58 PM
#4
Frenzied Member
Re: [2008] How do I compile a project into native code?
I believe the first is assembler and the second is the intermediary language of .NET (I forgot its name :S). I think that some time ago there was a discussion on this topic around here... Someone suggested using some third-party tool which would compile the code in a way which would not require the .NET platform to work... I'd suggest a forum search.
Please rate helpful ppl's posts. It's the best 'thank you' you can give 
-
Nov 22nd, 2008, 06:59 PM
#5
Fanatic Member
Re: [2008] How do I compile a project into native code?
Its called the MSIL.
And its interpreted by the JIT compiler.
-
Nov 22nd, 2008, 07:06 PM
#6
Frenzied Member
Re: [2008] How do I compile a project into native code?
Yeah, MSIL, Microsoft Intermediary Language... How could I forget... :S
Please rate helpful ppl's posts. It's the best 'thank you' you can give 
-
Nov 22nd, 2008, 07:38 PM
#7
Re: [2008] How do I compile a project into native code?
There are some tools that will compile MSIL into native code but they are not cheap.
http://www.remotesoft.com/salamander/protector.html
Microsoft does not provide such a tool because that would defeat the purpose of the .NET platform. They do provide a native image generator but you cannot simply distribute the image it creates as a standalone application. The native image compiler exists to create images that can be executed by the Framework directly without the need for JIT compilation and thereby improving perceived performance.
http://msdn.microsoft.com/en-us/library/ht8ecch6.aspx
-
Nov 22nd, 2008, 09:25 PM
#8
Re: [2008] How do I compile a project into native code?
 Originally Posted by moomoocow
I can't find the option for compiling a project into native code. Where is it?
Thank you in advance.
Re-make the whole thing in C/C++
-
Nov 23rd, 2008, 04:07 AM
#9
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
Would it help to use VB 6?
I see a lot of VB applications around that are in native code, starting with the classical:
Code:
start:
push offset dword_4096F4
call ThunRTMain
I doubt they all used some expensive tools for that. I am assuming they used VB 6.0 then, am I right? Well, anyway, I need to replicate that.
-
Nov 23rd, 2008, 04:47 AM
#10
Addicted Member
Re: [2008] How do I compile a project into native code?
Why is it that you want to do this, just out of interest?
-
Nov 23rd, 2008, 07:14 AM
#11
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
I need to test how VB handles a few pieces of code. Since machine code is a lot more straightforward than .NET code, then it's the only reasonable way to do this.
-
Nov 23rd, 2008, 08:47 AM
#12
Re: [2008] How do I compile a project into native code?
 Originally Posted by moomoocow
Would it help to use VB 6?
I see a lot of VB applications around that are in native code, starting with the classical:
Code:
start:
push offset dword_4096F4
call ThunRTMain
I doubt they all used some expensive tools for that. I am assuming they used VB 6.0 then, am I right? Well, anyway, I need to replicate that.
No, vb1 through 6 all require their versions of the vb runtime files, which is similar to the .Net Framework. Like I said, re-create your project in C/C++, those two are the ones that create native code.
-
Nov 23rd, 2008, 09:05 AM
#13
Re: [2008] How do I compile a project into native code?
People, you are getting carried away. Moomoocow wants the cpu instructions that result from a program. With or without the framework, it all boils down to simple mov, push and call. After all we don't need some special '.net certified' cpu to do the work.
The problem is that the framework generates these codes in run time only and, because of the JIT, only portions at a time. I don't know if a tool exists that lets you monitor what instructions the jit is executing.
-
Nov 23rd, 2008, 11:41 AM
#14
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
I think it would be easier to just use a pre-.NET version of VB (those which allowed to switch between p-code and native code). So I think I have to go for VB6.
JugaloBrotha, I am absolutely sure that some version of VB can generate native code executables, since I see hundreds of such executables everywhere. They do need some DLL and/or OCX files, but it's still machine code.
Last edited by moomoocow; Nov 23rd, 2008 at 11:45 AM.
-
Nov 23rd, 2008, 12:05 PM
#15
Re: [2008] How do I compile a project into native code?
Actually, I got a straight ASM view for dlls in VB.NET...by accident. Unfortunately, I don't remember how I got there, but it allowed me to step through the ASM, not the MSIL (which you can get fairly easily).
However, there is a somewhat bigger question here: If you switch to VB6 for the purpose of testing how VB handles a few pieces of code, what have you gained? VB6 <> VB.NET, and the handling will be totally different. If you are happy with the way VB6 handles whatever code, will you remain on a platform that is no longer supported simply because you can see the ASM? That seems unreasonable. What is the point of using any flavor of VB if the current flavor won't allow you to see the operations to the level you would like? C/C++ would solve that problem for you, and give you all the fine control that you would like, so why not use it? The most likely answer is that you are familiar with or prefer the VB syntax and RAD tools that VB provides (I sure do), but you can have it both ways: The code that you need the fine control access to can be compiled into C/C++ dlls and linked to VB.NET. That way you get the high level stuff where you can live with it, and the low level stuff where you need it.
My usual boring signature: Nothing
 
-
Nov 23rd, 2008, 03:09 PM
#16
Re: [2008] How do I compile a project into native code?
Got it. The window is hidden in the vb flavor of visual studio. To 'unhide' it go to Tools and select Customize.
In the Customize dialog select the Commands tab -> Categories -> Debug
In the Commands list select 'Disassembly' and drag it all the way to the debug menu or wherever you want to place it.
Now place a break point in your program, run it and when it breaks, open the disassembly window.
-
Nov 23rd, 2008, 04:20 PM
#17
Re: [2008] How do I compile a project into native code?
 Originally Posted by moomoocow
I can't find the option for compiling a project into native code. Where is it?
There isn;'t one - but you can use the Native Image Generator (NGEN)
-
Nov 24th, 2008, 03:46 PM
#18
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
 Originally Posted by Shaggy Hiker
Actually, I got a straight ASM view for dlls in VB.NET...by accident. Unfortunately, I don't remember how I got there, but it allowed me to step through the ASM, not the MSIL (which you can get fairly easily).
However, there is a somewhat bigger question here: If you switch to VB6 for the purpose of testing how VB handles a few pieces of code, what have you gained? VB6 <> VB.NET, and the handling will be totally different. If you are happy with the way VB6 handles whatever code, will you remain on a platform that is no longer supported simply because you can see the ASM? That seems unreasonable. What is the point of using any flavor of VB if the current flavor won't allow you to see the operations to the level you would like? C/C++ would solve that problem for you, and give you all the fine control that you would like, so why not use it? The most likely answer is that you are familiar with or prefer the VB syntax and RAD tools that VB provides (I sure do), but you can have it both ways: The code that you need the fine control access to can be compiled into C/C++ dlls and linked to VB.NET. That way you get the high level stuff where you can live with it, and the low level stuff where you need it.
This is not actually a real project as such. I need to specifically see how VB translates certain things into machine code. Consider it more as a research rather than a software project. I do all my real projects in C++, but here I have a specific reason why I need to test with VB.
Half, thanks, but I am more interested in the hidden constructors/destructors which I'm afraid I can't access by debugging that way.
VB6 seems to be a good choice here. People tend to think that if software gets old, it gets broken, but that's not actually so.
Thanks everyone, I will hopefully get all my questions answered with the help of VB6.
-
Nov 24th, 2008, 05:50 PM
#19
Re: [2008] How do I compile a project into native code?
I think this thread is a fine example of why we should explain what we really want and why in the very first post. If we don't then the thread is quite likely to drag on unnecessarily. If people don't understand what problem they're actually being asked to solve then they're unlikely to provide the most appropriate solution.
Also, machine code is just 1s and 0s. What you're asking for is assembler.
-
Nov 24th, 2008, 06:57 PM
#20
Re: [2008] How do I compile a project into native code?
I think I understand this less at this point than I thought I did back at the beginning. If you don't program in VB, but want to see how VB translates something into ASM, how can it possibly not be version dependent? VB.NET will do a different job from VB6, and for many things, each version of .NET will do a different job from the others. If you don't really care which language is converting the whatever into ASM, then why not just use MASM and be done with it?
My usual boring signature: Nothing
 
-
Nov 24th, 2008, 10:16 PM
#21
Re: [2008] How do I compile a project into native code?
Maybe moomoocow is interested in how something is achieved. If you want to make a compiler for example you might want to see how others are doing it.
-
Nov 25th, 2008, 07:00 AM
#22
Thread Starter
New Member
Re: [2008] How do I compile a project into native code?
 Originally Posted by jmcilhinney
I think this thread is a fine example of why we should explain what we really want and why in the very first post. If we don't then the thread is quite likely to drag on unnecessarily. If people don't understand what problem they're actually being asked to solve then they're unlikely to provide the most appropriate solution.
Also, machine code is just 1s and 0s. What you're asking for is assembler.
Yes, I should have stated that I wanted a native code executable and any other kind of solution would not fit here. People tend to assume the asker does not know what he's talking about. Mostly it is so too. My apologies.
Also, it's assembly, which is simply the textual representation of machine code. Ultimately, everything is just 1s and 0s when represented in binary, just as everything is just 00h-0FFh when represented in hexadecimal.
Shaggy Hiker - like I said, I wanted a native code executable generated by Visual Basic. Considering that, I need the latest version of VB that does generate them. Those which don't are no use for me.
Half, that's correct, though it's not actually for a compiler.
-
Nov 25th, 2008, 10:07 AM
#23
Re: [2008] How do I compile a project into native code?
That would be VB6 then, the last version of "original" Visual Basic that could compile to native code and didn't use a framework or JIT compiler.
-
Nov 25th, 2008, 12:08 PM
#24
Re: [2008] How do I compile a project into native code?
Consider what Half posted in #16. You CAN see code in ASM from .NET.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|