|
Also painters and decorators exist and you may add their phone numbers to the header files.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
ATL/MFC provides the CImage class (see, for instance [^]).
You may also use directly GDI+ Image class [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
is there any windows event which tell to the application thatthere is date change ?
Thanks.
|
|
|
|
|
You might look into the WM_TIMECHANGE message.
Another option would be to set up a timer to fire every minute. Keep track of the date each time the timer fires.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
check for changed date...
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Long story, this isnt the exact use case but its a representation of the problem im having.
Lets say i then call a function that takes a Char*, i pass into this function "Hello!", upon arriving at this function the pointer lets say points to 0x55 containing "Hello!", this function then does bit manipulation on the Char*, so it now says "!olleH" at location 0x55
Now I again pass "Hello!" into the same function that takes a Char*, it goes directly to 0x55 and does the exact same bit manipulation, UNDOING the "encoding" and bringing the text back to "Hello!" rather than actually passing in a new instance of "Hello!" that i passed into it and encoding it to "!olleH" as it should.
Its as if the compiler is optimizing and any time it see's "Hello!" being passed through this function to just go straight to that memory location not knowing ive done bitwise things too it.
How do i stop this from happening or how can i trick the compiler into stopping this?
If i sprintf "Hello!" into a temporary buffer, and then print that, it works fine. But thats not a solution I can use unfortunately as there are hundreds if not thousands of lines that print "Hello!".
During my bitwise manipulation i've tried to create a new char, copy my text over to it, bit manipulate the new char, and then copy it back. But no luck, it just seems to point to that same location when i call the function.
|
|
|
|
|
how about you post the smallest fragment(s)/part(s) of code that demonstrate the issue - its a bit hard without seeing the function def, how you're calling it etc etc - please use the [code block] pre & /pre xml around your code as well
'g'
|
|
|
|
|
So i have two functions
void Send(Char* Input, UINT32 DisplayType)
UINT8 SwapBits(UINT8 b)
I then call
Send("Hello", 0);
Which gets the length of Input and then
for(int i=0;i < len;i++)
{
Input[i] = SwapBits(Input[i]);
}
While doing this i have WinDbg open and look at the pointer location for Input, lets say its x00500, you can see all 5 characters in Hello and their hex codes in Byte view.
Swapbits reverses the hi 4 bits for the low 4 bits in each UINT8 byte put in. It does this through a lot of bit manipulation, i dont have the code available now but it doesnt matter its not pertinent really. So instead of having a Hex of 0x25 fed in, it outputs 0x52. Sort of a ghetto encryption method.
All good so far.
Now call this again...
Send("Hello", 0);
if you look at the pointer it uses it does NOT create a new char* pointer. Instead it points to the one it made the first time at 0x500(still encrypted). Obviously passing in the bit swapped value just bit swaps it back. So swapbits outputs 0x25, from the previous example.
Every time you call Send("Hello", 0) it will point to 0x500 not knowing its been manipulated. It has to be some compiler thing trying to optimize these strings used multiple times only delcaring them in memory once, but its breaking everything.
|
|
|
|
|
Ok, I think the problem you're having is how the compiler handles string literals by default. Every sting constant such as your "Hello!" has to be stored in your .exe file. By default, I think, VC++ combines indentical string literals into one instance to save space. Most of the time, these are put into programs to be treated as constants. In your case, you're saying it's ok to modify the memory locations that hold "Hello!". Since the compiler combines all instances of "Hello!" into one, all pointers to it will point to the same block of memory. Change that memory and it's changed for all instances.
I think there's a compiler or linker flag to force code generation to not combine string literals but I couldn't find it when I looked. Maybe they did away with it since the last version I saw that had it and now you're stuck with what you're seeing.
One way around it would be to define "Hello!" once and copy it to a separate buffer each time you want to play with it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
No, no, no, no! no.
In your example, you are sending the text as a constant - the compiler can do whatever it chooses to store/optimize constant usage. In my case something like that crashes...
What you should be doing is along the lines of:
#include <stdio.h>
#include <stdlib.h>
char *manip(char *manipMe)
{
return strrev(manipMe);
}
int main()
{
char *manipMe;
manipMe = (char*)malloc(strlen("Hello world!\n")+1);
strcpy(manipMe, "Hello world!\n");
printf("%s","Hello world!\n");
printf("%s",manip(manipMe));
printf("%s",manip(manipMe));
return 0;
}
Output:
Hello world!
!dlrow olleHHello world!
Process returned 0 (0x0) execution time : 0.031 s
Press any key to continue.
|
|
|
|
|
|
Can a DLL loaded into a memory table be used like a DLL into a file with LoadLibrary() ?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Are you wanting to know the difference between implicit and explicit linking?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I think I don't understand. The problem is that I want to avoid LoadLibrary() .
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
RomTibi wrote: The problem is that I want to avoid LoadLibrary().
Then you must link implicitly.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I think I don't know the difference between implicit and explicit . I think I need an example.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
RomTibi wrote: I think I need an example.
Google is your friend. See here.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks! I've a lot to learn! ...yet...
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
LoadLibrary requires the DLL to be on the disk.
So you will need to write the contents of the memory to a disk file and then call LoadLibrary on it.
|
|
|
|
|
See the reply to David Crow
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Yes. you can load one DLL into System Memory.
|
|
|
|
|
How?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Firstly, it's far from clear what you mean by "loaded into a memory table". It sounds like your want to re-implement the loader. In general I'm not sure if this is possible from user mode. There's a lot more to getting a module into memory in a executable state then simply having the module in memory: relocating, recursively loading all dependent modules, resolving imports (building the Import Address Table, for example), etc... Even if you did do all these things (and more that I've forgotten) it's far from clear that "unusual" things, for example code that enumerated all loaded modules, would work.
Steve
|
|
|
|
|