hook

Run startup code in the parent with Django and Gunicorn

我与影子孤独终老i 提交于 2019-12-06 01:01:01
I need my code run at Django application startup, before Django starts listening for incoming connections. Running my code upon the first HTTP request is not good enough. When I use Gunicorn, my code must run in the parent process, before it forks. https://stackoverflow.com/a/2781488/97248 doesn't seem to work in Django 1.4.2: it doesn't run the Middleware's __init__ method until the first request is received. Ditto for adding code to urls.py . A quick Google search didn't reveal anything useful. I have just run into this problem myself, and the solution was to basically chain the commands to

How can I set up a CBT hook on a Win32 console window?

烈酒焚心 提交于 2019-12-06 00:45:41
I've been trying to set up a CBT hook for my C++ Console application with the following code: ...includes... typedef struct _HOOKDATA { int type; HOOKPROC hookproc; HHOOK hhook; }_HOOKDATA; _HOOKDATA hookdata; //CBT LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam) { //do not proccess message if(code < 0) { cout<<"code less than 0"<<endl; return CallNextHookEx(hookdata.hhook,code,wParam,lParam); } switch(code) { case HCBT_ACTIVATE: break; case HCBT_CREATEWND: cout<<"CREATEWND"<<endl; break; case HCBT_MINMAX: cout<<"MINMAX"<<endl; break; default: //unknown cout<<"DEFAULT"<<endl;

C++ mid-function hook: get register values and jump back [x86 assembly on windows]

我只是一个虾纸丫 提交于 2019-12-05 22:24:07
There is an int value in register EBP and a string in EBX . I need to get the values from these registers in my own function, do some operations on them and finally jump back some code below. I do a JMP at 0x46AA17 to my function called JmpHook . void JmpHook() { char *mystring; _asm mov mystring, ebx printf("value: %s", mystring); _asm { jmp [0x46AA87] } } As you can see, I am trying to move the string at EBX into mystring and at the end jump back to 0x46AA87 which is located some lines below my JMP JmpHook . printf is being called and mystring being output but all this seems very untidy in

In what thread does a low-level mouse and keyboard hook callback run?

微笑、不失礼 提交于 2019-12-05 21:01:30
问题 I'm setting a low-level mouse hook with SetWindowsHookEx : HANDLE handle = SetWindowsHookEx(WH_MOUSE_LL, &callback, GetModuleHandle(NULL), NULL); Because this is a low-level callback, it will be executed inside my own process; no DLL injection is performed. Now, I've noticed that the callback sometimes (indirectly) gets invoked from standard API functions such as GetAncestor , GetWindowRect and such. It seems that these can cause some message queue to be flushed. Actually, my question is

How to use ZwQueryInformationProcess to get ProcessImageFileName in a kernel driver?

╄→гoц情女王★ 提交于 2019-12-05 19:27:13
问题 I'm writing a simple kernel driver for my application (think of a very simple anti-malware application.) I've hooked ZwOpenFile() and used PsGetCurrentProcess() to get a handle to the caller process. It returns a PEPROCESS structure: PEPROCESS proc = PsGetCurrentProcess(); I'm using ZwQueryInformationProcess() to get the PID and ImageFileName : DbgPrint("ZwOpenFile Called...\n"); DbgPrint("PID: %d\n", PsGetProcessId(proc)); DbgPrint("ImageFileName: %.16s\n", PsGetProcessImageFileName(proc));

Can you modify text files when committing to subversion?

别说谁变了你拦得住时间么 提交于 2019-12-05 19:19:15
I want to ran the following script on text files that are being committed: # Send the commands H and w to ed # ed will append newline if the file does not end in one printf "%s\n" H w | ed -s $1 # Strip trailing whitespace sed -i 's/[ \t]*$//g' $1 # Convert tabs to 4 spaces sed -i -r "s/\t/ /g" $1 I see subversion has a start-commit and pre-commit hooks but I can't follow the documentation about how I could process the text files with the above script. You mean change the text file before it's committed? You can (I'm not sure how), but it's generally not a good idea, as it doesn't tell the

HOOK C# method in DLL

谁说胖子不能爱 提交于 2019-12-05 18:27:26
I have C# application which calls SUM() function from a DLL. I want to hook that SUM() function in the DLL and manipulate the instructions by injecting my DLL into the process of C# application. Please reply. Please see this http://www.codeproject.com/Articles/463508/Net-CLR-Injection-Modify-IL-Codes-on-Run-time You can do that by modifying the IL code on runtime 来源: https://stackoverflow.com/questions/11101223/hook-c-sharp-method-in-dll

WindowsFromDc return null

别等时光非礼了梦想. 提交于 2019-12-05 18:13:47
I need some help about the win32 api and especially WindowsFromDc. I have a application which hook a another application. This two application communicate by a NamedPipe. In the second application, I have hook the DrawTextExW function and I get a HDC from this function. But when I do a WindowsFromDC with the DC returned by the DrawTextEx function, i got a null return. So, I have some question about that : -Is it possible a HDC don't have a HDWN with ? -How I can get the HWND of the window which call DrawTextEx ? There are other way do to that ? Thank you. Ps : Sorry for my bad english...

mysqldump schema only, schema update without drop

左心房为你撑大大i 提交于 2019-12-05 17:17:10
I'm looking at using the git pre-commit hook to export a MySQL db schema prior to commiting changes so that other developers can update their own databases with a SQL script from the git repo. By default a mysqldump (I'm using --no-data) will drop existing tables before rebuilding them which isn't what I'm after. I'm wondering if anyone knows of a way to do a mysqldump or similar to describe the db schemas with SQL to update tables if they exists instead of a drop and rebuild. I realize this might be a long shot but if anyone could point me in the right direction it would be great. How would

How do I create a 'route' in wordpress?

妖精的绣舞 提交于 2019-12-05 14:15:04
问题 For my own sanity I'm trying to create a route for an ajax api that looks something like: /api/<action> I'd like wordpress to handle this route and delegate to the proper action with do_action . Does wordpress give me a hook to implement this? Where's a good spot? 回答1: You have to use add_rewrite_rule Something like: add_action('init', 'theme_functionality_urls'); function theme_functionality_urls() { /* Order section by fb likes */ add_rewrite_rule( '^tus-fotos/mas-votadas/page/(\d)?',