mirror of
https://github.com/mirkobrombin/raven.git
synced 2026-11-03 21:46:32 +00:00
The program's library carries a manifest naming the private assembly raven.private, whose manifest and library are in a folder of that name beside the program; the library's import resolves there and the library reports that file as its own. Assisted-by: Claude Code:claude-opus-5-5 AI-Scope: the test fixture and its registration (cherry picked from commit b9278f1022a1ea1395f36214f7e973b5bb22e6d5)
24 lines
971 B
C
24 lines
971 B
C
#include <windows.h>
|
|
|
|
// A private side-by-side assembly, as Ruby ships its libraries: the program's library private_middle.dll carries a manifest that
|
|
// depends on the assembly raven.private, whose manifest and library are in the folder raven.private beside the program. The loader
|
|
// finds private_target.dll there for the library's imports. Returns 0, or the number of the check that failed.
|
|
__declspec(dllimport) int middle_value(void);
|
|
|
|
int raven_entry(void)
|
|
{
|
|
if (middle_value() != 43)
|
|
return 1;
|
|
HMODULE target = GetModuleHandleW(L"private_target.dll");
|
|
static WCHAR path[MAX_PATH];
|
|
const DWORD length = target ? GetModuleFileNameW(target, path, MAX_PATH) : 0;
|
|
static const WCHAR tail[] = L"\\raven.private\\private_target.dll";
|
|
const DWORD count = sizeof tail / sizeof *tail - 1;
|
|
if (length < count)
|
|
return 2;
|
|
for (DWORD index = 0; index < count; ++index)
|
|
if ((path[length - count + index] | 0x20) != (tail[index] | 0x20))
|
|
return 3;
|
|
return 0;
|
|
}
|