News:

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

Main Menu

C Sructures help

Started by xandaz, June 16, 2020, 10:14:13 PM

Previous topic - Next topic

xandaz

    Hey guys. I've been translating unRAR.h and came across some doubts. i know that this is an ASM forum but i'd like to know if someone could translate the following structure. Thanks in advance
struct RAROpenArchiveDataEx
{
  char         *ArcName;
  wchar_t      *ArcNameW;
  unsigned int  OpenMode;
  unsigned int  OpenResult;
  char         *CmtBuf;
  unsigned int  CmtBufSize;
  unsigned int  CmtSize;
  unsigned int  CmtState;
  unsigned int  Flags;
  UNRARCALLBACK Callback;
  LPARAM        UserData;
  unsigned int  OpFlags;
  wchar_t      *CmtBufW;
  unsigned int  Reserved[25];
};



Thanks guys

felipe

Translate to assembly? If that so, even if i don't know this structure i can give hints of the types you can use in an assembly source code (written in the comments):


struct RAROpenArchiveDataEx
{
  char         *ArcName;                  ;;;;;;;;;;; Just a pointer to a text buffer (size of each character 1 byte).
  wchar_t      *ArcNameW;            ;;;;;;;;;;; Just a pointer to a text buffer (size of each character 2 bytes i think).
  unsigned int  OpenMode;           ;;;;;;;;;;; A dword.
  unsigned int  OpenResult;           ;;;;;;;;;;; A dword.
  char         *CmtBuf;                     ;;;;;;;;;;; Just a pointer to a text buffer (size of each character 1 byte).
  unsigned int  CmtBufSize;           ;;;;;;;;;;; A dword.
  unsigned int  CmtSize;                 ;;;;;;;;;;; A dword.
  unsigned int  CmtState;               ;;;;;;;;;;; A dword.
  unsigned int  Flags;                     ;;;;;;;;;;; A dword.
  UNRARCALLBACK Callback;            ;;;;;;;;;;;Probably a pointer to some callback function.
  LPARAM        UserData;                ;;;;;;;; dword in 32 bit land, qword in 64 bits land.
  unsigned int  OpFlags;                 ;;;;;;;;;;; A dword.
  wchar_t      *CmtBufW;               ;;;;;;;;;;; Just a pointer to a text buffer (size of each character 2 bytes i think).
  unsigned int  Reserved[25];        ;;;;;;;;;;;Just 25 dwords i guess.
};


Don't know if this structure is defined in windows.inc or win64.inc, if not, there are different kinds of styles of code to write the structure in the data section of your code that you can use.  :icon_idea:



felipe

Here is the same as above using the classical structure definition in masm 32 bits code (c masters should correct me if i'm wrong):


RAROpenArchiveDataEx STRUCT
  ArcName        DWORD      ?
  ArcNameW      DWORD      ?
  OpenMode       DWORD      ?
  OpenResult      DWORD      ?
  CmtBuf          DWORD      ?
  CmtBufSize       DWORD      ?
  CmtState        DWORD      ?
  Flags           DWORD      ?
   _Callback        DWORD      ?
   UserData         DWORD      ?
   OpFlags        DWORD      ?
     Reserved     DWORD      25 dup(?)
RAROpenArchiveDataEx  ENDS


TimoVJL

32-bit
RAROpenArchiveDataEx 152 98h bytes
ArcName          +0h 4h
ArcNameW         +4h 4h
OpenMode         +8h 4h
OpenResult       +Ch 4h
CmtBuf           +10h 4h
CmtBufSize       +14h 4h
CmtSize          +18h 4h
CmtState         +1Ch 4h
Flags            +20h 4h
UserData         +28h 4h
OpFlags          +2Ch 4h
CmtBufW          +30h 4h
Reserved         +34h 64h
64-bitRAROpenArchiveDataEx 176 B0h bytes
ArcName          +0h 8h
ArcNameW         +8h 8h
OpenMode         +10h 4h
OpenResult       +14h 4h
CmtBuf           +18h 8h
CmtBufSize       +20h 4h
CmtSize          +24h 4h
CmtState         +28h 4h
Flags            +2Ch 4h
UserData         +38h 8h
OpFlags          +40h 4h
CmtBufW          +44h 8h
Reserved         +4Ch 64h
so PTR just for pointers
May the source be with you

jj2007

Quote from: xandaz on June 16, 2020, 10:14:13 PM
    Hey guys. I've been translating unRAR.h and came across some doubts. i know that this is an ASM forum but i'd like to know if someone could translate the following structure. Thanks in advance
struct RAROpenArchiveDataEx
{
  char         *ArcName;
  wchar_t      *ArcNameW;
  unsigned int  OpenMode;
  unsigned int  OpenResult;
  char         *CmtBuf;
  unsigned int  CmtBufSize;
  unsigned int  CmtSize;
  unsigned int  CmtState;
  unsigned int  Flags;
  UNRARCALLBACK Callback;
  LPARAM        UserData;
  unsigned int  OpFlags;
  wchar_t      *CmtBufW;
  unsigned int  Reserved[25];
};

CStruct2Asm (attached) translates it like this:
RAROpenArchiveDataEx STRUCT
ArcName    LPVOID ?
ArcNameW  LPVOID ?
OpenMode  DWORD ?
OpenResult DWORD ?
CmtBuf    LPVOID ?
CmtBufSize DWORD ?
CmtSize    DWORD ?
CmtState  DWORD ?
Flags      DWORD ?
Callback  UNRARCALLBACK <>
UserData  LPARAM ?
OpFlags    DWORD ?
CmtBufW    LPVOID ?
Reserved  dd 25 dup(?)
RAROpenArchiveDataEx ENDS


Usage: copy the C struct, launch the exe

xandaz

   thanks for the help guys.

deeR44

I'm learning Python. If I need any help with Python, I'm coming right here.