Solved

Change code seg priority

Posted on 1997-12-04
6
175 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
Comment Utility
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
Comment Utility
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
Comment Utility
16 bit is not the problem - 32 bit solutions are needed.


0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Expert Comment

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now