Skip to content

Instantly share code, notes, and snippets.

@dixyes
Created July 4, 2019 08:14
Show Gist options
  • Save dixyes/dd8a4b6f9fc61e53d8a25e96ceb6f7e7 to your computer and use it in GitHub Desktop.
Save dixyes/dd8a4b6f9fc61e53d8a25e96ceb6f7e7 to your computer and use it in GitHub Desktop.

使用类似

void replaceOnReceive(int (*cb) (/*arguments of php_swoole_OnReceive...*/)){
    void * pSwooleG = dlsym(/*arguments to get SwooleG...*/);
    void * pServ = pSwooleG+OFFSET_SERV;
    void * pOnReceive2Replace = (*pServ)+OFFSET_ONRECV;
    assert(*pOnReceive2Replace == php_swoole_OnReceive);
    *pOnReceive2Replace = cb;
}

的方法来替换OnReceive,其中根据版本不同,OFFSET_SERV和OFFSET_ONRECV分别如下

版本 OFFSET_SERV OFFSET_ONRECV
4.4.0-beta 612 1040
4.4.0-alpha 612 920
4.3.{5,4,3,2} 600 920
4.3.1 600 896
4.3.0 592 896
4.2.13 576 896
4.2.{12,11,10,10-beta} 576 1928
4.2.{9,8,7} 584 1928
4.2.6 640 1928
4.2.{5,4} 640 1920
4.2.{3,2,0},4.1.{2,1,0} 640 1912
4.2.1 648 1904
4.1.{0-beta,0-alpha},4.0.{4,3,2,1,0,0-rc1,0-beta} 640 1904
2.2.0,2.1.3(不用考虑) 656 1856
1.10.6 640 1896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment