c++

Nice way to do this in modern OO C-like language?

I have Tiles which represent the tiles in a game's 2-dimensional world. The tiles can have walls on any number of their 4 sides. I have something like this at the moment: interface Tile { boolean isWallAtTop(); boolean isWallAtRight(); boolean isWallAtLeft(); boolean isWallAtBottom(); } Somewhere else I also have 16 ...

How to catch file creation and the responsible caller

Hi, We are using a third part library to render 3d. In this library there is a "memory tracker" functionality that keeps track of all memory the library has allocated and freed during execution. This is a nice feature, since it helps by determining e.g. memory leaks. By calling a certain function in this library a log file is generated...

how to change the ACLs from c++?

how to change the ACLs from c++? can anyone help me to do the folowing from c++ without any confirmations: cacls c:\personal\file.txt /d everyone ? ...

C++ template specialization problem

I need a C++ template that, given a type and an object of that type, it can make a decision based on whether the type is an integer or not, while being able to access the actual objects. I tried this template <typename T, T &N> struct C { enum { Value = 0 }; }; template <int &N> struct C<int, N> { enum { Value = N }; }; but i...

Generating a Hardware-ID on Windows

What is the best way to generate a unique hardware ID on Microsoft Windows with C++ that is not easily spoofable (with for example changing the MAC Address)? ...

Failure with LogonUser in MC++

After fighting with this for a week I have not really gotten anywhere in why it constantly fails in my code, but not in other examples. My code, which while it compiles, will not log into a user that I know has the correct login information. Where it fails is the following line: wi = gcnew WindowsIdentity(token); It fails here because...

What is a good platform for devoloping web services in C++?

We're looking at developing a Web Service to function as a basis for a browser display/gui for a networked security prototype written in C++. My experience with web services has been limited to Java. I prefer Web Services in Java because it's on the "beaten path". One sure was to do this would be to simply code a Java client which invo...

"Uint32", "int16" and the like; are they standard c++?

I'm quite new to c++, but I've got the hang of the fundamentals. I've come across the use of "Uint32" (in various capitalizations) and similar data types when reading other's code, but I can't find any documentation mentioning them. I understand that "Uint32" is an unsigned int with 32 bits, but my compiler doesn't. I'm using visual c++ ...

a Process hidden from the Process Monitor

Hello, I need to create an application which will be reading and writing to files(C++/MFC). but I need the process not to appear in process monitor (which comes with SysInternals). From the reactions of others, I now confirm that this seems "illegal". but that is the request of the client I'm dealing with. so, I guess I just have to sa...

What is a good implementation of a peer to peer chat program with a server for assigning connections in c++?

I've been interested in creating a proof of concept chat program for a while using C++. I have given the idea a lot of thought and even wrote down the beginnings of how I would design the system, but I have hit a barrier in my thinking when it comes to the implementation. I want to know what an implementation of a peer to peer chat clie...

select(), recv() and EWOULDBLOCK on non-blocking sockets

Hi folks, I would like to know if the following scenario is real?! select() (RD) on non-blocking TCP socket says that the socket is ready following recv() would return EWOULDBLOCK despite the call to select() ...

Warning about hiding member variables?

The following code snippet has a memory leak that I spent too much time chasing down. The problem is that inside Foo(), the local variable x_ hides the member variable x_. It's quite annoying too, because the compiler could have warned me about it. Is there a flag in GCC for such a warning? (For the curious: I have arrived at the bugg...

Using VCCLCompilerTool with generated C++ source files.

In a Visual Studio 2005 Add-In, how would one specify that a new set of generated C++ source files should be compiled instead of the original source files? Since the two exist in separate directories, I assume that there's some way to change the source directory from the VCCLCompilerTool interface, but I haven't been able to figure out ...

What is faster (x < 0) or (x == -1)?

Variable x is int with possible values: -1, 0, 1, 2, 3. Which expression will be faster (in CPU ticks): 1. (x < 0) 2. (x == -1) Language: C/C++, but I suppose all other languages will have the same. P.S. I personally think that answer is (x < 0). More widely for gurus: what if x from -1 to 2^30? ...

Remote proxy with shared memory in C++

Suppose I have a daemon that is sharing it's internal state to various applications via shared memory. Processes can send IPC messages to the daemon on a named pipe to perform various operations. In this scenario, I would like to create a C++ wrapper class for clients that acts as a kind of "Remote Proxy" to hide some of the gory detai...

Append digit to an int without converting to string?

Is there a safe way of adding a digit at the end of an integer without converting it to a string and without using stringstreams ? I tried to google the answer for this and most solutions suggested converting it to a string and using stringstreams but I would like to keep it as an integer to ensure data integrity and to avoid converting...

How to find size of static allocations from binary?

Is it possible to determine the total amount of memory dedicated to static and global variables from the binary? I'm looking for a Linux utility that reads an elf file and figures out how much memory is pre-allocated for variables. ...

Is the following code using std::set "legal"?

I have this code: set<int>::iterator new_end = set_difference(set1.begin(), set1.end(), set2.begin(), set2.end(), set1.begin()); set1.erase(new_end, set1.end); It compiles and runs fine in visual studio. However, in a previous question, people stat...

Is it any good to define trivial inlined methods twice based to debug / release -state of the project?

I've always wondered, if it's good or bad practice to define trivial method twice, depending if the project's on debug / release -state. This is for inlining them. For instance, Foo.h: class Foo { public: ... const bool private: bool _boolean; }; #ifndef _DEBUG /** We'...

C++ Intellectual Property Protection/Anti-Reversing

I've seen a lot of discussion on here about copy protection. I am more interested in anti-reversing and IP protection. There are solutions such as Safenet and HASP that claim to encrypt the binary, but are these protected from reversing when used with a valid key? What kinds of strategies can be used to obfuscate code and throw off re...