C/C++ :: Debug Executable That Needs Flags

Mar 20, 2015

I'm trying to step through the machine instructions of a c program. This program needs to be run with a -t flag.

This is what I tried
gdbtui
file prog
layout asm
start
stepi

When I try 'file prog -t' it doesn't work.

View 4 Replies


ADVERTISEMENT

C :: Setting Flags In 32-bit Integer?

Oct 18, 2013

I am trying to create the lparam for the WM_KEYDOWN message. I know this is the C programming forum, but my code is standard enough to apply here. According to Microsoft, the lparam must be formatted like this : lParam The repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown following. Bits Meaning 0-15 The repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent.

However, the repeat count is not cumulative. 16-23 The scan code. The value depends on the OEM. 24 Indicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 The context code. The value is always 0 for a WM_KEYDOWN message. 30 The previous key state.

The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 The transition state. The value is always 0 for a WM_KEYDOWN message. ( WM_KEYDOWN message (Windows) )^ I'm troubled by setting it into the 32-bit value, and I get confused about what exactly happens when the logical or and the bitshift operators are used. I tried to use them below in my code by looking at Stack Overflow for setting a bit. I also don't know how to test for the endianess of my system, and how to handle it if it's big endian or little endian. Here is my code so far :

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

[Code].....

View 2 Replies View Related

C++ :: Using Resources In Executable?

Sep 8, 2014

i have seen a lot of programs that have images inside their exe, dont use external ones. I tried to add image in my codeblocks project, but trying to use it failed. It seems that to use a resource i have to add some kind of header file, but how to do this???

View 2 Replies View Related

C/C++ :: Executable Performance When Using TCHAR

Aug 16, 2014

I have started to move over to using Unicode, wide character null-terminated strings in my Windows programmes. Accordingly I set the Use Unicode Character Set Visual C++ compiler option. It is my understanding that once you do that the many macros which determine whether you transparently call ...A() or ...W() API functions automatically shift over to calling the wide character variants. As this is a compiler directive, all the choices are made and hardcoded in to the resultant executable at compile/link-time BEFORE it is ever run. Therefore using for example the macro OpenFileName() in the source code instead of specifically calling OpenFileNameW() has no impact on run-time performance.

The next logical step, instead of explicitly using wchar_t is to declare null-terminated string character arrays as TCHAR*. Then, so long as I also employ the tcn... variants of CRT string functions and call TEXT() or _T() macros to create string literals the preprocessor will chose, again transparently whether to create an executable using standard multibyte or unicode wide characters - and their associated functions - all determined by the Use Unicode Character Set switch. That way I can cover both eventualities with the same source code.

So, with all that - I THINK!!! - properly under by belt, I am fairly sure that using TCHAR and its friends will not effect run-time performance at all. However, in his otherwise excellent article the author makes it sound as if using Unicode EXPLICITLY through wchar_t, ...W() API functions and tcn... CRT calls is faster than the TCHAR alternative.

At the end of the day my question is - have I got the right end of the stick; TCHAR makes no difference to executable performance?

View 4 Replies View Related

C++ :: GUI That Will Allow User To Conveniently Invoke Executable

Feb 12, 2013

I use g++ compiler and need some tips on how to get started with making a c++ GUI. The project I have will need a gui that will allow the user to conveniently invoke executable (the command-line args they take are long and inconvenient to enter manually) and basically print their output streams into a control (e.g. read only textbox). There will be a few graphics involved too (the input for those graphics will be from a file), so I'll need a library that will allow drawLine methods (nothing too fancy, I don't need a gaming library).

Making a GUI in c++. In Java the ability to make a GUI is a part of the native library, so the c++ way seems foreign to me.

View 2 Replies View Related

Visual C++ :: Prevent Executable From Running?

Aug 30, 2013

I would like to programmatically monitor a directory for new files, and if the file happens to be an executable, I want to prevent it from running. Something like a AV program.

However, I don't know where to start. Simple is best.

View 9 Replies View Related

C++ :: Sharing A Program - Sending Executable Files

May 22, 2013

I am just wondering if it is possible to send a project to someone via email - In a simple way, almost like you would install software from the internet, maybe a setup file, or something. The compiler I use "Dev C++" creates a .cpp file and an executable. Unfortunately, I cannot send that .exe file. How would you recommend sharing a program?

View 5 Replies View Related

C/C++ :: Eclipse Terminating Executable After Adding A Bit Of Code

Feb 3, 2014

I have the following code

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath){
std::ifstream input(filePath.c_str());

[Code] ....

When I run it in Eclipse, it does not open an SDL window, and simply says <Terminated> Test.exe [C/C++ Application]. I can build the project successfully, but it simply won't run. There are no errors displayed.

HOWEVER, if I replace the above code with the code below, it runs fine, and creates an SDL window.

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath) {
std::string output;
return output;
}

To make things weirder, if I run it in debug mode, even with the first piece of code, it will run and open an SDL window.

On an unrelated note, what does " Can't find a source file at "e:pgiawsrcpkgmingwrt-4.0.3-1-mingw32-srcld/../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/main.c"

Locate the file or edit the source lookup path to include its location." mean? I am using Windows 8, MinGW, GDB 7.6.1-1, G++ 4.8.1-4, and MSYS 1.0.1 with Eclipse CDT.

View 3 Replies View Related

C++ :: How To Create Final Executable File That Can Upload For Users

Feb 16, 2013

I develop a software using QT 5 open source IDE. Now my question is two-fold:

1. How can I create the final executable file that I can upload for my users? I understand that runtime DLLs shall be required and I have tried Enigma Virtual Box software for bundling runtime files. It does create the file that I can execute from any folder in my PC. However, surprisingly when I transfer that "boxed" file to another PC, it does not run. Both the PCs have Windows 7 installed on them.

2. Secondly, I see possible future issues with Antivirus Softwares. Apparently when I try to run the boxed exe file, it gets rejected by the Antivirus Software on my PC. Is there a way in which I can get my exe file verified/checked/registered by the Antivirus Softwares so that my users don't face any problems in executing the program.

I cannot afford the QT commercial licence, but I am prepared to buy any economical "setup file generating" software (if it exists).

View 1 Replies View Related

C++ :: Parse Executable Files - Registering Types To Be Used At Runtime

Jul 30, 2014

I'm writing a program that needs to parse executable files. I've got an "executable" base-class, and currently an "elf" class which inherits from it for parsing ELF files, and I will add more parsers (COM, MZ, PE, a.out, MACH-O, whatever) later on.

I want the program to automatically detect which kind of executable it's loading at runtime. It should be easy because every executable format I'm aware of/plan to support starts with a magic number. But because I can't have the parsers not check the file type (what if I re-use the code?), and I don't want to check each file twice (not just for performance, but also because only the ELF parser should know that ELF files start with "x7fELF", etc.) so I've come up with a pretty lazy solution: just try to parse the file with each known parser and have them throw an exception ("exe_type_error") if they can't parse it. If that exception gets thrown, try the next parser; if not, stop.

The remaining problem is how, at runtime, my program will know what parsers are available. I don't want to hard-code it in the main function; instead, I'd like the parsers to "register" themselves as available. That way, if I decide to go down the route of adding new parsers via dynamic linking, I will only have to add an API for dynamic libraries to register their parser, without recompiling any of the main program's code. I also want to do the same thing for another key part of the program (it's a static executable optimizer; it will run a series of "tests" (e.g. "is xor eax, eax faster than mov eax, 0 on this machine?") and optimizations ("if yes, change all mov eax, 0 to xor eax, eax") and I want to load those at runtime too).

View 11 Replies View Related

C++ :: ReadFile Function Cannot Read Entire Executable File

Mar 30, 2014

I am writing a program which compresses files into .zip files.

Here's my problem: Whenever I want to compress an executable file, my readFile function does not read the entire file. When I extract the .exe I get a very tiny and incomplete file.

Here's the function I use to read files:

std::string miniz_wrapper::readFile(FILE* f, int MAX_FILEBUFFER)
//MAX_FILEBUFFER has a default value of 65536 {
char* tmp;
std::string tmp_s;
int count = 0;

[Code] .....

Prior to reading, every file is opened using fopen with the mode "rb".

View 6 Replies View Related

C++ :: Reducing The Size Of A Compiled Executable For Easier Distribution?

Jun 19, 2014

I am looking at reducing the size of a compiled executable for easier distribution.

What factors affect the size of an output executable?

Would literally having defined and implemented less functions, would make the exec. smaller? Meaning that instead of have a DLL ( yes im on windows ), I would download the source code of a library and comment out the functions ( and code ) that I am not using -- Would this process decrease the size of my exec.?

View 2 Replies View Related

C++ :: Sending Dynamic Allocated 2D Array Over Named Pipe Between 2 Executable

Oct 6, 2014

Im writing a scientific software where I like to sent a 2D array (5x4) over a named pipe from a server to a client. When im sending a static array (i.e., double res[5][4];), all goes fine and it works perfect, but when I allocate a dynamic array, it provides some nonsense numbers at the client side. I feel it might be caused because I point to a memory that cannot be shared through a pipe. Am I right and how can I pass the dynamic allocated array itself over the pipe.

//Server program

// Create a pipe to send/receive data
HANDLE pipe = CreateNamedPipe(
"\.pipemy_pipe", // name of the pipe
PIPE_ACCESS_DUPLEX, // 2-way pipe -- send and read
PIPE_TYPE_BYTE, // send data as a byte stream
1, // only allow 1 instance of this pipe
0, // no outbound buffer

[Code] .....

View 2 Replies View Related

C++ :: Turn Binary File Data Into Unsigned Character Array For Inclusion In Executable

Jul 10, 2013

So I wrote a program to turn a binary file's data into an unsigned character array for inclusion in an executable. It works just super.

I'm wondering how I can write a program that will perform this operation on every file in a directory and all it's sub-directories so that I can I can include everything I need all at ounce.

View 9 Replies View Related

C++ :: Coding And Debug Time Per LOC

Mar 23, 2013

I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:

Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;

[code].....

I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.

So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?

View 3 Replies View Related

C/C++ :: Debug Log Size Restrictions?

Dec 26, 2012

Iam creating one debug log in my c++ application through the below code.

file *log;
log = fopen("C:snmpApplicationlog.txt", "w");  

iam writing the statements in to this log by using fprintf(). As the .exe where i have put this mechanism runs continuously,the size of log file is increasing gradually.

1)If there is any way to restrict the Log file size,if the file reaches the mentioned size,the file should be discarded and logging should be done in another file with the same name.

{OR}

2)Put a time interval,once after that interval is elapsed, a new log file should be created.

View 1 Replies View Related

C++ :: Errors When Trying To Debug The Code (SFML)

May 22, 2014

I'm currently just trying C++ with SFML. So I've installe SFML 2.0 for Visual C++ 2010 Express 64 bit, and I get an error while trying to run the debug of my code.

//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720),"SFML Game1");
return 0;
}

And this is the result I'm getting when trying to run it

1
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 3 Replies View Related

Visual C++ :: How To Recover Debug Symbols

Oct 6, 2013

The breakpoints I am setting are not caught by the IDE. Any how I can recover that.

I used to know I can delete the sdf file and rebuild. Just to make sure...

View 4 Replies View Related

C++ :: Vector Iterators Incompatible In Debug Mode

Jul 11, 2013

I get this error when i try to run this code for an inventory in debug mode in VS. But for some reason it works just fine in release mode.

void Push_Back_Item(Item *item){
for(int y = 0; y < InvSizeY; y ++)
for(int x = 0; x < InvSizeX; x ++){
auto Iter = ItemList.find(std::make_pair(x,y));
if(Iter != ItemList.end()){
item->SetDead(); // ERROR
}
}
}

This isnt the full code though but it still gives me the same error.

The only thing "item->SetDead()" does is to set a bool to true.

This is the map i get the iterator from
std::map<std::pair<int,int>,Item*> ItemList;

This have been bugging me for quite some time now.

View 4 Replies View Related

C++ :: Program Works In Release Mode Not In Debug?

Feb 20, 2013

i've got an assigment that requires me to overload some operators and add some objects together.

I will show the code and explain as good as I can.

void SArray::operator+= (const SArray &obj)
{
Sphere * tmp_arr;
tmp_arr = new Sphere[obj.antalobjekt+this->antalobjekt]; //antalobjekt = //Gets amount of elements in the arrays.

[Code]......

m_arr is the inner array for storing elements, do ask if something is not clear enough. The copy constructor works, so i have not included it.

View 1 Replies View Related

C++ :: Debug Multithreaded Application In Unix Environment?

Mar 3, 2013

How can we debug the multithreaded application in unix environment?

View 1 Replies View Related

C++ :: Debug Error When Deleting Dynamic Array

Feb 18, 2013

I get this error when I'm attempting to delete an array. I'm new to dynamic arrays, and from what I have learned, arrays must be deleted after use. I plan on using this in a function later on, so deleting the array is a must.

Here's the error message: Debug Error!

HEAP CORRUPTION DETECTED: after Normal block (#154) at 0x007E55A0.
CRT detected that the application wrote to memory after the end of heap buffer.

Here's my code:
int main() {
//Declare variables
char persist = ' ';
int* primes = NULL;
int size2 = 0;

//Declare array
primes = new int[size2];

[Code] ....

View 3 Replies View Related

C/C++ :: How To Debug Error Saying Illegal Structure Operation

Dec 20, 2013

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class complex {
int real,imag;

[Code] .....

View 2 Replies View Related

Visual C++ :: Debug Assertion Failed With MessageBox

Mar 22, 2014

I am trying to use MessageBox in OnInitialUpdate function but its giving me "Debug Assertion Failed Message"

File: f:ddvctoolscrt_bldself_x86crtsrcvsprintf.c
Line:244

I am using the following code:

Code:
void CRotateImageView::OnInitialUpdate() {
int k;char str[2];
CView::OnInitialUpdate();
CString szStr,szstr1;

[Code] .....

However when i am using the same code in OnDraw its working.

Code:
void Csprintf_sEGView::OnDraw(CDC* /*pDC*/) {
Csprintf_sEGDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;

[Code] ....

View 3 Replies View Related

Visual C++ :: How To Debug Win32 Message Loop

Sep 28, 2014

You place a breakpoint at one of locations within the message loop. But I want the breakpoint to trigger when I click on the application window, for example. But I can't, it went so fast so long as I switch from VS to the application program, the breakpoint is hitted again, then the application is frozen again. I don't know how to setup a conditional breakpoint.

View 3 Replies View Related

Visual C++ :: Does Not Contain Debug Information - Press OK To Continue

Sep 18, 2012

i changed my code from release to debug mode. when i try to debug it shows a dialog box that '... does not contain debug information press ok to continue"..

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved