C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello ,

Any body knows a sample for re-calculate checksums and drop packets on netfilter module ?

Thank you
On Demand Webinar: Networking for the Cloud Era
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Hello ,

We are building an IDS/IPS/Waf system that reads the packets from PF_Ring and apply rules to IPTables / Netfilter / Ntuple .
That software needs to access to userspace for iptables and kernelspace for netfilter. So we already pipe the both side.
But our main concern is about the performace issue. Time is our biggest enemy and need to solve the problem in mikro / mili seconds.
So where is the best place working area for our  main core of software for performance ? kernel area or user area ? and why .

Thanks for information
Hello ,

I want to know if there is a possible way to apply BPF filter to drop packets on netfilter  

Thank you

#define __KERNEL__
#define MODULE
#include <linux/ip.h>             
#include <linux/kernel.h> 
#include <linux/module.h> 
#include <linux/netdevice.h>      
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> 
#include <linux/skbuff.h>         
#include <linux/udp.h>      

#include <linux/ip.h>

static struct nf_hook_ops netfilter_ops;                        
static unsigned char *ip_address = "\x5D\xBB\xCD\x73"; 
static char *interface = "p1p2";                          
unsigned char *port = "\x00\x17";                       
struct sk_buff *sock_buff;                              
struct udphdr *udp_header;                              
unsigned int main_hook(unsigned int hooknum,
                  struct sk_buff **skb,
                  const struct net_device *in,
                  const struct net_device *out,
                  int (*okfn)(struct sk_buff*))
  if(strcmp(in->name,interface) == 0){ return NF_DROP; }  
  struct iphdr* iph = ip_hdr(skb);
  if(iph->saddr == *(unsigned int*)ip_address){ return NF_DROP; }   
	/**sock_buff = *skb;
	if(!sock_buff){ return NF_ACCEPT; }                   
	if(!(iph)){ return NF_ACCEPT; }              
	if(iph->protocol != 17){ return NF_ACCEPT; }                 
	udp_header = (struct udphdr *)(sock_buff->data + (iph->ihl *4)); 

Open in new window

Hello ,

Is there any possible way remove if the number of rows exceeds X the oldest (Total_Row - X ) count rows.

Is there any body knows ready to use sub routine when we send an array it will draw sth. like that :

value |-------------------------------------------------- count
    0 |                                                     32167
    1 |                                                      9999
    2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  1723569
    4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        973472
    8 |@@@                                                 111055
   16 |                                                     14777
   32 |                                                       376
   64 |                                                       585
  128 |                                                        19
  256 |                                                         0
  512 |                                                         0

Open in new window

Are there any instructors like
simon allardice
from lynda.com, plursight.com
who explain computer science concepts without using a scripting language.

Just verbally.

Please add (or subtract) zones
Hello Experts,

I have a C++ program which allocates named shared memory of a structure. I need to be able to read that same structure from a c# program. Here is my c# code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        [StructLayout(LayoutKind.Sequential, Size = 218)]
        public struct TEST_STRUCT
            public long tnum;                     //size = 8
            public long pass_count;               //size = 8
            public long fail_count;               //size = 8
            public long try_count;                //size = 8
            public double sum_result;               //size = 8
            public double sumsq_result;             //size = 8
            public double min;                      //size = 8
            public double max;                      //size = 8
            public long histogram;                //size = 8*40
            public bool tested;                   //size = 4
            public bool passed;                   //size = 4 
            public double last_result;              //size = 8

Open in new window

I am trying to set permission on an application as read/execute only, I can achieve this by using c++ windows SetSecurityDescriptorDacl() function.

But after that admin can change it by right clicking on a file

    properties->security->advanced->Change Permission

But somehow antivirus prevents these charges on their application ..
//************************** tracks indexs*******************
each track saved in sd card has index , so to play track number we will using it's index 
for example to play track number 1 we will using "00003"  index which will send to play track function 
all the same for the rest of all tracks 
char buffer15[6]={"00001"};  // track 15 index 
char buffer16[6]={"00002"};  // track 16 index
char buffer1[6]={"00003"};   // track 1 index
char buffer2[6]={"00004"};   // track 2 index
char buffer3[6]={"00005"};   // track 3 index
char buffer4[6]={"00006"};   // track 4 index
char buffer5[6]={"00007"};   // track 5 index
char buffer6[6]={"00008"};   // track 6 index
char buffer7[6]={"00009"};   // track 7 index
char buffer8[6]={"00010"};   // track 8 index
char buffer9[6]={"00011"};   // track 9 index
char buffer10[6]={"00012"};  // track 10 index
char buffer14[6]={"00013"};  // track 14 index


Open in new window

How can I access these mp3files via filename not index
Hello everyone.

I've seen that what I'm trying to do which is monitoring the file IO require the use of Window File System Filter driver and I've also looked into it but was a bit hard to understands especially as I'm not a C++ developer. What I want to achieve is to be able to trap file copy, creation, as well as file sources and destinations, lets say I'm copying a file within my computer I want to get the source path of the file as well as destination path of the file and also the file name as well and if possible with the application that is sending the file.

I saw that this can also inform you if there is file access(opening of file, reading of file) this is very much important to me to also get it if possible while the request of file open is created. I wan to trap this and if the file is one of my file then I want to first work on the requested file first (decrypt).

Thank you.
Want to be a Web Developer? Get Certified Today!
Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Hi Experts,

         I have a alpha numeric text of length (4096 to 8192)Bytes. I need a compression algorithm to compress and decompress text length upto (128 to 256)Bytes.

I have already tried some compression methods but not able to compress text upto (128 to 256)Bytes .
(eg: Zip.)

To perform this job we need only compression method not hash value.

Thanks In advance
language : c++
(tools : visual studio , acrobat reader)
thanks a lot
I had this question after viewing C++ COM Method with Optional Arguments.

I am trying to produce a COM object in Visual C++, where one of the methods accepts optional arguments. Below are the interface declaration, the class implementing the interface, and the implementation of the method taking an optional argument. As it stands, it compiles. But when I try to call the function from an ASP page using VBS with the supposedly optional parameter missing, I get the following error

Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: comObject.ShowFinalSql

Following code in IDL
interface IWPharma : IDispatch{
   [id(2), helpstring("method ShowFinalSql")] HRESULT ShowFinalSql([in] BSTR query, [in] BSTR cleanup);

in C++:
    STDMETHOD(ShowFinalSql)(BSTR query, BSTR cleanup) override

in VB with error:
SET comObject = CreateObject("WPharma.Main")

REM Тест #1
comObject.ShowFinalSql "CHECK_SIGNATURES 01/01/2017", ""
Let's say you have a COM interface,IWebBrowser2, it has a function, it has a function Navigate, Is there anyway that I can hook to this function, like I hook CreateProcess function in kernel32.dll?

Thank you for any help.

I have a problem with custom templates not creating solutions correctly. It works fine on my Home computer but not on my office computer. I have reinstalled VS 2015 several times but problem remains. The issue is the "Location" and "Solution Name" dialog are not visible nor are the "Create directory for solution" or "add source to control" checkboxes and browse button.

Below is an example of what happens and below is one of the template files (this effects several new project templates under c++).

If I select New -> Visual C++ -> Empty Project, I get the following dialog at bottom of window (You can see that "Location Field" is Enabled and yet it does not show when I create a new project)

Name: Project 1
Location: C;\users\david\visual studio 2015\projects
Solution Name : Project 1
Also a "Browse" button, "Create directory for solution" checkbox and "add to source control" checkbox.

If I select New -> Visual C++ -> Particle Project (which is one of the custom projects) I get

Name : Sketch1

All the other dialogs and checkboxes are missing.

BUT, When I am on my computer at HOME, I see all the correct solution name, location and checkboxes ok, but NOT on my OFFICE computer.

I am sure it is related to some setting in a file somewhere that is overriding the parameters for the VM template but don't know which file will be controlling this behavior.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" …
My work Environment :Qt 5.8 MSVC2015 64bit, QT GraphicsView, QGraphicsRectItem, Windows 7 64 bit.

Issues : When I zoom in & zoom out on GraphicsView, I call GraphicsView scale method. But When I add QGraphicsRectItem to scene it failed to call its paint method.

my class hierachy :

  class GraphicsView : public QGraphicsView
  class mySquare : public QObject, public QGraphicsRectItem
  class Scene : public QGraphicsScene 

Open in new window

Code :

//////*****Draw Rect in QGraphicsRectItem *****////////////

void mySquare::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
      QRectF rect(0,0,_width,_height);

Open in new window

 void GraphicsView::wheelEvent(QWheelEvent * event)
    int angle = event->angleDelta().y(); // angle will tell you zoom in or out.
    double scaleFactor = 1.15; //How fast we zoom
    if (angle > 0)
        qDebug()<<"Zoom in";
        scale(scaleFactor, scaleFactor);
        qDebug()<<"Zoom out";
        scale(1.0 / scaleFactor, 1.0 / scaleFactor);
        mySquare  _square = new mySquare(0,blankImage);
       _square->setPos(QPointF(0, 0));
       //add square to scene. 
] //Bug!!! Why after scale function call, _square failed to draw rect in paint method.
]        _scene->addItem(_square);

Open in new window

My git gitcode
I spend days & hours but still not able to find out why it QGraphicsRectItem failed to print, when scale method get called. Any suggestion is highly appreciated ?
Hi All,

I want to change the face color of property sheet wizard button. The wizard has ID_WIZNEXT, ID_WIZFINISH and other default button. the button label and position is changed. i want to change the color of this default button.

class CDiskSanPropertySheet : public CPropertySheet

BOOL CDiskSanPropertySheet::OnInitDialog()

        CButton *tmpButtonNext = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZNEXT));
      CButton *tmpButtonFinish = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZFINISH));
      CButton *tmpButtonBack = reinterpret_cast<CButton *>(GetDlgItem(ID_WIZBACK));
      CButton *tmpButtonCancel = reinterpret_cast<CButton *>(GetDlgItem(IDCANCEL));


        LONG rightPos, nextRightPos;
      //inc. to 1.7 for greek issue
      MoveButton(tmpButtonCancel,shiftFactorX, 1.7,NULL,tmpButtonNext,&nextRightPos);
      MoveButton(tmpButtonFinish,shiftFactorX, 1.7,NULL,NULL,NULL);

      rightPos = nextRightPos;

      MoveButton(tmpButtonNext,shiftFactorX, 1.7,&rightPos,tmpButtonBack,&nextRightPos);
      rightPos = nextRightPos;
      MoveButton(tmpButtonBack,shiftFactorX, 1.7,&rightPos,NULL,NULL);


HBRUSH CDiskSanPropertySheet::OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor)
    HBRUSH hbr = CPropertySheet::OnCtlColor(pDC,pWnd, nCtlColor);

    COLORREF myColor = …
I installed C++ builder 6.0 on windows 10.
when I reopen a project , my working directory don't change to new project path and my new forms create on the directory that last time I used "FILE->Open Project" method.
if every body knows how can say to it change to the project path after reopen .
-- thanks reza
Hi guys.

I have Form1.h and Test.cpp files in my project which was generated by VS. I have around 5 functions in my Test.cpp file and each function has to update the label with its result. I've made the label1 public on my Form1.h file and with this solution I am now able to write to the label1 outside the h file, I mean I can write to the label1 from .cpp file but only when the application is starting up or should I say only from the main function. I've used the solution provided on this post here and now my problem is that I can not use the same approach on other 5 to 6 functions as this approach also uses the

Open in new window

which I don't think is appropriate to keep calling this from each and every function that needs to update the label.

The updates are based on the App returned results for each and every function its execute.
Introducing Priority Question
Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Hello I'm using C++ builder 10 and I need to bold (highlight) the last value that comes into advmemo from  advcombobox/advedit.
Maybe somehow with using AdvMemo->SyntaxStyles->HighlightStyle?
This question is for Visual C++ MFC application in Visual Studio Community 2015 under Windiws 7.

When you set some text in multi line CEdit box in OnInitDialog function, that is called to initialize dialog's controls. the text is displayed as selected (highlighted.) No manipulations with CEdit interface in OnInitDialog can't remove this highlighting (Like using SetSel(-1,0).)  
Somebody knows how to initialize CEdit with no selection?
I have a USB UP-90 phone which appears to just use Windows drivers for 'speakers' and a 'microphone'.

http://www.made-in-china.com/showroom/hedychan/product-detailCHmxnUQDmEKV/China-USB-Phone-UP-90-.html is the USB phone.

https://www.voiptalk.org/products/pdf/usb_phone_manual.pdf is the manual and it comes with its own software.

The software is very simple, where you select the software you use. It is compatible with Skype, X-Lite and other software. It appears this software is written in C++ and from what I can see all it does is macro certain packets from the USB device to the selected software.

I am trying to get this USB phone to be compatible with a software named PhonerLite. I used a program to rename the window title of PhonerLite to X-Lite, so the phone software thinks PhonerLite is X-Lite and therefore transmits those packets to PhonerLite.

This is a relatively good solution as when I pick up the USB phone from its hook, it will open the software and instantly I can hear the dial tone and will close the software when phone is put back on hook.

There is, unfortunately, some incompatibilities though (as expected, seeing as it's a completely different software to X-Lite). The keypad doesn't work and call will not automatically answer when picking up the phone from the hook.

Does anyone know of any software that would be compatible with this USB phone that could replace the software that comes with it? As it seems pretty limited and, if I can sniff …
I'm beginner in openGL , How can i change my object from smiley face to sad face then surprise face using the time?

I try to load my driver with following code..

	bool rt = Privilege(L"SeLoadDriverPrivilege",true); // I got SeLoadDriverPrivilege privilege

	HINSTANCE hDll = LoadLibrary(_T("c:\\windows\\system32\\ntdll.dll"));
	*(FARPROC *)&NtLoadDriver = GetProcAddress(hDll, "NtLoadDriver");
	_LSA_UNICODE_STRING drv = toLsaUnicodeString(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\\DemoDriver32");
	NTSTATUS ntStatus = NtLoadDriver(&drv); // --> returns 0xC0000033

Open in new window

Registry of "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\\DemoDriver32" includes followings..

ErrorControl  1
ImagePath     full_path_to_my_driver --> exists and signed both 32&64
Start  3
Type  1
Group  base

Any hints welcome
I've just installed Visual Studio 2015, in order to rely on it's Diagnostic Tools, to find memory leak in my C++ x64 Console application.
The tools work fine except the fact that taking a snapshot the heap view always show only unresolved allocations. The code is compiled with debug flags enabled, but not using a CRT debug version, due to compatibility issue with other dll used by the program. Is there a way to see in heap view the type and the content of each allocation?






C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.