Windows: this is my work on how to compile the complete project in win32 using a coverity scan

Download "cov-analysis-win32-2017.07" from Coverity Scan

Use CMake to build inside cov bin

Search for "Visual Studio Command Symbol (2010)"
and run as administrator

In "Visual Studio Command Prompt (2010)" type the following commands

CD ..

cd C:  Users  Dady  Desktop  Done_msvc  cov  bin

cov-build --dir cov-int msbuild C:  Users  Dady  Desktop  Done_msvc  cov  bin  Ascemu.sln

Then the construction is 100% made.
find the cov-int folder inside the bin folder, close it, and load it in Coverity Scan
attentively

Active directory – Change password DSRM – Error code WIN32: 0xa90

I am using Windows 2012 R2 with Active Directory.

One of my DC has had hardware failures. I would like to promote another server as DC, but when reading online it seems that I need the DSRM password to do it. I did not configure the domain controller and I can not find the password written anywhere. When I try to reset the password on the server while I am logged in as a domain administrator, I get error 0xa90. Google has not been very helpful, so hope that someone here knows what to do.

I already deleted the dead DC manually from Active Directory, thinking that it might be causing the problem.

C:> Ntdsutil
Ntdsutil: set password dsrm
Reset DSRM administrator password: reset password on null server
Enter the password for the administrator account of DS restore mode: ********
Please confirm the new password: ********
The configuration password failed.
WIN32 Error Code: 0xa90
Error message: (null)

performance – Editing a configuration file using C ++ and Win32

I have created a small and simple tool for Windows with C ++ and the Win32 API to allow people to change their resolution in Fortnite, without having to search for the configuration file and edit it manually. The program has a width and height entry for the user to enter the desired resolution and an application button to save the changes in the configuration file. I've tried it on some machines and it seems to work as expected.

This is my first attempt to use C ++ or the Win32 API, and I would love to launch this project to the Fortnite Community, but I want to make sure there are no obvious problems with it.

My questions / concerns are:

  1. Have I eliminated the system resources correctly? Any possible memory loss? (brushes, fonts, etc)
  2. Do I need more error handling? Any improvement in what I have?
  3. Should I separate the GetFortniteConfiguration (), SetFortniteConfiguration () Y CenterWindow () Does it work in its own file or is the project small enough to keep it the way it is?

I will also add comments to the code shortly, but any other advice, suggestion or learning resource will be welcome.

#include 
#include 
#include 
#include 

#include "alphares.h"
#include "resources.h"
#include "simpleini / simpleini.h"

LRESULT CALLBACK WindowProc (
HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam);

void CenterWindow (HWND window, DWORD style, DWORD exStyle) {
int screen_width = GetSystemMetrics (SM_CXSCREEN);
int screen_height = GetSystemMetrics (SM_CYSCREEN);
RECT client_rect;

GetClientRect (window, & client_rect);
AdjustWindowRectEx (& client_rect, style, FALSE, exStyle);

int client_width = client_rect.right - client_rect.left;
int client_height = client_rect.bottom - client_rect.top;

SetWindowPos (window, NULL,
screen_width / 2 - client_width / 2,
screen_height / 2 - client_height / 2,
client_width, client_height, 0);
}

int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
const wchar_t CLASS_NAME[] = L "alfares";
const wchar_t WINDOW_NAME[] = L "alfares";

WNDCLASS wc = {};
Message from MSG = {};

wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hbrBackground = CreateSolidBrush (RGB (43, 45, 92));
wc.hIcon = LoadIcon (wc.hInstance, MAKEINTRESOURCE (IDR_ICON));
wc.lpszClassName = CLASS_NAME;

yes (! RegisterClass (& wc)) {
returns 0;
}

HWND hwnd = CreateWindowEx (
0,
NAME OF THE CLASS,
WINDOW_NAME,
WS_OVERLAPPEDWINDOW & ~ WS_MAXIMIZEBOX ^ WS_THICKFRAME,
CW_USEDEFAULT, CW_USEDEFAULT, 250, 150,
NULL,
NULL,
hInstance,
NULL);

CenterWindow (hwnd, WS_OVERLAPPEDWINDOW & ~ WS_MAXIMIZEBOX ^ WS_THICKFRAME, 0);

if (hwnd == NULL) {
returns 0;
}

ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);

while (GetMessage (& message, NULL, 0, 0)) {
if (! IsDialogMessage (hwnd, & message)) {
TranslateMessage (& message);
DispatchMessage (& message);
}
}
returns 0;
}

LPCSTR GetFortniteConfiguration () {
char * way;
length size_t;
_dupenv_s (& path, & length, "LOCALAPPDATA");
std :: string fortnite = "\ FortniteGame \ Saved \ Config \ WindowsClient \ GameUserSettings.ini";
std :: string fullpath = path + fortnite;
free (path);

returns fullpath.c_str ();
}

void SetFortniteConfiguration (LPCSTR file, int user_width, int user_height) {
std :: string width_string = std :: to_string (user_width);
std :: string height_string = std :: to_string (user_height);
char const * width = width_string.c_str ();
char const * height = height_string.c_str ();

Attributes DWORD = GetFileAttributesA (file);

if (attributes & FILE_ATTRIBUTE_READONLY) {
attributes & = ~ FILE_ATTRIBUTE_READONLY;
SetFileAttributesA (file, attributes);
}

const char * section = "/Script/FortniteGame.FortGameUserSettings";

CSimpleIniA ini;
ini.SetSpaces (false);
ini.SetUnicode ();
ini.LoadFile (file);

ini.SetValue (section, "ResolutionSizeX", width);
ini.SetValue (section, "ResolutionSizeY", height);
ini.SetValue (section, "LastUserConfirmedResolutionSizeX", width);
ini.SetValue (section, "LastUserConfirmedResolutionSizeY", height);
ini.SetValue (section, "DesiredScreenWidth", width);
ini.SetValue (section, "DesiredScreenHeight", height);
ini.SetValue (section, "LastUserConfirmedDesiredScreenWidth", width);
ini.SetValue (section, "LastUserConfirmedDesiredScreenHeight", height);

ini.SaveFile (file);
}

LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof (ncm);
SystemParametersInfo (SPI_GETNONCLIENTMETRICS, sizeof (ncm), & ncm, 0);

HISTORY HISTORY;
static HFONT hFont = CreateFontIndirect (& ncm.lfMessageFont);
static HBRUSH hBrushStatic = CreateSolidBrush (RGB (43, 45, 92));
static HBRUSH hBrushEdit = CreateSolidBrush (RGB (35, 35, 79));
static HBRUSH hBrushButton = CreateSolidBrush (RGB (93, 107, 238));

switch (message) {
WM_CREATE case:
hInstance = GetModuleHandle (nullptr);

CreateWindowEx (
NULL,
TEXT ("Static"),
TEXT ("Width"),
WS_CHILD | WS_VISIBLE | ES_CENTER,
50, 15, 60, 20,
hwnd
(HMENU) IDC_WIDTH_LABEL,
hInstance,
NULL);

Send Message(
GetDlgItem (hwnd, IDC_WIDTH_LABEL),
WM_SETFONT,
(WPARAM) hFont,
TRUE);

CreateWindowEx (
NULL,
TEXT ("Static"),
Height of the text "),
WS_CHILD | WS_VISIBLE | ES_CENTER,
125, 15, 60, 20,
hwnd
(HMENU) IDC_HEIGHT_LABEL,
hInstance,
NULL);

Send Message(
GetDlgItem (hwnd, IDC_HEIGHT_LABEL),
WM_SETFONT,
(WPARAM) hFont,
TRUE);

CreateWindowEx (
NULL,
TEXT ("Edit"),
TEXT ("1920"),
WS_CHILD | WS_VISIBLE | ES_NUMBER | ES_CENTER | WS_TABSTOP,
50, 35, 60, 15,
hwnd
(HMENU) IDC_WIDTH_EDIT,
hInstance,
NULL);

Send Message(
GetDlgItem (hwnd, IDC_WIDTH_EDIT),
WM_SETFONT,
(WPARAM) hFont,
TRUE);

Send Message(
GetDlgItem (hwnd, IDC_HEIGHT_EDIT),
EM_SETLIMITTEXT,
4, 0);

CreateWindowEx (
NULL,
TEXT ("Edit"),
TEXT ("1080"),
WS_CHILD | WS_VISIBLE | ES_NUMBER | ES_CENTER | WS_TABSTOP,
125, 35, 60, 15,
hwnd
(HMENU) IDC_HEIGHT_EDIT,
hInstance,
NULL);

Send Message(
GetDlgItem (hwnd, IDC_HEIGHT_EDIT),
WM_SETFONT,
(WPARAM) hFont,
TRUE);

Send Message(
GetDlgItem (hwnd, IDC_WIDTH_EDIT),
EM_SETLIMITTEXT,
4, 0);

CreateWindowEx (
NULL,
TEXT ("Button"),
TEXT ("Apply"),
WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
50, 65, 135, 25,
hwnd
(HMENU) IDC_APPLY_BUTTON,
hInstance,
NULL);

Send Message(
GetDlgItem (hwnd, IDC_APPLY_BUTTON),
WM_SETFONT,
(WPARAM) hFont,
TRUE);

break;

WM_CTLCOLORSTATIC case:
{
HDC hdcStatic = (HDC) wParam;
SetTextColor (hdcStatic, RGB (93, 107, 238));
SetBkColor (hdcStatic, RGB (43, 45, 92));
return (INT_PTR) hBrushStatic;
}

WM_CTLCOLOREDIT case:
{
HDC hdcEdit = (HDC) wParam;
SetTextColor (hdcEdit, RGB (255, 255, 255));
SetBkColor (hdcEdit, RGB (35, 35, 79));
return (INT_PTR) hBrushEdit;
}

WM_CTLCOLORBTN case:
{
HDC hdcButton = (HDC) wParam;
SetTextColor (hdcButton, RGB (255, 255, 255));
SetBkColor (hdcButton, RGB (93, 107, 238));
return (INT_PTR) hBrushButton;
}

WM_COMMAND case:
if (LOWORD (wParam) == IDC_APPLY_BUTTON) {
File LPCSTR = GetFortniteConfiguration ();
struct stat buffer;

if (stat (file, & buffer) == 0) {
Success BOOL;

int width = GetDlgItemInt (
hwnd
IDC_WIDTH_EDIT,
&success,
FALSE);

int height = GetDlgItemInt (
hwnd
IDC_HEIGHT_EDIT,
&success,
FALSE);

if (success == TRUE) {
SetFortniteConfiguration (file, width, height);

MessageBoxA
hwnd
"His resolution was saved successfully."
"Success",
MB_OK);
} else {
MessageBoxA
hwnd
"Please, enter a resolution."
"Warning",
MB_OK | MB_ICONWARNING);
}
} else {
MessageBoxA
hwnd
"There was an error finding your configuration file.",
"Error",
MB_OK | MB_ICONERROR);
}
}
break;

WM_DRAWITEM case:
if (wParam == IDC_APPLY_BUTTON) {
LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT) lParam;
RECT rect = pdis-> rcItem;

DrawTextA (
pdis-> hDC,
"Apply",
5,
and rect
DT_CENTER | DT_SINGLELINE | DT_VCENTER);

return TRUE
}
break;

WM_DESTROY case:
DeleteObject (hFont);
DeleteObject (hBrushStatic);
DeleteObject (hBrushEdit);
DeleteObject (hBrushButton);
PostQuitMessage (0);
returns 0;

WM_PAINT case:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint (hwnd, & ps);
EndPaint (hwnd, & ps);
break;
}
returns 0;
}
returns DefWindowProc (hwnd, message, wParam, lParam);
}