Hello,all if CPU be setted the trap flag. Dynamic modify itself. else normally work. endif how it works?
dcskm4200 Your english is bad. Have you meant this: ---------------------- If trap flag is setted in CPU then modify itself dynamically else do normal work endif How does it work? ---------------------- it is not possible to determine is there a trap-flag on your thread. You can do it only from another thread.
Код (Text): OPVERBEGIN MACRO local opcodeStart, opcodeEnd DD (offset opcodeEnd - offset opcodeStart) ; block size opcodeStart LABEL BYTE ;----------------------------------- OPVEREND MACRO opcodeEnd LABEL BYTE ENDM ;----------------------------------- ENDM ;----------------------------------- R MACRO opcode:req OPVERBEGIN opcode OPVEREND ENDM CoolFunctionThatRunsBackwards proc ;; mark the beginning OPVERBEGIN ;; the size of every opcode here should have attached R < ror eax, 10 > R < mov eax, "what" > R < xor edx, ecx > R < add eax, "s up" > R < nop > ;; mark the end OPVEREND ret CoolFunctionThatRunsBackwards endp [/b] macros error: " Assembling: test.asm test.asm(44) : error A2006: undefined symbol : ??001A OPVERBEGIN(3): Macro Called From test.asm(44): Main Line Code " where does the erreo be occured? regards
Код (Text): ;---------------------------------------- [b]SEH_NODE struct _preHandler dword ? _execeptionHandler dword ? SEH_NODE ends ;---------------------------------------- ;; SEH macros PUSH_SEH MACRO sehHandler:req ASSUME FS:NOTHING mov eax,fs:[0] ASSUME eax: ptr SEH_NODE push sehHandler push [eax]._execeptionHandler mov fs:[0],esp ENDM ;----------------------------------- POP_SEH MACRO pop fs:[0] add esp,4 ENDM ;==================================== ;; exception handler expHandler proc c expRecord:dword,expFrame:dword,contextPtr:dword,dispContext:dword pusha mov ebx,contextPtr ASSUME ebx:ptr CONTEXT ;; clear trap flag and [ebx].regFlag,0FFFFFEFFh ;; change the opcode to NOP mov ebx,[ebx].regEip mov byte ptr [ebx],090h popa mov eax,ExceptionContinueExecution ret expHandler endp ;------------------------------------------- ;; Self tracing function SelfTracingCode proc ;; set up the Handler PUSH_SEH offset expHandler ;; set the trap flag pushf or byte ptr [esp+1],1 popf ;; this will not be traced xor eax,eax ;; endless loop - this code will change at run-time jmp $ ;; remove the handler POP_SEH ret SelfTracingCode endp[/b]