The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nvidia5500 on June 27, 2008, 01:53:52 PM

Title: GetThreadContext fails :(
Post by: nvidia5500 on June 27, 2008, 01:53:52 PM
Anyway, im new here. Just learned assembly programming and im quite stuck with this:

Why does GetThreadContext always fails in this code:

invoke CreateProcess, offset filename, 0, 0, 0, 0, CREATE_SUSPENDED, 0, 0,  offset StartupInfo,  offset ProcessInfo
mov Context.ContextFlags, CONTEXT_FULL
invoke GetThreadContext, ProcessInfo.hThread, offset Context


After stepping from invoke GetThreadContext, my debugger displays eax=0. I cant seem to find the problem.
Also, adding align 16 at .data gives me assembler errors: invalid combination with segment alignment : 16

Help  :'(
Title: Re: GetThreadContext fails :(
Post by: bozo on June 27, 2008, 04:12:55 PM
Did you call GetLastError()?

I don't want to tell you the answer, not because i'm mean, but because you wouldn't realise what went wrong
and i've been there, and most on the board has too when learning assembly.
Trust me, you'll be a better programmer solving this error yourself.

things we need to know, are did the process start? if not, is it because some of the structures weren't properly initialized
or received invalid parameters?

http://msdn.microsoft.com/ is very useful

you can get the error message using : net helpmsg <DECIMAL ERROR CODE> or using FormatMessage api
Title: Re: GetThreadContext fails :(
Post by: nvidia5500 on June 27, 2008, 09:55:00 PM
Quote from: Kernel_Gaddafi on June 27, 2008, 04:12:55 PM
I don't want to tell you the answer, not because i'm mean, but because you wouldn't realise what went wrong
and i've been there, and most on the board has too when learning assembly.
Trust me, you'll be a better programmer solving this error yourself.

You're cruel :). Anyway it waaaas a very stupid mistake. I made it to align 4 and it worked. Haha. Anyway thanks.
Just downloaded the masm reference book and Id say it's quite a useful resource