Hooking problem please tell me whats wrong :confused:

c++ / delphi package - dll injection and api hooking
Post Reply
LibX
Posts: 5
Joined: Sat Jan 08, 2005 6:49 pm

Hooking problem please tell me whats wrong :confused:

Post by LibX »

function NetQueryDisplayInformationCallback(ServerName: LPCWSTR; Level, Index, EntriesRequested, PreferredMaximumLength: DWORD; ReturnedEntryCount: LPDWORD; var SortedBuffer: PVOID): NET_API_STATUS; stdcall;
var
Offset: dword;
User, Users: PNET_DISPLAY_USER;
Group, Groups: PNET_DISPLAY_GROUP;
begin
Result := NetQueryDisplayInformationNextHook(ServerName, Level, Index, EntriesRequested, PreferredMaximumLength, ReturnedEntryCount, SortedBuffer);
if Result <> 0 then Exit;
case dword(Level) of
1:
begin
Offset := 0;
User := nil;
repeat
Users := PNET_DISPLAY_USER(pointer(dword(SortedBuffer) + Offset));
if SubTextExists(USERS_TO_HIDE, WideCharToString(Users.usri1_name), '|') then
begin
if Users.usri1_next_index = 0 then
begin
if User <> nil then User.usri1_next_index := 0;
Exit;
end
else
begin
User.usri1_next_index := User.usri1_next_index + Users.usri1_next_index;
end;
end
else
begin
User := Users;
end;
Offset := Offset + Users.usri1_next_index;
until Users.usri1_next_index = 0;
end;

3:
begin
Offset := 0;
Group := nil;
repeat
Groups := PNET_DISPLAY_GROUP(pointer(dword(SortedBuffer) + Offset));
if SubTextExists(GROUPS_TO_HIDE, WideCharToString(Groups.grpi3_name), '|') then
begin
if Groups.grpi3_next_index = 0 then
begin
if Group <> nil then Group.grpi3_next_index := 0;
Exit;
end
else
begin
Group.grpi3_next_index := Group.grpi3_next_index + Groups.grpi3_next_index;
end;
end
else
begin
Group := Groups;
end;
Offset := Offset + Groups.grpi3_next_index;
until Groups.grpi3_next_index = 0;
end;
end;
end;

This function is doing the hooking ok but handeling is not working ok :S i don't know why but all users get hidden but all group stay just visibel :S
can some1 explain me what iam doing wrong please

regardes
LibX
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Can you please reformat that using the "code" style and reasonable code indentions? It's just not readable the way it's now without the indentions.
Post Reply