PDA

View Full Version : WTF... PLz some one help me - C++



dr.bizar
07-07-2003, 01:11 PM
Hi all.

Better give you a little prelude:
I'm a hardware developer so all my program experience is in ASM.
but ASM and windows = too time consuming

So i started with C++ - seams like the reasonable thing to do:
But all of a sudent i'm having port restriction rights, and connection problems in win2000 - cant even connect to my 3310 :(
Beleive me, its not that i havn't spent enough time trying.

Here comes the Q:

How to initialize port in C++ ?

And how to send "directly to ports" ? - in ASM it was no problem as it's low level prg.

PS. plz take it from the top, as I otherwise expect my self to f... up.

Any advice is apriciated

Thx in advance

jeep
07-07-2003, 01:35 PM
This is due to the NT core in 2000/XP - it stops programs accessing the hardware directly. With 95/98 (and dos!) it was easy to play with the ports, but now you need a driver to sit in between your program and the port. That's where USERPORT comes in....

I think it might be as simple as just installing userport, but I've not read up on it.


George

dr.bizar
07-07-2003, 01:50 PM
Hi george - thx for repplying.

I forgot to mention that i want to make it a standalone app.


I will try to be more specific:
The problem exists on all 386 or higher processor, running in protected mode.

As there are only two I/O privilege levels used, level 0 & level 3. Usermode programs will run in privilege level 3, while device drivers and the kernel will run in privilege level 0.

Is there any way to intitialize my app to use I/O ring 0 in C++ ?

I know you can acces the ports dirrectly if you got a device driver that acces via IOCTL calls. But what driver do i need ?

Plz some give me some clues

Cheers

wumpus
07-07-2003, 02:17 PM
It's not a assembler versus C++ problem - all applications get ran in ring 3, no matter the programming language. This is because of the security problems involved with programs directly accessing the hardware. (and concurrency concerns when more processes try the same thing at the same time)

"Userport" was mentioned before - this is a device driver that exactly does what you need - permit direct user access to the LPT ports when installed.

I don't know what the exact API for USERPORT is, but you could look it up on google I guess.

dr.bizar
07-07-2003, 03:54 PM
Hi m8 thx for your answer

- but It is a question about ASM vs. C++, as you can addres any part of you comp (with an addr) directly - even CPU registers, with ASM. You can even do this cross platform - (not the userinterface of cause)

I know this because i made a "flushing" prog ages ago.

Regarding the API calls i can't find them :(


But can't I acces mscom with IOCTL calls to gain ring 0 priveliges ? or maybe just tickle it on the right spot ? :)

Cheers

wumpus
07-07-2003, 04:01 PM
You can access any memory spot in C++ too.


/* Put 'a' in address 0x12345678 */
unsigned long address = 0x12345678;
*((char*)address) = 'a';


But the only way to get ring 0 privileges is to run as a device driver. (which can't have a user interface, so you need a userspace/ring3 part too)

dr.bizar
07-07-2003, 04:10 PM
Thx m8. - Seem like we are saying the same thing differently :)

Didn't know the part about c++ though. thx

But why use userport when windows got drivers of its own ?
Is it realy that hard to gain acces with IOCTL calls ? - never tryed it myself


gues its back to the drawing board