Hi All!
I have some doubts about integrate pure ASM code into my Visual Studio applications. Could someone help me please?
1- I had developed a C++ application to call an ASM function (CPUID) using NASM/YASM, passing pointers of a string in C++ to the ASM file. In debug mode I can see the pointers are well received by ASM and the bytes change as expected. But when the ASM code ends and return to C++ the memory data is UNCHANGED! It seems the ASM code didn't change nothing. I checked the pointers addresses and I'm sure it's 100% right (I had tested changing the source bytes there and checking in ASM code if I was seeing the same bytes).
2- Is there any way to utilize ASM LIB files from my Visual Basic sources (as a DECLARE or something like that)?
3- Is there any way to compile MASM64 code to .OBJ or .DLL and utilize it from my Visual Basic 2010/2013?
I would appreciate ANY help about these doubts.
Thanks a lot.
All of that is possible (we discussed that (http://www.masmforum.com/board/index.php?topic=16239.0)), but without seeing any code, it's difficult to see where the problem is. You have a standalone VB app, or is it VB for apps? What can you zip & post here?
Re 1., have you checked if VB passes a copy of the original memory?
Using a 32-bit dll or lib with 64-bit code is NOT possible, of course.
it might be easier to write a PROC in asm, assemble to an OBJ or LIB, then link it
but, i am sure there's a way to inline it, as well
Thank you very much to you both.
Yes, I'll provide the code to you, but I need some days since during the work days it's really impossible to me since I have two jobs in different companies and I travel almost every day. But I promise that until the next weekend I'll upload it here.
My main goal is not just CPUID check, but:
1- check if CPU supports AVX os SSE 4.x instructions;
2- to call INTEL NASM code for SHA512 and perhaps AES-IN encryption.
I wonder that the *BEST* way is to make a C++ DLL to call ASM code (there is YASM/NASM not MASM one since they're INTEL resources), but I **REALLY** would like to make it only with Visual Basic + ASM CODE.
I'm very used to MASM32 since DOS time and I made some code to interface with VB6 some years ago. But I believe that now, with .NET Visual Basic, it is not possible to exchange data between VB and ASM... :(
I'll send the code as soon as possible! Thanks again for the support guys.
If I remember correctly 64 bit CL.EXE does not allow inline assembler so you are stuck with writing a module in MASM64 and linking it into the C/C++ code. If you have a way to interface C/C++ with VB then you have a technique to run assembler code from VB. You will need to get things like calling conventions right and 64 bit Windows is a lot more complicated than 32 bit in this area. From the very little I have seen of later VB.NET, its a really different animal to the older VB6 era and I personally don't know what its capacity is but if you can call C/C++ code you have a path to do what you need.
it doesn't need to be in a DLL
it can be in a static library
and - to exchange data, pass a pointer to a structure
let the asm module fill in the structure
as for CPUID and AVX....
as it happens, Gunther and I have both made some recent posts regarding these issues
the forum search tool might provide some help :t
Thank you Hutch, Dedndave!
I'll see what you advise to me, for sure.
See you as soon as possible.
And thank all of you for help and support. You're bad!
Quote from: David BS on July 10, 2014, 12:34:08 AM
And thank all of you for help and support. You're bad!
What's that? :( Could you explain it?
Gunther
Quote from: David BS on July 09, 2014, 11:46:58 PMI believe that now, with .NET Visual Basic, it is not possible to exchange data between VB and ASM...
If you can use the Windows API, e.g. Private Declare Function CreateWindowEx(...), then you can also use your own functions and procedures. I can't help you with 64-bit code, though, but some members here have quite a lot of experience - wait and see ;-)
For some people like me, a single letter is enough to understand the entire sentence...
I got success picking pieces of information of all of you. :greenclp:
Yes, jj2007, I was not supposing to mix x86/x64 codes. My problem was focused in blend Visual Studio Basic 2010/2013 with pure ASM code (via DLL). Some x86 DLL files weren't being correctly loaded from VB and I hadn't realized why.
Dedndave told me to work with structures instead pointers and it was crucial to solve my problem. I can now call the CPUID in ASM from within VB 2010/2013 and get the results to check if the computer is able to process INTEL AES-NI and SHA512 codes. My target is get more performance than .NET can provide.
Because of these few words from these guys (and a lot of patience and willingness to help me) I told them, Gunther, they're really bad (in other words, they ARE the guys!). They helped me quickly and in an effective way. One more time I thank you all. :t :t
Just seizing the opportunity: can EasyCode work with YASM? I had success making MASM syntax in it but the codes I'm looking for are made all in YASM syntax (via INTEL). EasyCode really makes easy to program in ASM since it has some macros and templates to help us. Do you know some equivalent tool for YASM?
Kindest regards to all of you.
Some of these poor old fellas failed to get it where I got it the first time, it works the same way as "A good woman is hard to find and a BAD one is nearly impossible to find". :biggrin:
Quote from: David BS on July 10, 2014, 04:29:04 PM
Just seizing the opportunity: can EasyCode work with YASM?
You should ask that question here (http://www.easycode.de/home.html?&L=1).
Gunther
Gunther, if you want to understand "bad = good". i suggest these 2 movies...
The Whole Nine Yards, The Whole Ten Yards
in the second movie, you will get the picture, but the first movie is a must-see :P
Hi Dave,
Quote from: dedndave on July 10, 2014, 09:37:41 PM
Gunther, if you want to understand "bad = good". i suggest these 2 movies...
The Whole Nine Yards, The Whole Ten Yards
in the second movie, you will get the picture, but the first movie is a must-see :P
Where can I find the movies? Youtube?
Gunther
This is where the idea comes from.
"When I'm good, I'm very good, but when I'm bad, I'm better. "
― Mae West
She was a master (Urrrgh Mistress) of brilliant one liners.
http://www.amazon.com/Whole-Nine-Yards-Double-Feature/dp/B000RETOH4 (http://www.amazon.com/Whole-Nine-Yards-Double-Feature/dp/B000RETOH4)
they star Bruce Willis, Natasha Henstridge, Matthew Perry, Amanda Peet, and a few others
but Kevin Pollak plays Janni Gogolak in the first movie - very funny
and in the second one, he plays Janni's father, Lazlo and Frank Collison plays Strabo - even funnier
those are probably region 1 DVD's - there are ways around that - or find them for your region
Dave,
thank you, I'll check it out. There's a German synchronization with the title Keine halben Sachen. Did you know that Bruce Willis is born in Germany?
Gunther
no didn't know that - he has an American accent
the other movie...
Keine halben Sachen 2
guess they don't go to 10 in German :P
:icon14:
Quote from: Gunther on July 10, 2014, 07:25:28 PM
Quote from: David BS on July 10, 2014, 04:29:04 PM
Just seizing the opportunity: can EasyCode work with YASM?
You should ask that question here (http://www.easycode.de/home.html?&L=1).
Gunther
Thanks Gunther!
I'll go there now.
Best regards!
Quote from: David BS on July 11, 2014, 01:36:39 PM
Thanks Gunther!
I'll go there now.
Best regards!
You're welcome.
Gunther
Quote from: dedndave on July 10, 2014, 12:17:38 AM
it doesn't need to be in a DLL
it can be in a static library
I can do it with a .dll, but how to make a static library in asm and then use it from VB? Can you please provide a sample? Well, I know how to build a .lib with ml64... I'm using VS 2015 and VS 2019.
It is surely possible.
What you have to do is to take care of the prototypes in use.Proto by Value,Byref Async ?.
Wich one to use ?,a little search and some tests are needed.
Byref (passing adress) seem to me the more possible candidate.
Quote from: i Z ! on October 01, 2020, 01:33:04 AMhow to make a static library in asm and then use it from VB?
Making a static library is not that difficult, see here (http://masm32.com/board/index.php?topic=7343.0), or search the forum for "-lib"
For linking it to VB see this post (https://www.vbforums.com/showthread.php?222856-static-libraries)
this sample is what you search,already made:
https://codes-sources.commentcamarche.net/source/32702-exemple-du-tutorial-mettre-de-l-asm-dans-vb (https://codes-sources.commentcamarche.net/source/32702-exemple-du-tutorial-mettre-de-l-asm-dans-vb)
jj2007, TouEnMasm: Thank you both for your replies. I followed the links you gave, but sadly I couldn't find any useful info. jj2007: I'm more interested in 64 bit version.