HelpSeDebugPrivilege

Posts 1–11 of 11 · Page 1 of 1
SeDebugPrivilege
Hello good evening. I'm having trouble setting privileges for my application, it's not setting. follow the code below.
Note: I am using this function in Console Window.

Code:
void SetPrivilege()
{
    TOKEN_PRIVILEGES TP;
    LUID luid;
    HANDLE hToken;

    OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
    LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid);

    TP.PrivilegeCount = 1;
    TP.Privileges[0].Luid = luid;
    TP.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

    AdjustTokenPrivileges(hToken, FALSE, &TP, sizeof(TP), NULL, NULL);
    CloseHandle(hToken);
}
How i use:

Code:
int main()
{
  SetPrivilege();
  return 0;
}
Quote Originally Posted by MSDN
If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call GetLastError, which returns one of the following values when the function succeeds:

Return code Description
ERROR_SUCCESS
The function adjusted all specified privileges.
ERROR_NOT_ALL_ASSIGNED
The token does not have one or more of the privileges specified in the NewState parameter. The function may succeed with this error value even if no privileges were adjusted. The PreviousState parameter indicates the privileges that were adjusted.

If the function fails, the return value is zero. To get extended error information, call GetLastError.
Have you tried this?
Quote Originally Posted by Hell_Demon View Post
Have you tried this?
yes I tried but did not return the value 0 but also did not edit the game memory.

https://prntscr.com/kwb82i

in case it was to change the bytes of the jump to nop.
note: if I make the same code in delphi, it changes the memory correctly already in Console Window it does not change
if u can provide working Delphi code, pls do it, i try to help u then
Quote Originally Posted by MikeRohsoft View Post
if u can provide working Delphi code, pls do it, i try to help u then
Code:
Procedure SetPrivilege;
var
  TP : TTokenPrivileges;
  luid : TLargeInteger;
  hToken : THandle;
  ReturnLength: DWord;
begin
	OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, hToken);
	LookupPrivilegeValue(nil, 'SeDebugPrivilege', luid);

	TP.PrivilegeCount := 1;
	TP.Privileges[0].Luid := luid;
	TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;

	AdjustTokenPrivileges(hToken, False, TP, SizeOf(TP), nil, ReturnLength);

	CloseHandle(hToken);

	If (GetLastError() = ERROR_NOT_ALL_ASSIGNED) Then
	begin
	 ShowMessage('The token does not have one or more of the privileges specified in the NewState parameter.');
  end;
end;
note: I think I can only change the memory of the game if I pause it. I was wrong when I said it changed the memory in delphi.

I'm setting the privileges, but I can only change the memory in another game, already I have to open the game and pause it to change the memory.
do you use "VirtualQueryEx" before you write?
Quote Originally Posted by MikeRohsoft View Post
do you use "VirtualQueryEx" before you write?
No, i don't use VirtualQueryEx.
Well for me it sounds like the Page is maybe Protected from writing, so check it and change it if needed before you write in there
Quote Originally Posted by MikeRohsoft View Post
Well for me it sounds like the Page is maybe Protected from writing, so check it and change it if needed before you write in there
The VirtualQueryEx function determines the attributes of the first page in the region and then scans subsequent pages until it scans the entire range of pages, or until it encounters a page with a nonmatching set of attributes. The function returns the attributes and the size of the region of pages with matching attributes, in bytes.
I did not understand how this function could help me. I think I should use the VPEx function, but it is already part of the WPM function.
Even with privilege I can not change the game memory. except if it is in another game.
I believe there is some function preventing me from changing the game memory.
To find that out, i would just scan with Cheat Engine and if it just shows nothing, something is preventing it.
Do you try to Hack a Game with strong Anti Cheat like EAC? Because then you can't read Memory by this ussual Methods. Not directly at least.
Quote Originally Posted by MikeRohsoft View Post
To find that out, i would just scan with Cheat Engine and if it just shows nothing, something is preventing it.
Do you try to Hack a Game with strong Anti Cheat like EAC? Because then you can't read Memory by this ussual Methods. Not directly at least.
I think not, because I can change the bytes of a memory address and also look for those addresses by the Cheat Engine without the anti-cheat detects.
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us