|
Thought it was a 63 bit issue but its not
As both wparam and lparam translate to 64 bit values
Thanks
|
|
|
|
|
|
Both wparam and lparam are translated to
'64 bit so
|
|
|
|
|
so what ?
It might be just a symptom of a lot of other problems.
Can you post a minimal working code snippet ?
Nihil obstat
|
|
|
|
|
Thank you
Ill do it later tonite I'm on EST and will be
Home at 11 the code from which I am doing
The SendMessage is in a worker thread
I attach the window handle to a CWnd object
And do a SendMessage
Ill post the code shortly thanks again
|
|
|
|
|
The following is the code that's giving me the exception
CWnd *windowptr = new CWnd;
windowptr->Attach(main_app->mybaseeventptr->windows_handle);
windowptr->AssertValid();
main_app = (CHERC_CMDApp *)AfxGetApp();
my_event = main_app->mybaseeventptr;
my_event->len = 30;
ret = windowptr->SendMessage(WM_HERCGUI_MESS,(WPARAM) my_event->len,(LPARAM) my_event->buffer_ptr);
|
|
|
|
|
Great, but which line (and value) is giving the exception?
Use the best guess
|
|
|
|
|
|
CWnd *windowptr = new CWnd;
windowptr->Attach(main_app->mybaseeventptr->windows_handle);
You are using pointers without initialising them; no wonder you get exceptions.
Use the best guess
|
|
|
|
|
ForNow wrote: CWnd *windowptr = new CWnd;
windowptr->Attach(main_app->mybaseeventptr->windows_handle);
Is this allowed when calling from another thread ? will this not break the messaging ?
Nihil obstat
|
|
|
|
|
This looks really messy.
You are using main_app before assingning AfxGetApp() . Is it assigned somewhere else? If not, you may get the exception here.
Also (inspired my Maximiliens post), why not just send the message using the API function passing a HWND ?
|
|
|
|
|
ForNow wrote: ret = windowptr->SendMessage(WM_HERCGUI_MESS,(WPARAM) my_event->len,(LPARAM) my_event->buffer_ptr); What are the values of windowptr , my_event->len , and my_event->buffer_ptr ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi,
I want to understand Stack, Heap and other Memory management in C++ in detail.
How stack and heap are managed, how and when memory gets allocated from these areas.
Any good book or any good tutorial about this.?
Regards,
Mbatra
|
|
|
|
|
Stack is place where local variables are allocated.( C++ run time environment is managing memory for the program) allocation and deallocation will be done by c++ runtime environment.
Heap is place when you allocated memory dynamically. ( that means you are managing memory for your variables) you have deallocate the memory.
Above is the fair difference about stack and heap
i would recommend Programming Application for Microsoft windows by Jeffery Richter. ( if you are targeting your c++ to windows environment)
|
|
|
|
|
Vijjuuu. wrote: allocation and deallocation will be done by c++ runtime environment.
There isnt a C++ run time, it is not C# or some other Java variant, so the stack allocation is managed by your code when it calls push and ret. (Ever looked at what your C++ code does in asenbler?)
Heap of course is allocated by calls to malloc and free, or new and delete, or any of the other heap managemet funcs.
You should probably mention static memory too, very usefull and often overlooked.
==============================
Nothing to say.
|
|
|
|
|
Have you tried this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Stack memory is managed by your code when it calls push and ret which decrement and increment the stack pointer respectively. (This is of course assembler, which is what your C code ends up as).
Heap is allocated and deallocated respectively by calls to malloc and free, or new and delete, or any of the other heap managemet funcs.
You should be aware of static memory too. It is allocated for the program when it loads, and contains all the variables you declare as static and all global variables. It also contains all the strings you declare in your code, such as char data[] = "my string". Have a shufti here: http://en.wikipedia.org/wiki/Data_segment[^]
==============================
Nothing to say.
|
|
|
|
|
Hey,
I've asked this question on Stack Overflow, as you probably have seen if you're active there, but they said my project was illegal therefore nobody helped me (though, I proved them there are lots of projects like mine) - my project is just about injecting a piece of code into a game (namely Grand Theft Auto VC) to create a big mod (multiplayer, I wouldn't like to say my current ideas just for the sake of not getting stolen, though sooner or later when I release the project there will be someone who will copy some of them anyway; and I think that's not necessary either).
Through the development process of the project, I came up with some questions:
1. Is it better to use Assembly to call a pointer returned by
GetProcAddress or type cast it and call it directly from C++?
__asm call pointer
vs
typedef int (*DOWINMAIN) ( HINSTANCE, HINSTANCE, LPSTR, int );
DOWINMAIN pDoWinMain = (DOWINMAIN)GetProcAddress ( hModule, "DoWinMain" );
2. As I mentioned above, my project is based on code injection, the thing is: DEP (Data Execution Prevention) doesn't let the program edit the game's memory, unless I, of course, disable it. Is there a way to inject the code without DEP caughing the program or do I really have to disable DEP definitely? Can that be made in C++ or do the users have to manually disable it?
Thanks for reading 
|
|
|
|
|
Though i don't support idea of injecting code in different application. however you may require it create different feature available in application, which don't expose plugin or support extensiblity.
However it totally depends on person's ethics. since if not coded properly or poorly its may result in bad then good.
ixjf wrote: DEP (Data Execution Prevention) doesn't let the program edit the game's memory, unless I, of course, disable it. Is there a way to inject the code without DEP caughing the program or do I really have to disable DEP definitely? Can that be made in C++ or do the users have to manually disable it?
I doubt that, I believe user should know this before actually confirming it. also it keep your app on high moral ground. since i believe you are not making virus.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I'm not, I can even give you the link to my repository so you can see the code (I haven't uploaded the new code, that one is old and gay ahah).
Repo is here: https://bitbucket.org/ixjf/vice-city-orange/overview[^]
I'll upload the new code ASAP, I know this code doesn't show you much, but I'll keep adding new code and you'll see.
As for the DEP, I think it's quite painful to have to disable DEP for the program, even though the user should know it needs that, and I know some softwares disabled DEP automatically (e.g. MTA:SA (another MP)) and I would like to know how could I do it (perhaps I could leave a message to the user saying DEP will be disabled for the software because..?)
|
|
|
|
|
ixjf wrote: s for the DEP, I think it's quite painful to have to disable DEP for the program, even though the user should know it needs that, and I know some softwares disabled DEP automatically (e.g. MTA:SA (another MP)) and I would like to know how could I do it (perhaps I could leave a message to the user saying DEP will be disabled for the software because..?)
better leave choice to user then you doing for them. also this will reduce complexity in your program
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ixjf wrote: I think it's quite painful to have to disable DEP for the program
and i think it's pretty sh*tty that a program would try to do that without telling me.
|
|
|
|
|
Whatever, it's your opinion.
Anyway, let's leave that question aside. Can somebody answer my 1st question?
|
|
|
|
|
Better compiler decide for the assembly code then you! , though performance wise direct assembly code is good, however it make program difficult to understand, if some other user is working on that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I doubt you will get much help from CP users either.
Disabling DEP, either globally or on individual applications, has to be done by the end user.
|
|
|
|