|
Thanks Matthew,
Do you have any books or documents to refer to read to learn x64 assembly? My current books/documents are only dealing with 32-bit or even 16-bit assembly language.
My issue happens only with 64-bit application. Any ideas or refers?
regards,
George
|
|
|
|
|
You should be able to make a simple C++ project that makes one
call to CoInitializeEx. Bring up the disassembly debug window and step
through the asm code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
Here is my code and related assembly code. How do you know which register/memory is used as 1st and 2nd input parameter to CoInitializeEx?
0:000> kp
Child-SP RetAddr Call Site
00000000`0012ff18 00000001`4000100e ole32!CoInitializeEx(void * pMalloc = 0x00000034`00000008, unsigned long flags = 0x184)
00000000`0012ff20 00000001`400011d2 TestCoInitializeEx1!main(void)+0xe
00000000`0012ff50 00000000`77d5964c TestCoInitializeEx1!__tmainCRTStartup(void)+0x11a
00000000`0012ff80 00000000`00000000 kernel32!BaseProcessStart(<function> * lpStartAddress = 0x00000001`40001320)+0x29
0:000> ub 00000001`4000100e
TestCoInitializeEx1!main <PERF> (TestCoInitializeEx1+0xff8):
00000001`40000ff8 0000 add byte ptr [rax],al
TestCoInitializeEx1!main <PERF> (TestCoInitializeEx1+0xffa):
00000001`40000ffa 0000 add byte ptr [rax],al
TestCoInitializeEx1!main <PERF> (TestCoInitializeEx1+0xffc):
00000001`40000ffc 0000 add byte ptr [rax],al
TestCoInitializeEx1!main <PERF> (TestCoInitializeEx1+0xffe):
00000001`40000ffe 0000 add byte ptr [rax],al
TestCoInitializeEx1!main [d:\visual studio 2008\projects\testcoinitializeex1\testcoinitializeex1\main.cpp @ 5]:
00000001`40001000 4883ec28 sub rsp,28h
00000001`40001004 33d2 xor edx,edx
00000001`40001006 33c9 xor ecx,ecx
00000001`40001008 ff152a110000 call qword ptr [TestCoInitializeEx1!_imp_CoInitializeEx (00000001`40002138)]
#include <windows.h>
#include <objbase.h>
int main()
{
CoInitializeEx(NULL, 0);
CoUninitialize();
return 0;
}
regards,
George
|
|
|
|
|
I'm not sure what you're looking for.
I don't see anything getting pushed on the stack or the actual call to
CoInitializeEx().
It looks like the edx and ecx registers are the parameters.
You may need to step into the _imp_CoInitializeEx call to see more.
This is 64-bit code?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
I have posted the assembly code here,
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2639624[^]
The code is x64 on Windows Server 2003 with full optimization turned on.
My further questions,
1.
From your experience, if we want to find out the input parameter values, it is more convenient to see the values from the caller or the callee?
2.
From my code posted in CoInitializeEx, could we find out which memory address/register is used as input parameters?
regards,
George
|
|
|
|
|
I've a crazy idea, use SetWindowRgn, let the visible part be the rgn.
======================================
[update]
I tried as below, the background of the list ctrl is still while, why the code that changes the background brush doesn't take effect?
int CThumbListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListCtrlHiddenSB::OnCreate(lpCreateStruct) == -1)
return -1;
DWORD dw = SetClassLong(GetSafeHwnd(), GCL_HBRBACKGROUND, (LONG)GetStockObject(BLACK_BRUSH));
SetExtendedStyle(LVS_EX_HIDELABELS | LVS_EX_BORDERSELECT);
return 0;
}
=========================================================
Here is the method I tried, but not successful:
(some error check codes are removed)
BOOL CMyWnd::PreCreateWindow(CREATESTRUCT& cs)
{
CWnd::PreCreateWindow(cs);
WNDCLASS wndclass;
BOOL b = ::GetClassInfo(AfxGetInstanceHandle(),cs.lpszClass,&wndclass);
wndclass.lpszClassName=L"classThumbListCtrl";
wndclass.hbrBackground=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
VERIFY(AfxRegisterClass(&wndclass));
cs.lpszClass=wndclass.lpszClassName;
return TRUE;
}
Any way to correct it? Or is there a better way?
Thanks.
system
modified on Monday, July 14, 2008 10:59 AM
|
|
|
|
|
You Can use SetLayeredWindowAttributes.
-@SuDhIrKuMaR@-
|
|
|
|
|
It does not apply to a list ctrl, though the ctrl has WS_EX_LAYERED style.
system
|
|
|
|
|
There's nothing that says the system controls need to honor your brush.
You'll need to use owner draw/custom draw.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am using a mybatch.bat file to execute one of my command line exe. Below I the batch file
@echo ON
App.exe %*
pause
director structure used:
c:\test\ mybatch.bat
c:\test\App.exe
When I execute this batch file from its current folder it executes the “App.exe” (for example : C:\test>mybatch.bat)
But when i run giving path, (c:\>test\mybatch.bat) in this case I am getting error as C:\>App.exe bad command. That is batch file is not executing the command c:\>test\App.exe rather it executes c:\>App.exe.
So please let me know how to take the dynamic path.
-Nand
|
|
|
|
|
I know it is a fix. Not the right way to implement. But it works. It is simple. Just try.
Follow these steps
1. Make one more folder under c:\test> as "mybatch". (c:\test\mybatch>)
2. modify your batch file as follows
@echo ON
%0\..\App.exe %*
pause
Now try the command from the root folder of c drive.
c:\> test\mybatch.bat
|
|
|
|
|
Thanks a Lot..its working fine.
-Nandu
|
|
|
|
|
Hi all!
Can anyone tell me if i could use try-catch block within a windows procedure to catch errors like
"Error occurred while creating window!" or
"Couldn't initialize COM object!"
for example my in winmain function:
try
{
SetupMessageBoxPointer();
// Initialize WinSock for peer to peer classes, and COM for ...
if (!InitializeWinSock2())
throw Error(L"Error: Cannot initialize Ws2_32.dll!", _FATAL_ERROR);
if ((hOK = CoInitialize(NULL)) != S_OK)
throw Error(L"Error: Cannot initialize COM object!", _FATAL_ERROR);
mainapp = new DataCrypt(hInstance);
if (mainapp == NULL)
throw Error(L"Cannot allocate memory for DataCrypt object!", _FATAL_ERROR);
mainapp->Initialize();
mainapp->Run(); // messages loop
}
catch(Error &err)
{
ERRORMSG(NULL, err.GetText(), err.GetErrorType());
}
|
|
|
|
|
With the code you've posted, catch block surelly handles the Error exceptions you throw; anyway Windows API (without using MFC) doesn't use exception mchanism.
|
|
|
|
|
Yes, your idea is sound. Clearly you will need to define the Error class appropriately and to enable C++ exception handling for your project. Catching exceptions by reference is also occasionaly flaky so if you find the catch part is not working then trying throwing and catching an Error pointer instead.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Matthew Faithfull wrote: Catching exceptions by reference is also occasionaly flaky
I'm not sure what you mean by this. Catching exceptions by reference (usually a const reference) is the norm.
Steve
|
|
|
|
|
I was recently looking into this because I've been implementing exception handling myself, as opposed to just using it, ( based on porting a VC6 OSS implementation). There's a set of matching rules that decide whether a particular catch handler matches a particular thrown exception. The more I looked into how to implement this the more complex I realised it is. Added to which the flags in the underlying Windows (and VC++ generated code ) exception information don't seem adequate to accurately differentiate between for example a reference to a type and a reference to a pointer type. On the basis that I could find no documentation on these rules, maybe they're buried in an appendix of the C++ spec somewhere, I determined to advise extreme caution when throwing anything other than a straight forward pointer. Plain pointers are clearly flagged in the built in data structures and can definitely be caught reliably. I need to do a good deal more investigation, and ideally get hold of the formal rules, to determine if VC++ does indeed generate enough information to fully implement them and whether MSs own exception system has any holes in this area which I strongly suspect it might. I have stuggled in the past to get catch handlers to match with anything other than very simple thrown types and now I think I know why.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi.
I need to disable visual style to a MFC project; that is, no window had to be rendered with visual style. I've tried the code
SetWindowTheme(m_hWnd, L" ", L" ");
in the MainFrame, but it removes the style to only the title bar.
The application is SDI with a single view and I've tried to use the above line even in the OnInitialUpdate handler, but seems it doesn't work.
Any hint?
Thanks
Atropo
|
|
|
|
|
Why do you need to do this?
Can't you use a console application?
Or is it just one single window, then again what do you want to do with it? Because the only use of an invisible window is to receive events. And this can be done by creating a CWnd dummy object.
Please clarify your needs.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
> Why do you need to do this?
'Cause with visual styles, the appearence of the application's controls (sizes, position, ecc.) changes.
> Can't you use a console application?
No! I need to use a GUI application!!!
>Or is it just one single window, then again what do you want to do with it? Because the only use of an invisible window is to receive events. And this can be done by creating a CWnd dummy object.
> Please clarify your needs.
It shouldn't matter. I simply need a window that is rendered with the basic visual style (classic Windows XP style).
|
|
|
|
|
which version of visual studio are you using?
|
|
|
|
|
VS 2008. It includes application manifest; I thought it could be modified to disable visual styles, but I don't know how.
|
|
|
|
|
If you open the stdafx.h, you can find some statements like...
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
Comment it all. Doing so will prevent your application from creating a manifest file that have dependency with comctrl version 6.
|
|
|
|
|
It works!!!
Thanks a lot!!!!
|
|
|
|
|
how can i send a clist of cstring elements to another process using writeprocessmemory?
when i try to send the list, the list is getting copied in the dest process but i cannot access its elements (i think the elements dont get copied).
thanks
|
|
|
|