?
Solved

Change code seg priority

Posted on 1997-12-04
6
Medium Priority
?
181 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
[X]
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
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 200 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

741 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