Solved

how to call outp (conio.h)

Posted on 2001-07-12
7
502 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
Comment Utility
Why don't you use

ExitWindowsEx ( EXW_REBOOT, NULL);

instead?
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now