我已经使用 WordPress 钩子init在 WordPress 的早期执行自定义代码,但是还有另一个钩子比这更早执行吗?
我有一个虚拟机,它在 VM_Create 上将函数(systemCalls)的地址传递给虚拟机。
所以我hook VM_Create 并窃取syscalls 地址,将其放入备份函数指针中,我修改后的systemCalls 函数的地址传递给原始VM_Create,从中我可以更改参数,添加或删除调用,然后调用支持的- up syscalls 函数。这运作良好,直到游戏的新版本。
我相信已经发现了问题:
这是未修改的 systemCalls 函数的开头:
intptr_t CL_CgameSystemCalls(intptr_t *args) {
switch (args[0]) {
case CG_PRINT:
Com_Printf( "%s", (const char*)VMA(1));
return 0;
case CG_ERROR:
Com_Error(ERR_DROP, "%s", (const char*)VMA(1));
return 0;
Run Code Online (Sandbox Code Playgroud)
这是我修改后的系统调用函数:
intptr_t modified_CL_CgameSystemCalls (intptr_t *args)
{
switch (*args)
{
case CG_GETSNAPSHOT:
mysnap = mysnap ;
mynextSnap = (snapshot_t*) (CG_QVM2NATIVE(args[2]));
mysnap = mynextSnap;
retval = original_CL_CgameSystemCalls(args);
break ;
Run Code Online (Sandbox Code Playgroud)
问题是从修改后的函数中调用原始函数:
intptr_t modified_CL_CgameSystemCalls(intptr_t *args)
{
retval = original_CL_CgameSystemCalls(args);
return retval;
}
Run Code Online (Sandbox Code Playgroud)
已经失败了。
从反汇编的伪代码可以看出,CL_CgameSystemCalls的新定义似乎是:
char __usercall …Run Code Online (Sandbox Code Playgroud) 我包括一个我想修改的脚本“foo.js”:
<head>
<script src="/myPath/foo.js" type="text/javascript"> </script>
</head>
Run Code Online (Sandbox Code Playgroud)
为了能够挂接到我的主页上的 ajax 调用:
$.ajax({
url: urlPath,
success: function (data) {
//hook into here from foo.js somehow??
}
});
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以仅在 foo.js 中执行此操作,而无需修改主页的脚本?(也许挂钩到正在填写/更改内容的主脚本内的调用?)
谢谢!
这是我第一次尝试hooks。
我正在寻找一些好的资源来实施CallWndProc hook. MSDN 的东西有点让人不知所措。
我发现使用这种类型的钩子需要注入外部 dll。这主要是我被困住的地方。
不确定 dll 中需要包含什么以及.NET应用程序中需要包含什么。
有dll例子吗?
我是 C++ 和 Hooking 的新手。为了创建窗口挂钩,我使用以下代码
static HRESULT WINAPI HookCreateWindowEx(
__in DWORD dwExStyle,
__in_opt LPCTSTR lpClassName,
__in_opt LPCTSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam
)
{
return TrueCreateWindowEx(dwExStyle,lpClassName, lpWindowName, dwStyle, x, y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
}
Run Code Online (Sandbox Code Playgroud)
在这里我想知道 lpClassName 它没有给出正确的名称。我怎样才能得到正确的名字?
我读过eval-after-load和add-hook.根据页面,代码输入eval-after-load执行一次.
另一方面,add-hook每次打开该模式的缓冲区时,内部代码都会运行.
好.但是,如何确定哪些代码应该在eval-after-load块或add-hook块内?例如,
(eval-after-load "js2-mode"
'(progn
(js2-basic-offset 2)))
Run Code Online (Sandbox Code Playgroud)
要么
(eval-after-load "js2-mode"
'(progn
(defun custom:js2-config ()
(js2-basic-offset 2))
(add-hook 'js2-mode-hook 'custom:js2-config)))
Run Code Online (Sandbox Code Playgroud)
我不是在问js2-basic-offset.
有一般规则吗?或..每当我使用时eval-after-load,我都要问?
我试图做一个简单的键盘记录测试,但我的程序没有按预期工作,我不知道为什么。
在我的程序中,我有一个低级键盘钩子,并为其附加了一个简单的过程。该过程只是打开/创建一个文件并写入“Hello World”然后关闭。但是它没有创建文件,可能是因为我的过程不正确或者因为我的钩子没有正确建立。
代码:
#include<windows.h>
#include<stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam){
ofstream myfile;
myfile.open ("[PATH]/example.txt");
myfile << "Hello world";//((KBDLLHOOKSTRUCT *)lParam)->vkCode
myfile.close();
return CallNextHookEx(NULL,code,wParam,lParam);
}
int main(void){
HINSTANCE hInst = NULL;
HHOOK hHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, hInst, 0);
printf("HHOOK is not null: %s\n", (hHook != NULL) ? "True" : "False");
char q;
for (cout << "q to quit\n"; q != 'q'; cin >> q);
printf("Successfully unhooked: %s", UnhookWindowsHookEx(hHook) ? "True" : …Run Code Online (Sandbox Code Playgroud) 我使用 CF7 来获取用户详细信息。当用户提交他的表单时,我想将输入字段放到我的 custom.php 文件中并在那里做一些事情。
我试着用 js on_sent_ok: URL/custom.php?...fields data.. 来做这件事……但我认为这不是正确的方法。但无论如何这对我有用。
有没有办法用钩子动作来做到这一点?我试过这个。
function wpcf7_do_something (&$cfdata) {
$goURL = 'http://contactform7.com';
$cfdata->set_properties( array( 'additional_settings' => "on_sent_ok: \"location = '".$goURL."';\"" ) );
}
add_action("wpcf7_before_send_mail", "wpcf7_do_something");
Run Code Online (Sandbox Code Playgroud)
我试图 echo something ,触发 js console.log,并在 wpcf7_do_something 函数内部重定向,但没有任何效果。我真的不知道它是否有效。
有没有办法测试这个动作是否有效?有没有办法重定向到另一个位置?
谢谢
我制作了一个简单的 UWP 应用程序和一个桌面应用程序。这段代码将ConsoleApplication1.dll文件注入桌面是正常的,但是我无法注入到UWP应用程序中。我有两个问题:为什么此代码无法注入 UWP 应用程序?以及如何解决?
此代码注入一个 DLL 文件
#include "pch.h"
#include <vector>
#include <string>
#include <windows.h>
#include <Tlhelp32.h>
using std::vector;
using std::string;
int main(void)
{
while (true)
{
vector<string>processNames;
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
HANDLE hTool32 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
BOOL bProcess = Process32First(hTool32, &pe32);
if (bProcess == TRUE)
{
while ((Process32Next(hTool32, &pe32)) == TRUE)
{
processNames.push_back(pe32.szExeFile);
if (strcmp(pe32.szExeFile, "ConsoleApplication4.exe") == 0 || strcmp(pe32.szExeFile, "UWP.exe") == 0)
{
printf("Hooked %s, %d \n", pe32.szExeFile, pe32.th32ProcessID);
char* DirPath = new char[MAX_PATH];
char* FullPath …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个模块来在类中的方法调用之前挂钩方法:
module Hooks
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
# everytime we add a method to the class we check if we must redifine it
def method_added(method)
if @hooker_before.present? && @methods_to_hook_before.include?(method)
hooked_method = instance_method(@hooker_before)
@methods_to_hook_before.each do |method_name|
begin
method_to_hook = instance_method(method_name)
rescue NameError => e
return
end
define_method(method_name) do |*args, &block|
hooked_method.bind(self).call
method_to_hook.bind(self).(*args, &block) ## your old code in the method of the class
end
end
end
end
def before(*methods_to_hooks, hookers)
@methods_to_hook_before = methods_to_hooks
@hooker_before = hookers[:call]
end …Run Code Online (Sandbox Code Playgroud)