|
You might be able to get its address if you used a Debug build. Is there any reason you're trying to debug using a Release build?
|
|
|
|
|
Hi Alan,
The release version is running and serves some users, I do not want to stop it to replace with a debug version. And I can not reproduce the same issue in debug version. Just want to attach to release version running code to see some variable values.
I think debugger is using PDB file to resolve name/symbol correct? But in release version PDB has some issues and not be able to tract the correct value of variable?
regards,
George
|
|
|
|
|
1. Could you take the source code to a different machine, make a debug version, and debug it?
2. The .PDB has debugging infomation, such as variable names, as far as I know.
3. In a release version, the compiler may eliminate some variables for optimization, e.g. using a register instead of a memory location. One possibility is you could make a release version but turn off optimization. This may allow you to watch a variable.
|
|
|
|
|
Thanks Alan,
I have checked debug version debugging is fine. But if I really need to debug release version, how to monitor variable values correctly -- how to do this task efficiently? See assembly code or some other more convenient ways?
regards,
George
|
|
|
|
|
There is a compiler option to generate assembly code. If you're going to do this, the assembly code will match your source code closer if you turn off optimization.
You could also write variable values to a log file. This may be less work than using assembly code.
If your program crashes, the log file may not have the last few values written to it. You can get by this with the Lockbox debugging pattern:
For every value written, append it to the log file, then close the file. This way the file is intact even after a crash.
|
|
|
|
|
Thanks Alan,
Do you think it is a bug of PDB file which could not display the correct variable values -- my point is even if compiler is making optimization to put some variable into register other than put on the stack, PDB is not aware of this?
regards,
George
|
|
|
|
|
It could be; I don't know for sure. I think PDB files are intended to be used in debug mode, which isn't optimized.
|
|
|
|
|
Thanks Alan,
You have reproduced the same issue I mentioned?
regards,
George
|
|
|
|
|
I'm not sure what you mean. I was just giving you several suggestions that may help with your debugging.
Alan's First Rule of Debugging is: "Watch it happen."
Often the problem is not what we assume it is. Watch the bug occur either in the debugger, or by displaying variable values, possibly using the Lockbox Debugging Pattern.
Once you've seen the bug occur, then you can trace back to its cause.
|
|
|
|
|
Could you reproduce this issue I mentioned, Alan?
regards,
George
|
|
|
|
|
I want to connect a small numerical keyboard to my laptop computer. I would like to re-program the keys on the numerical keyboard, for example, when the user presses "/" I want that to be equivalent to pressing F1 on the regular keyboard. However, the regular keyboard should function as usual, that is, pressing "/" on the regular keyboard should type a "/"-character. Is this possible? If so, how do I implement it? Thanks in advance for any help.
|
|
|
|
|
If you are using an old-style "Y" splitter, I would say no.
If you are using a USB keypad, likely not, because of how the device is identified and used. At least, not without writing your own driver. It is entirely possible that the keypad was designed with USB hardware that was designed to send specific keystrokes (1-9 / * - + . ) directly to the system instead of sending generic keystrokes (key01 key02 key03 etc.) that are translated by some kind of driver to specific keystrokes.
If a serial one, it may have come with a tool to remap the keys. If not, then I believe a custom driver would be needed.
Note that writing a custom driver is not easy work, and you would need technical documentation on the specific device that you are using.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> 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! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
A hook would work -- but only if you could disambiguate where the keys are coming from. Without that information, you would not know of the key-press came from the normal keyboard, the keypad, a virtual keyboard (i.e. an on-screen keyboard or other input device, like Dasher[^]), etc, so you would not know if the key should be translated or not.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> 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! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I seem to get identical values on the parameters (nCode, wParam and lParam) in the call to KeyboardProc regardless of which keyboard I use so I guess it is impossible to determine where there key event came from. Thanks anyway for your input!
|
|
|
|
|
Hello everyone,
I met with a problem when writing the experiment code. My issue is, how to sync code (e.g. struct definition in IDL and in C++ source files, like .cpp/.h).
Suppose I manually added the following code in IDL, then how to add the definition of struct and also the GUID mapping of the struct name into C++ source files (.cpp/.h)? Add them manually or there are some automatic ways which could add both struct definition in IDL and in C++ source files altogether?
(for primitive data type like int we do not have such issue, but for complex data type, we have such issue.)
[
uuid(96BF543D-58B2-480B-A484-253D8838EB42)
]
struct MyValue {
long x;
};
interface ITestStrcut1 : IDispatch{
[id(1), helpstring("method SetMyStruct")] HRESULT SetMyStruct([in]struct MyValue* value);
};
regards,
George
|
|
|
|
|
Hmm, That looks wrong. If you're going to pass your own structs through a COM interface then you'll need to do your own marshalling. Doing that in combination with IDispatch, which is primarily used for 'automation' compatible interfaces for ActiveX controls and cross language compatibility e.g. C++ & VB is not something I would even consider unless I had to. There are lots of ways of passing this data that don't involve such a clash of ideas, lookup SAFEARRAYs, VARIANTs and automation interfaces to see what I'm talking about.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi Matthew,
Do you mean struct is not automation compatible data type? If yes, I disagree. Please refer here. Struct with only primitive type members are automation compatible.
Any comments?
http://vcfaq.mvps.org/com/4.htm[^]
regards,
George
|
|
|
|
|
George_George wrote: Do you mean struct is not automation compatible data type? If yes, I disagree. Please refer here. Struct with only primitive type members are automation compatible.
I disagree with you. From my (personal) point of view an automation compatible data type can be used by scripting clients. Well, the page you provided states clearly: "IMPORTANT: Structs cannot be used by scripting clients".
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 CPallini,
From scripting language point of view, I agree with you. Let me re-state my question to cover C++/VB client only.
Any ideas to my original question about code sync issue with C++/IDL?
regards,
George
|
|
|
|
|
George_George wrote: Any ideas to my original question about code sync issue with C++/IDL?
Nope, I may only suggest you to have a look at MIDL compiler generated files (if I remeber well a header file and a source one).
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 CPallini,
Do you mean the _i.h file? It is for COM consumer to include the definition of the struct along with its GUID. Yes, it is updated with IDL file update, I have checked with that.
But we also need to use the struct in COM server (not COM consumer, and my question is about COM server side, not COM consumer side), for example, accessing its field and using the struct type as function parameter type or something. But seems the source files for the COM server is not including any struct definitions? My question is whether to add the definition of struct manually or there are some automatic ways to sync struct defined in IDL to server source codes? Any comments or ideas?
regards,
George
|
|
|
|
|
How a.dll inject into SVCHOST.EXE (process)
I produced a.DLL
|
|
|
|
|
|
Hope you're familiar with DLL Injection techniques[^]
You may have to adjust the privileges [^] of your application to open the generic service host process (svchost.exe).
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|