flat assembler
Message board for the users of flat assembler.
Index
> Windows > simple win64 program Goto page 1, 2 Next |
Author |
|
ACP 13 Apr 2013, 22:16
One thing is that according to MSDN you should end your program by invoking ExitProcess() even if other methods work. Secondlyg shouldn't you use call [ShowWindow]? Please use code tags for posting code so it is a bit more readable.
This is just a quick peek into your code so there maybe other issues as well. Is there any exception when you run your code under debugger? |
|||
13 Apr 2013, 22:16 |
|
bitRAKE 13 Apr 2013, 22:46
ShowWindow isn't needed if you use WS_VISIBLE flag on window.
Please use [code] [/code] tags. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
13 Apr 2013, 22:46 |
|
HaHaAnonymous 13 Apr 2013, 23:41
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:05; edited 1 time in total |
|||
13 Apr 2013, 23:41 |
|
bitRAKE 13 Apr 2013, 23:45
Process creation can create other threads. RET would only end the current thread - which is a valid way to end a thread, btw, Yet, other threads just hang in the process and do whatever. So, to reiterate: Windows and loaded DLLs can create threads in your programs process space (this is not under your control), and ExitProcess is needed to end those threads.
I have an internal belief that there is some memory clean-up involved as well, but I don't have anything concrete to say about that. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
13 Apr 2013, 23:45 |
|
HaHaAnonymous 14 Apr 2013, 01:13
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:05; edited 1 time in total |
|||
14 Apr 2013, 01:13 |
|
bitRAKE 14 Apr 2013, 03:17
Program crashing is different than a run-away program. Program crash signals a need to respond to an error. This doesn't happen in the case of a run-away program. The computer can't solve the halting problem - It needs to be told something is wrong.
Here, try it out: Code: format PE64 GUI 5.0 at $543210000 include '%INCLUDE%\win64wxp.inc' .code At_The_Start: invoke CreateThread,0,1,BusyThread,0,0,0 invoke Sleep,1000 xor eax,eax div eax ; comment this to leave a thread hanging... pop rax ; FASM macro put a QWORD on stack retn align 64 BusyThread: @@: call @F jmp @B @@: enter 0,0 leave retn .end At_The_Start _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
14 Apr 2013, 03:17 |
|
HaHaAnonymous 14 Apr 2013, 03:42
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:05; edited 1 time in total |
|||
14 Apr 2013, 03:42 |
|
bitRAKE 14 Apr 2013, 04:07
I thought you'd say that.
Coding small programs, I still use RETN and cross my fingers that no other thread is created, or just don't end the program - force the user to kill the process. That way it seems like a "feature". Whereas the error looks like "bad" programming. IMHO, there are accessibility tools which create thread attached to processes. So, using RETN causing problems for people using IME, or the handicap. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
14 Apr 2013, 04:07 |
|
tixvin 14 Apr 2013, 04:47
the windows event viewer tells about the mistake 0xc0000005
its about memory access violation |
|||
14 Apr 2013, 04:47 |
|
revolution 14 Apr 2013, 04:58
HaHaAnonymous wrote: Good! Then I can exit my program by intentionally crashing it. |
|||
14 Apr 2013, 04:58 |
|
tixvin 14 Apr 2013, 05:44
so does anybody really know whats wrong here with code
|
|||
14 Apr 2013, 05:44 |
|
revolution 14 Apr 2013, 06:08
tixvin: We don't know what you mean by fails.
But anyhow, there is at least one problem that I can see. 1) There appears to be no message loop to pass commands to the window procedure. You just quit directly after creating the window. Where is your window procedure? Have a look in the sub-folders of the fasm download for examples of creating and managing a window in 64-bit mode. |
|||
14 Apr 2013, 06:08 |
|
tixvin 14 Apr 2013, 06:12
this code just create a window nothing more
Ii looked through win64 examples and I do not want to use invoke I just want to use pure asm commands as for fail the window does not appear at all and exit with error 0xc0000005 |
|||
14 Apr 2013, 06:12 |
|
revolution 14 Apr 2013, 06:16
Sure you create a window but then you immediately do a ShowWindow and then quit the program.
I'm not talking about invoke, I'm talking about having a valid windows procedure to process the command necessary to manage a window, and having a valid message loop to pass those command to the window. Without those two things you will never get a window to display anything. |
|||
14 Apr 2013, 06:16 |
|
tixvin 14 Apr 2013, 06:28
this is simply a copy of this c program in asm
Here is the complete code to create the window. Remember that WindowProc is still just a forward declaration of a function. Копировать Code: // Register the window class. const wchar_t CLASS_NAME[] = L"Sample Window Class"; WNDCLASS wc = { }; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.lpszClassName = CLASS_NAME; RegisterClass(&wc); // Create the window. HWND hwnd = CreateWindowEx( 0, // Optional window styles. CLASS_NAME, // Window class L"Learn to Program Windows", // Window text WS_OVERLAPPEDWINDOW, // Window style // Size and position CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, // Parent window NULL, // Menu hInstance, // Instance handle NULL // Additional application data ); if (hwnd == NULL) { return 0; } ShowWindow(hwnd, nCmdShow); Congratulations, you've created a window! Right now, the window does not contain any content or interact with the user. In a real GUI application, the window would respond to events from the user and the operating system. The next section describes how window messages provide this sort of interactivity. |
|||
14 Apr 2013, 06:28 |
|
baldr 14 Apr 2013, 08:42
tixvin,
MSDN wrote: …An application-defined window procedure should pass any messages that it does not process to the DefWindowProc function for default processing. Your example in C is incomplete, maybe you'd overlooked something (outside posted code) when translating to fasm? |
|||
14 Apr 2013, 08:42 |
|
tixvin 14 Apr 2013, 08:49
look at
http://msdn.microsoft.com/ru-RU/library/windows/desktop/ff381397(v=vs.85).aspx |
|||
14 Apr 2013, 08:49 |
|
tixvin 14 Apr 2013, 10:07
function WindowsCreateEx returns zero- fail creating window
|
|||
14 Apr 2013, 10:07 |
|
ACP 14 Apr 2013, 10:22
tixvin wrote: the windows event viewer tells about the mistake 0xc0000005 You haven't read my post - have you? If you would run your code under debugger (WinDbg for example) you would find out that access valiotion happens due to wrong call address which is result of: Code: call ShowWindow |
|||
14 Apr 2013, 10:22 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.