Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yehoudie committed Sep 18, 2024
1 parent 552c0d6 commit e80c8d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Compiles and runs under


## Version
1.8.2
Last changed: 10.09.2024
1.8.3
Last changed: 17.09.2024


## REQUIREMENTS
Expand Down
4 changes: 2 additions & 2 deletions src/hexter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include "utils/Strings.h"

#define BIN_NAME ("hexter")
#define BIN_VS "1.8.2"
#define BIN_LAST_CHANGED "10.09.2024"
#define BIN_VS "1.8.3"
#define BIN_LAST_CHANGED "17.09.2024"

#define LIN_PARAM_IDENTIFIER ('-')
#define WIN_PARAM_IDENTIFIER ('/')
Expand Down
34 changes: 17 additions & 17 deletions src/utils/win/processes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ typedef struct _MODULE_INFO {
*/
INT AddPrivileges(
PCHAR *Privileges,
UINT32 PrivilegeCount
UINT32 PrivilegesCount
)
{
INT s = 0;
HANDLE htoken;
HANDLE token;
ULONG i;

TOKEN_PRIVILEGES* p = NULL;
TOKEN_PRIVILEGES* tp = NULL;

if ( OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &htoken) )
if ( OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token) )
{
size_t htokenSize = sizeof(TOKEN_PRIVILEGES) + (PrivilegeCount-1) * sizeof(LUID_AND_ATTRIBUTES);
p = (PTOKEN_PRIVILEGES)malloc(htokenSize);
if ( !p )
size_t tpSize = sizeof(TOKEN_PRIVILEGES) + (PrivilegesCount-1) * sizeof(LUID_AND_ATTRIBUTES);
tp = (PTOKEN_PRIVILEGES)malloc(tpSize);
if ( !tp )
{
s = GetLastError();
goto clean;
}

for ( i = 0; i < PrivilegeCount; i++ )
for ( i = 0; i < PrivilegesCount; i++ )
{
if ( !LookupPrivilegeValueA(NULL, Privileges[i], &(p->Privileges[i].Luid)) )
if ( !LookupPrivilegeValueA(NULL, Privileges[i], &(tp->Privileges[i].Luid)) )
{
s = GetLastError();
goto clean;
}

p->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED;
tp->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED;
}
p->PrivilegeCount = PrivilegeCount;
tp->PrivilegeCount = PrivilegesCount;

if ( !AdjustTokenPrivileges(htoken, FALSE, p, (ULONG)htokenSize, NULL, NULL)
if ( !AdjustTokenPrivileges(token, FALSE, tp, (ULONG)tpSize, NULL, NULL)
|| GetLastError() != ERROR_SUCCESS )
{
s = GetLastError();
Expand All @@ -56,8 +56,8 @@ INT AddPrivileges(
}

clean:
if ( p )
free(p);
if ( tp )
free(tp);

return s;
}
Expand All @@ -71,12 +71,12 @@ BOOL IsProcessElevated()

if ( !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken) )
{
goto clean; // if Failed, we treat as False
goto clean;
}

if (!GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &dwSize))
if ( !GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &dwSize) )
{
goto clean;// if Failed, we treat as False
goto clean;
}

fIsElevated = elevation.TokenIsElevated;
Expand Down

0 comments on commit e80c8d2

Please sign in to comment.