🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #104

Re: Access violation masc.dll

#104
From: DaveTV
Date: Sun, 16 Jan 2005 04:19
72 lines
3820 bytes
Martin wrote:
> Hi,
> 
> I'm writing an application to test Mobitex and the MASC protocol. I've
> decided to use an dll(masc.dll). The MASC DLL is a Windows DLL that
> implements the MASC protocol, allowing applications that have no
> knowledge of MASC to communicate with Mobitex modems.
> 
> I'm using Delphi and has converted masc.h (written in C/C++) to
> delphicode. When I call a method I get the following message: 'Access
> violation att address 10001029 in module masc.dll'. Read of address
> 00000000'.
> 
> 
> This is the method I tried to call
> 
> Defintion in masc.h
> 
> EXPORT int CALLBACK MASC_Open(HMASC* hMASC, char* address,
> MASC_SETTINGS* settings, unsigned long timeout);
> 
> Definition in Delphi
> 
> function MASC_Open(hMASC :HMASC; address: PChar;
> settings:MASC_SETTINGS; Timeout: LongInt):integer; cdecl; external
> MASCDLL;
> 
> My call to MASC_Open in the code:
> 
> status := MASC_Open(hMasc, address, settings, 0);
> 
> Declaration HMASC, MASC_SETTINGS
> 
> HMASC: In masc.h typedef void* 
>        in delphi  HMASC=pointer;
> 
> MASC_SETTINGS In masc.h typedef struct 
>                         {
>                           unsigned int frameQueueSize;    
>                           unsigned int commandQueueSize;  
>                           unsigned int mpakQueueSize;     
>                           }
>              in delphi  type
>                             MASC_SETTINGS = record
> 
>                               frameQueueSize :cardinal;
>                               mpakQueueSize :cardinal;
>                              commandQueueSize :cardinal;
>                               end{MASC_SETTINGS};
> 
> I'm not very familiar with c/c++ and pointers so I wouldn't be
> surprised if the explanation to the "access violation" lies in the
> conversion of different data types and pointers.
> 
> Please help if you can, I'm stuck...
> 
> Martin
> pointers from c/c++ to delphi.
I think that you are passing the record as an argument rather than a 
pointer to the record that the dll function requires
try :-

function MASC_Open(hMASC :HMASC; address: PChar;
settings:PMASC_SETTINGS; Timeout: LongInt):integer; cdecl; external
MASCDLL;

type MASC_SETTINGS = record
  frameQueueSize :cardinal;
  mpakQueueSize :cardinal;
  commandQueueSize :cardinal;
end;
type PMASC_SETTINGS = ^MASC_SETTINGS
Technical Details
Message-ID: <JXlGd.120305$K7.117156@news-server.bigpond.net.au>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!lon-transit.news.telstra.net!lon-in.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail
References: <7b95a6bf.0501140238.40e08340@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10baee,eb7f1ca82bd8ffc4
X-Google-Thread: 10545b,eb7f1ca82bd8ffc4
X-Google-Thread: 1043cf,eb7f1ca82bd8ffc4
X-Google-Attributes: gid10baee,gid10545b,gid1043cf,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!lon-transit.news.telstra.net!lon-in.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail
From: DaveTV <dave.tv@gmail.com>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.ide,borland.public.delphi.objectpascal
Subject: Re: Access violation masc.dll
References: <7b95a6bf.0501140238.40e08340@posting.google.com>
In-Reply-To: <7b95a6bf.0501140238.40e08340@posting.google.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 72
Message-ID: <JXlGd.120305$K7.117156@news-server.bigpond.net.au>
Date: Sun, 16 Jan 2005 04:19:53 GMT
NNTP-Posting-Host: 141.168.108.87
X-Complaints-To: abuse@bigpond.net.au
X-Trace: news-server.bigpond.net.au 1105849193 141.168.108.87 (Sun, 16 Jan 2005 15:19:53 EST)
NNTP-Posting-Date: Sun, 16 Jan 2005 15:19:53 EST
Organization: BigPond Internet Services