Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static INLINE_FUNCTION short isBufEmpty() {

static void clearBufPackets(PacketNode *tail) {
PacketNode *oldLast = tail->prev;
LOG("Cap end, send all %d packets. Buffer at max: %s", bufSize, bufSize);
LOG("Cap end, send all %d packets.", bufSize);
while (!isBufEmpty()) {
insertAfter(popNode(bufTail->prev), oldLast);
--bufSize;
Expand Down Expand Up @@ -113,7 +113,7 @@ static short capProcess(PacketNode *head, PacketNode *tail) {

if (totalBytes > bytesCapped) {
break;
}
}
}

// process live packets
Expand All @@ -130,7 +130,7 @@ static short capProcess(PacketNode *head, PacketNode *tail) {
if (totalBytes > bytesCapped) {
int capCnt = 0;
capped = TRUE;
// buffer from pac to head
// buffer from pac to head
while (bufSize < KEEP_AT_MOST && pac != head) {
pacTmp = pac->prev;
insertAfter(popNode(pac), bufHead);
Expand Down
34 changes: 18 additions & 16 deletions src/elevate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
#include <Windows.h>
#include "common.h"

//
//
// FUNCTION: IsRunAsAdmin()
//
// PURPOSE: The function checks whether the current process is run as
// administrator. In other words, it dictates whether the primary access
// token of the process belongs to user account that is a member of the
// PURPOSE: The function checks whether the current process is run as
// administrator. In other words, it dictates whether the primary access
// token of the process belongs to user account that is a member of the
// local Administrators group and it is elevated.
//
// RETURN VALUE: Returns TRUE if the primary access token of the process
// belongs to user account that is a member of the local Administrators
// RETURN VALUE: Returns TRUE if the primary access token of the process
// belongs to user account that is a member of the local Administrators
// group and it is elevated. Returns FALSE if the token does not.
//
// EXCEPTION: If this function fails, it throws a C++ DWORD exception which
// EXCEPTION: If this function fails, it throws a C++ DWORD exception which
// contains the Win32 error code of the failure.
// * changed to not throw and return false *
//
// EXAMPLE CALL:
// try
// try
// {
// if (IsRunAsAdmin())
// wprintf (L"Process is run as administrator\n");
Expand All @@ -43,18 +43,18 @@ BOOL IsRunAsAdmin()
// Allocate and initialize a SID of the administrators group.
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
if (!AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&pAdministratorsGroup))
{
dwError = GetLastError();
goto Cleanup;
}

// Determine whether the SID of administrators group is enabled in
// Determine whether the SID of administrators group is enabled in
// the primary access token of the process.
if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
{
Expand Down Expand Up @@ -103,7 +103,8 @@ BOOL IsElevated( ) {
BOOL tryElevate(HWND hWnd, BOOL silent) {
// Check the current process's "run as administrator" status.
BOOL fIsRunAsAdmin;
OSVERSIONINFO osver = {sizeof(osver)}; // MUST initialize with the size or GetVersionEx fails
OSVERSIONINFO osver = {0};
osver.dwOSVersionInfoSize = sizeof(osver); // MUST initialize with the size or GetVersionEx fails
if (!GetVersionEx(&osver)) {
if (!silent) MessageBox(hWnd, (LPCSTR)"Failed to get os version. clumsy only supports Windows Vista or above.",
(LPCSTR)"Aborting", MB_OK);
Expand All @@ -125,7 +126,8 @@ BOOL tryElevate(HWND hWnd, BOOL silent) {
if (GetModuleFileName(NULL, (LPSTR)szPath, ARRAYSIZE(szPath)))
{
// Launch itself as administrator.
SHELLEXECUTEINFO sei = { sizeof(sei) };
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(sei);
sei.lpVerb = (LPSTR)"runas";
sei.lpFile = (LPSTR)szPath;
sei.hwnd = hWnd;
Expand Down