diff -r dmidecode-2.8/CHANGELOG dmidecode/CHANGELOG
0a1,8
> 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
>
diff -r dmidecode-2.8/README dmidecode/README
23c23
< ** INSTALLATION **
---
> ** GETTING THE SOFTWARE **
32c32,45
< 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 **
Only in dmidecode-2.8/: biosdecode.c
Only in dmidecode/: dmidecode.dev
Only in dmidecode-2.8/: man
Only in dmidecode/: native.h
Only in dmidecode-2.8/: ownership.c
diff -r dmidecode-2.8/util.c dmidecode/util.c
33,38c33,45
< #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__ */
>
>
92a100,286
>
> #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;
> }
>
96a291,343
> 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
165a413
> #endif /* __WIN32__ */
diff -r dmidecode-2.8/util.h dmidecode/util.h
6a7
>
Only in dmidecode-2.8/: vpddecode.c
Only in dmidecode-2.8/: vpdopt.c
Only in dmidecode-2.8/: vpdopt.h