![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
|
It doesn't work, because you have changed string declarations. Don't declare them as no-size arrays - if you do, compiler treats their names different (push causes actual string content to be pushed, not its address). Declare them as before:
char *str = "something";
__________________
Vulnerant omnes, ultima necat. |
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
If he declares them that way, they'll not be modifiable if he tries to change them as he did before. Recall that I mentioned the calling conventions. I checked your procedure and it is of the type that cleans the stack. Consequently you don't need the pops. You have to check these things. As I mentioned earlier, your ability to post sucks. You're asking for free help but you aren't helping your helpers. The post, "Hmmm, this doesn't work," is not a decent question; it's an implicit question. I could give you an implicit answer like, "Well, your code's effed up." You should go sit behind the barn and think about that and the price you're paying for the help you receive. This works for me:
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char msg []= "128";
char msg2 []= "Equal";
char msg3 []= "NotEqual";
MessageBox(0,msg3,msg,0);
__asm{
push 0;
lea ecx, msg;
push ecx;
lea ecx, msg3;
push ecx;
push 0;
call dword ptr [MessageBoxA];
}
MessageBox(0,NULL,NULL,0);
return 0;
}
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#13 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4
![]() |
Thanks to both...btw dawei...why would u need to go "lea" as you would have to dereference msg using "[]" before using anyway? isnot that a bit u know?
__________________
Spread your wings and fly! Chicken! |
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
LEA means "the address of MSG". That's what I want to pass to the function, not the first four bytes OF the message. It's the job of the function to perform the dereferencing. Don't mix up C and ASM in your head, they aren't the same.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|