Quantcast
Channel: 看雪安全论坛
Viewing all articles
Browse latest Browse all 9556

【求助】Delphi码.Hook NtCreateMutant自己成功,其他程序就死了。

$
0
0
function NewNtCreateMutant(
    MutantHandle : PHANDLE;
   DesiredAccess : ACCESS_MASK;
ObjectAttributes : POBJECT_ATTRIBUTES;
    InitialOwner : BOOLEAN ); NTSTATUS; stdcall;

 var
 wide:widestring;
begin
ObjectAttributes.ObjectName.Length:=ObjectAttributes.ObjectName.Length+16;
ObjectAttributes.ObjectName.MaximumLength:=ObjectAttributes.ObjectName.MaximumLength+16;
wide :=ObjectAttributes.ObjectName.Buffer;
wide:=wide + (inttohex(GetCurrentProcessId,8));
ObjectAttributes.ObjectName.Buffer:=Pwidechar(wide);

Result := TNewNtCreateMutant(Hook[22].BaseAddr)(MutantHandle,DesiredAccess,ObjectAttributes,InitialOwner);
end;

Hook自己写的程序createmutex(nil,false,'MuOnline');可以修改成功不出错。

Hook其他游戏进程,全部都会致命错误,直接挂掉。

哪里错了,请指点。
type
  POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;
  {$EXTERNALSYM POBJECT_ATTRIBUTES}
  _OBJECT_ATTRIBUTES = record
    Length: ULONG;//我试了这里+16也会崩溃,是不是其他参数也需要改下。
    RootDirectory: HANDLE;
    ObjectName: PUNICODE_STRING;
    Attributes: ULONG;
    SecurityDescriptor: PVOID;       // Points to type SECURITY_DESCRIPTOR
    SecurityQualityOfService: PVOID; // Points to type SECURITY_QUALITY_OF_SERVICE
  end;

Viewing all articles
Browse latest Browse all 9556

Trending Articles