COFF Object Datei - Init-Routine
-
Hallo,
ich erzeuge mit MASM eine COFF-Object Datei. In dieser möchte ich eine Initialisierungs-Routine ausführen, die beim Laden der Object Datei ausgeführt werden soll.
Ist das möglich?
-
wie währe es mit DLL_PROCESS_ATTACH in der DllMain?
-
DllMain? schrieb:
wie währe es mit DLL_PROCESS_ATTACH in der DllMain?
Was für eine DLL? Ich rede von einer simplen COFF-Object Datei. Ich denke wenn ich diese Initialisierung durchführen will, dann werde ich wohl oder über es tatsächlich in eine Library packen müssen.
Es handelt sich um folgenden Code, der globale Variablen initialisiert:
TITLE IntelSIMD.asm - check for MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 support .386 .MODEL FLAT .DATA? ; ---------------- ; ; global variables ; ; ---------------- ; PUBLIC _SIMD_INSTRUCTION_SET _SIMD_INSTRUCTION_SET db ? .DATA ; --------- ; ; constants ; ; --------- ; ID_BIT EQU 00200000h FEATURE_BYTE EQU 1 MMX_BIT EQU 00800000h SSE_BIT EQU 02000000h SSE2_BIT EQU 04000000h SSE3_BIT EQU 00000001h SSSE3_BIT EQU 00000200h SSE41_BIT EQU 00080000h MMX EQU 1 ; MMX Technology Support SSE EQU 2 ; SSE Technology Support SSE2 EQU 4 ; SSE2 Technology Support SSE3 EQU 8 ; SSE3 Technology Support SSSE3 EQU 10h ; SSSE3 Technology Support SSE41 EQU 20h ; SSE41 Technology Support ; ---------------- ; ; global variables ; ; ---------------- ; _CPUID_AVAILABLE db 0 ; set to false (0) by default _EFLAGS_AVAILABLE db 0 ; "" .CODE Initialize: ; mov ax, @data ; mov ds, ax pushfd ; push eflags to stack pop eax ; load eflags to eax mov edx, eax ; save value in edx xor eax, ID_BIT ; not ID bit push eax ; back to stack popfd ; from stack to eflags with not ID bit pushfd ; push eflags to stack (again) pop eax ; load it to eax xor eax, edx ; check for equality jz SHORT done ; equals? if true cpuid is not available (pre Pentium+) inc BYTE PTR [ds:_CPUID_Available] .586 ; enable Penium-Instructionset (f. CPUID) mov eax, FEATURE_BYTE ; check byte 1 (processor info and feature bits) cpuid mov eax, 20h ; assume that SSE4.1 is available test ecx, SSE41_BIT ; check for SSE4.1 support jnz SHORT done shr eax, 1 test ecx, SSSE3_BIT ; check for Supplemental Streaming SIMD Extensions 3 support jnz SHORT done shr eax, 1 test ecx, SSE3_BIT ; check for SSE3 support jnz SHORT done shr eax, 1 test edx, SSE2_BIT ; check for SSE2 support jnz SHORT done shr eax, 1 test edx, SSE_BIT ; check for Streaming SIMD Extensions (SSE) support jnz SHORT done shr eax, 1 test edx, MMX_BIT ; check for MMX Technology support jnz SHORT done shr eax, 1 done: mov [ds:_SIMD_INSTRUCTION_SET], al END
-
FrEEzE2046 schrieb:
Ich rede von einer simplen COFF-Object Datei.
Wie soll bitte eine Objekt Datei irgend etwas Ausführen? - die wird an den Linker übergebn.
-
DllMain? schrieb:
FrEEzE2046 schrieb:
Ich rede von einer simplen COFF-Object Datei.
Wie soll bitte eine Objekt Datei irgend etwas Ausführen? - die wird an den Linker übergebn.
So war das auch nicht gemeint, aber ich hab's jetzt über eine Lib gelöst.