Code: Select all
unit File_Unit;
interface
uses
Windows,
madCodeHook,
Common_Unit;
var
CreateFileWNext : function (lpFileName: PWideChar; dwDesiredAccess, dwShareMode: DWORD; lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD; hTemplateFile: THandle): THandle; stdcall;
DeleteFileWNext : function (lpFileName: PWideChar): BOOL; stdcall;
CopyFileWNext : function (lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
CopyFileExWNext : function (lpExistingFileName, lpNewFileName: PWideChar; lpProgressRoutine: TFNProgressRoutine; lpData: Pointer; pbCancel: PBool; dwCopyFlags: DWORD): BOOL; stdcall;
MoveFileWNext : function (lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
MoveFileExWNext : function (lpExistingFileName, lpNewFileName: PWideChar; dwFlags: DWORD): BOOL; stdcall;
CreateFileMappingWNext : function (hFile: THandle; lpFileMappingAttributes: PSecurityAttributes; flProtect, dwMaximumSizeHigh, dwMaximumSizeLow: DWORD; lpName: PWideChar): THandle; stdcall;
OpenFileMappingWNext : function (dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: PWideChar): THandle; stdcall;
function CreateFileWCallback(lpFileName: PWideChar; dwDesiredAccess, dwShareMode: DWORD; lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD; hTemplateFile: THandle): THandle; stdcall;
function DeleteFileWCallback(lpFileName: PWideChar): BOOL; stdcall;
function CopyFileWCallback(lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
function CopyFileExWCallback(lpExistingFileName, lpNewFileName: PWideChar; lpProgressRoutine: TFNProgressRoutine; lpData: Pointer; pbCancel: PBool; dwCopyFlags: DWORD): BOOL; stdcall;
function MoveFileWCallback(lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
function MoveFileExWCallback(lpExistingFileName, lpNewFileName: PWideChar; dwFlags: DWORD): BOOL; stdcall;
function CreateFileMappingWCallback(hFile: THandle; lpFileMappingAttributes: PSecurityAttributes; flProtect, dwMaximumSizeHigh, dwMaximumSizeLow: DWORD; lpName: PWideChar): THandle; stdcall;
function OpenFileMappingWCallback(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: PWideChar): THandle; stdcall;
implementation
function CreateFileWCallback(lpFileName: PWideChar; dwDesiredAccess, dwShareMode: DWORD; lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD; hTemplateFile: THandle): THandle; stdcall;
begin
Result :=CreateFileWNext(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
if not IsAllowed(MsgExecType, 'CreateFileW', lpFileName) then
begin
Result :=0;
SetLastError(ERROR_ACCESS_DENIED);
end; { if }
end; { CreateFileWCallback }
function DeleteFileWCallback(lpFileName: PWideChar): BOOL; stdcall;
begin
Result :=DeleteFileWNext(lpFileName);
if not IsAllowed(MsgExecType, 'DeleteFileW', lpFileName) then
begin
Result :=False;
SetLastError(ERROR_ACCESS_DENIED);
end; { if }
end; { DeleteFileW }
function CopyFileWCallback(lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
var
St : WideString;
begin
Result :=CopyFileWNext(lpExistingFileName, lpNewFileName, bFailIfExists);
St :=lpExistingFileName + ' --> ' + lpNewFileName;
if not IsAllowed(MsgExecType, 'CopyFileW', PWideChar(St)) then
begin
Result :=False;
SetLastError(ERROR_ACCESS_DENIED);
end;{ if }
end; { CopyFileWCallback }
function CopyFileExWCallback(lpExistingFileName, lpNewFileName: PWideChar; lpProgressRoutine: TFNProgressRoutine; lpData: Pointer; pbCancel: PBool; dwCopyFlags: DWORD): BOOL; stdcall;
var
St : WideString;
begin
Result :=CopyFileExWNext(lpExistingFileName, lpNewFileName, lpProgressRoutine, lpData, pbCancel, dwCopyFlags);
St :=lpExistingFileName + ' --> ' + lpNewFileName;
if not IsAllowed(MsgExecType, 'CopyFileExW', PWideChar(St)) then
begin
Result :=False;
SetLastError(ERROR_ACCESS_DENIED);
end;{ if }
end; { CopyFileExWCallback }
function MoveFileWCallback(lpExistingFileName, lpNewFileName: PWideChar; bFailIfExists: BOOL): BOOL; stdcall;
var
St : WideString;
begin
Result :=MoveFileWNext(lpExistingFileName, lpNewFileName, bFailIfExists);
St :=lpExistingFileName + ' --> ' + lpNewFileName;
if not IsAllowed(MsgExecType, 'MoveFileW', PWideChar(St)) then
begin
Result :=False;
SetLastError(ERROR_ACCESS_DENIED);
end;{ if }
end; { MoveFileWCallback }
function MoveFileExWCallback(lpExistingFileName, lpNewFileName: PWideChar; dwFlags: DWORD): BOOL; stdcall;
var
St : WideString;
begin
Result :=MoveFileExWNext(lpExistingFileName, lpNewFileName, dwFlags);
St :=lpExistingFileName + ' --> ' + lpNewFileName;
if not IsAllowed(MsgExecType, 'MoveFileExW', PWideChar(St)) then
begin
Result :=False;
SetLastError(ERROR_ACCESS_DENIED);
end;{ if }
end; { MoveFileExWCallback }
function CreateFileMappingWCallback(hFile: THandle; lpFileMappingAttributes: PSecurityAttributes; flProtect, dwMaximumSizeHigh, dwMaximumSizeLow: DWORD; lpName: PWideChar): THandle; stdcall;
begin
Result :=CreateFileMappingWNext(hFile, lpFileMappingAttributes, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, lpName);
if not IsAllowed(MsgExecType, 'CreateFileMappingW', lpName) then
begin
Result :=0;
SetLastError(ERROR_ACCESS_DENIED);
end; { if }
end; { CreateFileMappingWCallback }
function OpenFileMappingWCallback(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: PWideChar): THandle; stdcall;
begin
Result :=OpenFileMappingWNext(dwDesiredAccess, bInheritHandle, lpName);
if not IsAllowed(MsgExecType, 'OpenFileMappingW', lpName) then
begin
Result :=0;
SetLastError(ERROR_ACCESS_DENIED);
end;{ if }
end; { OpenFileMappingWCallback }
end.
+ If I used Opera to surf any website, It closed automatically.