⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getbiosid.txt

📁 获取BIOS ID: ReadBiosIdClass.h: interface for the CReadBiosIdClass class.
💻 TXT
📖 第 1 页 / 共 2 页
字号:
from csdn by taianmonkey


获取BIOS   ID:   
  //   ReadBiosIdClass.h:   interface   for   the   CReadBiosIdClass   class.   
  //   
  //////////////////////////////////////////////////////////////////////   
    
  #if   !defined(AFX_READBIOSIDCLASS_H__70BE242F_AA8A_4E12_9F03_80EF82BD053D__INCLUDED_)   
  #define   AFX_READBIOSIDCLASS_H__70BE242F_AA8A_4E12_9F03_80EF82BD053D__INCLUDED_   
    
  #if   _MSC_VER   >   1000   
  #pragma   once   
  #endif   //   _MSC_VER   >   1000   
    
  #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;   }   
    
  class   CReadBiosIdClass       
  {   
  public:   
  void   PrintError(   char   *message,   NTSTATUS   status   );   
  BOOL   LocateNtdllEntryPoints();   
  HANDLE   OpenPhysicalMemory();   
  BOOL   MapPhysicalMemory(   HANDLE   PhysicalMemory,PDWORD   Address,   PDWORD   Length,PDWORD   VirtualAddress   );   
  VOID   UnmapPhysicalMemory(   DWORD   Address   );   
  int   biosCheckAMI(DWORD   Add);   
  int   biosCheckPhoenix(DWORD   Add);   
  int   biosCheckAward(DWORD   Add);   
  CReadBiosIdClass();   
  virtual   ~CReadBiosIdClass();   
    
  };   
    
  #endif   //   !defined(AFX_READBIOSIDCLASS_H__70BE242F_AA8A_4E12_9F03_80EF82BD053D__INCLUDED_)
//   ReadBiosIdClass.cpp:   implementation   of   the   CReadBiosIdClass   class.   
  //   
  //////////////////////////////////////////////////////////////////////   
    
  #include   "stdafx.h"   
  #include   "ReadBiosIdClass.h"   
    
  #ifdef   _DEBUG   
  #undef   THIS_FILE   
  static   char   THIS_FILE[]=__FILE__;   
  #define   new   DEBUG_NEW   
  #endif   
    
  //////////////////////////////////////////////////////////////////////   
  //   Construction/Destruction   
  //////////////////////////////////////////////////////////////////////   
  //   
  #define   BYTESPERLINE   16   
  //   
  //   Lines   to   print   before   pause   
  //   
  #define   LINESPERSCREEN   25   
    
    
  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   
  );   
    
  CReadBiosIdClass::CReadBiosIdClass()   
  {   
    
  }   
    
  CReadBiosIdClass::~CReadBiosIdClass()   
  {   
    
  }   
    
  int   CReadBiosIdClass::biosCheckAward(DWORD   Add)   
  {   
  //Example   
  //AWard:07/08/2002-i845G-ITE8712-JF69VD0CC-00     
  // 10/10/98-xxx……   
  //Phoenix-Award:03/12/2002-sis645-p4s333   
  if(*(PUCHAR)(Add+2)=='/'   &&   *(PUCHAR)(Add+5)=='/'){   
  CHAR   *p=(CHAR*)Add;   
  while(*p){   
  if(*p   <   0x20   ||   *p   >   0x71)   
  goto   NOT_AWARD;   
  p++;   
  }   
  return   1;                           
    
  }   
    
  NOT_AWARD:   
  return   0;   
  }   
    
  int   CReadBiosIdClass::biosCheckPhoenix(DWORD   Add)   
  {   
  //Example   
  //Phoenix:NITELT0.86B.0044.P11.9910111055     
  if(*(PUCHAR)(Add+7)=='.'   &&   *(PUCHAR)(Add+11)=='.'){   
  CHAR   *p=(PCHAR)Add;   
  while(*p){   
  if(*p   <   0x20   ||   *p   >   0x71)   
  goto   NOT_PHOENIX;   
  p++;   
  }   
  return   1;                           
  }   
  NOT_PHOENIX:   
  return   0;   
  }   
    
  int   CReadBiosIdClass::biosCheckAMI(DWORD   Add)   
  {   
  //Example   
  //AMI:51-2300-000000-00101111-030199-   
  if(*(PUCHAR)(Add+2)=='-'   &&   *(PUCHAR)(Add+7)=='-'){   
  CHAR   *p=(PCHAR)Add;   
  while(*p){   
  if(*p   <   0x20   ||   *p   >   0x71)   
  goto   NOT_AMI;   
  p++;   
  }   
  return   1;                           
    
  }   
  NOT_AMI:   
  return   0;   
  }   
    
  VOID   CReadBiosIdClass::UnmapPhysicalMemory(DWORD   Address)   
  {   
          NTSTATUS   status;   
          status   =   NtUnmapViewOfSection(   (HANDLE)   -1,   (PVOID)   Address   );   
          if(   !NT_SUCCESS(status))   
          {   
                  PrintError("Unable   to   unmap   view",   status   );   
          }   
  }   
    
  BOOL   CReadBiosIdClass::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;   
  }   
    
  HANDLE   CReadBiosIdClass::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;   
  }   
    
  BOOL   CReadBiosIdClass::LocateNtdllEntryPoints()   
  {   
        if(   !(RtlInitUnicodeString   =   (void   (__stdcall   *)(PUNICODE_STRING,PCWSTR))   GetProcAddress(   GetModuleHandle("ntdll.dll"),"RtlInitUnicodeString"   ))   )   
          {   
                  return   FALSE;   
          }   
          if(   !(NtUnmapViewOfSection   =   (NTSTATUS   (__stdcall   *)(HANDLE,PVOID))   GetProcAddress(   GetModuleHandle("ntdll.dll"),"NtUnmapViewOfSection"   ))   )   
          {   
                  return   FALSE;   
          }   
          if(   !(NtOpenSection   =   (NTSTATUS   (__stdcall   *)(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES))   GetProcAddress(   GetModuleHandle("ntdll.dll"),"NtOpenSection"   ))   )   
          {   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -