flat assembler
Message board for the users of flat assembler.
Index
> Windows > Return Value Of Function Goto page Previous 1, 2, 3 Next |
Author |
|
Picnic 03 Feb 2017, 09:23
@Trentie89 deactivate your antivirus (if you have one) and try to compile again.
|
|||
03 Feb 2017, 09:23 |
|
Trentie89 04 Feb 2017, 02:09
That doesn't work either, thanks bro. I Think it has something to do with the compiler, because when I modify other code, it says illegal instruction ''.code" etc... Weird.....
Maybe its my windows 10 how its configed or something? The antivirus thing sounds right came with McAfee I just deactivated it(real time scanning) and nope.... Hmm..... Thanks again, asm file attached.
_________________ I Am the greatest.!. ( NOT YET ). |
|||||||||||
04 Feb 2017, 02:09 |
|
Walter 04 Feb 2017, 05:16
So much for "A picture is worth a thousand words." Last edited by Walter on 05 Feb 2017, 01:48; edited 1 time in total |
|||
04 Feb 2017, 05:16 |
|
Trentie89 04 Feb 2017, 12:19
wow thanks man. Ill do it the non-cheating way now. . Your a legend. Thanks heaps.
|
|||
04 Feb 2017, 12:19 |
|
revolution 04 Feb 2017, 13:43
Wow, how did all those non-breaking spaces get in there? Some type of "helpful" browser extension?
Strangely include was the only one that managed to not have 0xa0, so why did it fail? |
|||
04 Feb 2017, 13:43 |
|
Trinitek 04 Feb 2017, 16:30
Tried copying from Edge and I didn't get any 0xA0's. What kind of browser extension would even mess with that?
|
|||
04 Feb 2017, 16:30 |
|
Trentie89 05 Feb 2017, 01:31
I Hope none that is fucking too badly with my code, Trinitek. Now I know that its formatting errors that produce those unusual responses from FASM's compiler.
Thanks to the great help of fasmnewbie(fasmpro) :-p. Now I can start learning this excellent language again, why waste your time with high-level compilers when you can create/code such beautifully pure executables with no metadata. . Will be posting here lots, hopefully, as i learn more, i can help out more, whats the best fasm tutorial.???????. Trent. |
|||
05 Feb 2017, 01:31 |
|
Trentie89 05 Feb 2017, 03:10
Hi Guys,
Instead of starting a new thread, I might on as well keep this one running with some newbie questions, I wanted to change the text of a window if found, I can only do that if the window is opened by my own process right.?. I am having some issues with CreateProcess, the code below compiles, but the MessageBox doesn't even show up. Hmmmmm. Weird. Code: include 'win32ax.inc' .code start: sinfo STARTUPINFO pinfo PROCESS_INFORMATION meemul db 'C:\Users\Trent\Desktop\HELLO.EXE',0 progpath db 'C:\Users\Trent\Desktop\HELLO,EXE',0 invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo invoke MessageBox,HWND_DESKTOP,"Process Manufacturized.","Process Machined.",MB_OK invoke ExitProcess,0 .end start What do y'all reckon.?. Cheers dudes. Trent. |
|||
05 Feb 2017, 03:10 |
|
revolution 05 Feb 2017, 03:56
You have data immediately following the start label. So the CPU will try to execute your data, that is never a good thing.
Move your data away from the code, perhaps into its own data section. Code: include ... .data sinfo ... etc. .code start: ;code goes here .end start |
|||
05 Feb 2017, 03:56 |
|
Trentie89 05 Feb 2017, 04:43
Thanks Legend.....
I Am a really new beginner with ASM/Fasm, but you guys have solved my two problems so far. I'm sure ill have new questions, but ill keep them to this thread. Hope that you guys have an awesome day/and or night. . Trent. |
|||
05 Feb 2017, 04:43 |
|
Trentie89 07 Feb 2017, 04:34
Hey Guys,
As you probably know, I am working around process functions here with FASM, I Want to learn all about process creation and handles and what not, and even be able to write data to a processes memory, you get the gist, or even read process memory. My code below is my attempt at trying to open a process with CreateProcess and then change its window text. It doesn't work, can you tell me whats happening.?. Thanks legends. Code: include 'win32ax.inc' .data meemul db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 progpath db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 sinfo STARTUPINFO pinfo PROCESS_INFORMATION .code start: invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo invoke SetWindowText,eax,"New Text!" invoke MessageBox,HWND_DESKTOP,"Process Manufacturized.",eax,MB_OK invoke ExitProcess,0 .end start |
|||
07 Feb 2017, 04:34 |
|
revolution 07 Feb 2017, 05:28
You need to check the return values for each API that you call. Don't simply assume that they always succeed. The return value will give you information as to why it may have failed. You can either print the value to the screen, or better use a debugger to follow the progress.
BTW: For your particular problem, you don't have any mechanism to wait for the target process to finish initialising. In a multi-threaded OS things won't necessarily happen in any particular order. The target process may be setting the title after you set it, or it may happen in the reverse order. Also, your OS might be limiting your ability to change the target process due to security restrictions. You have passed a NULL security descriptor and your defaults might be to block remote tasks from making changes. Anyhow, the return value from each API will tell you what is happening. |
|||
07 Feb 2017, 05:28 |
|
Trentie89 17 Feb 2017, 06:39
Code: include 'win32ax.inc' .data meemul db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 progpath db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 sinfo STARTUPINFO pinfo PROCESS_INFORMATION .code start: invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo invoke SetWindowText,eax,"New Text!" invoke MessageBox,HWND_DESKTOP,"Process Manufacturized.",eax,MB_OK invoke ExitProcess,0 .end start The msg box title says "Error". Is their a more specific function i could use to check the error in more greater detail.?. I Know my OS(Windows 10) might not let me set the window text even if i have created the process in my very own code. Do i need to pass a specific security descriptor when calling CreateProcess in order to be able to change the child processes window text.?. I Cant find much info on process functions on this board, or anywhere, not that i am anywhere near an advanced Assembly programmer, they seem to be advanced functions originally made by microsoft for developers wishing to create debuggers. Can you help me out.?. God bless Ya and yours.!. Trent. |
|||
17 Feb 2017, 06:39 |
|
revolution 17 Feb 2017, 07:03
You have to convert the numeric code in EAX to text form (you might want either hex or decimal (or both) format(s)). If you pass EAX directly then the API thinks it is a pointer to some memory location with the text to show.
Also, you still need to check the return value from CreateProcess, it might have failed. You can do "CMP EAX,0" and then "JE some_label", or whatever code makes sense, and then show error messages when necessary. |
|||
17 Feb 2017, 07:03 |
|
Trentie89 17 Feb 2017, 07:12
I Dont think that CreateProcess failed, as it does indeed launch the process. As a newbie as you know to ASM, can you please tell me how to convert eax to text.?. Thanks champ.
BTW: I Am on a major learning curve here, what are some great books to read to get to know FASM.?. I Intend on making it my second language after PHP(Im a professional at that, been doing it for 13 years). Not to make people angry, its just as a beginner i have lots of questions, and thanks to awesome people like you others can learn new languages and put their skills to the limit.!. I Only ever intend to master ASM, along with PHP which i have already mastered. Trent. |
|||
17 Feb 2017, 07:12 |
|
revolution 17 Feb 2017, 07:37
When your code runs, your code doesn't know if it fails. Only you, as the viewer knows. So it is still a good idea to check the return value in the code so that the code can take the appropriate action.
But anyhow, to convert numbers to text you can use the API wsprintf, or link to MSVCRT and use printf. Code: cinvoke wsprintf,addr dest_buff,'Some value = %08x',eax |
|||
17 Feb 2017, 07:37 |
|
Trentie89 17 Feb 2017, 10:15
I'm starting to think that its a Windows 10 thing. Unless someone can be kind enough to somehow show me otherwise. Heres me code, i called GetLastError. And displayed it on a messagebox, here is the code and screenshot.
Code: include 'win32ax.inc' .data meemul db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 progpath db 'C:\Users\Trent\Desktop\Assembly\fasmw17159\EXAMPLES\DIALOG\DIALOG.EXE',0 sinfo STARTUPINFO pinfo PROCESS_INFORMATION .code start: invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo invoke SetWindowText,eax,"New Text!" invoke MessageBox,HWND_DESKTOP,GetLastError,"Show Error",MB_OK invoke ExitProcess,0 .end start
_________________ I Am the greatest.!. ( NOT YET ). |
||||||||||
17 Feb 2017, 10:15 |
|
revolution 17 Feb 2017, 10:59
GetLastError is just an address pointer to data. So trying to print it as text won't be useful to you.
You can invoke GetLastError to retrieve the error string and then pass the return address to MessageBox. |
|||
17 Feb 2017, 10:59 |
|
revolution 17 Feb 2017, 11:02
But even if you do all that, you still have the problem of the race condition I explained above. You have to synchronise with the target application to make sure it is ready to set the title.
Also, the process itself doesn't have window text to display, only the windows within the application have title bars. So you have to communicate with the target app to find its window handles and then set the titles there. |
|||
17 Feb 2017, 11:02 |
|
Goto page Previous 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.