Solved

Change code seg priority

Posted on 1997-12-04
6
177 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

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 extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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