首页 > 代码库 > EnterCriticalSection 如何实现得到锁?
EnterCriticalSection 如何实现得到锁?
_RtlEnterCriticalSection@4:
77E022D0 mov edi,edi
77E022D2 push ebp
77E022D3 mov ebp,esp
77E022D5 sub esp,0Ch
77E022D8 push esi
77E022D9 push edi
77E022DA mov edi,dword ptr [ebp+8]
77E022DD lea esi,[edi+4]
77E022E0 mov eax,esi
77E022E2 lock btr dword ptr [eax],0 //原子查看 LockCount 最低位是否为0, 如果为0, 则认为已经得倒
77E022E7 jae _RtlEnterCriticalSection@4+1030Bh (77E125DBh)
77E022ED mov eax,dword ptr fs:[00000018h]
77E022F3 mov ecx,dword ptr [eax+24h]
77E022F6 mov dword ptr [edi+0Ch],ecx //设置OwningThread
77E022F9 mov dword ptr [edi+8],1 //RecursionCount
77E02300 pop edi
77E02301 xor eax,eax
77E02303 pop esi
77E02304 mov esp,ebp
77E02306 pop ebp
77E02307 ret 4
EnterCriticalSection 如何实现得到锁?