📄 dll.dpr
字号:
library Dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
{$IMAGEBASE $57800000}
uses
Windows, madCodeHook;
var
capCreateCaptureWindowANext: function(
lpszWindowName: PChar;
dwStyle: DWord;
x, y: Integer;
nWidth, nHeight: Integer;
hwndParent: THandle;
nID: Integer): THandle; stdcall;
capCreateCaptureWindowWNext: function(
lpszWindowName: PWideChar;
dwStyle: DWord;
x, y: Integer;
nWidth, nHeight: Integer;
hwndParent: THandle;
nID: Integer): THandle; stdcall;
function IsAllowed(lpszWindowNameA: PChar;lpszWindowNameW: PWideChar): boolean;
var
FileName: array[0..1023] of char;
begin
GetModuleFileName(0, FileName, sizeof(FileName));
if lpszWindowNameA<>nil then
Result := MessageBox(0, Pchar('程序"' + FileName + '"欲调用API函数capCreateCaptureWindowA创建摄像头窗口进行捕获,摄像头窗口名称:"'+lpszWindowNameA+'"是否允许?'), '信息', MB_ICONQUESTION + MB_YESNO + MB_TOPMOST) = ID_YES
else
Result := MessageBox(0, Pchar('程序"' + FileName + '"欲调用API函数capCreateCaptureWindowW创建摄像头窗口进行捕获,摄像头窗口名称:"'+WideCharToString(lpszWindowNameW)+'"是否允许?'), '信息', MB_ICONQUESTION + MB_YESNO + MB_TOPMOST) = ID_YES;
end;
function capCreateCaptureWindowACallback(
lpszWindowName: PChar;
dwStyle: DWord;
x, y: Integer;
nWidth, nHeight: Integer;
hwndParent: THandle;
nID: Integer): THandle; stdcall;
begin
if not IsAllowed(lpszWindowName,nil) then
begin
// the user doesn't like this capCreateCaptureWindow call, so we block it
result := 0;
SetLastError(ERROR_ACCESS_DENIED);
end else
begin
// this capCreateCaptureWindow call is okay
result := capCreateCaptureWindowANext(lpszWindowName,
dwStyle,
x, y,
nWidth, nHeight,
hwndParent,
nID);
// capCreateCaptureWindow hooks are used very often, so to be sure we renew the hook
RenewHook(@capCreateCaptureWindowANext);
end;
end;
function capCreateCaptureWindowWCallback(
lpszWindowName: PWideChar;
dwStyle: DWord;
x, y: Integer;
nWidth, nHeight: Integer;
hwndParent: THandle;
nID: Integer): THandle; stdcall;
begin
if not IsAllowed(nil,lpszWindowName) then
begin
// the user doesn't like this capCreateCaptureWindow call, so we block it
result := 0;
SetLastError(ERROR_ACCESS_DENIED);
end
else
begin
// this capCreateCaptureWindow call is okay
result := capCreateCaptureWindowWNext(lpszWindowName,
dwStyle,
x, y,
nWidth, nHeight,
hwndParent,
nID);
// capCreateCaptureWindow hooks are used very often, so to be sure we renew the hook
RenewHook(@capCreateCaptureWindowWNext);
end;
end;
begin
HookAPI('AVICAP32.dll', 'capCreateCaptureWindowA', @capCreateCaptureWindowACallback, @capCreateCaptureWindowANext);
HookAPI('AVICAP32.dll', 'capCreateCaptureWindowW', @capCreateCaptureWindowWCallback, @capCreateCaptureWindowWNext);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -