26
votes
Accepted
Checking if a number is prime in NASM Win64 Assembly
Style: Indent your operands to a consistent column, so mnemonics of different length don't make your code look so ragged. And use local .label labels inside ...
18
votes
Checking if a number is prime in NASM Win64 Assembly
There are numerous small things.
You don't have to keep subtracting and adding 32 from rsp. Allocate the space once at the start of the function (...
16
votes
Accepted
Windows keylogger in C
You register keydown events for Control and Alt keys, but don't note when they are released. Therefore, you would not be able to distinguish between r and Controlr by reading the transcript.
Those ...
16
votes
Accepted
15
votes
Accepted
2D Collision Detection
Collision detection
You can calculate the collision much easier with the Rectangle structure.
Use the Contains method if you ...
14
votes
x64 assembly clearmem / zeromem
The comments in the clearmem procedure for the Linux block look a bit confusing. You could just have a summary of the procedure commented above, and have the ...
14
votes
Full C++ Snake game
Using constants
Rather than using #define and creating a bunch of macros like this:
...
13
votes
Accepted
x64 assembly clearmem / zeromem
I can't say I particularly like this code as it is right now. It seems to me that there are two reasonable approaches: if you think most of what you zero will be in main memory, then you probably just ...
12
votes
Windows keylogger in C
You have some global variables in main.c:
bool invisible = true;
char fileName[MAX_PATH];
They should be placed in the closest local scope possible and passed to ...
12
votes
Accepted
Date of latest GitHub project release
You're actually writing in C but using some C++ features, I'd drop C style (and functions) in favor of their C++ counterparts:
1) Even if you're using a C API you should write C++ classes to hide ...
12
votes
Accepted
Windows filepath and filename validation
For the if(filePath.Length >= 240) part, you can use the Path object.
It throws a ...
11
votes
Accepted
First socket class
I think you have too many different responsibilities bound up into one class. That ends up not only making that class more complex, but adding extra complexity overall as well. As a starting point, I'...
11
votes
Quadratic equation solver in C++
You have committed a grave error here with operator precedence, which should have easily been caught with simple testing:
X1 = Sector4Arithmetic / 2 * a;
The ...
11
votes
Accepted
Text-based User Interface in Python
General
Try to comply with PEP-8. PEP-8 is the name of the official Python style guide. Complying with it makes your code easier to read. Ultimately, developers can more easily collaborate on a ...
10
votes
Accepted
How random is this password-generating algorithm?
Copy&pasting code multiple times does not make it more secure. If we clean up your mutate_seed method, we'd end up with this:
...
10
votes
Date of latest GitHub project release
Your code can benefit from RAII. For example by creating a small HInternet struct with a destructor to hold a single HINTERNET. ...
10
votes
Removing multiple slashes from path
Here are some suggestions for how you might improve your code.
Use the appropriate #includes
This program fragment requires headers, which should be included:
<...
10
votes
Add and enable/disable Windows Firewall rules with Python
I agree with @Ludisposed answer, but you have a few subprocess gotchas:
You don't need to spawn a shell in order to run the command, simply build your command as a ...
9
votes
Removing multiple slashes from path
Your specification has holes in it.
What will be if user passes NULL? Undefined behavior? Return?
What if the path is already valid? Copy the string? Return ...
9
votes
Accepted
Add and enable/disable Windows Firewall rules with Python
This seems OK
We can add a little flavor to it:
Don't use string concatenation, but use f"{strings}" or ...
8
votes
How random is this password-generating algorithm?
Expected behaviour / User experience
Logging passwords to a file in unhashed, unencrypted form is bad practice. Doing so without telling the user is a sin.
Using ...
8
votes
Lemonade stand menu program
Here's a few things I noted:
Don't have using namespace std; in your code. It's almost universally considered a bad practice.
The C++ standard states that you ...
8
votes
Accepted
Find installed and available Windows Updates
Loop like a native
I suggest you have a look/read at Ned Batchelder's excellent presentation "Loop like a native".
In your case, any time you write:
...
8
votes
Accepted
Windows Keylogger
A few thoughts:
1. Fix your formatting
Code that appears within a function scope should be indented by another set of spaces (tab):
...
7
votes
Accepted
Virtual Slots Implementation
The usual improvements we often suggest here on Code Review:
Using namespace:
Try not to using namespace std. Read a discussion about this here. Instead, just ...
7
votes
Accepted
Function "between" for "Everything in One Line" library
There's no need to use the conditional operator here. This would be enough:
bool between (WORD n, WORD x, WORD y) {
return n >= x && n <= y;
}
...
7
votes
Accepted
Makefile for C++ OpenGL with GLFW and glad
First of all, good for you for learning how to write a proper makefile. Few people are any good at it, and it's a really fundamental tool. Even when nice tools ...
7
votes
Accepted
Batch file command looper
If you want an easy way to loop an arbitrary command several times...
set /a loop=100
for /L %%P in (1,1,%loop%) do (
echo Looping for one hundred times
)
...
7
votes
Quadratic equation solver in C++
Separate IO and logic.
Group logical parts into classes / functions.
Declare variables where they are used.
Declare IO routines for classes when appropriate.
I'd also seriously reconsider using ...
7
votes
Accepted
Platform independent whereis function
A couple of small things:
If you're specifically looking for executable files, you might use which instead of whereis command. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
windows × 340c++ × 138
c × 54
python × 50
console × 33
performance × 32
winapi × 32
beginner × 29
file-system × 29
powershell × 24
c# × 21
batch × 17
assembly × 15
python-3.x × 14
multithreading × 14
game × 13
c++11 × 12
object-oriented × 10
linux × 10
file × 9
networking × 9
snake-game × 9
socket × 8
strings × 7
image × 7