News:

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

Main Menu

ULARGE_INTEGER & LARGE_INTEGER

Started by mabdelouahab, March 25, 2015, 07:23:29 PM

Previous topic - Next topic

mabdelouahab

Hello everyone
I came across the definition of the type LARGE_INTEGER & ULARGE_INTEGER, in MSDN:
typedef union _ULARGE_INTEGER {
  struct {
    DWORD LowPart;
    DWORD HighPart;
  };
  struct {
    DWORD LowPart;
    DWORD HighPart;
  } u;
  ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    LONG  HighPart;
  };
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } u;
  LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;


ULARGE_INTEGER union:Represents a 64-bit unsigned integer value.
LARGE_INTEGER union  :Represents a 64-bit signed integer value.
But in a windows.inc:

LARGE_INTEGER UNION
    STRUCT
      LowPart  DWORD ?
      HighPart DWORD ?
    ENDS
  QuadPart QWORD ?
LARGE_INTEGER ENDS

Can I say that  HighPart is SDWORD  because "LONG  HighPart"

_LARGE_INTEGER UNION
    STRUCT
      LowPart  DWORD ?
      HighPart SDWORD ?
    ENDS
  QuadPart QWORD ?
_LARGE_INTEGER ENDS
_ULARGE_INTEGER UNION
    STRUCT
      LowPart  DWORD ?
      HighPart DWORD ?
    ENDS
  QuadPart QWORD ?
_ULARGE_INTEGER ENDS

Second: If I call the function that contain Qword or any 64 size Param:
OleFunction       PROTO :DWORD,:QWORD,:DWORD,:DWORD
Can I transform her on this form:


MasmFunction proc _a:DWORD,_b:QWORD,_c:DWORD,_d:DWORD
push _d
push _c
lea ecx,_b
push dword ptr [ecx+4]
push dword ptr [ecx]
push _a
mov edx,CInt
push edx
mov edx,dword ptr [edx]
call (Interface_ ptr [edx]).OleFunction

ret

func endp

Is there a professor corrector?

dedndave

Hutch has simplified many such definitions in windows.inc
the masm assembler isn't as strongly typed as a C compiler
so, signed or unsigned isn't as critical
also, INT is an intel instruction - so, it's a masm reserved word (CINT also, i think)
INT, UINT, CINT, LONG - all DWORD's, as far as masm is concerned
also, HANDLE, HMENU, HFILE, HBITMAP (and many others) are TYPEDEF'ed as aliases for DWORD's

a large integer is 64 bits
but, you may often wish to access it as (2) 32-bit DWORD's
with a structure union, you can access it either way

you can PROTOtype a function with QWORD
but, the assembler makes (2) 32-bit PUSH'es to make it happen
in most cases, Hutch will prototype it as (2) DWORD's
the high-order half is pushed first, then the low-order half
this allows you to PUSH from registers
    INVOKE  SomeFunc,eax,edx
in that example, EAX has the low-order half
if it were prototyped as qword, you would only be able to pass qword variables from memory

mabdelouahab

Hi dedndave
Thanks for the valuable information,
for calling the function, I wanted to call OLE functions that contain Param a size of 64 bits, by MASM, functions and I put example to ask am I right way pass the Param length 64-bit to OLE functions
SomeFunc proc   b:qword:

0000339B  FF 35 00001290 R *     push   dword  ptr _b+000000004h
000033A1  FF 35 0000128C R *     push   dword  ptr _b
000033A7  E8 FFFFFFE8    *     call   SomeFunc

Is it the same with Ole call functions?

dedndave

it probably is
you can always look at the include file to see how it's prototyped

there are several OLE include files
but, most used are ole32 and oleaut32
for example, you can open \masm32\include\ole32.inc with NotePad   :t

OleCreateLinkEx PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

i bet Hutch got tired of typing "DWORD" when he made these files   :lol:

mabdelouahab

Quote from: dedndave on March 25, 2015, 10:36:52 PM
it probably is
you can always look at the include file to see how it's prototyped

there are several OLE include files
but, most used are ole32 and oleaut32
for example, you can open \masm32\include\ole32.inc with NotePad   :t
My question is related to the generation INC files for TLB (Automation), So I wanted to make sure of the validity of what I'm doing,  LARGE_INTEGER is one of the 32 Type that define the variable,
void,NULL,short,long,float,double,CY,DATE,BSTR,IDispatch,SCODE,bool,VARIANT far,IUnknown,decimal,{15},signed char,unsigned char , unsigned short,unsigned long,LARGE_INTEGER,ULARGE_INTEGER,signed int,unsigned int,void,HRESULT,{ptr},safearray,{array},userdef},char far*,wchar far*


I just wanted to translate it to the masm and to know how to work with them
EMPTY,NULL,SWORD,SDWORD,REAL4,REAL8,QWORD,REAL8,POINTER,POINTER,SDWORD,WORD,POINTER,POINTER,DWORD,{15},SBYTE,BYTE,WORD,DWORD,LARGE_INTEGER,LARGE_INTEGER,SDWORD,DWORD,EMPTY,DWORD,PTR,POINTER,POINTER,USERDEF,POINTER,POINTER

I think that there are a lot of questions I ask for in the future
Quote from: dedndave on March 25, 2015, 10:36:52 PM
i bet Hutch got tired of typing "DWORD" when he made these files   :lol:
Great professor,

dedndave

that's a COM interface
i also break the VARIANT structures up into DWORD's to make them easier to work with - same idea

this is for IShellDispatch, but gives you an idea
;###############################################################################################

;METHOD macro by qWord

METHOD  MACRO   name,args:VARARG
        LOCAL   _type1,_type2
        _type1  TYPEDEF PROTO args
        _type2  TYPEDEF PTR _type1
        EXITM   <name _type2 ?>
        ENDM

;###############################################################################################

;IUnknown interface vTable (structure)

IUnknown STRUCT
  METHOD(QueryInterface, _this:LPVOID,riid:LPVOID,ppvObj:LPVOID)
  METHOD(AddRef,         _this:LPVOID)
  METHOD(Release,        _this:LPVOID)
IUnknown ENDS

;IDispatch interface vTable (structure)

IDispatch STRUCT
    IUnknown                 <>
  METHOD(GetTypeInfoCount, _this:LPVOID,pctinfo:LPVOID)
  METHOD(GetTypeInfo,      _this:LPVOID,iTInfo:UINT,lcid:LCID,ppTInfo:LPVOID)
  METHOD(GetIDsOfNames,    _this:LPVOID,riid:LPVOID,rgszNames:LPOLESTR,cNames:UINT,lcid:LCID,rgDispId:LPVOID)
  METHOD(dInvoke,          _this:LPVOID,dispIdMember:DWORD,riid:LPVOID,lcid:LCID,wFlags:DWORD,pDispParams:LPVOID,pVarResult:LPVOID,pExcepInfo:LPVOID,puArgErr:LPVOID)
IDispatch ENDS

;IShellDispatch interface vTable (structure)
;       vDir VARIANT struct = vtDir:DWORD,vD0:DWORD,vstrDir:LPVOID,vDV0:DWORD
;vRootFolder VARIANT struct = vtRoot:DWORD,vR0:DWORD,vstrRoot:LPVOID,vRV0:DWORD

IShellDispatch STRUCT
    IDispatch                <>
  METHOD(Application,      _this:LPVOID,ppid:LPVOID)
  METHOD(Parent,           _this:LPVOID,ppid:LPVOID)
  METHOD(NameSpace,        _this:LPVOID,vtDir:DWORD,vD0:DWORD,vstrDir:LPVOID,vDV0:DWORD,ppsdf:LPVOID)
  METHOD(BrowseForFolder,  _this:LPVOID,Hwnd:DWORD,lpTitle:LPVOID,Options:DWORD,vtRoot:DWORD,vR0:DWORD,vstrRoot:LPVOID,vRV0:DWORD,ppsdf:LPVOID)
  METHOD(Windows,          _this:LPVOID,ppid:LPVOID)
  METHOD(Open,             _this:LPVOID,vtDir:DWORD,vD0:DWORD,vstrDir:LPVOID,vDV0:DWORD)
  METHOD(Explore,          _this:LPVOID,vtDir:DWORD,vD0:DWORD,vstrDir:LPVOID,vDV0:DWORD)
  METHOD(MinimizeAll,      _this:LPVOID)
  METHOD(UndoMinimizeALL,  _this:LPVOID)
  METHOD(FileRun,          _this:LPVOID)
  METHOD(CascadeWindows,   _this:LPVOID)
  METHOD(TileVertically,   _this:LPVOID)
  METHOD(TileHorizontally, _this:LPVOID)
  METHOD(ShutdownWindows,  _this:LPVOID)
  METHOD(Suspend,          _this:LPVOID)
  METHOD(EjectPC,          _this:LPVOID)
  METHOD(SetTime,          _this:LPVOID)
  METHOD(TrayProperties,   _this:LPVOID)
  METHOD(Help,             _this:LPVOID)
  METHOD(FindFiles,        _this:LPVOID)
  METHOD(FindComputer,     _this:LPVOID)
  METHOD(RefreshMenu,      _this:LPVOID)
  METHOD(ControlPanelItem, _this:LPVOID,bstrDir:LPVOID)
IShellDispatch ENDS

;IShellDispatch::NameSpace Folder object interface vTable (structure)
;   vItem VARIANT struct = vtItem:DWORD,vI0:DWORD,vdwItem:DWORD,vIV0:DWORD
;vOptions VARIANT struct = vtOpt:DWORD,vO0:DWORD,vdwOpt:LPVOID,vOV0:DWORD

Folder STRUCT
    IDispatch            <>
  METHOD(getTitle,     _this:LPVOID,pbs:LPVOID)
  METHOD(Application,  _this:LPVOID,ppid:LPVOID)
  METHOD(Parent,       _this:LPVOID,ppid:LPVOID)
  METHOD(ParentFolder, _this:LPVOID,ppsf:LPVOID)
  METHOD(Items,        _this:LPVOID,ppid:LPVOID)
  METHOD(ParseName,    _this:LPVOID,bstrName:LPVOID,ppid:LPVOID)
  METHOD(NewFolder,    _this:LPVOID,bstrName:LPVOID,vtOpt:DWORD,vO0:DWORD,vdwOpt:LPVOID,vOV0:DWORD)
  METHOD(MoveHere,     _this:LPVOID,vtItem:DWORD,vI0:DWORD,vdwItem:DWORD,vIV0:DWORD,vtOpt:DWORD,vO0:DWORD,vdwOpt:LPVOID,vOV0:DWORD)
  METHOD(CopyHere,     _this:LPVOID,vtItem:DWORD,vI0:DWORD,vdwItem:DWORD,vIV0:DWORD,vtOpt:DWORD,vO0:DWORD,vdwOpt:LPVOID,vOV0:DWORD)
  METHOD(GetDetailsOf, _this:LPVOID,vtItem:DWORD,vI0:DWORD,vdwItem:DWORD,vIV0:DWORD,iColumn:DWORD,pbs:LPVOID)
Folder ENDS

;###############################################################################################