Address review: forwarder split, CreateDelegate guard, API-set docs
- PeHeaderParser: split export forwarders on the FIRST dot (IndexOf), not the last. A forwarder is "Module.Function" and the module name has no extension, so the last-dot split misparsed export names that themselves contain a dot. - PeHeaderParser: document that API-set (api-ms-win-*/ext-ms-*) and ordinal forwarders are unsupported and should be resolved via the OS loader. - RemoteFunction.CreateDelegate now throws InvalidOperationException unless the session is in-process; an external target's address is not host-mapped and a delegate to it would access-violate on invocation. Tests cover both paths. - Reword the SSE-payload comment: the 16-byte scratch sits below the saved return address, which the aligned store leaves intact (it never overwrote it). Tests: 223 passing, 4 skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,15 @@ public sealed class PeHeaderParser
|
||||
/// <param name="functionName">The exported symbol name (case-sensitive, as stored
|
||||
/// in the export name table).</param>
|
||||
/// <returns>The absolute address of the export in the target process.</returns>
|
||||
/// <remarks>
|
||||
/// Forwarders are resolved by locating the target module in the process's loaded-module
|
||||
/// list. API-set forwarders (virtual <c>api-ms-win-*</c> / <c>ext-ms-*</c> names) are NOT
|
||||
/// supported: those are not real loaded modules, so resolution through the module list is
|
||||
/// impossible without parsing the API-set schema — such a forwarder throws
|
||||
/// <see cref="NotSupportedException"/>. On modern Windows many system-DLL exports forward
|
||||
/// through API sets; resolve those via the OS loader (<c>GetProcAddress</c>) instead.
|
||||
/// Ordinal forwarders (<c>Module.#N</c>) are likewise unsupported.
|
||||
/// </remarks>
|
||||
/// <exception cref="InvalidOperationException">The export is not present.</exception>
|
||||
/// <exception cref="NotSupportedException">The export forwards to an ordinal or to a
|
||||
/// module (such as an API set) that is not resolvable from the target's module list.</exception>
|
||||
@@ -212,7 +221,10 @@ public sealed class PeHeaderParser
|
||||
|
||||
private IntPtr ResolveForwarder(string forwarder, int depth)
|
||||
{
|
||||
int dot = forwarder.LastIndexOf('.');
|
||||
// A forwarder is "Module.Function"; the module name carries no extension, so the
|
||||
// FIRST dot is the boundary. Splitting on the last dot would misparse export names
|
||||
// that themselves contain a dot (e.g. some C++/managed exports).
|
||||
int dot = forwarder.IndexOf('.');
|
||||
if (dot <= 0 || dot >= forwarder.Length - 1)
|
||||
throw new InvalidDataException($"Malformed export forwarder string '{forwarder}'.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user