- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在上钩GetWindowThreadProcessId()
使用以下代码成功。
现在我想检查dwProcessID参数是否对应于确定进程的ID,并且在肯定情况下阻止执行原始函数:
Result := OldGetWindowThreadProcessId(hWnd, dwProcessID);
我尝试过这个,但没有成功:
if dwProcessID = 12345 then exit;
这是我的完整代码:
library MyLIB;
uses
Windows,
ImageHlp;
{$R *.res}
type
PGetWindowThreadProcessId = function(hWnd: THandle; dwProcessID: DWord)
: DWord; stdcall;
var
OldGetWindowThreadProcessId: PGetWindowThreadProcessId;
function HookGetWindowThreadProcessId(hWnd: THandle; dwProcessID: DWord)
: DWord; stdcall;
begin
try
// Check if is some process
except
MessageBox(0, 'Error', 'HookGetWindowThreadProcessId Error', 0);
end;
Result := OldGetWindowThreadProcessId(hWnd, dwProcessID);
end;
procedure PatchIAT(strMod: PAnsichar; Alt, Neu: Pointer);
var
pImportDir: pImage_Import_Descriptor;
size: CardinaL;
Base: CardinaL;
pThunk: PDWORD;
begin
Base := GetModuleHandle(nil);
pImportDir := ImageDirectoryEntryToData(Pointer(Base), True,
IMAGE_DIRECTORY_ENTRY_IMPORT, size);
while pImportDir^.Name <> 0 Do
begin
If (lstrcmpiA(PAnsichar(pImportDir^.Name + Base), strMod) = 0) then
begin
pThunk := PDWORD(Base + pImportDir^.FirstThunk);
While pThunk^ <> 0 Do
begin
if DWord(Alt) = pThunk^ Then
begin
pThunk^ := CardinaL(Neu);
end;
Inc(pThunk);
end;
end;
Inc(pImportDir);
end;
end;
procedure DllMain(reason: Integer);
begin
case reason of
DLL_PROCESS_ATTACH:
begin
OldGetWindowThreadProcessId := GetProcAddress(GetModuleHandle(user32),
'GetWindowThreadProcessId');
PatchIAT(user32, GetProcAddress(GetModuleHandle(user32),
'GetWindowThreadProcessId'), @HookGetWindowThreadProcessId);
end;
DLL_PROCESS_DETACH:
begin
end;
end;
end;
begin
DllProc := @DllMain;
DllProc(DLL_PROCESS_ATTACH);
end.
最佳答案
您的 PGetWindowThreadProcessId 类型和 HookGetWindowThreadProcessId() 函数都错误地声明了 dwProcessID 参数。它是一个输出参数,因此需要将其声明为 var dwProcessID: DWord
或 dwProcessID: PDWord
。
然后您需要调用 OldGetWindowThreadProcessId()
来检索实际的 PID,然后才能将其与任何内容进行比较。因此,您的“在积极情况下阻止执行原始函数”的要求是不现实的,因为您需要执行原始函数才能确定要比较的dwProcessID
值。
试试这个:
type
PGetWindowThreadProcessId = function(hWnd: THandle; var dwProcessID: DWord): DWord; stdcall;
...
function HookGetWindowThreadProcessId(hWnd: THandle; var dwProcessID: DWord): DWord; stdcall;
begin
Result := OldGetWindowThreadProcessId(hWnd, dwProcessID);
try
if dwProcessID = ... then
...
except
MessageBox(0, 'Error', 'HookGetWindowThreadProcessId Error', 0);
end;
end;
关于delphi - GetWindowThreadProcessId() IAT Hook : How compare "dwProcessID" parameter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52787911/
我经常有一个 Comparator 类型,而我需要一个 Comparable 类型,反之亦然。是否有可重用的 JDK API 可以相互转换?类似的东西: public static Comp
我怎么能写这个 Comparator sort = (i1, i2) -> Boolean.compare(i2.isOpen(), i1.isOpen()); 像这样(代码不起作用): Compa
请帮助她。我有一个错误 Collections.sort(var4, new Comparator() { public int compare(TreeMap var1, TreeMa
学习 Kotlin,我试图了解 Java 的 Comparator接口(interface)有效 - 主要是 compare() 函数,这样我就可以利用它。 我已经尝试阅读 compare() 的文档
我有以下程序 List numbers = Arrays.asList("10", "68", "97", "9", "21", "12"); Collections.sort(numbers, (
我想根据嵌套类的属性对如下所示的列表进行排序。 class Test { private NestedClass nestedClass; private AnotherNes
我很好奇“Beyond Compare”的算法是如何工作的? 我猜想他们使用了一种标准的(众所周知的?)算法来实现“字符与字符”的比较。你知道这个算法的名字吗?谢谢 最佳答案 Beyond Compa
这个问题已经有答案了: How does the sort() method of the Collection class call the Comparable's compareTo()? (1
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicates: difference between compare() and compareTo() Java: What i
我被要求为某个类实现Comparable或Compartor,我们称之为V。 假设我有一个 V 的 Collection 或 Set(还不确定,但我认为这并不重要)。 V 有一个方法,可以评估它的“权
我正在查看Java8中实现的Comparator.comparing方法的源代码 这是代码 public static Comparator comparing( Function
假设我有一个类 ClassA,它的属性是 ClassB: public ClassA { private String attr; private ClassB classB; } p
我有一个自定义比较器,其比较逻辑如下: List l = new ArrayList(); l.add("tendercoupon"); l.add("giftcard
我正在努力实现一个处理 Comparator 和 Comparable 接口(interface)的层次结构。我不清楚的几件事: 如果我将比较器添加到比较器链中,这段代码究竟意味着什么 chain.a
正在关注 this question关于按另一个列表对列表进行排序,我尝试做同样的事情 - 但由于某种原因它对我不起作用。我错过了什么? List nums = Arrays.asList(5
假设我有一个像这样的领域模型: class Lecture { Course course; ... // getters } class Course { Teache
在表达式 > 中像这样的签名 public static > foo(T x) { ... } T的描述递归地依赖于Comparable . 如果T延伸Comparable ,和Comparable延
所有“数字”比较器(例如 Comparer.Default 、 Comparer.Default 等)返回 -1 的原因是什么? , 0或 1 ,但是 Comparer.Default和 Compar
(如果这是重复的,请指出正确的答案!我搜索并阅读了几个(> 5)个相关问题,但似乎没有一个是正确的。还查看了泛型常见问题解答和其他来源...) 当一个集合类接受一个比较器时,它应该具有 Compara
SBCL 1.3.1 综上所述,a是一个列表,'(7),b通过setq sbcl This is SBCL 1.3.1.debian, an implementation of ANSI Common
我是一名优秀的程序员,十分优秀!