锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品捆绑调教,亚洲女女做受ⅹxx高潮,欧美视频一区二区三区…http://www.shnenglu.com/leo-chen/zh-cnSat, 06 Dec 2025 16:56:23 GMTSat, 06 Dec 2025 16:56:23 GMT60 濡備綍璁〢PI鍥炶皟浣犵殑VC綾繪垚鍛樺嚱鏁拌屼笉鏄潤鎬佸嚱鏁?http://www.shnenglu.com/leo-chen/archive/2007/05/16/24201.htmlLeoChenLeoChenWed, 16 May 2007 05:32:00 GMThttp://www.shnenglu.com/leo-chen/archive/2007/05/16/24201.htmlhttp://www.shnenglu.com/leo-chen/comments/24201.htmlhttp://www.shnenglu.com/leo-chen/archive/2007/05/16/24201.html#Feedback2http://www.shnenglu.com/leo-chen/comments/commentRss/24201.htmlhttp://www.shnenglu.com/leo-chen/services/trackbacks/24201.html 

鍙鍦ㄥ嚱鏁板0鏄庡墠鍔爏tatic灝卞ソ浜嗭紝鍝堝搱鍝堝搱鍝垀~~~~  

銆傘傘傚紑涓帺絎戙備互鍓嶇‘瀹炲ぇ瀹墮兘鏄繖鏍峰仛鐨勶紝鍦ㄩ潤鎬佺殑鎴愬憳鍑芥暟涓啀鏌ユ壘this鎸囬拡錛屽畠澶氬崐鏄叏灞鍙橀噺錛屾垨鑰呮槸鍥炶皟鍑芥暟鎻愪緵鐨勯檮鍔犲弬鏁般傚鏋滄槸鍓嶈咃紝灝變細澶уぇ鐮村潖紼嬪簭鐨勭粨鏋勩傝岀幇鍦紝闅忕潃紺句細鐢熶駭鍔涚殑鍙戝睍錛屽伓浠凡緇忚兘鍋氬埌灝嗘垚鍛樺嚱鏁版槧灝勬垚涓轟竴涓復鏃剁殑闈欐佸嚱鏁頒簡銆傛湰鏂囧氨鏉ユ紨紺轟竴涓嬭繖縐嶅疄鐜版柟寮忋?/p>

棣栧厛闇瑕佸寘鍚竴涓敱yzwykkldczsh鍚屽織緙栧啓鐨勬ā鏉跨被-----涓囪兘澶氱敤鑷傚簲鏃犻檺鍒跺洖璋冩ā鏉匡紙涓虹邯蹇靛弸浜篺ishskin錛屾妯℃澘鍙堢О涓篐>W妯℃澘錛?nbsp;

/**************************************************************************
 *   ACCallback.h
 *   Helper class of Member function callback mechanism
 **************************************************************************/
#include "stdafx.h"
#include "windows.h"

#pragma pack(push, 1)
struct _ACCallbackOpCodes
{
 unsigned char tag;  // CALL e8
 LONG_PTR offset;  // offset (dest - src - 5, 5=sizeof(tag + offset))
 LONG_PTR _this;   // a this pointer
 LONG_PTR _func;   // pointer to real member function address
};
#pragma pack(pop)

static __declspec( naked ) int STDACJMPProc()
{
 _asm
 {
  POP ECX 
  MOV EAX, DWORD PTR [ECX + 4] // func
  MOV ECX, [ECX]     // this  
  JMP EAX
 }
}

static LONG_PTR CalcJmpOffset(LONG_PTR Src, LONG_PTR Dest)
{
 return Dest - (Src + 5);
}

/*
 * NOTE: _TPStdFunc: a type of function pointer to API or Callbacks, *MUST* be _stdcall
         _TPMemberFunc: a type of function pointer to class member function,
         *MUST* be the *DEFAULT* calling conversation, *NO* prefix should be added,
          that is, using ECX for "this" pointer, pushing parameters from right to left,
          and the callee cleans the stack.
          _TClass: the class who owns the callback function. The caller should only own the _stdcall function pointer
   LIFE TIME:  It is important to keep the ACCallback object alive until the CALLBACK is not required!!!
 */
template<typename _TPStdFunc, class _TClass, typename _TPMemberFunc>
class ACCallback
{
public:
 _TClass *m_pThis;
 _TPMemberFunc m_pFunc;

private:
 _TPStdFunc m_pStdFunc;

 void MakeCode()
 {
  if (m_pStdFunc) ::VirtualFree(m_pStdFunc, 0, MEM_RELEASE);
  m_pStdFunc = (_TPStdFunc)::VirtualAlloc(NULL, sizeof(_ACCallbackOpCodes), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  _ACCallbackOpCodes *p = (_ACCallbackOpCodes *)m_pStdFunc;
  p->_func = *(LONG_PTR *)&m_pFunc;
  p->_this = (LONG_PTR)m_pThis;
  p->tag = 0xE8;
  p->offset = CalcJmpOffset((LONG_PTR)p, (LONG_PTR)STDACJMPProc);
 }

public:
 ACCallback<_TPStdFunc, _TClass, _TPMemberFunc>()
 {
 }
 ACCallback<_TPStdFunc, _TClass, _TPMemberFunc>(_TClass* pThis,
  _TPMemberFunc pFunc
  )
 {
  m_pFunc = pFunc;
  m_pThis = pThis;
  m_pStdFunc = NULL;
  MakeCode();
 }
 void Assign(_TClass* pThis,
  _TPMemberFunc pFunc
  )
 {
  m_pFunc = pFunc;
  m_pThis = pThis;
  m_pStdFunc = NULL;
  MakeCode();
 }
 ~ACCallback<_TPStdFunc, _TClass, _TPMemberFunc>()
 {
  ::VirtualFree(m_pStdFunc, 0, MEM_RELEASE);
 }
 operator _TPStdFunc()
 {
  return m_pStdFunc;
 }
};

/********************************** EXAMPLE **********************************
class CClass1
{
public:
 TCHAR m_Buf[255];
 BOOL EnumWindowProc(HWND hwnd, LPARAM lp)
 {
  GetWindowText(hwnd, m_Buf, 255);
  printf("Enum window=%s\n", m_Buf);
  return TRUE;
 }
 typedef BOOL (CClass1::*CLASSWNDENUMPROC)(HWND, LPARAM);
};

TO USE:
 CClass1 c1;
 ACCallback<WNDENUMPROC, CClass1, CClass1::CLASSWNDENUMPROC> cb(&c1, &CClass1::EnumWindowProc);
 EnumWindows(cb, 0);

************************* END OF EXAMPLE *********************************/

妯℃澘鐨勪笁涓弬鏁板垎鍒槸錛欰PI鍑芥暟鎸囬拡鐨勭被鍨嬶紝綾誨悕瀛楋紝綾繪垚鍛樺嚱鏁版寚閽堢殑綾誨瀷錛堜袱縐嶅嚱鏁版寚閽堝湪鍙傛暟鍜岃繑鍥炲間笂搴旇涓鏍鳳紝鍙槸鍓嶈呭0鏄庝負_stdcall錛屽悗鑰呬笉鍔犱換浣曡皟鐢ㄤ慨楗幫紝鍗抽粯璁ょ殑__thiscall鏂瑰紡錛?br>璇ラ」澶存枃浠剁殑娉ㄩ噴涓粰浜嗕竴涓皟鐢ˋPI鍑芥暟EnumWindows鐨勪緥瀛愩傜幇鍦ㄥ伓浠潵璇曡瘯璋冪敤SetTimer銆?/p>

class CTestCallback
{
private:
 /* A callback of SetTimer, mirrored into member OnTimer */
 typedef void (CTestCallback::*CLASSTIMERPROC)(HWND, UINT, UINT_PTR, DWORD);
 void OnTimer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
 ACCallback<TIMERPROC, CTestCallback, CLASSTIMERPROC> m_DOnTimer;
}

璋冪敤鏃訛紝鍙榪欐牱鍐欙細
/* 鍒濆鍖栧洖璋冪粨鏋?*/
m_DOnTimer.Assign(this, &CTestCallback::OnTimer);
m_uid = ::SetTimer( NULL, 0, 1000, m_DOnTimer);

鏈鍚庤寰楀湪CTestCallback鐨勬瀽鏋勫嚱鏁頒腑KillTimer銆傜敱浜巑_DOnTimer浼氬疄鐜拌漿鍖栧埌闈欐佸嚱鏁版寚閽堢被鍨嬬殑鎿嶄綔絎︼紝鎵浠ヨ皟鐢ㄧ殑鍦版柟鍙鐩存帴鍐欏洖璋冪粨鏋勭殑鍚嶅瓧灝卞彲浠ヤ簡銆?/p>

浣跨敤璇ユā鏉塊渶瑕佹敞鎰忎袱鐐癸細
1.API鍑芥暟搴斿綋鏄痏stdcall綾誨瀷鐨勶紙榪欎竴鐐圭粷澶ч儴鍒咥PI閮芥弧瓚籌級銆傜被鎴愬憳鍑芥暟蹇呴』鏄粯璁ょ殑璋冪敤鏂瑰紡錛屼笉瑕佸姞_stdcall鎴朹cdecl涔嬬被鐨勪慨楗般傛鏂瑰紡鐨勯噸瑕佹潯浠跺氨鍦ㄤ簬_stdcall鍜宊_thiscall涔嬮棿鍙浉宸簡涓涓狤CX鎸囧嚭鐨則his鎸囬拡錛屾墍浠ユ垜浠墠鑳藉疄鐜拌繖縐嶆槧灝勶紙榪欑鏂瑰紡鍦╒CL鍜孉TL鐨勭獥鍙g被涓兘鏈変嬌鐢ㄥ埌錛夛紱
2.鍥炶皟緇撴瀯鐨勭敓瀛樺懆鏈熷簲褰撴槸鍦ㄦ暣涓洖璋冨嚱鏁版湁鏁堢殑鏃墮棿鍐呫傚洜姝わ紝瀵逛簬EnumWindows榪欐牱鐨勫嚱鏁幫紝鍙澹版槑鍦ㄦ爤涓婂氨鍙互浜嗭紱浣嗗浜嶴etTimer錛屽氨蹇呴』瀹氫箟涓虹被鎴愬憳鍙橀噺錛屽悓鏃訛紝鍦ㄧ被鐨勬瀽鏋勫嚱鏁頒腑蹇呴』鍙婃椂閿姣佽繖涓猼imer銆?/p>



LeoChen 2007-05-16 13:32 鍙戣〃璇勮
]]>
How to use SetTimer() with callback to a non-static member functionhttp://www.shnenglu.com/leo-chen/archive/2007/05/16/24186.htmlLeoChenLeoChenWed, 16 May 2007 02:31:00 GMThttp://www.shnenglu.com/leo-chen/archive/2007/05/16/24186.htmlhttp://www.shnenglu.com/leo-chen/comments/24186.htmlhttp://www.shnenglu.com/leo-chen/archive/2007/05/16/24186.html#Feedback0http://www.shnenglu.com/leo-chen/comments/commentRss/24186.htmlhttp://www.shnenglu.com/leo-chen/services/trackbacks/24186.htmlQuick update...

After reviewing the comments and suggestions from a few people, I made the solution better. Look for an update to this article which uses a better approach, namely using the functions:

  • CreateWaitableTimer()
  • SetWaitableTimer()
  • WaitForMultipleObjects()

The solution based on these functions will allow multiple instances of the CSleeperThread class to run (instead of just one using the current example). So stay tuned, I'll have this article updated as soon as possible. :-)

Introduction

I have seen many questions on the boards about how to properly use SetTimer(). I've also noticed that most of these questions are around how to put a thread to sleep for X seconds. One obvious answer would be to use the Sleep() function. The main drawback is, how do you gracefully shut down your thread, or cancel the Sleep() operation before the time expires.

This article is meant to address all of the above. I give an example of putting a thread to sleep using SetTimer(). The SetTimer() calls back to a non-static function. This is key, because normally you have to pass a static member to SetTimer() which means it can't access any other non-static variables or member functions of the class.

Details

Since implementing a non-static callback member is key to this, we'll go into this first. Implementing a callback to a static member function doesn't require anything different from implementing a regular C callback function. Since static member functions have the same signature as C functions with the same calling conventions, they can be referenced using just the function name.

Making a non-static callback member function is a different story, because they have a different signature than a C function. To make a non-static member function, it requires the use of two additional items:

  • A global (void*) pointer, referencing the class of the callback function
  • A wrapper function which will be passed to SetTimer()

This is actually a fairly simple implementation. First, you need to define your class:

class CSleeperThread : public CWinThread {
public:
static VOID CALLBACK TimerProc_Wrapper( HWND hwnd, UINT uMsg,
UINT idEvent, DWORD dwTime );
VOID CALLBACK TimerProc( HWND hwnd,
UINT uMsg, UINT idEvent, DWORD dwTime );
void ThreadMain();
void WakeUp();
private:
static void * pObject;
UINT_PTR pTimer;
CRITICAL_SECTION lock;
};

Then, don't forget to include the following line in your class implementation file:

void * CSleeperThread::pObject;

Now that we have our class declared, we can look at the wrapper function, the non-static member function and the member function that will call SetTimer():

VOID CALLBACK CSleeperThread::TimerProc_Wrapper( HWND hwnd, UINT uMsg,
UINT idEvent, DWORD dwTime ) {
CSleeperThread *pSomeClass = (CSleeperThread*)pObject; // cast the void pointer
pSomeClass->TimerProc(hwnd, uMsg, idEvent, dwTime); // call non-static function
}

The wrapper function first initializes a CSleeperThread pointer with pObject. Since pSomeClass is a local pointer, we can access it within the static wrapper function.

VOID CALLBACK CSleeperThread::TimerProc(HWND hwnd,
UINT uMsg, UINT idEvent, DWORD dwTime) {
::EnterCriticalSection(&lock);
if(idEvent == pTimer) {
KillTimer(NULL, pTimer);  // kill the timer so it won't fire again
ResumeThread();  // resume the main thread function
}
::LeaveCriticalSection(&lock);
}

The TimerProc member function isn't static, so we can access other non-static functions like ResumeThread() and we can access the private variable lock. Notice that I've entered a critical section which prevents a second timer event to enter the callback, thus ensuring that the first execution of TimerProc() will cancel out the timer.

Next, let's take a look at the main execution function, ThreadMain().

void CSleeperThread::ThreadMain()
{
pObject = this; // VERY IMPORTANT, must be initialized before
// calling SetTimer()
// call SetTimer, passing the wrapper function as the callback
pTimer = SetTimer(NULL, NULL, 10000, TimerProc_Wrapper);
// suspend until the timer expires
SuspendThread();
// the timer has expired, continue processing 
}

The first step in ThreadMain() is absolutely critical. We need to assign the class instance pointer (this) to the pObject variable. This is how the wrapper callback function will gain access to execute the non-static member function.

Next, we just call SetTimer() passing in a function pointer to our wrapper function. SetTimer() will call the wrapper function when the timer expires. The wrapper function in turn, will execute the non-static function TimerProc(), by accessing the static variable pSomeClass.

NOTE: I chose to implement a main function that will create the timer, go to sleep, continue processing and then exit when finished. This is in effect a function that will only execute once per timer. You could easily add a loop to ThreadMain() which would execute once for each timer event.

One last little function. Since we used SuspendThread() in ThreadMain(), if we need to wake up the thread (for whatever reason), all we have to do is make a call to ResumeThread(). So, I've added an access function like so:

void WakeUp() {
::EnterCriticalSection(&lock);
KillTimer(NULL, pTimer);
ResumeThread(); // wake the thread up
}

Buh dee buh dee, that's all folks...

And there we have it. A thread safe class that goes to sleep using SetTimer() and a non-static callback function; which also has the ability to wake up before the timer expires.

Hopefully, you have found this helpful. I've actually used this code in a project I'm working on now, and was in hopes someone else would get some good use out of it.

Someone once told me "you'll like programming if you like banging your head against the wall repeatedly". I've found that to be true, it took me literally several days to figure out what I've put into this article, I'm just slow I guess.

Whew, my head hurts, time for some Advil...or Ibooprofin.. or asssprin.... or something.

Credits...

I probably learned way more in the process of writing this article. So, much thanks goes to Lars Haendel for creating a web-site dedicated to understanding function pointers, without which I wouldn't know didley.

www.function-pointer.org.



LeoChen 2007-05-16 10:31 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美一区二区在线观看| 亚洲精品国精品久久99热| 亚洲自拍偷拍一区| 国产精品久久久久国产a级| 亚洲女人天堂av| 亚洲欧美成人精品| 国内精品美女av在线播放| 久久婷婷影院| 欧美寡妇偷汉性猛交| 99精品99| 午夜亚洲性色视频| 亚洲国产精品ⅴa在线观看| 亚洲国产日韩欧美在线99| 欧美人与禽猛交乱配视频| 亚洲在线观看免费视频| 亚洲综合第一| 在线看日韩欧美| 亚洲片区在线| 国产一级精品aaaaa看| 欧美福利视频在线观看| 欧美日韩成人一区| 久久久久一区二区三区| 欧美高清影院| 久久丁香综合五月国产三级网站| 久久婷婷综合激情| 亚洲午夜精品国产| 久久都是精品| 亚洲视频第一页| 欧美在线视频免费播放| 99热在这里有精品免费| 午夜精品福利电影| 99精品热视频| 久久亚洲精品视频| 久久精品国产99| 欧美日韩免费在线| 欧美国产一区二区| 国产视频精品va久久久久久| 亚洲国产日韩综合一区| 国产一区二区三区奇米久涩| 亚洲精品你懂的| 亚洲缚视频在线观看| 亚洲欧美日韩天堂| 亚洲香蕉成视频在线观看| 美女啪啪无遮挡免费久久网站| 午夜精品免费| 欧美日韩综合精品| 亚洲精品欧美在线| 亚洲精品美女久久久久| 久久av一区| 久久精品人人做人人爽| 国产精品国产自产拍高清av王其| 欧美jizzhd精品欧美巨大免费| 国产欧美精品va在线观看| 一本色道久久综合狠狠躁的推荐| 亚洲免费观看高清完整版在线观看熊| 久久久久久尹人网香蕉| 久久影院午夜论| 国产综合自拍| 久久精品五月| 另类亚洲自拍| 在线观看亚洲视频啊啊啊啊| 欧美有码在线观看视频| 久久久久久电影| 国内精品亚洲| 久久在线免费观看| 欧美激情免费观看| 亚洲靠逼com| 欧美日韩亚洲系列| 亚洲视频网站在线观看| 亚洲欧美一区二区三区极速播放| 欧美午夜a级限制福利片| 亚洲私人影院| 久久精品人人做人人爽| 国内精品视频在线观看| 久久久久看片| 亚洲国产精品电影| 一区二区三区视频在线| 欧美视频在线观看免费| 亚洲欧美久久久久一区二区三区| 午夜欧美精品| 极品中文字幕一区| 欧美成人高清| 亚洲性夜色噜噜噜7777| 久久精品女人| 亚洲激情黄色| 欧美偷拍一区二区| 久久成人人人人精品欧| 欧美韩日精品| 亚洲制服av| 在线日韩av| 欧美色大人视频| 欧美在线不卡视频| 亚洲日韩欧美视频一区| 亚洲欧美在线网| 亚洲国产精品久久久久秋霞不卡| 欧美黄色视屏| 午夜一区在线| 亚洲精品视频啊美女在线直播| 欧美亚洲免费高清在线观看| 在线色欧美三级视频| 国产精品mm| 噜噜噜91成人网| 午夜日韩福利| 亚洲欧洲日夜超级视频| 久久久高清一区二区三区| 亚洲精品在线看| 黄色日韩精品| 国产精品高潮呻吟久久| 免费观看在线综合| 欧美一区二区三区免费视| 亚洲精品免费在线播放| 卡一卡二国产精品| 亚洲欧美日韩国产另类专区| 影音先锋中文字幕一区| 国产精品女主播一区二区三区| 裸体女人亚洲精品一区| 欧美影院午夜播放| 亚洲伊人网站| 亚洲免费大片| 欧美激情久久久久| 久久综合色婷婷| 欧美伊人精品成人久久综合97| 99精品视频免费全部在线| 亚洲二区在线观看| 影视先锋久久| 国内在线观看一区二区三区| 国产精品久久久久久超碰| 欧美激情精品久久久久久蜜臀| 久久久另类综合| 久久久国产91| 欧美一区二区三区精品| 亚洲欧美日韩国产另类专区| 一本色道久久综合亚洲91| 亚洲美女福利视频网站| 最新69国产成人精品视频免费| 欧美成人自拍视频| 欧美电影免费观看高清| 欧美成人精品1314www| 蜜臀av国产精品久久久久| 久久亚洲精品欧美| 久久只有精品| 欧美成人免费一级人片100| 另类激情亚洲| 欧美电影专区| 亚洲人成在线观看网站高清| 亚洲日本电影在线| 日韩视频中文字幕| 亚洲一区免费观看| 午夜精品久久久久久99热软件| 亚洲综合日本| 久久www成人_看片免费不卡| 久久av老司机精品网站导航| 久久久99精品免费观看不卡| 久久一区视频| 欧美日韩国产在线观看| 欧美午夜精品久久久久久久| 国产精品免费一区二区三区在线观看| 国产精品一区二区久久| 国产在线国偷精品产拍免费yy| 伊人色综合久久天天| 亚洲精品国产精品乱码不99| 一区二区三区视频在线观看| 亚洲欧美日韩国产综合在线 | 亚洲欧洲一区二区天堂久久| 亚洲国产专区校园欧美| 中文在线资源观看视频网站免费不卡| 亚洲天堂免费观看| 久久国产精品亚洲77777| 久久综合九色99| 最新国产乱人伦偷精品免费网站 | 久久激五月天综合精品| 玖玖综合伊人| 99精品99久久久久久宅男| 亚洲欧美一区二区三区久久| 久久久福利视频| 欧美日韩综合另类| 黄色一区二区在线| 宅男66日本亚洲欧美视频| 久久久久九九九九| 亚洲欧洲一区二区三区| 午夜精品久久久久久久久久久久| 老色鬼久久亚洲一区二区| 欧美日韩中文字幕在线视频| 国产综合自拍| 亚洲欧美国产一区二区三区| 久久综合九色综合久99| 一本大道久久精品懂色aⅴ| 久久精品夜夜夜夜久久| 国产精品播放| 亚洲美女在线看| 久久蜜桃精品| 亚洲无限av看| 欧美精品一区在线播放| 激情文学综合丁香| 欧美一区二区免费视频| 亚洲精品久久久久久下一站| 久久国产主播| 国产欧美日本一区视频| 一本大道久久a久久精二百| 欧美不卡视频一区|