comp.lang.ada
 help / color / mirror / Atom feed
* Help on translating this thing in ada
@ 2002-11-06 16:55 Sim Con
  2002-11-06 17:23 ` Programmer Dude
  0 siblings, 1 reply; 3+ messages in thread
From: Sim Con @ 2002-11-06 16:55 UTC (permalink / raw)


Hello! In my search for an ada code for a winnt cpu usage program i
found some problem translating this instruction

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!!!


-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help on translating this thing in ada
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Programmer Dude @ 2002-11-06 17:23 UTC (permalink / raw)


Sim Con wrote:

> Hello! In my search for an ada code for a winnt cpu usage program i
> found some problem translating this instruction
> 
> 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.

Probably what this defines is the signature of a callback function.

-- 
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|



Opinions expressed herein are my own and may not represent those of my employer.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help on translating this thing in ada
  2002-11-06 17:23 ` Programmer Dude
@ 2002-11-10  1:35   ` David Thompson
  0 siblings, 0 replies; 3+ messages in thread
From: David Thompson @ 2002-11-10  1:35 UTC (permalink / raw)


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








^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-10  1:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox