Недопустимая инструкция: .if[..arg?Sm]=DLL_PROCESS_ATTACH
Код:
format PE GUI 4.0 DLL
entry DllEntryPoint
include 'include\win32a.inc'
macro wrapperapi a
{
jmp dword [a]
}
HOOK_DLL_NAME equ 'msimg32.dll'
szSysDllPath db 256 dup (?)
hHookMod dd ?
msimgname:
db 'vSetDdrawflag',0
db 'AlphaBlend',0
db 'DllInitialize',0
db 'GradientFill',0
db 'TransparentBlt',0
dw 0
msimgaddr:
_vSetDdrawflag dd ?
_AlphaBlend dd ?
_DllInitialize dd ?
_GradientFill dd ?
_TransparentBlt dd ?
vSetDdrawflag:
wrapperapi _vSetDdrawflag
AlphaBlend:
wrapperapi _AlphaBlend
DllInitialize:
wrapperapi _DllInitialize
GradientFill:
wrapperapi _GradientFill
TransparentBlt:
wrapperapi _TransparentBlt
;--------------------------------------------------------------------------------;
; [DllEntryPoint]
;--------------------------------------------------------------------------------;
proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
.if [fdwReason] = DLL_PROCESS_ATTACH
invoke GetSystemDirectory,szSysDllPath,256
mov edx,szSysDllPath
mov byte[edx+eax],'\'
invoke lstrcat,szSysDllPath,HOOK_DLL_NAME
stdcall get_API,szSysDllPath,msimgname,msimgaddr
mov [hHookMod],eax
.elseif [fdwReason] = DLL_PROCESS_DETACH
invoke FreeLibrary,[hHookMod]
.endif
mov eax,TRUE
ret
endp
;--------------------------------------------------------------------------------;
; [get_API]
;--------------------------------------------------------------------------------;
proc get_API uses esi edi,lpDllName,lpApiName,lpApiAddres
locals
hlib dd ?
endl
mov esi,[lpApiName]
mov edi,[lpApiAddres]
invoke LoadLibrary,[lpDllName]
test eax,eax
je .err
mov [hlib],eax
.next:
invoke GetProcAddress,[hlib],esi
test eax,eax
je .err
stosd
@@:
lodsb
test al,al
jnz @b
lodsw
test ax,ax
jz .exit
dec esi
dec esi
jmp .next
.exit:
mov eax,[hlib]
.err:
ret
endp
data import
library kernel32,'KERNEL32.DLL'
import kernel32,\
GetSystemDirectory,'GetSystemDirectoryA',\
GetModuleHandle,'GetModuleHandleA',\
LoadLibrary,'LoadLibraryA',\
FreeLibrary,'FreeLibrary',\
GetProcAddress,'GetProcAddress',\
lstrcat,'lstrcat'
end data
data export
export 'msimg32.dll',\
vSetDdrawflag,'vSetDdrawflag',\
AlphaBlend,'AlphaBlend',\
DllInitialize,'DllInitialize',\
GradientFill,'GradientFill',\
TransparentBlt,'TransparentBlt'
end data
section '.reloc' fixups data discardable
entry DllEntryPoint
include 'include\win32a.inc'
macro wrapperapi a
{
jmp dword [a]
}
HOOK_DLL_NAME equ 'msimg32.dll'
szSysDllPath db 256 dup (?)
hHookMod dd ?
msimgname:
db 'vSetDdrawflag',0
db 'AlphaBlend',0
db 'DllInitialize',0
db 'GradientFill',0
db 'TransparentBlt',0
dw 0
msimgaddr:
_vSetDdrawflag dd ?
_AlphaBlend dd ?
_DllInitialize dd ?
_GradientFill dd ?
_TransparentBlt dd ?
vSetDdrawflag:
wrapperapi _vSetDdrawflag
AlphaBlend:
wrapperapi _AlphaBlend
DllInitialize:
wrapperapi _DllInitialize
GradientFill:
wrapperapi _GradientFill
TransparentBlt:
wrapperapi _TransparentBlt
;--------------------------------------------------------------------------------;
; [DllEntryPoint]
;--------------------------------------------------------------------------------;
proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
.if [fdwReason] = DLL_PROCESS_ATTACH
invoke GetSystemDirectory,szSysDllPath,256
mov edx,szSysDllPath
mov byte[edx+eax],'\'
invoke lstrcat,szSysDllPath,HOOK_DLL_NAME
stdcall get_API,szSysDllPath,msimgname,msimgaddr
mov [hHookMod],eax
.elseif [fdwReason] = DLL_PROCESS_DETACH
invoke FreeLibrary,[hHookMod]
.endif
mov eax,TRUE
ret
endp
;--------------------------------------------------------------------------------;
; [get_API]
;--------------------------------------------------------------------------------;
proc get_API uses esi edi,lpDllName,lpApiName,lpApiAddres
locals
hlib dd ?
endl
mov esi,[lpApiName]
mov edi,[lpApiAddres]
invoke LoadLibrary,[lpDllName]
test eax,eax
je .err
mov [hlib],eax
.next:
invoke GetProcAddress,[hlib],esi
test eax,eax
je .err
stosd
@@:
lodsb
test al,al
jnz @b
lodsw
test ax,ax
jz .exit
dec esi
dec esi
jmp .next
.exit:
mov eax,[hlib]
.err:
ret
endp
data import
library kernel32,'KERNEL32.DLL'
import kernel32,\
GetSystemDirectory,'GetSystemDirectoryA',\
GetModuleHandle,'GetModuleHandleA',\
LoadLibrary,'LoadLibraryA',\
FreeLibrary,'FreeLibrary',\
GetProcAddress,'GetProcAddress',\
lstrcat,'lstrcat'
end data
data export
export 'msimg32.dll',\
vSetDdrawflag,'vSetDdrawflag',\
AlphaBlend,'AlphaBlend',\
DllInitialize,'DllInitialize',\
GradientFill,'GradientFill',\
TransparentBlt,'TransparentBlt'
end data
section '.reloc' fixups data discardable
include 'macro\if.inc'
Код:
HOOK_DLL_NAME equ 'msimg32.dll'
Код:
HOOK_DLL_NAME db 'msimg32.dll',0
Код:
invoke lstrcat,DWORD [szSysDllPath],DWORD [HOOK_DLL_NAME]
Я ФАСМом не пользуюсь, но, насколько я знаю, в нем нету .if ... .endif. Это МАСМовская конструкция. Но могу я еще и ошибаться: попробуйте двойное равенство (в стиле Си). А почему нельзя написать сравнение ч/з cmp?
Нет, это точно FASM
в инвок попробуй адрес передавать
Как именно это должно выглядеть, напиши пожалуста пример
Код:
invoke lstrcat,DWORD [szSysDllPath],DWORD [HOOK_DLL_NAME]
На выходе должна быть dll
Цитата: reconnect
Эти DWORD'ы важны?
Да не вроде и без них должно работать.
Спасибо arrjj !