The MASM Forum

Specialised Projects => Compiler Based Assembler => Assembler With Microsoft Visual C => Topic started by: jj2007 on September 07, 2012, 09:55:51 AM

Title: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 07, 2012, 09:55:51 AM
Hi,

I just downloaded the ComIntro from Michael Dunn from CP (http://www.codeproject.com/Articles/633/Introduction-to-COM-What-It-Is-and-How-to-Use-It)

So I tried to open it in Visual C++ 2010 Express. When opening COMIntro.dsp, VS gives me a box saying the project has to be converted to the current format. When I click "Yes", VS does - nothing, absolutely nothing. It's probably by design - greetings to Redmond :icon_mrgreen:

Any VS geeks around who have an idea how to get this running? Thanks...
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 07, 2012, 10:16:12 AM
.dsp is the extension for C++ 6.0 project files.

I haven't tested this, but I found this page from Microsoft.  It looks like they're suggesting C++ 2008.

http://msdn.microsoft.com/en-us/library/kyb7zzw4.aspx
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 07, 2012, 10:19:04 AM
How many source files are in the project?  It may be easier to create a new project in 2010 and import the source files.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 07, 2012, 10:27:23 AM
I tried "import from existing code" and it works but ends up with complaining that afx.h doesn't exist.
The good news is afx.h exists here (http://www.cppdoc.com/example/mfc/classdoc/MFC/AFX.H.html), the bad news is more error messages about missing files are waiting. Every time I touch this C++ bullshit, I end up wasting my time :eusa_boohoo:

Thanks anyway. The purpose of my wasted efforts was to see how a C++ COM app really works, i.e. through the eyes of Olly. If anybody has a really simple example that compiles with VS 2010 Express, that would be great.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 07, 2012, 10:35:12 AM
I have C++ 6.0.  I may be able to compile the project.  I don't have a log in or whatever CP wants.  Could you reattach the zip?  It shows 0 kB.

EDIT:  Never mind.  I thought you had to pay to create an account, but I guess it's not necessary.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 07, 2012, 10:43:31 AM
I've compiled it.  I have the student "Introductory" Edition from school.  It puts a little disclaimer message box in.

Here it is...
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 07, 2012, 03:43:41 PM
Looks good - thanks a lot!
:t

004010A9     ³> À6A 00                   push 0
004010AB     ³.  FF15 B4204000           call near [<&ole32.CoInitialize>]
...
004010F4     ³.  FF15 B0204000           call near [<&ole32.CoCreateInstance>]
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: TouEnMasm on September 07, 2012, 03:54:50 PM

The good method with vc++ 2010 express edition is to create a new project with the existing files and not to use the translator of project.
This apply when the version of the project is too old to be understanding by c++ express.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 07, 2012, 05:37:16 PM
The good method would have been to write a translator that works, and if it doesn't, at least to inform the user what didn't work. But nobody expects "good methods" from M$ anyway :icon13:
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 07, 2012, 09:17:43 PM
Glad it worked with Olly  :t

The sample code from CP uses some MFC and ATL.  C++ Express doesn't come with built-in support for those things: http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express#Visual_C.2B.2B_Express

It may be why importing the source files didn't work.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Vortex on September 08, 2012, 03:41:05 AM
The 2010 release is the last version of Visual Studio which can be installed on Windows XP.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 13, 2012, 01:22:18 AM
I downloaded 138MB of sample code for VS 2010 Express - you know, those specifically designed for use with VS.

The good news is that the CPUID example in C++\crt\cpuid works!

The bad news is that the other 137.99MB are just wasting disk space - loads of error messages mostly related to absent MFC and ATL header files. Intense search on the net suggests to download another 2.5GB of platform SDK, but I haven't seen anybody writing "thanks for the suggestion, my code works now"
:( :icon13: :icon13: :icon13: :icon13: :icon13:
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: Ryan on September 13, 2012, 01:29:29 AM
It's weird that they would have examples for Express that use MFC or ATL header files.  They are intentionally withheld from the edition so people have something to pay for.

I tried a few times to install the SDK.  It fails when I try.  It doesn't specify the reason, just that it failed.  I tried disabling anti-virus and other programs that were running, but no change.
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: japheth on September 13, 2012, 03:41:25 AM
Quote from: jj2007 on September 13, 2012, 01:22:18 AM
Intense search on the net suggests to download another 2.5GB of platform SDK, but I haven't seen anybody writing "thanks for the suggestion, my code works now"

Of course you'll need the SDK header files if you want to build a C++ COM application.

I've attached a nice little sample, COM with pure C++, it's the "grandfather" of the IE container sample. IIRC it was Xtreme who first tried to convert it to assembly - back 11 years ago. Note: the format of the attachment is 7z.

I did compile it with the MS VC++ 2003 toolkit ( which was free of charge and is more or less the last version of MS's C++ compiler that works fine, before they ruined it with their dotnet stuff ). MS wouldn't be MS if they hadn't crippled this free package a little - there are 4 files missing for full COM support: comdef.h, comdefsp.h, comip.h and comsupp.lib.

The SDK version I used was from 06/2001 - include files zipped are 3.8 MB. If you have difficulties to download that 2.5 GB package, perhaps you can contact me privately to "discuss" this issue?
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: jj2007 on September 13, 2012, 05:36:29 AM
Quote from: japheth on September 13, 2012, 03:41:25 AM
The SDK version I used was from 06/2001 - include files zipped are 3.8 MB. If you have difficulties to download that 2.5 GB package...

Incredible, some warnings but it compiles with VC Express 2010 on WinXP SP3 :t
Minor problem - on exit it crashes (for google.com, but not for local files) here:

40324587       BE 05400080               mov esi, 80004005  << google for CLR error 80004005
4032458C      74 2F                     je short 403245BD
4032458E       8B08                      mov ecx, [eax]
40324590       8D55 14                   lea edx, [ebp+14]
40324593       52                        push edx
40324594       68 84293340               push 40332984
40324599       50                        push eax
4032459A       FF11                      call near [ecx]  <<<<< ecx is ddddddddh


Actually, I am trying to translate a Windows CE example that is suspiciously simple, and it fails when I try to query for the client site:
otf CoCreateI:  OK
otf Qu_OleObj:  OK
otf MiscFlags:  OK
otf Qu_Client:  Interface not supported


The MSDN .cpp code is included in the attachment. Apologies that this is MasmBasic ;-)

.code
CLSID_WebBrowser   GuidFromString(8856F961-340A-11D0-A96B-00C04FD705A2)      ; ExDisp.h (http://\program%20files\microsoft%20sdks\windows\v7.0a\include\exdisp.h)
IID_IWebBrowser2     GuidFromString(D30C1661-CDAF-11D0-8A3E-00C04FC9E26E)   ; OleIdl.h (http://%programfiles%\microsoft%20sdks\windows\v7.0a\include\oleidl.h)
IID_IUnknown      GuidFromString(00000000-0000-0000-C000-000000000046)
IID_IOleObject      GuidFromString(00000112-0000-0000-C000-000000000046)     ; MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms683922%28v=vs.85%29.aspx)
IID_IOleClientSite      GuidFromString(00000118-0000-0000-C000-000000000046)

OleTestFail MACRO arg
  ifnb <arg>
   pushad
   .if eax
      Print "otf &arg&: ", Tb$, Utf8$(MsgTable$(eax, "kernel32"))
   .else
      PrintLine cStyle$("otf &arg&: \tOK")
   .endif
   popad
  endif
  .if esp!=jesp
   mov edx, jesp
   sub edx, esp
   deb 1, "CoInv stack &arg&", edx
  .endif
  cmp eax, S_OK
  jne OleErr
ENDM

CreateBrowserObject proc   ; based on MSDN Windows CE example (http://msdn.microsoft.com/en-us/library/aa451938)
LOCAL pUnk:IUnknown, pObject:IOleObject, pClientSite:IOleClientSite, cboRc:RECT, dwFlags
  ClearLocalVariables uses esi edi
  mov jesp, esp      ; check stack to see if # of params correct
  lea edi, pUnk      ; ptr to unknown interface
  lea esi, pObject      ; ptr to OLE object
  .if !pWB2   ; global pInterface WebBrowser2
   ;  hr = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IUnknown, (LPVOID *)(&pUnk));
   invoke CoCreateInstance, offset CLSID_WebBrowser, NULL, CLSCTX_INPROC, offset IID_IWebBrowser2, edi
   OleTestFail CoCreateI
   m2m pWB2, [edi]
   ; hr = pUnk->QueryInterface(IID_IOleObject, (LPVOID *)(&pObject));
   CoInvoke [edi], IUnknown.QueryInterface, offset IID_IOleObject, esi
   OleTestFail Qu_OleObj
   ; // Check if Shdocvw requires a client site to be created first.
   ; hr = pObject->GetMiscStatus(DVASPECT_CONTENT, &dwFlags);
   CoInvoke [esi], IOleObject.GetMiscStatus, DVASPECT_CONTENT, addr dwFlags
   OleTestFail MiscFlags
   and dwFlags, 20000h   ; OLEMISC_SETCLIENTSITEFIRST ->MSDN: OLEMISC enumeration (http://msdn.microsoft.com/en-us/library/windows/desktop/ms678497%28v=vs.85%29.aspx)
   .if Zero?
      deb 1, "No client site required", dwFlags   ; never seen
   .else
      ; IOleClientSite *pClientSite;
      ; hr = QueryInterface(IID_IOleClientSite, (LPVOID *)(&pClientSite));
      lea ecx, pClientSite   ; IOleObject::IOleClientSite
      CoInvoke [esi], IUnknown.QueryInterface, offset IID_IOleClientSite, ecx
      ; ---------- fails here: -------------
      OleTestFail Qu_Client
      ; hr = QueryInterface(IID_IOleClientSite, (LPVOID *)(&pClientSite));
      lea ecx, pClientSite
      ; hr = pObject->SetClientSite(pClientSite);
      CoInvoke [esi], IOleObject.SetClientSite, ecx
      OleTestFail SetClientSite
      ; pClientSite->Release();
      lea ecx, pClientSite
      CoInvoke [ecx], IOleObject.xUnknown.Release
      OleTestFail Release
   .endif
  .endif
OleErr:
  PopUses
  ret
CreateBrowserObject endp

P.S.: I smuggled in a new MACRO called GuidsEqual:
; expected: EQUAL, DIFFER, EQUAL, DIFFER
.if GuidsEqual(offset IID_IUnknown, IID_IUnknown)
nop ; offset, direct
.endif

.if GuidsEqual(IID_IUnknown, IID_IOleObject)
nop ; direct
.endif

mov eax, offset IID_IOleObject
.if GuidsEqual(eax, IID_IOleObject)
nop ; one offset in reg32
.endif

invoke CmpGUIDS, addr IID_IOleObject, addr IID_IUnknown


Works fine except that for JWasm they are all equal :(
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: herge on January 18, 2013, 12:16:44 AM

HI jj:

I have never used 2010 c++
But on 2008 if you have a //CLR
problem you have to Change the Project's propertys.
Find the CLR and change it run CLR i use the top one.
I hope it helps you.

Regards herge
Title: Re: Visual Studio 2010 - a Microsoft product
Post by: farrier on January 18, 2013, 01:44:59 PM
I just went thru an install of Visual Studio 2010 Express and made many mistakes.  From the readme.htm "Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1 Readme"--which showed after the install--advice on how to do it!

2.1.3. Recommended Installation Order

To ensure that your system has a supported configuration, uninstall the following products and then reinstall them in the order listed:

Visual Studio 2010
Windows SDK 7.1
Visual Studio 2010 SP1
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1

hth,

farrier