diff -ruN dmidecode-2.8/AUTHORS dmidecode/AUTHORS --- dmidecode-2.8/AUTHORS 2006-01-21 21:08:35.000000000 -0200 +++ dmidecode/AUTHORS 2006-08-16 18:43:40.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 -ruN dmidecode-2.8/CHANGELOG dmidecode/CHANGELOG --- dmidecode-2.8/CHANGELOG 2006-02-04 14:23:04.000000000 -0200 +++ dmidecode/CHANGELOG 2006-08-16 18:43:40.000000000 -0300 @@ -1,3 +1,11 @@ +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 -ruN dmidecode-2.8/README dmidecode/README --- dmidecode-2.8/README 2006-01-21 21:02:57.000000000 -0200 +++ dmidecode/README 2006-08-16 18:43:40.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, WindowsNT, Windows2000, WindowsXP, BeOS and Cygwin as well. +So far there's no suport on Windows95/98/Me and Windows 2003. + +** 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, Windows2000 and WindowsXP. + +** 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 -ruN 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-08-16 18:43:40.000000000 -0300 @@ -0,0 +1,199 @@ +[Project] +FileName=dmidecode.dev +Name=dmidecode +UnitCount=10 +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=vpdopt.c +CompileCpp=0 +Folder=dmidecode +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit12] +FileName=vpdopt.h +CompileCpp=0 +Folder=dmidecode +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 -ruN 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-08-16 18:43:40.000000000 -0300 @@ -0,0 +1,78 @@ +//======================================================== +// +// 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. +// +//======================================================== +#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__ */ diff -ruN 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-08-16 18:43:40.000000000 -0300 @@ -30,12 +30,19 @@ #include "config.h" -#ifdef USE_MMAP -#include -#ifndef MAP_FAILED -#define MAP_FAILED ((void *) -1) -#endif /* !MAP_FAILED */ -#endif /* USE MMAP */ +#ifdef __WIN32__ + #include + #include "native.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,10 +97,250 @@ return (sum==0); } + +#ifdef __WIN32__ +// +// Functions in NTDLL that we dynamically locate +// + +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 + ); + +//-------------------------------------------------------- +// +// LocateNtdllEntryPoints +// +// Finds the entry points for all the functions we +// need within NTDLL.DLL. +// +//-------------------------------------------------------- +BOOLEAN LocateNtdllEntryPoints() +{ + 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; + } + return TRUE; +} + +//---------------------------------------------------------------------- +// +// PrintError +// +// Formats an error message for the last error +// +//---------------------------------------------------------------------- +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. +// +//-------------------------------------------------------- +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. +// +//-------------------------------------------------------- +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 +// +//-------------------------------------------------------- +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. */ +void *mem_chunk(size_t base, size_t len, const char *devmem){ + 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; +} +#else void *mem_chunk(size_t base, size_t len, const char *devmem) { void *p; @@ -163,3 +410,4 @@ return p; } +#endif /* __WIN32__ */ diff -ruN dmidecode-2.8/util.h dmidecode/util.h --- dmidecode-2.8/util.h 2005-02-11 21:52:40.000000000 -0200 +++ dmidecode/util.h 2006-08-16 18:43:40.000000000 -0300 @@ -4,3 +4,4 @@ int checksum(const u8 *buf, size_t len); void *mem_chunk(size_t base, size_t len, const char *devmem); +