|
Although not a trivial task, it is indeed possible. It requires knowledge of the PE file format. See here. There is Web site referrred to in one of the C++ threads but I am unable to find it right now.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
If the wrapped file is already in a binary/exe format when imported into the VC++ resource hex table, then exporting that file to memory in binary form should load it to memory in the correct format ie a binary exacutable, the PE format is automatically taken care of. As long as the start of that memory location can be referenced as an exe in some way, all should run okay, shouldn't it?
V interesting links, thanks
u6ik
|
|
|
|
|
This is true for the most part. The executable file on disk is very similar to what the module will look like after Windows has loaded it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi... I got a weird problem here : ). I'm made a VC++ 6 DLL (Simple Win32 DLL Project). It's a DLL that installs a system-wide hook for the keyboard. I used keyboard because it's quite easy, my final purpose is to monitor messages with WH_GETMESSAGE. Anyhow, even this doesn't work.
My main Application is a VB6 Application. I will call the DLL from there. As you know, in order for a hook to work, you have to give it an address for a callback function which the hook will call each time it catches a keyboard event or message. The trick in my DLL is that the callback ain't here. I pass to the DLL (from VB) a parameter obtained from VB with the AddressOf operator. The parameter is the address of a VB function. Practically, I`m setting up the hook in VC++, but the callback function is in VB : ). I use "AddressOfCallBackFunction" parameter below to achieve this.
#include "stdafx.h"
#include "winuser.h"
HANDLE hInstance;
HHOOK hhookHooks;
const int WH_KEYBOARD = 2;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hInstance = hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int HookSystem(int AddressOfCallBackFunction);
int UnHookSystem(int HookID);
int HookSystem(int AddressOfCallBackFunction)
{
hhookHooks = SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC) AddressOfCallBackFunction,
(HINSTANCE) hInstance,
0);
return (int)hhookHooks;
}
int UnHookSystem(int HookID)
{
int iResult = 0;
iResult = UnhookWindowsHookEx((HHOOK)HookID);
if (iResult == 0) return 0; else return 1;
}
The VB code is simple and short.
In a module I got this...
Public Declare Function HookSystem Lib "D:\Lucru\Test\ASDClock.dll" (ByVal AddressOfTheCallBackFunction As Long) As Long
Public Declare Function UnHookSystem Lib "D:\Lucru\Test\ASDClock.dll" (ByVal HookID As Long) As Long
Public Function KeyboardCallback(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
MsgBox Code
End Function
And in the Form I got this.
Dim test As Long
test = HookSystem(AddressOf KeyboardCallback)
Surprise surprise! When VB reaches test = HookSystem(AddressOf KeyboardCallback) guess what? Error : BAD DLL CALLING CONVENTION. However, great must be your amazement when you hear that the hook IS ACTUALLY INSTALLED. The Application crashes, I must stop it, but the hook is succesfully installed.
As I learned, the error I just wrote above occurs when there are data type inconsistencies between VB and the DLL (or wrong number of parameters). Weird, because this is not the case. Long in VB = int in C++. The number of parameters is correct too.... Passing the parameters by ByVal is also correct. So anybody know what could be the problem?? Because I sure don't know. I've been using VB for quite some time...
The .DEF file for the VC++ DLL is :
LIBRARY ASDClock
DESCRIPTION "Testing some hook."
EXPORTS
HookSystem @1
UnHookSystem @2
Hm... I'm in the dark here : ).
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Hi !
No, a calling convention error is not because the parameters you pass are wrong. A calling convention describe in fact which part will clean the stack after the function has been called: the program which calls the dll or the dll itselfs. VB and C++ uses different calling conventions: for VB it is the standard calling convention (__stdcall) and for C++ it is the the C calling convention.
So, here your HookSystem and UnHookSystem functions have the C calling convention in the dll but VB calls them with it own calling convention. So, you have to change the calling convention of these functions inside your dll: just add a __stdcall :
<br />
int __stdcall HookSystem(int AddressOfCallBackFunction);<br />
int __stdcall UnHookSystem(int HookID);<br />
<br />
int __stdcall HookSystem(int AddressOfCallBackFunction)<br />
{ <br />
....<br />
}<br />
int __stdcall UnHookSystem(int HookID)<br />
{<br />
....<br />
}
You could also use APIENTRY as it is defined as __stdcall
|
|
|
|
|
Hi Cedric : ). Thanks a lot for your answer. That solved the problem!
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Hi everybody,
I'm planning to write a multi platform driver in order to capture
applications on a desktop and send them to FlashComm server.
I know that I may use Camtasia, but I'm planning an open source
project and I would like to implemet my own drivers.
I have to be able to select my screen output if you click on a flash movie and go to properties. There you can select all available cameras from a dropdown menu. My goal is that my screen output can be selected here.
Anyone with solutions
Tom Lismont
|
|
|
|
|
Hey
I'm building this small image processing program using MFC with the Doc/View stuff and i'm annoyed about the 3D border of the frame (or the inlay so to speak) in which the view is placed. I tried to remove that border or whatever it is by adjusting the CREATESTRUCT in the PreCreateWindow function of the child frame which holds my view. That doesn't seem to work. Any ideas/suggestions what it should be or what i did wrong?
thanks and greetings Joris
|
|
|
|
|
try using ModifyStyle().....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
try using ModifyStyle() or ModifyStyleEx......
u can change/modify the window char/styles dynamically(u have border optionz in that if i am right!!!.....search in msdn for WS_EX_STATICEDGE(for modifystylex) or WS_THICKFRAME(for modifyStyle) .....there r many optionz i dunno what kind of frame ,but u ought to find ur type of frame listed in these parameterz(WS_EX_.....,WS_....).....
hope that helpz!!!!!
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hey
Thanks. I solved it. I removed the WS_EX_CLIENTEDGE in the PreCreateWindow function from both the MDI child frame AND the view. I stumbled on that by accident. Seems to work fine, but i have no clue why the client edge has to be removed from both parts of the framework.
greetings Joris
|
|
|
|
|
i am writting an ActiveX control.
i want change mouse cursor at run time.
i written the following code in OnSetCursor.
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
But OnSetCursor is not called.
how call the OnSetCursor. won't framework call it?
|
|
|
|
|
well.....
u have to override the OnSetCursor function!!!!!
just calling it wont help!!!!!
add the WM_SETCURSOR.....
then in that function..... remove the return statement and replace it with return TRUE;
eg:
bool EXAMPLE::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
....
...
....
return CDialog::OnSetCursor(pWnd, nHitTest, message);
return TRUE;
}
now add the code where u want to add it ......
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
hope that helpz!!!!!
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
I'm creating a property sheet with many property pages but I don't know how to handle the Close button to save my data on the property page . Please help me!
Love
|
|
|
|
|
|
Hello,
I try to compile and get that the sddl.h file is missing.
Is there anyone that have this file and can EMail me that
goran.larsson@neteye.se
|
|
|
|
|
Looks like you may need to install the latest Platform SDK.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ok,
And where can I get that?
|
|
|
|
|
|
hiho@ll
just wanted to know what to do if i have 2 classes
class example1
class example2
to use the class example1 in example2 i use #include "exmple1.h" in the example2.h
but then i want to program a function in example1 which uses example2
if i add #include "example2.h" in example1.h i get a compiler error in example1.h
syntax error: identifier 'example2'
i understand why this error occurs
but how i make a workaround?
thx
|
|
|
|
|
You just forward-declare example 2:
<br />
<br />
class example2;<br />
<br />
class example1<br />
{<br />
public:<br />
....<br />
example2* pex2;<br />
}<br />
but as you can see, you can only use pointers to the forwarded class, not the class itself.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
well u c u have example1 class and example2 class,u cant interrelate themeboth for a simple reason that can be explained by thiz example.....
cansider a case where u have a classes that need each other.....that is example1 object is there in example 2 and vice versa.....
observe.....
class example2
{
example1 ex1;
}b;
class example1
{
example2 ex2;
}a;
letz consider object b.....
note that "b" would contain "ex1" and "ex1" would contain "ex2"....and what is ex2???....logically it goes to infinity(since each instance contains the instance of the other in itself)!!!!!
so it doesnt make sense.....moreover u can only create an object if itz memberz are all defined!!!!!.....say in class example2, the example1 need to be understood by the compliler to allocate /putaside the value for that object,but to get theat done example1 class must be fully defined,u will find it dependz on example2 and hence not possible!!!!!
thiz iz the way i reason it out!!!!!!;)
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
hello
i am working on my final project for graduation.
i have a tv tuner card connected with a wireless camera.
i want the video retrieved by camera to be processed in VC.
the problem is how could i get that video in VC from tv tuner card.
also some attributes to be sent to the camera for its movement.
tell me plz the path and API to be used.
thanx
|
|
|
|
|
Hi everyone.
My problem: I want to determine if a http server accepts bytes ranges. I am using wininet functions, (internetopen->internetconect->httpopenrequest->httpsendrequest->httpqueryinfo). If anyone can suggest me how to do this, or point me to a piece of relevant code (VC++) please help.
THANKZ.
|
|
|
|
|
HI
I am using visual C++ .net. I just created dialog box A under project 1, dialog box B and one edit control box under project 2.
It is possible to display the 'caption' of dialog box A on the edit control box of dialog B? If yes, what codes whould I type ?
Thx
|
|
|
|