comp.lang.ada
 help / color / mirror / Atom feed
From: "David Thompson" <david.thompson1@worldnet.att.net>
Subject: Re: Help on translating this thing in ada
Date: Sun, 10 Nov 2002 01:35:05 GMT
Date: 2002-11-10T01:35:05+00:00	[thread overview]
Message-ID: <dJiz9.10350$SY3.579759@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: 3DC95003.33DC2119@mmm.com

Programmer Dude <cjsonnack@mmm.com> wrote :
> Sim Con wrote:
...
> > typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
> >
> > this seems needed for define PROCNTQSI NtQuerySystemInformation; and the
> > dll call NtQuerySystemInformation. Any help? Thanx in advance!!!
>
> This defines PROCNTQSI as a pointer to a function that returns a LONG
> (long) and takes a UINT (unsigned int), a PVOID (void* -- an untyped
> data pointer), a ULONG (unsigned long) and a PULONG (a pointer to an
> unsigned long (probably an Ada-style "in out" parameter).  The WINAPI
> symbol has to do with the calling convention.
>
To be precise, it defines (in C) PROCNTQSI to be a *type*
which is a pointer to function as described.  It does not
define or even reference an actual pointer variable.

> Probably what this defines is the signature of a callback function.
>
More likely it defines the signature of a dynamically-accessed
function, namely NtQuerySystemInformation.  With Windows DLLs,
at the lowest level, you have to:
0) Map the DLL (with LoadLibrary) which may put it at different
addresses in different callers (or executions) depending
1) Define a variable or other object e.g. struct member to be
used as a pointer to function, with a type like the above
2) Call GetProcAddress to find where the routine you want
got loaded in #0; store the returned pointer in your variable
3) Use your pointer-to-function variable to call the function

It's usually easier to just call the routine by name, here
NtQuerySystemInformation, and link against the import
library (assuming you have or can get or generate it),
and let the system do the magic for you.  Especially
for kernel routines like this where there's no point in
trying to continue (recover) if the DLL isn't available.

--
- David.Thompson 1 now at worldnet.att.net








      reply	other threads:[~2002-11-10  1:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 16:55 Help on translating this thing in ada Sim Con
2002-11-06 17:23 ` Programmer Dude
2002-11-10  1:35   ` David Thompson [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox