|
Hi, all
I am trying to write a little experiment program where it is supposed to copy a function (the bytecode) during runtime. But I have encountered a problem, which seems to be VC++ fault (at least in debug mode). Whenever you want a function reference, VC++ gives you a different memory location than the where actual function is located. VC++ gives you a location of a jump instruction, which jumps to the actual function. But because I want the exact functions location in memory I am experiencing a problem. I hope you understood my problem (if not please reply, so I can clarify my self). Any ideas on how to avoid the problem with getting the wrong location?
Thanks in Advance
Aidman » over and out
We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.
|
|
|
|
|
Is the function you are copying inside a DLL?
John
|
|
|
|
|
nop, a regular exe
Aidman » over and out
We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.
|
|
|
|
|
I brought this up because I know dlls use a lot of JMP instructions into the actual code. The thing is that this is perfectly legal but not what you would expect. You may have to play with the compiler settings to turn off that feature.
John
|
|
|
|
|
Not sure if this will disable it in Debug mode, but you can try turning off the "Link incrementally" option on the Linker tab of the project settings. However, it may be that in debug mode it always uses the jmp instruction, regardless of the setting, so it can link faster.
Chris Richardson Terrain Software
|
|
|
|
|
Thanks man! That did the trick
Aidman » over and out
We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.
|
|
|
|
|
I am updating old code and came across a marco that is causing a few thousand warnings in my debugging. I was hoping that one of you could help me understand how to get rid of these warnings.
The Macro is:
#define CNULL(a, b) ((V_VT(&(a)) == VT_NULL) ? b : a)
The code to call it is:
CString name = CNULL(f->Item[_T("StationName")]->Value, btEmpty).bstrVal;
where
f->Item[_T("StationName")]->Value is a BSTR wrapped as a _variant_t
btEmpty is a blank BSTR
I get "warning C4238: nonstandard extension used : class rvalue used as lvalue"
However, I get no warning when I do:
_variant_t tmp = f->Item[_T("StationName")]->Value;
CString name = CNULL(tmp, btEmpty).bstrVal;
Does Anybody know how I can form my macro to not get this warning?
Thanks
Rob Pellegrini
|
|
|
|
|
Hi,
I'm attempting to write an improved file packer for a game package. (The one I already created extracts the game files from an archive to the hard-drive before running the game, which is obviously very insecure.) Essentially, what I want to do is use a compressed .zip file as though it were a regular Windows directory - in other words, to run the game from inside the .zip file without unpacking it - is this possible?
Eg. I would compress all the game files into a zip file. Then I would like to write the code for an executable that could run the game from inside the zip file without needing to extract all of the files to a temporary directory on the hard-drive first. (By password-protecting the zip file it would have some very low-level protection, which is all I really need.)
I have seen something about "mounting" zip files, "virtual file systems" and transparently opening files elsewhere, but I'm not sure if this is what I need or where to start (obviously I don't want my users to be able to see the files inside the zip unless they open it with a zip program) - I am a novice when it comes to programming, and my only experience is with the WinAPI, which is what I would prefer to stick with.
If anyone can point me in the right direction - or even better, towards a library that will suit my needs - I would be eternally grateful.
Many thanks,
KB
|
|
|
|
|
From what I have heard password protected zip files are easily cracked if you have the right software and a fast cpu...
John
|
|
|
|
|
I'm not too concerned about this - the average user won't be able to crack it, and pretty much any file packer with low-level protection can be cracked. I'm more interested in archiving the files to take up less space on the disk and running them without the need to extract them; that the average Joe won't be able to mess around with (or mess up) the files is an added bonus.
Does anybody know of a way to do this? (Other file packing suggestions are welcome too, though I quite like the Zip process as it saves me writing a packer.)
Many thanks,
KB
|
|
|
|
|
code a loader program, which extracts the zip file to memory, and then include a module in your program, which extracts and loads game data to memory!
Don't try it, just do it!
|
|
|
|
|
Thanks for the reply, but easier said than done!
I have been using the ZipArchive library from www.artpol-software.com so far, but I have no idea how to make the transition from extracting files to the hard-drive and then using ShellExecute() to launch the extracted game EXE (my current method) to extracting all the files to memory and running them from there (and bear in mind that the main game executable relies on a number of the other files that have to be extracted).
If anyone could provide some links to useful libraries or tutorials with code, or tell me the sorts of things I would need to do so that I can look them up, I would be really grateful.
Like I say, I am a novice who has only really used the basic WinAPI, so this is a very steep learning curve for me.
Many thanks!
KB
|
|
|
|
|
I'm new to C++, and I'm in the process of porting a program I made in Delphi to C++. The program creates a horizon chart, with stars and constellations and stuff. But I haven't got a clue how to create a bitmap in C++. Been looking at tutorials but none of them take u through the complete process. Can anyone help?
Thanx
The more knowledge we gain, the less we understand
|
|
|
|
|
what excactly do u wanna do with this chart??
display on a window, or save to the hard drive?
Don't try it, just do it!
|
|
|
|
|
Entire section of codeproject dedicated to this ....
http://www.codeproject.com/bitmap/
What you are asking is simple:
1) Create memory DC compartible with screen.
2) Create bitmap
3) Select bitmap into memory DC save original bitmap
4) Now all dc GDI functions will draw on your bitmap.
5) When done select original bitmap.
|
|
|
|
|
Our application allows the users to configure interface screens, using edit boxes, comboboxes and drawing elements.
If a combobox is designed on Win2K, and made say 10 characters wide, it will often only display 9 characters on WinXP because the default widths of scrollbars are not the same.
I'd rather not force people to use a particular scroll bar size, but short of changing the font size I can think of any other way to ensure the contents of my combos is fully visible.
We could design eveything on XP, which is fixes the immediate problem. But we'd still be stuck if anyone decided to customise their scrollbar width and make it wider.
Anyone have any suggestions?
Dan
|
|
|
|
|
You could find out the scrollbar width, and then compensate for it.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi all. I have an MFC dll that uses the CFileDialog class. I'm making a custom version using the default template, and capturing the messages and doing what I need to do. One thing I must do is force the window into list view only and keep it there, prevent the user from changing the view to thumbnail or list or icon view.
On NT my code works like a champ. For some odd reason though, it doesn't on Win2k. On Win2k the Open/Save dialog comes up, shows the list view ever so briefly, and then display a blank listbox with no items in it. When looking at the messages (using Spy++) I see the window gets the style change I'm sending (It actually gets 4 which is where I think my problem lies), and when it attempts the call the SetItemText, it fails.
Why is this happening? I think it's becuase there is another GWL_STYLE message being sent by the default message processing for the window, but its coming AFTER I perform my change, therefore overriding my change. I can change the view using the view button (But I'm going to hide this button) but that doesn't help me. Yes the dialog is set with the OFN_EXPLORER option. Here's the code snippet:
if(strcmp(_strlwr(szClassName), "syslistview32") == 0)
{
switch(x -> message)
{
//case WM_NCPAINT : // Needed if there are no items to display
case LAST_LISTVIEW_MSG : // Magic message sent after all items are inserted
// force report view (Gives the details)
ln=GetWindowLong(x->hwnd,GWL_STYLE);
ln&=~(LVS_ICON|LVS_LIST|LVS_SMALLICON);
ln|=LVS_REPORT;
SetWindowLong(x->hwnd,GWL_STYLE,ln);
//::SetWindowPos(x->hwnd,HWND_NOTOPMOST,
// 0,0,0,0,
// SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
ln=GetWindowLong(x->hwnd,GWL_STYLE);
ln&=~(LVS_ICON|LVS_LIST|LVS_SMALLICON);
ln|=LVS_REPORT;
SetWindowLong(x->hwnd,GWL_STYLE,ln);
// Hide the tool bar stuff we don't need.
TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_STATE;
tbinfo.fsState = TBSTATE_HIDDEN | TBSTATE_INDETERMINATE;
::SendMessage(hWndToolbar,TB_SETBUTTONINFO,(WPARAM)TB_BTN_LISTVIEW,(LPARAM)&tbinfo);
::SendMessage(hWndToolbar,TB_SETBUTTONINFO,(WPARAM)TB_BTN_DETAILVIEW,(LPARAM)&tbinfo);
// This id is the Windows 2k/Xp combo button for the detail option list
// With the current problem on Win2k, we should leave this button viewable until we can
// figure out why the list box doesn't update to the detail view properly.
// ::SendMessage(hWndToolbar,TB_SETBUTTONINFO,(WPARAM)40970,(LPARAM)&tbinfo);
...
Do the other stuff
..
Any ideas on how to ensure I am the last one to set the ListBox Style?
|
|
|
|
|
Hi!
How to get the music's detail information such as title, artist, album and genre etc from a CD format file?
Thanks!
|
|
|
|
|
...you may get them trough an InterNet service (try WinAmp) !
Kochise
In Cod we trust !
|
|
|
|
|
|
I have recently installed Microsoft SDK. The help folder of the main Microsoft SDK folder contains files with extensions .HXC, .HXI, .HXK, .HXQ, .HXS, .HXT etc. These are the help files as it is shown in the file type column of explorer. However, these files do not open. I am using WIN98 SE.
How to read/ view these files? Do I have to install some other update to read these?
Pani
|
|
|
|
|
|
Thank you Stephane.
I'll download h2viewer and try to view the files.
Pani;)
|
|
|
|
|
how can i begin to become a C++ programmer ?
thanks for reading
|
|
|
|
|