Solved

how to call outp (conio.h)

Posted on 2001-07-12
7
528 Views
Last Modified: 2008-02-01
I get a
LNK2001 unresolved external symbol _outp
link error on the following code:

#include "conio.h"

int main (void)
{
  outp(0x64, 0xFE); //reboot Win95
  return 0;
}

Can somebody help me to get this code running?
I am trying to reproduce assembler
OUT 0x64, 0xFE
code to perform a Win95 reboot.
0
Comment
Question by:saracoglu
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6278716
Why don't you use

ExitWindowsEx ( EXW_REBOOT, NULL);

instead?
0
 
LVL 32

Expert Comment

by:jhance
ID: 6278759
Basically, you cannot call the outp instruction from a WIN32 user-mode application.  It's a protected instruction and can only be executed from the privileged instruction level.

jkr has the correct suggestion to reboot Windows from a WIN32 app.  If you really need to do outp, you need a VxD or static device driver or you need to "thunk" to 16-bit mode.
0
 
LVL 3

Author Comment

by:saracoglu
ID: 6278760
I need to reboot win95 on an almost crashed situation. The ExitWindowsEx API does not work then.
Somebody has compiled me a VC dll to call from VB. It works perfect.
He sent me only this code piece, and said, that was it.
Now he is on holiday, and I need to reproduce this code.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:KangaRoo
ID: 6278860
You may have to compile and link the code for 16 bit DOS mode (target = Dos executable, /not/ win32 console)
0
 
LVL 3

Author Comment

by:saracoglu
ID: 6278894
I have found it.
I needed to put an underscore before outp (like: _outp)

thanks for the ideas.
The code is now working as follows:

#define DllExport __declspec( dllexport )

#include <conio.h>

extern "C" DllExport long Reboot9x()
{
 int Dummy;
 Dummy = _outp(0x64, 0xFE);
 return 0;
}

I will contact ee to move this question to paq
0
 
LVL 3

Expert Comment

by:JackThornton
ID: 6279293
jhance:

Actually, you can do ins and outs in Win32, at least from Win95. It is expensive, because when the priviledged instruction is trapped by the operating system, Win95 (at least) reproduces the in or out in ring0 before returning to the ring3 code. Moral is you can do it, but it is ***slow***.

- jack
0
 
LVL 3

Accepted Solution

by:
modder earned 0 total points
ID: 6292832
As you found your own solution, I'll refund your points, and I'll make this a PAQ

modder
Community Support Moderator@Experts-Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 66
c++ how to tell if the progra is ctl or mfc atl ect 6 98
AVI wait icons for CAnimateCtrl in Visual Studio 2008 MFC 1 160
Path to  STL Map header file 1 74
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question