Skip to content

Commit 68aae4d

Browse files
committed
Add __dllonexit hook
1 parent fe51b28 commit 68aae4d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

qiling/os/windows/dlls/msvcrt.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,27 @@ def hook__onexit(ql: Qiling, address: int, params):
539539

540540
return addr
541541

542+
# _onexit_t __dllonexit(
543+
# _onexit_t func,
544+
# _PVFV ** pbegin,
545+
# _PVFV ** pend
546+
# );
547+
@winsdkapi(cc=STDCALL, params={
548+
'function': POINTER,
549+
'pbegin': POINTER,
550+
'pend': POINTER
551+
})
552+
def hook___dllonexit(ql: Qiling, address: int, params):
553+
function = params['function']
554+
555+
if function:
556+
addr = ql.os.heap.alloc(ql.arch.pointersize)
557+
ql.mem.write_ptr(addr, function)
558+
559+
return addr
560+
561+
return 0
562+
542563
# void *memset(
543564
# void *dest,
544565
# int c,

0 commit comments

Comments
 (0)