Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change code seg priority

Posted on 1997-12-04
6
178 Views
Last Modified: 2013-12-03
How do I change a system DLL's code segment to writeable from a ring 3 application in Win 95? (example code is prefered)
0
Comment
Question by:jcbhmc
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1409113
Strictly speaking you can never write to a code segment in protected mode.  

I use an indocumented call PrestoChangoSelector() to get a data
segment that corresponds to the same memory space as a code segment.  This works for a 16 bit exe.  Never tried it for a DLL or 32 bit.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1409114
I guess you probably need to know how to use it.

The procedure is declared as

WORD FAR PASCAL PrestoChangoSelector(WORD Source, WORD Destination)

Source is a selector for a code segment.  Destination is a selector for the same segment that has been allocated with AllocSelector().  Destination will be made into a data segment by the presto call.

for example:

WORD CodSeg,DatSeg;

   _asm
   {
   MOV AX,CS
   MOV CodSeg,AX
   }
   DatSeg = AllocSelector(CodSeg);
   PrestoChangoSelector(CodSeg,DatSeg);

There are also some other calls that are related, AllocCStoDSAlias(), AllocDStoCSAlias(), and ChangeSelector().  However, I don't think I've ever used them.
0
 

Author Comment

by:jcbhmc
ID: 1409115
16 bit is not the problem - 32 bit solutions are needed.


0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:2good
ID: 1409116
In Win95 it is possible to execute code in ring 0 mode using something called Call Gates. It's really low-level poking and I think it's described in Andrew Schulman's book Unauthorized Windows 95, but I'm not sure.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1409117
I believe in 32 bits this is a page issue, not a segment issue.  in a 32 bit process the code and data segments are 4 gig and overlap.  Some pages (4K chunks) are considered code and other pages are considered data.  The code pages are not writable.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1409118
Call VirtualProtect() (if the page is in your own process) or VirtualProtectEx() (if the page is in some other process).

If you're writing a debugger or a post mortem tool, that's what you need to do. If you're doing something else, you're guilty of making a greasy, silly hack and should find some other way to solve your problem.

.B ekiM


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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