Last active
October 11, 2016 02:24
-
-
Save toptensoftware/cf263e4730d4525feb65f5272174deb9 to your computer and use it in GitHub Desktop.
Patching exported functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreach (var ep in _neFile.GetAllEntryPoints().Where(x=>(x.flags & Win3muCore.NeFile.EntryPoint.FLAG_EXPORTED)!=0)) | |
| { | |
| // Get the segment | |
| var segment = segments[ep.segmentNumber - 1].globalHandle; | |
| var data = machine.GlobalHeap.GetBuffer(segment); | |
| // Shared DS? | |
| if ((ep.flags & Win3muCore.NeFile.EntryPoint.FLAG_SHAREDDS)!=0) | |
| { | |
| // Insert MOV AX,xxxx instruction | |
| data[ep.segmentOffset] = 0xb8; | |
| data.WriteWord(ep.segmentOffset + 1, this.DataSelector); | |
| } | |
| else | |
| { | |
| if (!this.IsDll) | |
| { | |
| // NOP out the push ds, pop ax instructions | |
| data[ep.segmentOffset] = 0x90; // NOP | |
| data[ep.segmentOffset+1] = 0x90; // NOP | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment