diff -ruNEwB dmidecode-2.8/AUTHORS dmidecode/AUTHORS
--- dmidecode-2.8/AUTHORS 2006-01-21 21:08:35.000000000 -0200
+++ dmidecode/AUTHORS 2006-04-24 08:50:52.000000000 -0300
@@ -12,6 +12,7 @@
Dave Johnson
Petter Reinholdtsen
Roberto Nibali
+Hugo Weber
MANY THANKS TO (IN CHRONOLOGICAL ORDER)
Werner Heuser
@@ -63,3 +64,4 @@
Garry Belka
Klaus Muth
Antoine Fuselier
+Mark Russinovich
\ No newline at end of file
diff -ruNEwB dmidecode-2.8/CHANGELOG dmidecode/CHANGELOG
--- dmidecode-2.8/CHANGELOG 2006-02-04 14:23:04.000000000 -0200
+++ dmidecode/CHANGELOG 2006-10-04 11:55:08.000000000 -0300
@@ -1,3 +1,24 @@
+2006-10-04 Hugo Weber
+ Written the code to compile under Windows 2003 and Vista
+ * util.c: the functions used to have mem_chunk working
+ on WindowsNT/2000/XP were moved to winsmbios.c.
+ * winsmbios.h: added to organize functions to get SMBIOS
+ on Windows.
+ * winsmbios.c: holds all functions needed to get SMBIOS
+ on Windows.
+ * dmidecode.c: small changes on the main and dmi_table
+ functions to support windows 2003.
+ * types.h: the dmi_header struct moved from dmidecode.c
+ to this header due to windows functions uses it too.
+
+2006-04-20 Hugo Weber
+ Written the code to compile under windows NT, 2k, XP
+
+ * dmidecode.dev: DevC++ project. Used to compile dmidecode.
+ get DevC++ on http://www.bloodshed.net/devcpp.html
+ * util.c: written mem_chunck to work on winnt, 2k, xp
+ * native.h: added in order to work on winnt, 2k, xp
+
2006-02-04 Jean Delvare
* vpddecode.c: Update lookup table from revision 2006-01-31 of IBM
diff -ruNEwB dmidecode-2.8/README dmidecode/README
--- dmidecode-2.8/README 2006-01-21 21:02:57.000000000 -0200
+++ dmidecode/README 2006-10-04 11:47:54.000000000 -0300
@@ -20,7 +20,7 @@
to.
-** INSTALLATION **
+** GETTING THE SOFTWARE **
The home web page for dmidecode is hosted on Savannah:
http://www.nongnu.org/dmidecode/
@@ -29,7 +29,20 @@
articles.
This program was first written for Linux, and has since been reported to work
-on FreeBSD, NetBSD, BeOS and Cygwin as well.
+on FreeBSD, NetBSD, BeOS, WindowsNT/2000/XP/2003/Vista and Cygwin as well.
+So far there's no suport on Windows9x/Me.
+
+** INSTALATION ON WINDOWS **
+
+First you'll need to get the Dev-C++ on http://www.bloodshed.net/devcpp.html.
+Dev-C++ uses Mingw port of GCC (GNU Compiler Collection) as it's compiler and
+it's all open source.
+
+After installed, double click on dmidecode.dev to open the project and then
+click on project -> compile. That's it, you'll get dmidecode.exe to work on
+WindowsNT/2000/XP/2003/Vista.
+
+** INSTALATION ON LINUX **
There's no configure script, so simply run "make" to build dmidecode, and
"make install" to install it. You also can use "make uninstall" to remove
diff -ruNEwB dmidecode-2.8/dmidecode.c dmidecode/dmidecode.c
--- dmidecode-2.8/dmidecode.c 2005-10-06 13:51:12.000000000 -0300
+++ dmidecode/dmidecode.c 2006-10-04 11:37:59.000000000 -0300
@@ -63,16 +63,13 @@
#include "dmidecode.h"
#include "dmiopt.h"
+#ifdef __WIN32__
+#include "winsmbios.h"
+#endif /*__WIN32__*/
+
static const char *out_of_spec = "";
static const char *bad_index = "";
-struct dmi_header
-{
- u8 type;
- u8 length;
- u16 handle;
-};
-
#ifdef ALIGNMENT_WORKAROUND
#define HANDLE(x) WORD((u8 *)&(x->handle))
#else
@@ -3803,6 +3800,7 @@
static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
{
+
u8 *buf;
u8 *data;
int i=0;
@@ -3816,6 +3814,19 @@
printf("\n");
}
+ /*
+ * if devmem is NULL then base has the SMBIOS Table address
+ * already allocated and not the physical memory address that
+ * needs to be mapped.
+ * This change was made to support Windows 2003 that blocks
+ * access to physical memory but returns the SMBIOS Table
+ * througth GetSystemFirmwareTable API.
+ *
+ * see more on winsmbios.h and winsmbios.c
+ */
+ if(devmem == NULL){
+ buf = (u8 *)base;
+ }else{
if((buf=mem_chunk(base, len, devmem))==NULL)
{
#ifndef USE_MMAP
@@ -3823,6 +3834,7 @@
#endif
return;
}
+ }
data=buf;
while(iSMBIOSTableData[0], smb->Length);
+
+ if(!(opt.flags & FLAG_QUIET)){
+ printf("SMBIOS %u.%u present.\n", smb->SMBIOSMajorVersion,
+ smb->SMBIOSMinorVersion);
+ }
+
+ //shows the smbios information
+ dmi_table((u32)&smb->SMBIOSTableData[0], smb->Length, num_structures,
+ (smb->SMBIOSMajorVersion<<8)+smb->SMBIOSMinorVersion, NULL);
+
+ free(smb);
+ goto exit_free;
+ break;
+
+ case WIN_UNSUPORTED://prints error and exits
+ printf("\nDMIDECODE runs on Windows NT/2000/XP. Windows 9x/Me are not supported.\n");
+ goto exit_free;
+ break;
+
+ default:
+ /*
+ * do nothing. Follow the code below, scans for the
+ * SMBIOS table entry point, etc...
+ */
+ break;
+ }
+#endif /*__WIN32__*/
+
if((buf=mem_chunk(0xF0000, 0x10000, opt.devmem))==NULL)
{
ret=1;
diff -ruNEwB dmidecode-2.8/dmidecode.dev dmidecode/dmidecode.dev
--- dmidecode-2.8/dmidecode.dev 1969-12-31 21:00:00.000000000 -0300
+++ dmidecode/dmidecode.dev 2006-10-03 17:06:11.000000000 -0300
@@ -0,0 +1,199 @@
+[Project]
+FileName=dmidecode.dev
+Name=dmidecode
+UnitCount=12
+Type=1
+Ver=1
+ObjFiles=
+Includes=
+Libs=
+PrivateResource=
+ResourceIncludes=
+MakeIncludes=
+Compiler=
+CppCompiler=
+Linker=
+IsCpp=0
+Icon=
+ExeOutput=
+ObjectOutput=
+OverrideOutput=0
+OverrideOutputName=
+HostApplication=
+Folders=
+CommandLine=-t 1
+UseCustomMakefile=0
+CustomMakefile=
+IncludeVersionInfo=0
+SupportXPThemes=0
+CompilerSet=0
+CompilerSettings=
+
+[Unit2]
+FileName=dmidecode.c
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit3]
+FileName=dmidecode.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit4]
+FileName=dmiopt.c
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit5]
+FileName=dmiopt.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit6]
+FileName=types.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit8]
+FileName=util.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit9]
+FileName=version.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit11]
+FileName=winsmbios.h
+CompileCpp=0
+Folder=
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit12]
+FileName=winsmbios.c
+CompileCpp=0
+Folder=
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit13]
+FileName=native.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit14]
+FileName=vpdopt.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[VersionInfo]
+Major=0
+Minor=1
+Release=1
+Build=1
+LanguageID=1033
+CharsetID=1252
+CompanyName=
+FileVersion=
+FileDescription=Developed using the Dev-C++ IDE
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=
+AutoIncBuildNr=0
+
+[Unit15]
+FileName=native.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit1]
+FileName=config.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit7]
+FileName=util.c
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit10]
+FileName=native.h
+CompileCpp=0
+Folder=dmidecode
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
diff -ruNEwB dmidecode-2.8/native.h dmidecode/native.h
--- dmidecode-2.8/native.h 1969-12-31 21:00:00.000000000 -0300
+++ dmidecode/native.h 2006-10-03 17:05:25.000000000 -0300
@@ -0,0 +1,83 @@
+//========================================================
+//
+// Native.h
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//
+// This file contains tyepdefs and defines from NTDDK.H.
+// They are included here so that we don't have to
+// include NTDDK.H and get all the other stuff that
+// we don't really need or want.
+//
+//========================================================
+#ifndef NATIVE_H
+#define NATIVE_H
+
+#ifdef __WIN32__
+/*
+#define PAGE_NOACCESS 0x01 // winnt
+#define PAGE_READONLY 0x02 // winnt
+#define PAGE_READWRITE 0x04 // winnt
+#define PAGE_WRITECOPY 0x08 // winnt
+#define PAGE_EXECUTE 0x10 // winnt
+#define PAGE_EXECUTE_READ 0x20 // winnt
+#define PAGE_EXECUTE_READWRITE 0x40 // winnt
+#define PAGE_EXECUTE_WRITECOPY 0x80 // winnt
+#define PAGE_GUARD 0x100 // winnt
+#define PAGE_NOCACHE 0x200 // winnt
+*/
+typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; // windbgkd
+
+
+typedef LONG NTSTATUS;
+#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
+
+typedef struct _UNICODE_STRING {
+ USHORT Length;
+ USHORT MaximumLength;
+#ifdef MIDL_PASS
+ [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
+#else // MIDL_PASS
+ PWSTR Buffer;
+#endif // MIDL_PASS
+} UNICODE_STRING;
+typedef UNICODE_STRING *PUNICODE_STRING;
+
+typedef enum _SECTION_INHERIT {
+ ViewShare = 1,
+ ViewUnmap = 2
+} SECTION_INHERIT;
+
+#define OBJ_INHERIT 0x00000002L
+#define OBJ_PERMANENT 0x00000010L
+#define OBJ_EXCLUSIVE 0x00000020L
+#define OBJ_CASE_INSENSITIVE 0x00000040L
+#define OBJ_OPENIF 0x00000080L
+#define OBJ_OPENLINK 0x00000100L
+#define OBJ_VALID_ATTRIBUTES 0x000001F2L
+
+
+typedef struct _OBJECT_ATTRIBUTES {
+ ULONG Length;
+ HANDLE RootDirectory;
+ PUNICODE_STRING ObjectName;
+ ULONG Attributes;
+ PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
+ PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
+} OBJECT_ATTRIBUTES;
+typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
+
+
+#define InitializeObjectAttributes( p, n, a, r, s ) { \
+ (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \
+ (p)->RootDirectory = r; \
+ (p)->Attributes = a; \
+ (p)->ObjectName = n; \
+ (p)->SecurityDescriptor = s; \
+ (p)->SecurityQualityOfService = NULL; \
+ }
+#endif /* __WIN32__ */
+
+#endif /*NATIVE_H*/
diff -ruNEwB dmidecode-2.8/types.h dmidecode/types.h
--- dmidecode-2.8/types.h 2004-04-22 16:08:09.000000000 -0300
+++ dmidecode/types.h 2006-10-03 17:05:28.000000000 -0300
@@ -6,6 +6,13 @@
typedef signed short i16;
typedef unsigned int u32;
+struct dmi_header
+{
+ u8 type;
+ u8 length;
+ u16 handle;
+};
+
/*
* These macros help us solve problems on systems that don't support
* non-aligned memory access. This isn't a big issue IMHO, since the tools
diff -ruNEwB dmidecode-2.8/util.c dmidecode/util.c
--- dmidecode-2.8/util.c 2005-02-12 14:53:19.000000000 -0200
+++ dmidecode/util.c 2006-10-03 17:05:47.000000000 -0300
@@ -30,12 +30,18 @@
#include "config.h"
+#ifdef __WIN32__
+ #include "winsmbios.h"
+#else
#ifdef USE_MMAP
#include
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif /* !MAP_FAILED */
#endif /* USE MMAP */
+#endif /* __WIN32__ */
+
+
#include
#include
@@ -90,6 +96,15 @@
return (sum==0);
}
+
+#ifdef __WIN32__
+
+void *mem_chunk(size_t base, size_t len, const char *devmem){
+ return mem_chunk_win(base, len);
+}
+
+#else
+
/*
* Copy a physical memory chunk into a memory buffer.
* This function allocates memory.
@@ -163,3 +178,4 @@
return p;
}
+#endif /* __WIN32__ */
diff -ruNEwB dmidecode-2.8/winsmbios.c dmidecode/winsmbios.c
--- dmidecode-2.8/winsmbios.c 1969-12-31 21:00:00.000000000 -0300
+++ dmidecode/winsmbios.c 2006-10-04 11:19:22.000000000 -0300
@@ -0,0 +1,463 @@
+/*
+ * Functions to allow to read SMBIOS from physical memory on windows
+ * or to get the SMBIOS table on windows 2003 SP1 and above.
+ *
+ * This file is part of the dmidecode project.
+ *
+ * (C) 2002-2006 Hugo Weber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For the avoidance of doubt the "preferred form" of this code is one which
+ * is in an open unpatent encumbered format. Where cryptographic key signing
+ * forms part of the process of creating an executable the information
+ * including keys needed to generate an equivalently functional executable
+ * are deemed to be part of the source code.
+ */
+
+#ifdef __WIN32__
+#include
+#include "winsmbios.h"
+#include "native.h"
+
+
+
+/*
+ * Functions in NTDLL that allows access to physical memory
+ * from Windows NT to Windows XP.
+ *
+ * Made by Mark Russinovich
+ * Systems Internals
+ *
+ * see more on:
+ * http://www.sysinternals.com/Information/TipsAndTrivia.html#PhysMem
+ */
+NTSTATUS (__stdcall *NtUnmapViewOfSection)(
+ IN HANDLE ProcessHandle,
+ IN PVOID BaseAddress
+ );
+
+NTSTATUS (__stdcall *NtOpenSection)(
+ OUT PHANDLE SectionHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes
+ );
+
+NTSTATUS (__stdcall *NtMapViewOfSection)(
+ IN HANDLE SectionHandle,
+ IN HANDLE ProcessHandle,
+ IN OUT PVOID *BaseAddress,
+ IN ULONG ZeroBits,
+ IN ULONG CommitSize,
+ IN OUT PLARGE_INTEGER SectionOffset, /* optional */
+ IN OUT PULONG ViewSize,
+ IN SECTION_INHERIT InheritDisposition,
+ IN ULONG AllocationType,
+ IN ULONG Protect
+ );
+
+VOID (__stdcall *RtlInitUnicodeString)(
+ IN OUT PUNICODE_STRING DestinationString,
+ IN PCWSTR SourceString
+ );
+
+ULONG (__stdcall *RtlNtStatusToDosError) (
+ IN NTSTATUS Status
+ );
+
+
+/*
+ * API found on Windows 2003 or newer. From Windows 2003 SP1
+ * Microsoft only allows access to physical memory by kernel
+ * mode. The other way to get the SMBIOS, without to access
+ * physical memory is GetSystemFirmwareTable API.
+ *
+ * see more on:
+ * http://download.microsoft.com/download/5/D/6/5D6EAF2B-7DDF-476B-93DC-7CF0072878E6/SMBIOS.doc
+ */
+
+u32 (__stdcall *GetSystemFirmwareTable)(
+ u32 FirmwareTableProviderSignature,
+ u32 FirmwareTableID,
+ void *pFirmwareTableBuffer,
+ u32 BufferSize
+);
+
+
+//--------------------------------------------------------
+//
+// LocateNtdllEntryPoints
+//
+// Finds the entry points for all the functions we
+// need within NTDLL.DLL.
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//--------------------------------------------------------
+BOOLEAN LocateNtdllEntryPoints()
+{
+
+ switch(get_windows_platform()){
+ case WIN_2003_VISTA:
+ if( !(GetSystemFirmwareTable = (void *) GetProcAddress( GetModuleHandle("kernel32.dll"),
+ "GetSystemFirmwareTable" )) ) {
+
+ return FALSE;
+ }
+ break;
+
+ default:
+ if( !(RtlInitUnicodeString = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
+ "RtlInitUnicodeString" )) ) {
+
+ return FALSE;
+ }
+ if( !(NtUnmapViewOfSection = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
+ "NtUnmapViewOfSection" )) ) {
+
+ return FALSE;
+ }
+ if( !(NtOpenSection = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
+ "NtOpenSection" )) ) {
+
+ return FALSE;
+ }
+ if( !(NtMapViewOfSection = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
+ "NtMapViewOfSection" )) ) {
+
+ return FALSE;
+ }
+ if( !(RtlNtStatusToDosError = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
+ "RtlNtStatusToDosError" )) ) {
+
+ return FALSE;
+ }
+
+ break;
+ }
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------
+//
+// PrintError
+//
+// Formats an error message for the last error
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//----------------------------------------------------------------------
+void PrintError( char *message, NTSTATUS status )
+{
+ char *errMsg;
+
+ FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, RtlNtStatusToDosError( status ),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &errMsg, 0, NULL );
+ printf("%s: %s\n", message, errMsg );
+ LocalFree( errMsg );
+}
+
+//--------------------------------------------------------
+//
+// UnmapPhysicalMemory
+//
+// Maps a view of a section.
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//--------------------------------------------------------
+static VOID UnmapPhysicalMemory( DWORD Address )
+{
+ NTSTATUS status;
+
+ status = NtUnmapViewOfSection( (HANDLE) -1, (PVOID) Address );
+ if( !NT_SUCCESS(status)) {
+
+ PrintError("Unable to unmap view", status );
+ }
+}
+
+
+//--------------------------------------------------------
+//
+// MapPhysicalMemory
+//
+// Maps a view of a section.
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//--------------------------------------------------------
+static BOOLEAN MapPhysicalMemory( HANDLE PhysicalMemory,
+ PDWORD Address, PDWORD Length,
+ PDWORD VirtualAddress )
+{
+ NTSTATUS ntStatus;
+ PHYSICAL_ADDRESS viewBase;
+ char error[256];
+
+ *VirtualAddress = 0;
+ viewBase.QuadPart = (ULONGLONG) (*Address);
+ ntStatus = NtMapViewOfSection (PhysicalMemory,
+ (HANDLE) -1,
+ (PVOID) VirtualAddress,
+ 0L,
+ *Length,
+ &viewBase,
+ Length,
+ ViewShare,
+ 0,
+ PAGE_READONLY );
+
+ if( !NT_SUCCESS( ntStatus )) {
+
+ sprintf( error, "Could not map view of %X length %X",
+ *Address, *Length );
+ PrintError( error, ntStatus );
+ return FALSE;
+ }
+
+ *Address = viewBase.LowPart;
+ return TRUE;
+}
+
+
+//--------------------------------------------------------
+//
+// OpensPhysicalMemory
+//
+// This function opens the physical memory device. It
+// uses the native API since
+//
+// Mark Russinovich
+// Systems Internals
+// http://www.sysinternals.com
+//--------------------------------------------------------
+static HANDLE OpenPhysicalMemory()
+{
+ NTSTATUS status;
+ HANDLE physmem;
+ UNICODE_STRING physmemString;
+ OBJECT_ATTRIBUTES attributes;
+ WCHAR physmemName[] = L"\\device\\physicalmemory";
+
+ RtlInitUnicodeString( &physmemString, physmemName );
+
+ InitializeObjectAttributes( &attributes, &physmemString,
+ OBJ_CASE_INSENSITIVE, NULL, NULL );
+ status = NtOpenSection( &physmem, SECTION_MAP_READ, &attributes );
+
+ if( !NT_SUCCESS( status )) {
+
+ PrintError( "Could not open \\device\\physicalmemory", status );
+ return NULL;
+ }
+
+ return physmem;
+}
+
+/*
+ * Copy a physical memory chunk into a memory buffer.
+ * This function allocates memory.
+ *
+ * base - The physical address start point
+ *
+ * len - Length from the base address
+ *
+ * return - pointer to the buffer which the physical memory was mapped to
+ *
+ * Hugo Weber address@hidden
+ */
+void *mem_chunk_win(size_t base, size_t len){
+ void *p;
+ size_t mmoffset;
+ SYSTEM_INFO sysinfo;
+ HANDLE physmem;
+ DWORD paddress, vaddress, length;
+
+ //
+ // Load NTDLL entry points
+ //
+ if( !LocateNtdllEntryPoints() ) {
+
+ printf("Unable to locate NTDLL entry points.\n\n");
+ return NULL;
+ }
+
+ //
+ // Open physical memory
+ //
+ if( !(physmem = OpenPhysicalMemory())) {
+ return NULL;
+ }
+
+ GetSystemInfo(&sysinfo);
+ mmoffset = base%sysinfo.dwPageSize;
+ len += mmoffset;
+
+ paddress = (DWORD)base;
+ length = (DWORD)len;
+ if(!MapPhysicalMemory( physmem, &paddress, &length, &vaddress )){
+ free(p);
+ return NULL;
+ }
+
+ if((p=malloc(length))==NULL){
+ return NULL;
+ }
+
+ memcpy(p, (u8 *)vaddress + mmoffset, length - mmoffset);
+
+ //
+ // Unmap the view
+ //
+ UnmapPhysicalMemory( vaddress );
+
+ //
+ // Close physical memory section
+ //
+ CloseHandle( physmem );
+
+ return p;
+}
+
+
+/*
+ * Counts the number of SMBIOS structures present in
+ * the SMBIOS table.
+ *
+ * buff - Pointer that receives the SMBIOS Table address.
+ * This will be the address of the BYTE array from
+ * the RawSMBIOSData struct.
+ *
+ * len - The length of the SMBIOS Table pointed by buff.
+ *
+ * return - The number of SMBIOS strutctures.
+ *
+ * Remarks:
+ * The SMBIOS Table Entry Point has this information,
+ * however the GetSystemFirmwareTable API doesn't
+ * return all fields from the Entry Point, and
+ * DMIDECODE uses this value as a parameter for
+ * dmi_table function. This is the reason why
+ * this function was make.
+ *
+ * Hugo Weber address@hidden
+ */
+int count_smbios_structures(const void *buff, u32 len){
+
+ int icount = 0;//counts the strutures
+ void *offset = (void *)buff;//points to the actual address in the buff that's been checked
+ struct dmi_header *header = NULL;//header of the struct been read to get the length to increase the offset
+
+ //searches structures on the whole SMBIOS Table
+ while(offset < (buff + len)){
+ //get the header to read te length and to increase the offset
+ header = (struct dmi_header *)offset;
+ offset += header->length;
+
+ icount++;
+
+ /*
+ * increses the offset to point to the next header that's
+ * after the strings at the end of the structure.
+ */
+ while( (*(WORD *)offset != 0) && (offset < (buff + len)) ){
+ offset++;
+ }
+
+ /*
+ * Points to the next stucture thas after two null BYTEs
+ * at the end of the strings.
+ */
+ offset += 2;
+ }
+
+ return icount;
+}
+
+/*
+ * Checks what platform its running.
+ * This code doesn't run on windows 9x/Me, only windows NT or newer
+ *
+ * return - WIN_UNSUPORTED if its running on windows 9x/Me
+ * - WIN_NT_2K_XP if its running on windows NT 2k or XP
+ * - WIN_2003_VISTA if its running on windows 2003 or Vista
+ *
+ * Remarks:
+ * Windows 2003 and Vista blocked access to physical memory and
+ * requires the use of GetSystemFirmwareTable API in order to
+ * get the SMBIOS table.
+ *
+ * Windows NT 2k and XP have to map physical memory and search
+ * for the SMBIOS table entry point, as its done on the other
+ * systems.
+ */
+int get_windows_platform(){
+
+ OSVERSIONINFO version;
+ version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&version);
+
+ switch(version.dwPlatformId){
+ case VER_PLATFORM_WIN32_NT:
+
+ if(version.dwMajorVersion >= 5 && version.dwMinorVersion >= 2){
+ return WIN_2003_VISTA;
+ }else{
+ return WIN_NT_2K_XP;
+ }
+
+ break;
+
+ default:
+ return WIN_UNSUPORTED;
+ break;
+ }
+}
+
+/*
+ * Gets the raw SMBIOS table. This function only works
+ * on Windows 2003 and above. Since Windows 2003 SP1
+ * Microsoft blocks access to physical memory.
+ *
+ * return - pointer to the SMBIOS table returned
+ * by GetSystemFirmwareTable.
+ *
+ * see RawSMBIOSData on winsmbios.h
+ *
+ * Hugo Weber address@hidden
+ */
+PRawSMBIOSData get_raw_smbios_table(void){
+
+ void *buf = NULL;
+ u32 size = 0;
+
+ if(get_windows_platform() == WIN_2003_VISTA){
+ size = GetSystemFirmwareTable('RSMB', 0, buf, size);
+ buf = (void *)malloc(size);
+ GetSystemFirmwareTable('RSMB', 0, buf, size);
+ }
+
+ return buf;
+}
+
+#endif /*__WIN32__*/
diff -ruNEwB dmidecode-2.8/winsmbios.h dmidecode/winsmbios.h
--- dmidecode-2.8/winsmbios.h 1969-12-31 21:00:00.000000000 -0300
+++ dmidecode/winsmbios.h 2006-10-03 17:05:37.000000000 -0300
@@ -0,0 +1,60 @@
+/*
+ * Functions to allow to read SMBIOS from physical memory on windows
+ * or to get the SMBIOS table on windows 2003 SP1 and above.
+ *
+ * This file is part of the dmidecode project.
+ *
+ * (C) 2002-2006 Hugo Weber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For the avoidance of doubt the "preferred form" of this code is one which
+ * is in an open unpatent encumbered format. Where cryptographic key signing
+ * forms part of the process of creating an executable the information
+ * including keys needed to generate an equivalently functional executable
+ * are deemed to be part of the source code.
+ */
+
+#ifdef __WIN32__
+
+#ifndef WINSMBIOS_H
+#define WINSMBIOS_H
+
+#include "types.h"
+
+#define WIN_UNSUPORTED 1
+#define WIN_NT_2K_XP 2
+#define WIN_2003_VISTA 3
+
+/*
+ * Struct needed to get the SMBIOS table using GetSystemFirmwareTable API.
+ */
+typedef struct _RawSMBIOSData{
+ u8 Used20CallingMethod;
+ u8 SMBIOSMajorVersion;
+ u8 SMBIOSMinorVersion;
+ u8 DmiRevision;
+ u32 Length;
+ u8 SMBIOSTableData[];
+} RawSMBIOSData, *PRawSMBIOSData;
+
+int get_windows_platform(void);
+RawSMBIOSData *get_raw_smbios_table(void);
+int count_smbios_structures(const void *buff, u32 len);
+void *mem_chunk_win(size_t base, size_t len);
+
+#endif /*WINSMBIOS_H*/
+
+#endif /*__WIN32__*/