News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Headers update

Started by donkey, January 17, 2010, 06:48:35 AM

Previous topic - Next topic

Yuri

Edgar, the use of the WIN64 switch in the headers seems to me a little confusing. It is not defined in windows.h before other headers are included, so it's not obvious whether it is on or off. Whether I have to define it myself or not. What do you think about putting its definition (depending on #if x64) in the beginning of windows.h?

donkey

Hi Yuri,

In my current working headers WIN64 is defined in windef.h, your suggestion is better and I will move it to Windows.h. The next header update is still some ways off due to bitfield issues that have been discovered, translating all direct draw headers up to and including 11 and starting ont he Windows 8 definitions. It is taking more time than I expected to get the job done.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Yuri

Hi, Edgar

I have just searched for the definition of CRITICAL_SECTION and it seems that though members of some structures in atlbase.h are defined as CRITICAL_SECTION <>, but CRITICAL_SECTION itself isn't defined anywhere in the headers. I could only find RTL_CRITICAL_SECTION in winnt.h.

Yuri

Also, all the members of RTL_CRITICAL_SECTION are difined as DD. I think it should be:

RTL_CRITICAL_SECTION STRUCT
    DebugInfo PTR
    LockCount DD
    RecursionCount DD
    OwningThread HANDLE
    LockSemaphore HANDLE
    SpinCount ULONG_PTR
ENDS

donkey

Hi Yuri,

Thanks, I'll take a look at it on the weekend.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Hi Yuri,

I had some time to look into CRITICAL_SECTION, it is defined in SDK 7.1 in the WinBase.h file as

typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;

So you can use RTL_CRITICAL_SECTION in its place although as with many structures of this type the size is all that's important, there seems to be no practical use for knowing the member values. Also your version of the structure is correct, it must have slipped through in the 64 bit edits. The corrected structure and the equate will be in the next release of the headers. Since GoAsm does not assemble 16 bit applications the other typedef's I found will not be added because as far as I can see they apply only to DOS programs i.e. from MAPIWin.h:

#define   CRITICAL_SECTION         ULONG

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

FlySky

Great work as always donkey.
I've got a small question though.
I am trying to translate a couple C/C++ header files to work with GoASM.

I've got these lines for example:
typedef void* (*FactoryFn)( const char *pName );

and the project contains classes.
class GetGameID
{
public:

   //-----------------------------------------------------------------------------
   // Purpose: Constructor
   //-----------------------------------------------------------------------------
   GetGameID()
   {
      m_gameid.m_comp.m_unAccountID = 0;
      m_gameid.m_comp.m_EAccountType = k_EAccountTypeInvalid;
      m_gameid.m_comp.m_EUniverse = k_EUniverseInvalid;
      m_gameid.m_comp.m_unAccountInstance = 0;
   }

Basicly the question how can the above class (header) be translated.


donkey

Hi FlySky,

Sorry but I have no idea, sort of looks like a Java class but without the complete file its hard to tell. Can you zip and post the header file and I'll take a look at it.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

FlySky

#ifndef ISTEAMAPPS002_H
#define ISTEAMAPPS002_H
#ifdef _WIN32
#pragma once
#endif

#include "SteamTypes.h"
#include "AppsCommon.h"

//-----------------------------------------------------------------------------
// Purpose: interface to app data
//-----------------------------------------------------------------------------
abstract_class ISteamApps002
{
public:
   virtual bool BIsSubscribed() = 0;
   virtual bool BIsLowViolence() = 0;
   virtual bool BIsCybercafe() = 0;
   virtual bool BIsVACBanned() = 0;

   virtual const char *GetCurrentGameLanguage() = 0;
   virtual const char *GetAvailableGameLanguages() = 0;

   // only use this member if you need to check ownership of another game related to yours, a demo for example
   virtual bool BIsSubscribedApp( AppId_t nAppID ) = 0;
};


#endif // ISTEAMAPPS002_H

It's from OPENSTEAMWORKS an opensource project which allows you to code steam applications.
Is it possible to use a .lib file to use the functions.
Basicly when compiled it uses some sort of VTABLE to call the right function.

donkey

Hi FlySky,

I generally do not translate the class objects, they are not particularly useful when accessing the interface and unless you are translating the DLL to GoAsm they are not something you would ever access. The vTable on the other hand is critical as well as the CLSID and IID for the interface. Under normal circumstances the data defined in the class object is unavailable to programs using the interface, you simply create an instance of the class and treat it as a "black box", that is you let it handle the internal class data. I will take a look at the header though.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

FlySky

I couldn't follow it completely.
A Class Object is compiled into a Vtable.
Than in C++ you would acces the right function in the Class
by using something like Client *ISteamApps002 = BIsSubscribed();
right?


donkey

Hi Flysky,

Not exactly, the vTable is just a single component of the class object, it is usually defined separately as an interface, not with the class. A class object also contains pointers to vTables, variables, working data, and fixed data that are needed when an instance of the class is created. This data is generally reserved for use by the class and is not meant to be accessed by programs instantiating it. For this reason I normally find that there is little gained by actually defining the class object itself except ofcourse if it is your own class and you are writing a COM server application.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

FlySky

I will see if I can pick up a C++ book to give me a better understanding, this doesn't make much sense yet :bg

donkey

Hi Flysky,

This article isn't bad, it explains the differences between classes (actually coclasses since they are not the same as C++ classes) and interfaces. It can be a bit hard to wrap your head around at first but once you get it you'll find that COM is actually not too bad and a remarkably easy way to implement very complex functions and even easier to use than straight API programming if you want a lot of bang for a little code. And by the way, it can make your code a pain in the arse to reverse engineer since it does not use many named APIs.

Your confusion is pretty well dealt with in the "Attributes of Interfaces" section of the article I posted, pay special attention to that section, specifically "An interface is not a class".
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

i am trying to work up some bravery to play with it, Edgar   :bg
i was also thinking i might play with GoAsm, just so i could read all your examples