Convert c to c++

This is a discussion on Convert c to c++ within the C++ Programming forums, part of the General Programming Boards category; The code you have yields undefined behaviour, as you're writing to a specific address. That tends to make things break ...

  1. #16
    Registered User
    Join Date
    May 2010
    Posts
    15
    The code you have yields undefined behaviour, as you're writing to a specific address. That tends to make things break when you change compilers or compiler settings
    Its nothing to do with compilers.
    let alone change languages (C to C++)
    I figure that in C++ my code needs to be modified in order to work correctly that is why I posted this thread.

    Given that you are clearly doing a hack (I'm guessing cheating in a game or bypassing some program's registration checks), I'm guessing this thread - or your objective at any rate - is against site rules here
    Don’t just assume that I have bad/illegal intentions, when DLL injection could be helpful in various ways without compromising any legal rights.

  2. #17
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Alex; consider this a help-free post but looking at your code snippet reminds me of why I am glad I don't have to code DLLs anymore. In Unix you don't have *any* of that nonsense; to create the Unix version of a DLL (a shared object in our parlance) you just put functions/classes/whatever in a file and compile it with some basic switches for things like position independent code, telling GCC to make a shared object, etc. The point I am making is that you don't have to do anything special to your code to make it work, regardless if it is a static lib, a shared object (dynamically loadable and everything) or a plain old executable. No DllMain(), no import/export defines, etc. I know, this doesn't help your situation; its just that I am at this moment writing some shared objects for work and am SO glad I don't have to do that stuff. As for your code, it looks like it was written for the Win3.1 era SDK; is that correct? If so I do recall C++ objects having issues with DLLs (either certain types existing within them or passing them in and out or something like that). Still I know this doesn't help so I will wait for Elysia or Neo or one of the other Redmond-ites to help you or for the inevitable "you should write this in .NET" suggestion. I will get back to cranking out code.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #18
    Registered User
    Join Date
    Jun 2005
    Posts
    5,830
    Quote Originally Posted by AlexWu View Post
    Its nothing to do with compilers.

    I figure that in C++ my code needs to be modified in order to work correctly that is why I posted this thread.
    Undefined behaviour has everything to do with compilers, as it refers to specific instances where the C and C++ standards specifically allow compilers and libraries to do anything, without restriction.

    Quote Originally Posted by AlexWu View Post
    Donít just assume that I have bad/illegal intentions, when DLL injection could be helpful in various ways without compromising any legal rights.
    Yeah, right. An injected DLL with code that repeatedly reads and overwrites a specific memory location in a program is not attempting to subvert functioning of that program. I believe in the Easter Bunny too.

    In C, a function declaration is not required before calling it. In C++, it is. So add a valid declaration of the sleep() function.

    In any event, if the code is not compiling, it might pay to actually let people know what the error message is. If the code is compiling and not working, it would pay to characterise what you consider to be "working" and what you are actually observing.
    Right 98% of the time, and don't care about the other 3%.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [33.8] Can I convert a pointer-to-function to a void*?
    By EVOEx in forum C++ Programming
    Replies: 40
    Last Post: 08-19-2009, 07:50 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 3
    Last Post: 08-21-2006, 06:42 AM
  4. Convert Char to Int Function
    By drdroid in forum C++ Programming
    Replies: 9
    Last Post: 02-19-2003, 11:53 AM
  5. please help ... to convert date to string
    By mel in forum C Programming
    Replies: 1
    Last Post: 06-12-2002, 10:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21