Jump to content
  • Advertisement
Sign in to follow this  
Painless

Accessing device memory (win98)

This topic is 5069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on a program in which I need to - in a very time-critical spot - write to a certain address in the memory of a device. So far, I've been using the device's own driver DLL to do this. However, now it seems that this is too slow and I need to write the memory as directly as possible. The device's documentation tells me that I need to write to base address (0x220) + 13, however, it seems to me (if I'm wrong, just tell me - I can't test it right now) that I can't just say int address = 0x220 + 13; char *foo = *( char ** )&address; *foo = value; (I still don't know how to use code tags) So how should I go about this? A hackish solution is acceptable, but I'd prefer to keep it simple, no "ring 0" madness unless I have to do that. I'm using visual c++.NET (no managed stuff, just plain win32 code).

Share this post


Link to post
Share on other sites
Advertisement
An address of a memory address is simply written like this:

int* addr = (int *)0x220+13;

*addr = poke;
peek = *addr;

However - you do have a problem - all user mode (ring 3) code running under Windows uses a virtual address space. The 0x220 for your device will be a physical address not virtual.

I'm afraid ring 0 madness is likely your best option (save for a few nasty OS specific hacks). You could find the VXD the DLL is talking to and talk to that instead.

Are you certain of where the slowness is actually coming from? - from the switch to kernel mode to write the register; or from the DLL interface; from the PC hardware side; from the device side.

Windows is still able to make tons of kernel mode switches to write to display adapters, hard-disks and the like, so it's not THAT slow in the grand scheme of things. Of course Windows isn't a "realtime" OS either [smile]

Share this post


Link to post
Share on other sites
Thank you for the reply. I think I'll try the ring0 way - it seems to be my best bet (I have to debug and run this code on a computer that's not my development computer, which complicates things).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!