ExpTimerApcRoutine函數分析之作用是ActiveTimerListHead里面移除定時器_etimer


第一部分:
VOID
ExpTimerApcRoutine (
??? IN PKAPC Apc,
??? IN PKNORMAL_ROUTINE *NormalRoutine,
??? IN PVOID *NormalContext,
??? IN PVOID *SystemArgument1,
??? IN PVOID *SystemArgument2
??? )

/*++

Routine Description:

??? This function is the special APC routine that is called to remove
??? a timer from the current thread's active timer list.

Arguments:

??? Apc - Supplies a pointer to the APC object used to invoke this routine.

??? NormalRoutine - Supplies a pointer to a pointer to the normal routine
??????? function that was specified when the APC was initialized.

??? NormalContext - Supplies a pointer to a pointer to an arbitrary data
??????? structure that was specified when the APC was initialized.

??? SystemArgument1, SystemArgument2 - Supplies a set of two pointers to
??????? two arguments that contain untyped data.

Return Value:

??? None.

--*/

{

??? PETHREAD ExThread;
??? PETIMER ExTimer;
??? KIRQL OldIrql1;
??? ULONG DerefCount;

??? UNREFERENCED_PARAMETER (NormalContext);
??? UNREFERENCED_PARAMETER (SystemArgument1);
??? UNREFERENCED_PARAMETER (SystemArgument2);

??? //
??? // Get address of executive timer object and the current thread object.
??? //

??? ExThread = PsGetCurrentThread();
??? ExTimer = CONTAINING_RECORD(Apc, ETIMER, TimerApc);

??? //
??? // If the timer is still in the current thread's active timer list, then
??? // remove it if it is not a periodic timer and set APC associated FALSE.
??? // It is possible for the timer not to be in the current thread's active
??? // timer list since the APC could have been delivered, and then another
??? // thread could have set the timer again with another APC. This would
??? // have caused the timer to be removed from the current thread's active
??? // timer list.
??? //
??? // N. B. The spin locks for the timer and the active timer list must be
??? //? acquired in the order: 1) timer lock, 2) thread list lock.
??? //

??? DerefCount = 1;
??? ExAcquireSpinLock(&ExTimer->Lock, &OldIrql1);
??? ExAcquireSpinLockAtDpcLevel(&ExThread->ActiveTimerListLock);
??? if ((ExTimer->ApcAssociated) && (&ExThread->Tcb == ExTimer->TimerApc.Thread)) {
??????? if (ExTimer->Period == 0) {
??????????? RemoveEntryList(&ExTimer->ActiveTimerListEntry);
??????????? ExTimer->ApcAssociated = FALSE;
??????????? DerefCount++;
??????? }

??? } else {
??????? *NormalRoutine = (PKNORMAL_ROUTINE)NULL;
??? }

??? ExReleaseSpinLockFromDpcLevel(&ExThread->ActiveTimerListLock);
??? ExReleaseSpinLock(&ExTimer->Lock, OldIrql1);

??? ObDereferenceObjectEx(ExTimer, DerefCount);

??? return;
}


1: kd> dv
??????????? Apc = 0x893b13b0
? NormalRoutine = 0xba30ed48
? NormalContext = 0xba30ed3c
SystemArgument1 = 0xba30ed40
SystemArgument2 = 0xba30ed44
?????? OldIrql1 = 0x89 ''
???? DerefCount = 0x3d


1: kd> dt kapc 893b13b0
CSRSRV!KAPC
?? +0x000 Type???????????? : 0n18
?? +0x002 Size???????????? : 0n48
?? +0x004 Spare0?????????? : 0x220
?? +0x008 Thread?????????? : 0x896d9da0 _KTHREAD
?? +0x00c ApcListEntry???? : _LIST_ENTRY [ 0x896d9ddc - 0x896d9ddc ]
?? +0x014 KernelRoutine??? : 0x80af2e9a???? void? nt!ExpTimerApcRoutine+0
?? +0x018 RundownRoutine?? : (null)
?? +0x01c NormalRoutine??? : 0x7340a79a???? void? +7340a79a
?? +0x020 NormalContext??? : (null)
?? +0x024 SystemArgument1? : 0x3218d5d4 Void
?? +0x028 SystemArgument2? : 0x01db94bc Void
?? +0x02c ApcStateIndex??? : 0 ''
?? +0x02d ApcMode????????? : 1 ''
?? +0x02e Inserted???????? : 0x1 ''


??? ExTimer = CONTAINING_RECORD(Apc, ETIMER, TimerApc);


//
// Executive timer object structure definition.
//

typedef struct _ETIMER {
??? KTIMER KeTimer;
??? KAPC TimerApc;
??? KDPC TimerDpc;
??? LIST_ENTRY ActiveTimerListEntry;
??? KSPIN_LOCK Lock;
??? LONG Period;
??? BOOLEAN ApcAssociated;
??? BOOLEAN WakeTimer;
??? LIST_ENTRY WakeTimerListEntry;
} ETIMER, *PETIMER;

1: kd> dt _etimer 893b13b0-28
nt!_ETIMER
?? +0x000 KeTimer????????? : _KTIMER
?? +0x028 TimerApc???????? : _KAPC
?? +0x058 TimerDpc???????? : _KDPC
?? +0x078 ActiveTimerListEntry : _LIST_ENTRY [ 0x896d9f8c - 0x896d9f8c ]
?? +0x080 Lock???????????? : 0
?? +0x084 Period?????????? : 0n0
?? +0x088 ApcAssociated??? : 0x1 ''
?? +0x089 WakeTimer??????? : 0 ''
?? +0x08c WakeTimerListEntry : _LIST_ENTRY [ 0x0 - 0x5000000 ]
1: kd> dx -id 0,0,89601250 -r1 (*((ntkrnlmp!_KAPC *)0x893b13b0))
(*((ntkrnlmp!_KAPC *)0x893b13b0))???????????????? [Type: _KAPC]
??? [+0x000] Type???????????? : 18 [Type: short]
??? [+0x002] Size???????????? : 48 [Type: short]
??? [+0x004] Spare0?????????? : 0x220 [Type: unsigned long]
??? [+0x008] Thread?????????? : 0x896d9da0 [Type: _KTHREAD *]
??? [+0x00c] ApcListEntry???? [Type: _LIST_ENTRY]
??? [+0x014] KernelRoutine??? : 0x80af2e9a [Type: void (*)(_KAPC *,void (**)(void *,void *,void *),void * *,void * *,void * *)]
??? [+0x018] RundownRoutine?? : 0x0 [Type: void (*)(_KAPC *)]
??? [+0x01c] NormalRoutine??? : 0x7340a79a [Type: void (*)(void *,void *,void *)]
??? [+0x020] NormalContext??? : 0x0 [Type: void *]
??? [+0x024] SystemArgument1? : 0x3218d5d4 [Type: void *]
??? [+0x028] SystemArgument2? : 0x1db94bc [Type: void *]
??? [+0x02c] ApcStateIndex??? : 0 [Type: char]
??? [+0x02d] ApcMode????????? : 1 [Type: char]
??? [+0x02e] Inserted???????? : 0x0 [Type: unsigned char]
1: kd> dx -id 0,0,89601250 -r1 (*((ntkrnlmp!_LIST_ENTRY *)0x893b1400))
(*((ntkrnlmp!_LIST_ENTRY *)0x893b1400))???????????????? [Type: _LIST_ENTRY]
??? [+0x000] Flink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]
??? [+0x004] Blink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]

0x896d9f8c-0x896d9da0=0x1ec


第二部分:??? ExAcquireSpinLockAtDpcLevel(&ExThread->ActiveTimerListLock);之后

ExAcquireSpinLockAtDpcLevel(&ExThread->ActiveTimerListLock);之前
1: kd> dt eTHREAD 896d9da0
ntdll!ETHREAD
?? +0x000 Tcb????????????? : _KTHREAD
?? +0x1c8 CreateTime?????? : _LARGE_INTEGER 0x0edca5e1`45f8e6e0
?? +0x1c8 NestedFaultCount : 0y00
?? +0x1c8 ApcNeeded??????? : 0y0
?? +0x1d0 ExitTime???????? : _LARGE_INTEGER 0x896d9f70`896d9f70
?? +0x1d0 LpcReplyChain??? : _LIST_ENTRY [ 0x896d9f70 - 0x896d9f70 ]
?? +0x1d0 KeyedWaitChain?? : _LIST_ENTRY [ 0x896d9f70 - 0x896d9f70 ]
?? +0x1d8 ExitStatus?????? : 0n0
?? +0x1d8 OfsChain???????? : (null)
?? +0x1dc PostBlockList??? : _LIST_ENTRY [ 0x896d9f7c - 0x896d9f7c ]
?? +0x1e4 TerminationPort? : 0xe15ae778 _TERMINATION_PORT
?? +0x1e4 ReaperLink?????? : 0xe15ae778 _ETHREAD
?? +0x1e4 KeyedWaitValue?? : 0xe15ae778 Void
?? +0x1e8 ActiveTimerListLock : 0
?? +0x1ec ActiveTimerListHead : _LIST_ENTRY [ 0x893b1400 - 0x893b1400 ]

ExAcquireSpinLockAtDpcLevel(&ExThread->ActiveTimerListLock);之后

1: kd> dt eTHREAD 896d9da0
ntdll!ETHREAD
?? +0x000 Tcb????????????? : _KTHREAD
?
?? +0x1e8 ActiveTimerListLock : 0x896d9da1

第三部分:RemoveEntryList(&ExTimer->ActiveTimerListEntry);之后


RemoveEntryList(&ExTimer->ActiveTimerListEntry);之前

1: kd> dt eTHREAD 896d9da0
ntdll!ETHREAD
?? +0x000 Tcb????????????? : _KTHREAD
?? +0x1c8 CreateTime?????? : _LARGE_INTEGER 0x0edca5e1`45f8e6e0
?? +0x1c8 NestedFaultCount : 0y00
?? +0x1c8 ApcNeeded??????? : 0y0
?? +0x1d0 ExitTime???????? : _LARGE_INTEGER 0x896d9f70`896d9f70
?? +0x1d0 LpcReplyChain??? : _LIST_ENTRY [ 0x896d9f70 - 0x896d9f70 ]
?? +0x1d0 KeyedWaitChain?? : _LIST_ENTRY [ 0x896d9f70 - 0x896d9f70 ]
?? +0x1d8 ExitStatus?????? : 0n0
?? +0x1d8 OfsChain???????? : (null)
?? +0x1dc PostBlockList??? : _LIST_ENTRY [ 0x896d9f7c - 0x896d9f7c ]
?? +0x1e4 TerminationPort? : 0xe15ae778 _TERMINATION_PORT
?? +0x1e4 ReaperLink?????? : 0xe15ae778 _ETHREAD
?? +0x1e4 KeyedWaitValue?? : 0xe15ae778 Void
?? +0x1e8 ActiveTimerListLock : 0
?? +0x1ec ActiveTimerListHead : _LIST_ENTRY [ 0x893b1400 - 0x893b1400 ]

1: kd> dx -id 0,0,89601250 -r1 (*((ntkrnlmp!_LIST_ENTRY *)0x893b1400))
(*((ntkrnlmp!_LIST_ENTRY *)0x893b1400))???????????????? [Type: _LIST_ENTRY]
??? [+0x000] Flink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]
??? [+0x004] Blink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]


RemoveEntryList(&ExTimer->ActiveTimerListEntry);之后

1: kd> dt eTHREAD 896d9da0
ntdll!ETHREAD
?? +0x000 Tcb????????????? : _KTHREAD

?? +0x1e8 ActiveTimerListLock : 0x896d9da1
?? +0x1ec ActiveTimerListHead : _LIST_ENTRY [ 0x896d9f8c - 0x896d9f8c ]


1: kd> dx -id 0,0,89601250 -r1 (*((ntdll!_LIST_ENTRY *)0x896d9f8c))
(*((ntdll!_LIST_ENTRY *)0x896d9f8c))???????????????? [Type: _LIST_ENTRY]
??? [+0x000] Flink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]
??? [+0x004] Blink??????????? : 0x896d9f8c [Type: _LIST_ENTRY *]

第四部分:??? ExReleaseSpinLockFromDpcLevel(&ExThread->ActiveTimerListLock);之后
1: kd> dt eTHREAD 896d9da0
ntdll!ETHREAD
?? +0x000 Tcb????????????? : _KTHREAD

?? +0x1e8 ActiveTimerListLock : 0

第五部分:????? ExReleaseSpinLock(&ExTimer->Lock, OldIrql1);之后
1: kd> dt _etimer 893b13b0-28
nt!_ETIMER
?? +0x000 KeTimer????????? : _KTIMER
?? +0x028 TimerApc???????? : _KAPC
?? +0x058 TimerDpc???????? : _KDPC
?? +0x078 ActiveTimerListEntry : _LIST_ENTRY [ 0x896d9f8c - 0x896d9f8c ]
?? +0x080 Lock???????????? : 0x896d9da1
?? +0x084 Period?????????? : 0n0
?? +0x088 ApcAssociated??? : 0 ''
?? +0x089 WakeTimer??????? : 0 ''
?? +0x08c WakeTimerListEntry : _LIST_ENTRY [ 0x0 - 0x5000000 ]

??? ExReleaseSpinLock(&ExTimer->Lock, OldIrql1);之后

1: kd> dt _etimer 893b13b0-28
nt!_ETIMER
?? +0x000 KeTimer????????? : _KTIMER
?? +0x028 TimerApc???????? : _KAPC
?? +0x058 TimerDpc???????? : _KDPC
?? +0x078 ActiveTimerListEntry : _LIST_ENTRY [ 0x896d9f8c - 0x896d9f8c ]
?? +0x080 Lock???????????? : 0
?? +0x084 Period?????????? : 0n0
?? +0x088 ApcAssociated??? : 0 ''
?? +0x089 WakeTimer??????? : 0 ''
?? +0x08c WakeTimerListEntry : _LIST_ENTRY [ 0x0 - 0x5000000 ]

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/73711.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/73711.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/73711.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

算法分析與設計 專題三

目錄 一、實驗目的 二、實驗內容 三、問題分析與求解 四、AC源代碼、截圖 五、實驗小結 一、實驗目的 1、了解貪心算法的分析過程,學會用貪心算法解決一些具體的問題。 2、了解廣度優先算法和深度優先算法。 二、實驗內容 1992 當然,我們的收藏中…

1688商品詳情接口:深度解析與應用實踐

在電商領域,1688作為中國領先的B2B平臺,擁有海量的商品信息。對于開發者、商家和數據分析師來說,獲取1688商品的詳細信息是實現數據分析、競品研究、自動化管理和精準營銷的重要手段。本文將詳細介紹1688商品詳情接口的使用方法、技術細節以及…

每日算法-250328

記錄今天學習和解決的LeetCode算法題。 92. 反轉鏈表 II 題目 思路 本題要求反轉鏈表中從 left 到 right 位置的節點。我們可以采用 頭插法 的思路來反轉指定區間的鏈表。 具體來說,我們首先定位到 left 位置節點的前一個節點 prev。然后,從 left 位置…

C語言中的位域:節省內存的標志位管理技術

位域(Bit-field) 是 C 語言中的一種特性,允許在結構體(struct)中定義占用特定位數的成員變量。通過位域,可以更精細地控制內存的使用,尤其是在需要存儲多個布爾值或小范圍整數時,可以…

【AI編程學習之Python】第一天:Python的介紹

Python介紹 簡介 Python是一種解釋型、面向對象的語言。由吉多范羅蘇姆(Guido van Rossum)于1989年發明,1991年正式公布。官網:www.python.org Python單詞是"大蟒蛇”的意思。但是龜叔不是喜歡蟒蛇才起這個名字,而是正在追劇:英國電視喜劇片《蒙提派森的飛行馬戲團》(Mo…

【openstack系列】虛擬化技術

OpenStack 是一個開源的云計算管理平臺,它本身并不直接提供虛擬化技術,而是通過集成不同的虛擬化解決方案來管理和編排計算、存儲和網絡資源。OpenStack 的核心優勢在于其靈活性和可擴展性,支持多種虛擬化技術(Hypervisor),使企業可以根據需求選擇合適的底層虛擬化方案。…

保姆級教程:Vue3 + Django + MySQL 前后端聯調(PyCharm+VSCode版)

一、環境準備與驗證 這里為減少篇幅,默認大家都安裝好了這些軟件。不會下載安裝的,教程也很多,這里不再做贅述。話不多說,咱們開始: 1. 安裝驗證 確保已安裝以下軟件并驗證版本: # 驗證Node.js node -v…

Spring Data審計利器:@LastModifiedDate詳解!!!

🕒 Spring Data審計利器:LastModifiedDate詳解🔥 🌟 簡介 在數據驅動的應用中,記錄數據的最后修改時間是常見需求。Spring Data的LastModifiedDate注解讓這一過程自動化成為可能!本篇帶你掌握它的核心用法…

洛谷題單1-P1001 A+B Problem-python-流程圖重構

題目描述 輸入兩個整數 a,b,輸出它們的和(∣a∣,∣b∣≤109)。 輸入格式 兩個以空格分開的整數。 輸出格式 一個整數。 輸入輸出樣例 輸入 20 30輸出 50方式-print class Solution:staticmethoddef oi_input():"""從…

CCF CSP 第33次(2024.03)(2_相似度計算_C++)(字符串中字母大小寫轉換+哈希集合)

CCF CSP 第33次(2024.03)(2_相似度計算_C) 題目背景:題目描述:輸入格式:輸出格式:樣例1輸入:樣例1輸出:樣例1解釋:樣例2輸入:樣例2輸出…

Windows .gitignore文件不生效的情況排查

概述 今天下班在家里搗騰自己的代碼,在配置.gitignore文件忽略部分文件的時候,發現死活不生效 問題根源 經過一通分析和排查才發現,是.gitignore文件的編碼錯了,剛開始還沒注意到,因為是在Windows下開發&#xff0c…

Uniapp自定義TabBar組件全封裝實踐與疑難問題解決方案

前言 在當前公司小程序項目中,我們遇到了一個具有挑戰性的需求:根據不同用戶身份動態展示差異化的底部導航欄(TabBar) 。這種多角色場景下的UI適配需求,在提升用戶體驗和實現精細化運營方面具有重要意義。 在技術調研…

四川省汽車加氣站操作工備考題庫及答案分享

1.按壓力容器的設計壓力分為( )個壓力等級。 A. 三 B. 四 C. 五 D. 六 答案:B。解析:按壓力容器的設計壓力分為低壓、中壓、高壓、超高壓四個壓力等級。 2.緩沖罐的安裝位置在天然氣壓縮機( )。 A. 出口處 …

2025年- G27-Lc101-542. 01 矩陣--java版

1.題目描述 2.思路 總結:用廣度優先搜索,首先要確定0的位置,不為0的位置,我們要更新的它的值,只能往上下左右尋找跟它最近的0的位置。 解題思路 我們用 BFS(廣度優先搜索)求解,因為 …

CANopen基本理論

目錄 一、CANopen簡介 二、OD對象字典 2.1 OD對象字典簡介 2.2 CANopen預定義連接集 三、PDO過程數據對象 四、SDO過程數據對象 五、特殊協議 5.1 同步協議 5.2 時間戳協議 5.3 緊急報文協議 六、NMT網絡管理 6.1 NMT節點狀態 6.2 NMT節點上線報文 6.3 NMT心跳報…

【Zookeeper搭建】Zookeeper分布式集群搭建完整指南

Zookeeper分布式集群搭建 (一)克隆前準備工作 一、時鐘同步 步驟: 1、輸入date命令可以查看當前系統時間,可以看到此時系統時間為PDT(部分機器或許為EST),并非中國標準時間。我們在中國地區…

MVC基礎概念及相應代碼示例

(舊的)代碼實現方法 一個功能模塊的代碼邏輯(顯示處理,數據處理,邏輯判定)都寫在一起(耦合) (新的)代碼MVC分層實現方法 顯示部分實現(View視圖) 數據處理實…

nginx優化(持續更新!!!)

1.調整文件描述符 # 查看當前系統文件描述符限制 ulimit -n# 永久修改文件描述符限制 # 編輯 /etc/security/limits.conf 文件,添加以下內容 * soft nofile 65535 * hard nofile 65535# 編輯 /etc/sysctl.conf 文件,添加以下內容 fs.file-max 655352.調…

apache連接池機制討論

apache連接池的連接有效性 server一般會配置keep-alive超時時間,過了這個時間還沒新請求到來,則關閉連接。客戶端從連接池里拿出連接時,會檢查一下連接是否已關閉,如已關閉,會丟棄掉該連接,并嘗試從連接池…

【QT5 多線程示例】條件變量

文章目錄 條件變量使用 wakeOne()使用 wakeAll() 條件變量 QT的條件變量類是QWaitCondition,有wakeOne() 和 wakeAll() 兩個方法 wakeOne():僅喚醒一個等待的線程。wakeAll():喚醒所有等待的線程。 使用 wakeOne() https://github.com/Bi…