Ich will NtQueryObject aufrufen, bekomme aber eine AccessViolation. Wieso?
So ist NtQueryObject importiert:
Delphi-Quellcode:
const
ntdll = 'ntdll.dll';
NTSTATUS = ULONG;
PVOID = Pointer;
USHORT = Word;
OBJECT_INFORMATION_CLASS = (ObjectBasicInformation, ObjectNameInformation,
ObjectTypeInformation, ObjectAllInformation, ObjectDataInformation);
TObjectInformationClass = OBJECT_INFORMATION_CLASS;
function NtQueryObject(
ObjectHandle: THandle;
ObjectInformationClas: TObjectInformationClass;
out ObjectInformation: PVOID;
ObjectInformationLength: ULONG;
out ReturnLength: PULONG): NTSTATUS; stdcall; external ntdll name 'NtQueryObject';
So rufe ich es auf:
Delphi-Quellcode:
var
ObjectInformation: Pointer;
ReturnLength: PULONG;
hMutex: THandle;
begin
hMutex := CreateMutex(nil, False, 'testmutex');
if hMutex = 0 then
begin
SysErrorMessage(GetLastError);
Exit;
end;
NtQueryObject(hMutex, ObjectNameInformation,
ObjectInformation, 2048, ReturnLength);
end;