Click here to Skip to main content
15,358,266 members
Articles / Desktop Programming / MFC
Article
Posted 24 Nov 2002

Stats

65.8K views
1.4K downloads
8 bookmarked

Obtaining BIOS DATE through a file created by a 16 bit console process in a synchronous way.

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
24 Nov 2002CPOL2 min read
This is only one way to get Bios date.

Sample Image - BiosDate.gif

The problem

For now it is very easy to obtain access violation in WIN32 platform, when we try to read bios memory address. It is for this that virtual machines provide memory protection, virtual memory, and privilege checking. If an application in a virtual machine reads or writes memory addresses that has not been mapped into its virtual machine or manipulates Bios Interrupts to which it has not been allowed access, an exception (fault) is generated, and the VMM regains control.

The solution

Ok, this program is only one option for trying to get Bios date in WIN32 platform. For that, I wrote a console program, created for 16 bit compilers, using VC++ 1.0 | BC++ 4.0 | Turbo C++ 3.0. This program generates a file with Bios date.

Other 32-bit Windows-based applications, execute this 16-bit console process in a synchronous way and hidden mode. This means that, first we create the process and then kill the process. For this I use the functions CreateProcess() for creation and TerminateProcess() for kill, respectively. For synchronous process, the function WaitForSingleObject(m_hProcess, INFINITE), and ready.

16-bit console process

Bios date is stored in 8 bytes starting from address F000:FFF5, using ASCII character. To read this address we can use the function peek(...) and poke(...) of BC++ 4.0 library or in another case use the function below. This function returns the contents of the specified memory location segment:offset.

unsigned char pekAux(unsigned int segment, unsigned int offset)
{
     unsigned char _far *ptr;
     ptr = (unsigned char _far *)(((long)segment << 16) | (long)offset);
     return *ptr;
}

32-bit Windows-based application

Here we execute and HIDE the 16-bit console process

void CBiosDateDlg::StartProcess(char* lpszFileName)
{
  BOOL bWorked;
  STARTUPINFO suInfo;
  PROCESS_INFORMATION procInfo;

  char *m_Process = lpszFileName;
  //"start.exe whatever command line arguments here";
  char *vip = lpszFileName;  

    memset (&suInfo, 0, sizeof(suInfo)); 
    suInfo.cb = sizeof(suInfo);
    suInfo.lpReserved = NULL;
    suInfo.lpDesktop = "";
    suInfo.dwFlags = STARTF_USESHOWWINDOW  | STARTF_USESTDHANDLES;
    suInfo.wShowWindow = SW_HIDE;   // <==  Here HIDE Process Console
    bWorked = CreateProcess(m_Process,
             NULL,  //szBuffer,         // can also be NULL
             NULL,
             NULL,
             TRUE,
             REALTIME_PRIORITY_CLASS,
             NULL,
             NULL,
             &suInfo,
             &procInfo);

  if (procInfo.dwThreadId = NULL)
  {
    //AfxMessageBox("I can't init process !!!",MB_OK);
        ExitProcess(1);
  }
  //member variable that pointer to PROCESS_INFORMATION structure
    m_hProcess = procInfo.hProcess; //HANDLE a la Process 
    m_dwProcessPid = procInfo.dwProcessId; //DWORD a Procesos ID
}

Then wait for the end process, using function:

// m_hProcess ==> Handle for manipulate process
WaitForSingleObject(m_hProcess, INFINITE);   

and kill process.

C++
void CBiosDateDlg::KillProcess()
{
    //Here use m_dwProcessPid for terminate process
    HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_QUERY_INFORMATION, 
                                                 TRUE,  m_dwProcessPid);
    TerminateProcess(ps, 1);
    CloseHandle(ps);
}

That's it

If somebody has some idea or article, with respect to reading Bios address memory in WIN32 platform, avoiding message exception and access violation, please don't doubt to send me your suggestions, I will be grateful.

Thanks my friends.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Josue Pari Cortez
Web Developer
Bolivia Bolivia
Hobies: Salir de paseo con mi Hijo Josue, tocar el piano, desarrollar en ever in C++

Comments and Discussions

 
GeneralError in Demo Project Pin
rhtbhegade13-Jul-09 20:13
Memberrhtbhegade13-Jul-09 20:13 
Hi Experts

I have downloaded the demo project for obtailing the BIOS date,but it gives me the error- "Error Open ReadFile BIOS.bin"
What will be the solution to this....

Thanks In Advance
GeneralDirect memory access in win32 Pin
D3Y025-Feb-05 12:56
MemberD3Y025-Feb-05 12:56 
GeneralRe: Direct memory access in win32 Pin
Josue Pari Cortez14-Mar-05 14:47
MemberJosue Pari Cortez14-Mar-05 14:47 
GeneralA question about Serial Number Pin
hover_11-Apr-03 14:45
Memberhover_11-Apr-03 14:45 
GeneralRe: A question about Serial Number Pin
hover_12-Apr-03 16:36
Memberhover_12-Apr-03 16:36 
GeneralWMI Pin
Daniel Turini26-Nov-02 0:29
MemberDaniel Turini26-Nov-02 0:29 
GeneralRe: WMI Pin
Venkata Kommaraju19-Dec-03 21:02
MemberVenkata Kommaraju19-Dec-03 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.