October 22, 2024
Chicago 12, Melborne City, USA
C#

How to intercept and possibly block process creation, system-wide?

I’m trying to make an AppLocker-like service that should intercept creation of processes based on certain restrictions set by an administrator. (For those who are wondering why I can’t simply use Microsoft’s AppLocker, the answer is that it is available only on the Server, Enterprise and Ultimate versions of Windows 7 and up.) So I

Read More
C#

Does malloc assign memory in the same location if you use the same variable name again on every iteration of a loop?

I am writing code to take in a weighted adjacency list in c. Each edge is stored in the form of a struct. I created a an array of pointers where each pointer leads to the list for a node. Here’s what I did: #include<stdio.h> #include<stdlib.h> struct edge{ int u; int v; int w; };

Read More
C#

Read a file with unknown number of lines in C using fscanf

I tried to search for the answer here and elsewhere on the Internet, but didn’t get exactly what I am looking for. I have a data file that looks like this: 0,4 0,6 0,9 0,10 1,5 1,7 1,9 2,6 2,8 2,10 3,4 3,7 I can read this file line by line using fscanf() without any

Read More
C#

Error Compiling Binutils for i386-elf on macOS: Malformed Archives

I’m trying to cross-compile binutils for i386-elf on macOS (Sequoia 15.0.1, arm64) but encounter an error when running make. Here are the steps I followed: Installed required dependencies: brew install gmp mpfr libmpc texinfo Downloaded and extracted binutils 2.41: mkdir -p ~/src cd ~/src wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz tar -xzf binutils-2.41.tar.gz Created a build directory: mkdir build-binutils

Read More
C#

Storing context prior to sleep (PIC)

Wonder if anybody knows the correct C syntax to store context (in my case just one int) before a PIC 24F sleeps and then recover it when woken. The example code (Microchip app note), which is supposed to store context in DSGPRO, set the DSEN bit and call sleep is – asm("MOV #0x8000, w2"); asm("MOV

Read More
C#

fast algorithm for drawing filled circles?

I am using Bresenham’s circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle. Is there a fast and efficient way of doing this? Something along the same lines of Bresenham? The language I am using is C. You need to sign in to

Read More
C#

How can I suppress “unused parameter” warnings in C?

For instance: Bool NullFunc(const struct timespec *when, const char *who) { return TRUE; } In C++ I was able to put a /*...*/ comment around the parameters. But not in C, of course, where it gives me the error: error: parameter name omitted You need to sign in to view this answers

Read More
C#

Kill syscall not working correctly on ArchLinux machine

I’m trying to use the signaling mechanism of UNIX to do some processing. To test out this functionality, I wrote the following code: #include <stdio.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> void handler(int sig) { printf("Received %d signal in %d!\n", sig, getpid()); if(sig == SIGUSR2) exit(0); signal(sig, handler); } int main() { pid_t

Read More
C#

How do you get a directory listing in C?

How do you scan a directory for folders and files in C? It needs to be cross-platform. You need to sign in to view this answers

Read More
C#

Listing and finding windows on OS X

I am trying to do some stuff on OS X using the carbon api, but I can’t find anything I am looking for on google or the Apple development website. Ideally I would like to find a function that finds the window at a certain location on screen. It seems that there are similar functions,

Read More