Pelles C forum
Assembly language => Assembly discussions => Topic started by: Grincheux on April 25, 2021, 10:27:46 AM
-
Where Is the Window?
My progran only runs when I start Degug mode with or without any break point.
I don't understand why. Is it crached ? I thing but where?
The program just enumerates the windows and store some informations into a file.
Not very difficult.
I must start my program with the debugger even for release. It stops at first line, I made "Go" and it runs...
Some help would be welcome
-
I'm not clear on the problem, but I downloaded the attached 7z file and just ran the exe and it showed up w/o issue, as the top window. Not sure what I was to see but it used the whole screen. Attached screen shot.
On your system you might see if a previous crash has left something running in the background by using the task manager or possibly Pelles Process Viewer. I've run into that on occasion.
I'll can try to compile and run too.
John Z
-
Thank You John, this what I try to get on my screen.
I will made search as you say.
Have a good sunny day
-
Just unpacked it and it compiled w/o error and appeared to run creating the same full screen black window. It created a file "WiW - Windows.txt." The file is not fully readable by a plain text editor although that maybe by design....
On occasion I've messed up so badly that I had to reboot the computer to clear something before PellesC would work correctly again ;( So might try that if you haven't already.
John Z
-
I have found.
If my spirit was so special I would append to to something good.
Just had to take some time to read my code.
Nothing was good... It was a spaghetti code...
-
What is there on your screen, that could help you to find...
-
Exception: Access violation in function WriteFile
-
I am sorry, I never had this problem.
Here is an updated version.
I was asking to myself if you were dead or alive?
I have updated the program, removed sqlite3, no dll needed.
Dead code removed.
No need to create a file for storing datas!
Added a fixed font for the listview.
If the hInstance stored int the class structure is not the same as the one that is stored into the window (GWLP_HINSTANCE), the two are listed.
Idem for the windowProc, if the value stored is not the same as in GWLP_WNDPROC, the two values are listed.
Why that? I would like to indicate if the window has been subclassed or no.
There is a ini file where you can overide the defaut for WindowDisplaySetting.
If the file is found into the program folder it is read.
If not found, the value WDA_EXCLUDEFROMCAPTURE is set.
Now, if you double click on a item, it researches the children and displays them into an other window.
(https://www.mediafire.com/convkey/1285/bpbpyxz2617l6mb6g.jpg)
-
Now the program walk on many levels. He is not a walker but rather a diver.
On my machine, after the main level, I could go 6 levels down!
In the previous versions I could not do this because I used a global variable.
Sometimes, in the "hModule" column ou in the "Window Proc" you can see "xxxxx / yyyyyyy" this because the values
found into the WNDCLASSEX structure and the value got with GetWindowLongPtrA were not the same.
I told to JohnZ that I will add a hook, finaly not because it does not match my goal that is to find any subclassing.
For the beginners the program aligns all its datas and jumps.
One thing that can be misunderstood is that sometimes I replace the "CALL" with a "PUSH" and a "JMP".
As would say Frankie "The standard..." :P
By security in some functions there is a QWORD of difference if you count the parameters of the biggest function. That's normal.
An other detail: I add 2 times the first column and at the end I delete the first column!
This is because the formats is not applied on the first colum.
Info: The MSDN doc about LVM_SETSELECTEDCOLUMN is wrong.
LVM_SETSELECTEDCOLUMN message
05/31/2018
2 minutes to read
Sets the index of the selected column.
Parameters
wParam Value of type **int** that specifies the column index.
lParam Must be zero.
Return value The return value is not used.
Remarks
The column indices are stored in an int array. See the puColumns member of LVITEM.
In fact call this message as follow :
mov rcx,_hListView
mov edx,LVM_SETSELECTEDCOLUMN
mov r8d,3 <------------------------------- Column to select
xor r9d,r9d
call SendMessageA
-
Can you explain a bit more for this table issue?
An other detail: I add 2 times the first column and at the end I delete the first column!
This is because the formats is not applied on the first column.
I also use this listview table, performance is poor for big tables but I've had no problem setting the first column text, font, color, etc in my C vCard program. The only thing I can think offhand is the 1st column needs to be referred to as column 0. Shouldn't need to do extra work :)
John Z
-
The first column always is aligned on the left, try to align right or center, you can't.
For doing this once the first column is inserted, send LVM_SETITEM with LVI.iSubItem = 1 for duplicating the first column. Continue inserting colums, at the end delete the first colum, the one for which you call LVM_INSERTITEM.
-
You are absolutely right! Didn't need that so I hadn't tried.
Thanks!
John Z
-
Numbers are better when aligned on right, in France... :D
-
Sorry to report :( that the latest version posted above, Yesterday at 01:58:21 doesn't work on my system.
Tried as administrator too. Not hiding in the background either.
Mod date on the file Friday, April 30, 2021, 6:53:08 AM
SHA256: 153BA8F04DB11C5D376D77BA0C0C002F117A6516697FEC44BDFEBBB12F322E26
John Z
Windows 10 64 bit BTW.
-
Ok, I will look at
-
I found the problem - no ini file. I re-extracted the ini file into the exe directory and it runs.
Soooo - if the ini file ever disappears there would be no way to get the program to run again....
Seems if the ini file can't be found a default ini file should automatically be created so that the
program still works . . . . just a suggestion.
John Z
-
I will remove it.
-
Bug corrected.
When pressing the F5 key the listview content was not refreshed.
Removed SteWindowsAffinity, no need Wiw.ini file.
The first image shows the main screen.
The second shows the children of PhotoFilvtre 11.0
The last shows Pelle's IDE children
-
Note about LVCOLUMN
Remarks: If a column is added to a list-view control with index 0 (the leftmost column), it is always LVCFMT_LEFT. Setting other flags on column 0 does not override that alignment. Therefore if you keep inserting columns with index 0, the text in all columns are left-aligned. If you want the first column to be right-aligned or centered you can make a dummy column, then insert one or more columns with index 1 or higher and specify the alignment you require. Finally delete the dummy column.
https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumna (https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumna)
-
Added windows potion, width and Height.
There is a problem taht I don't append to solve when sorting on these columns 0 si lower than a negatif number!
I join the current version
-
Thanks - grabbed it.
I had noticed the Menu Refresh didn't change the form. I was trying to see before and after starting my vCard program. I'll try this new one.
Fortunately in my use of the listview table I did not keep inserting at column 0. It is a good tip you provided about that Micro$oft issue.
John Z
-
I don't have too much time playing with it right now, but... looks good!
-
Hi Grincheux,
Got the new one working - looks pretty good. However maybe some issue which could just be my understanding.
Here is what I did
Start the WiW program - looks good, reviewed windows title column.
Started a program, hit refresh and saw my program window Title, but the filename column was blank (attachment 1).
Within the program I started I opened another window, actually a table in a window like yours.
hit refresh and saw the second window title shown in the Window Title column but the window FileName
column attributed the window to WiW.exe and not my program(attachment 2).
Started another sub window within my program, again hit refresh, WiW then saw that window title too, but
also attributed it to WiW.exe and not my program(attachment 3).
So this maybe my understanding issue, or could be WiW is not retrieving the base file program name correctly all of the time.
Now - here is just a personal preference - I wish when WiW starts it did not automatically consume my entire screen. :)
A suggestion: I was trying to compare before and after starting a specific program to see changes. To do that I needed to do screen shots or run two instances of WiW without refreshing the first. It could be useful to be able to export the table to a comma separated output file, then two output files could be compared to see what changed. Alternatively F5 could highlight changes when refreshing. New/changed entries from the prior run could be highlighted -- well this might a very aggressive idea.. Anyway just a suggestion, you may have accomplished your original concept and it is very useful as is.
The ability to sort by any column is very helpful.
Thanks for your hard work!
John Z
-
Thank You John for these good remarks.
I will some changes like you said.
For the filename not displayed, I knew it and tested an other program written by Hutch on Masm32, he has the same problem. For the instant I have no answer, I continue to search.
-
I try to get the full path and filename.
The problem is how to get the flename of an other process
For doing this, set DebugPrivilege (I found someone that wrote a function)
BOOL EnableDebugPrivilege(BOOL bEnable)
{
HANDLE hToken = NULL;
LUID luid;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) return FALSE;
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) return FALSE;
TOKEN_PRIVILEGES tokenPriv;
tokenPriv.PrivilegeCount = 1;
tokenPriv.Privileges[0].Luid = luid;
tokenPriv.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
if (!AdjustTokenPrivileges(hToken, FALSE, &tokenPriv, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) return FALSE;
return TRUE;
}
my code
mov [_dwProcessID],ecx
mov [_hModule],rdx
mov ecx,TRUE
call EnableDebugPrivilege
mov ecx,PROCESS_QUERY_INFORMATION or READ_CONTROL or PROCESS_VM_READ
xor edx,edx
mov r8d,_dwProcessID
call OpenProcess ; ALWAYS RETURNS 0 AND GetLastError gives 0x57
test rax,rax
jz @Eoj
mov [_hProcess],rax
mov rcx,rax
xor edx,edx
lea r8,_szModuleName
mov r9d,SIZEOF _szModuleName
call QueryFullProcessImageNameA
mov rcx,[_hProcess]
call CloseHandle
0x57 = Bad Parameter
I always get an error. Could you help me.
-
I'll give the C version a try and see what happens.
I did suspect that privilege's might have been an issue when I tried your program so I also ran it explicitly as an administrator. The results were the same. I mention this because in looking over Debug Privilege I found this:
By default, this property is enabled for users with Administrator rights. A user with Administrator privileges can enable this property for other user groups.
So it seems that even if the code were working it may not produce the desired capability.
John Z
P.S It is possible that it does work in your program but only the first time used? I noticed in some sample code that it explicitly frees hToken with CloseHandle. In that example hToken is a Global though so maybe in yours it is not needed.
Update: OpenProcess requires three inputs dword DesiredAccess, bool inherithandle, and dword ProcessID
since DesiredAccess and InheritHandle seem to be constants I'd guess the dword ProcessID is wrong?
Update2: In the C version a bad process ID gives a "The Parameter is incorrect" error code. A good process ID by using GetCurrentProcessId() works.
-
Update2: In the C version a bad process ID gives a "The Parameter is incorrect" error code. A good process ID by using GetCurrentProcessId() works.
Ok, but the files we want are into an other process.
I have tried in setting admin rights into the manifest, no change
mov rcx,OFFSET szSeDebugPrivilege
call EnableWindowsPrivilege
With this function, I get "ERROR_NOT_ALL_ASSIGNED"
This should be the reason why OpenProcess fails.
-
I HAVE FOUND
This is a new version
-
Great work!!!!
It is really working well I see a lot of filenames now. Very informative.
I'm a bit suspicious though that there are exactly 254 …… ;)
Impressive,
John Z
-
It seems that Windows does not list all the windows. Metro...
-
Well it was coincidence. Started more processes and got over 270, so all good!
Now you are one up on Hutch!
John Z
-
Yes, but there is one problem I don't append to solve.
If a column has negative numbers the sort result is false for them.
-
Yes, I saw it was sorting as absolute value, the newest is different. No big deal in my view. I don't think the window position is a major feature.
John Z
-
Oops - I accidentally crashed the program.
To replicate the crash just double click on a row, then click on a column to sort. Bam, crash...
Sorry about that.
John Z
-
Hello John,
The error is corrected.
I made many tests but I had forgottent this test for children windows.
Many functions are common to Parents and Children, if it is ok for parents that is ok for children.
Yes, but it must be initialized correctly!
Thank You very much.
I join a version that I hope will have less bugs.
I don't say no bugs because we don't have to be sure at 100% it is impossible.
Even if "Nothing is impossible" for Frenchies, be modest.
------------------------------------------------------------------------------------------
Update 2021/5/5
The last version did not save the RDI register in two functions.
Use of SSE registers to avoid LOCAL variables and for returning the result.
-
Thank you Sir Grincheux!
The Child window pops up on double click and you change the title to "Where is the Child Window",
should it really be "Where are the Children" - :) seems like a lot of siblings for one parent.
The grandchildren window is blank ;) (only sometimes)
John Z