|
The function in the DLL does not have a real address until that DLL is loaded into your processes address space. Since a normal DLL cannot be reliably forced into a specific address (it may collide with an already-loaded DLL's load address), you cannot presume what the function's address will be.
Your second program, B, will have to load the DLL into its address space in order to get a valid address for the function.
Going the hack route, you may be able to directly allocate virtual memory in process B, copy the actual code from the function from process A to process B (by some other means), place it into the allocated buffer, set the protection on the buffer to PAGE_EXECUTE_READ , create a suitable function pointer and set it to the address of the buffer, and try to execute it.
-But you are going to have to find out further details about that route on your own...!
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
My application is crashing at customer's computer (Win XP). I've told him to run drwtsn32 -I to get minidump. Although drwtsn said it was installed, after crash there is still only standard "Send report" dialog. Any ideas why drwtsn is not catching the crash ?
Thank you
rrrado
|
|
|
|
|
oh it seems dump was created silently. ok solved
rrrado
|
|
|
|
|
In my VC++ application I want to get a folder opened in windows explorer when its path is given.
Something similar to Find Target..." for a shortcut
Can anybody provide me an example?
Thanks
sss
|
|
|
|
|
Use the ShellExecute() function
nav
|
|
|
|
|
Hi Sandakith !
Here is solution for you. just put the following code, that would do just what you want.
ShellExecute(0,"explore","c:\\malli\\",0,0,SW_SHOWNORMAL);
or
ShellExecute(0,"open","c:\\malli\\",0,0,SW_SHOWNORMAL);
you just go throught the difference between both the solutions, it's a noticable difference. And don't forget to include "windwos.h" and "shellapi.h" files into your project... ! All the best !
- Malli... !
|
|
|
|
|
|
toxcct wrote: prefer using NULL instead of 0...
any Particular Reason Tox for that as NULL is defined as 0 in Windows.h!.. or i am sure you want to increase readibilty of code! am i right?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
readability, definitely !
i know that NULL is 0, because it is actually defined like this :
#define NULL ((void*)0)
but as most C/C++ programmer used to use NULL macro for null pointers, i think it can help reading the code... nothing more.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Thanks all
sss
|
|
|
|
|
I'm trying to create a function which will combine two ints to create a DWORD. Both the ints are a percentage. So far, nothing I have tried is working.
For example, If I pass:
100 and 100 to create a DWORD val of 0xFFFFFFFF.
100 and 50 to create a DWORD val of 0xFFFF7FFF.
0 and 50 to create a DWORD val of 0x00007FFF.
Any help would be greatly appreciated.
|
|
|
|
|
pretty easy :
<font color=blue>DWORD</font> func(<font color=blue>unsigned short</font> paramMSB, <font color=blue>unsigned short</font> paramLSB) {
<font color=green>
<font color=blue>return</font> ((paramMSB * USHRT_MAX / 100) << 16) +
((ParamLSB * USHRT_MAX / 100);
}
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 4:41 Tuesday 14th February, 2006
|
|
|
|
|
Thanks for the quick reply. I have never used the << & >> operators in any form of mathematics before. That was my problem. Thankyou so much.
|
|
|
|
|
waldermort wrote: Thanks for the quick reply. I have never used the << & >> operators in any form of mathematics before. That was my problem. Thankyou so much.
In Continuation With Tox Reply , you can go for less complicated MACROS like
MAKEPARAM for making the DWORD from two Int...
HIWORD and LOWORD to reterive value of two int
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
Is there any way to change the selection color of an edit box
nav
|
|
|
|
|
|
Hi
Following link will help you in the same...If you are taking edit boc(textbox).
http://www.codeproject.com/editctrl/ceditbkcolor.asp
Cheers
"Peace of mind through Technology"
|
|
|
|
|
The sample in that project changes only the color of non selected items.But I want to change the color of seleted text's background color.
Thanks
nav
|
|
|
|
|
Handle WM_CTLCOLOREDIT and WM_CTLCOLORSTATIC
~RaGE();
|
|
|
|
|
almost impossible.. thats the default implementation .. but have try by subclassing and redrawing control!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
Can anyone tell me as why i face a problem with the following code.
Problem: The size of int and float in 4 bytes each and that of char is 1 byte. But when I print the sizeof the object of class A, it prints it as 12. what could be the reason?
class A
{
public:
char c;
int a;
float b;
};
void main()
{
A objA1;
int size = sizeof(A);
cout << size << endl;
}
|
|
|
|
|
Because the members of your structure are aligned on some boundaries (which can be modified with the #pragma pack macro). In your case, the members are aligned on 4-bytes boundaries:
c: 1 byte and start at byte 0
a: 4 bytes but start at the next 4-bytes boundary so at byte 4
b: 4 bytes and start at byte 8
Thus, that makes 12 bytes for your structure.
|
|
|
|
|
Thank you very much.
But still I have some more doubts on this. Why is it behaving like this only when a 'char' variable is declared? If I dont have a 'char' variable declared in the below snippet then it shows the size correctly as 16(int 4,float 4 and double 8). In case I include a 'char' varialbe then it shows the size as 24. why so?
class A
{
public:
// char c;
int a;
float b;
double d;
};
void main()
{
A objA1;
int size = sizeof(objA1);
cout << size << endl;
}
Could you please clarify me on this please.
|
|
|
|
|
I had a deeper look at that and I think I was a little bit wrong in my first answer.
First, the purpose of having structure alignment is for optimizing the speed. It is faster to get the data at once rather (so, contained in the same 8 bytes block starting at an index multiple of 8) than needing to get it in two operations (get the first part that is contained in the previous memory block from the second part).
Thus, for 32 bits systems, memory blocks are accessed in 8 bytes blocks. Thus, the member will be contained completely in a 8 bytes block.
So, let's take your example:
First, you put your char: 1 byte.
Then you have your integer (4 bytes): there is enough space to put it there so you have 5 bytes
Then, your float (4 bytes): there is not enough space left in the previous memory block so make it start in a new block (and add 3 padding bytes in the previous block). That makes 12 bytes.
The double now (8 bytes): there is not enough in the previous block so padd it with 4 bytes and put the double in a new memory block.
So, in total, that makes 24 bytes.
So, I was wrong in my first post: your member struct alignment is set on 8-bytes boundary (and not 4). And that is more logical because it is the default value.
I hope this is clear. Sorry for my previous post.
|
|
|
|
|
Because the compiler will aligned your struct.
The principle is flowing: alignment must accoring to the largest member size. so this struct will be aligned as 8 bytes(double).
|
|
|
|