Created
October 11, 2016 02:34
-
-
Save toptensoftware/918226d72e2b5aeb19427bfa39ecb6dd to your computer and use it in GitHub Desktop.
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
| public override void Init(Machine machine) | |
| { | |
| if (IsDll) | |
| { | |
| // Save DS | |
| var saveds = machine.ds; | |
| // Call Library entry point | |
| machine.di = hModule; | |
| machine.ds = DataSegment == null ? (ushort)0 : DataSegment.globalHandle; | |
| machine.cx = _neFile.Header.InitHeapSize; | |
| // Find entry point | |
| var ip = (ushort)(_neFile.Header.EntryPoint & 0xFFFF); | |
| var cs = _neFile.Segments[(int)((_neFile.Header.EntryPoint >> 16) - 1)].globalHandle; | |
| // Call it | |
| machine.FarCall(BitUtils.MakeDWord(ip, cs)); | |
| // Success? | |
| if (machine.ax==0) | |
| throw new VirtualException("LibMain failed"); | |
| // Restore DS | |
| machine.ds = saveds; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment