From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,11061552bd31311d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-09 17:35:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!wn11feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <0552b568e58f18d139d6ce0ec4c204ff.110780@mygate.mailgate.org> <3DC95003.33DC2119@mmm.com> Subject: Re: Help on translating this thing in ada X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-Mimeole: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sun, 10 Nov 2002 01:35:05 GMT NNTP-Posting-Host: 12.89.166.201 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1036892105 12.89.166.201 (Sun, 10 Nov 2002 01:35:05 GMT) NNTP-Posting-Date: Sun, 10 Nov 2002 01:35:05 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:30673 Date: 2002-11-10T01:35:05+00:00 List-Id: Programmer Dude 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