Jinoh Kang jinoh.kang.kr@gmail.com writes:
+#define INLINE_IMPORT_BEGIN_PROLOG(id) INLINE_IMPORT_BEGIN_PROLOG_(id) +#define INLINE_IMPORT_BEGIN_PROLOG_(id) \
- __asm__( \
".section \".idata$2\", \"a\"\n\t" /* IMAGE_IMPORT_DESCRIPTOR */ \
".rva .Limport_ilt_" #id "\n\t" /* .OriginalFirstThunk */ \
".long 0\n\t" /* .TimeDateStamp */ \
".long -1\n\t" /* .ForwarderChain */ \
".rva .Limport_dllname_" #id "\n\t" /* .Name */ \
".rva .Limport_iat_" #id "\n\t" /* .FirstThunk */ \
".p2align 2\n\t" /* (section alignment) */ \
".section \".idata$4\", \"a\"\n\t" /* IMAGE_THUNK_DATA (ILT) */ \
IATGAS_EMIT_PTRALIGN "\n\t" \
".Limport_ilt_" #id ":\n\t" \
".section \".idata$5\", \"a\"\n\t" /* IMAGE_THUNK_DATA (IAT) */ \
IATGAS_EMIT_PTRALIGN "\n\t" \
".Limport_iat_" #id ":\n\t" \
".section \".idata$7\", \"a\"\n\t" \
".Limport_dllname_" #id ":\n\t"
+#define INLINE_IMPORT_BEGIN(dll_name) INLINE_IMPORT_BEGIN_PROLOG(__COUNTER__) \
".asciz \"" dll_name "\"\n\t"
+#define INLINE_IMPORT_ENTRY(entry, impsym) \
".section \".idata$4\", \"a\"\n\t" /* IMAGE_THUNK_DATA (ILT) */ \
entry "\n\t" /* .AddressOfData | .Ordinal */ \
".section \".idata$5\", \"a\"\n\t" \
"__imp_" impsym ":\n\t" /* IMAGE_THUNK_DATA (IAT) */ \
entry "\n\t" /* .AddressOfData | .Ordinal */
+#define INLINE_IMPORT_BY_ORDINAL(ordinal, impsym) \
INLINE_IMPORT_ENTRY(IATGAS_EMIT_IMPORT_BY_ORDINAL(ordinal), impsym)
+#define INLINE_IMPORT_BY_NAME(hint, name, impsym) \
INLINE_IMPORT_ENTRY(IATGAS_ZERO_EXTEND_32_TO_PTR(".rva .Limport_procname_" impsym), impsym) \
".section \".idata$6\", \"a\"\n\t" \
".Limport_procname_" impsym ":\n\t" /* IMAGE_IMPORT_BY_NAME */ \
".short " #hint "\n\t" /* .Hint */ \
".asciz \"" name "\"\n\t" /* .Name */ \
".p2align 1\n\t" /* (section alignment) */
+#define INLINE_IMPORT_END() \
".section \".idata$4\", \"a\"\n\t" /* IMAGE_THUNK_DATA (ILT) */ \
IATGAS_ZERO_EXTEND_32_TO_PTR(".long 0") "\n\t" \
".section \".idata$5\", \"a\"\n\t" /* IMAGE_THUNK_DATA (IAT) */ \
IATGAS_ZERO_EXTEND_32_TO_PTR(".long 0") "\n\t" \
".text" \
- );
+#endif
I don't think we want to do that sort of thing, it's really ugly. In any case, you should be able to test that stuff using existing dlls, there are plenty of Windows dlls that use forwards.
It will also have to wait until after code freeze of course.