On Nov 13 16:32, Ozkan Sezer wrote:
> On Mon, Nov 12, 2012 at 7:37 PM, Corinna Vinschen <vinsc...@redhat.com> wrote:
> 
> About the correction made in SYSTEM_BASIC_INFORMATION:
> 
> [...]
> > Index: winternl.h
> > ===================================================================
> > --- winternl.h  (revision 5451)
> > +++ winternl.h  (working copy)
> > @@ -688,9 +688,9 @@
> >      ULONG LowestPhysicalPage;
> >      ULONG HighestPhysicalPage;
> >      ULONG AllocationGranularity;
> > -    ULONG LowestUserAddress;
> > -    ULONG HighestUserAddress;
> > -    ULONG ActiveProcessors;
> > +    ULONG_PTR LowestUserAddress;
> > +    ULONG_PTR HighestUserAddress;
> > +    ULONG_PTR ActiveProcessors;
> >      CCHAR NumberOfProcessors;
> >    } SYSTEM_BASIC_INFORMATION,*PSYSTEM_BASIC_INFORMATION;
> 
> If we compare original structure, we have:
> 
>       BYTE Reserved1[24];
>       PVOID Reserved2[4];
>       CCHAR NumberOfProcessors;
> 
> So, PVOID Reserved2[4] should correspond to 4 ULONG_PTR members
> in the detailed version: do we not need the following, too?
> 
> -      ULONG AllocationGranularity;
> +      ULONG_PTR AllocationGranularity;

No, the AllocationGranularity is a ULONG value.  The size of the
structure is a result of the automatic 8 byte alignment of 8 byte types.
Try this:

=== SNIP ===
#include <stdio.h>
#include <string.h>
#include <windows.h>

#ifndef NT_SUCCESS
#define NT_SUCCESS(status)      ((NTSTATUS) (status) >= 0)
#endif

typedef int NTSTATUS;

typedef struct _SYSTEM_BASIC_INFORMATION
{
  ULONG Unknown;
  ULONG MaximumIncrement;
  ULONG PhysicalPageSize;
  ULONG NumberOfPhysicalPages;
  ULONG LowestPhysicalPage;
  ULONG HighestPhysicalPage;
  ULONG AllocationGranularity;
#ifdef _WIN64
  ULONG dummy1;
#endif
  ULONG_PTR LowestUserAddress;
  ULONG_PTR HighestUserAddress;
  ULONG_PTR ActiveProcessors;
  UCHAR NumberProcessors;
} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;

NTSTATUS NTAPI NtQuerySystemInformation (ULONG, PVOID, ULONG, PULONG);

int
main ()
{
  NTSTATUS status;
  ULONG i, size;
  SYSTEM_BASIC_INFORMATION sbi;

  memset (&sbi, 0xbf, sizeof sbi);
  status = NtQuerySystemInformation (0, &sbi, sizeof sbi, &size);
  if (!NT_SUCCESS (status))
    {
      fprintf (stderr, "NtQuerySystemInformation: 0x%lx\n", status);
      return 1;
    }
  printf ("Size: %lu\n", size);
  printf ("AllocationGranularity: %lu\n", sbi.AllocationGranularity);
#ifdef _WIN64
  printf ("dummy1: 0x%lx\n", sbi.dummy1);
#endif
  return 0;
}
=== SNAP ===

$ x86_64-w64-mingw32-gcc -g -o sbi sbi.c -lntdll
$ ./sbi
Size: 64
AllocationGranularity: 65536
dummy1: 0xbfbfbfbf


Corinna

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to