Marneus901 Posted November 18, 2007 Share Posted November 18, 2007 LOL Aight, Im Kinda Not The Best At This Stuff. BUT It Deals With Assembly From OllyDBG And A Game Called GunZ.Im Trying To Figure Out A Way To Get This typedef void (__cdecl* ZChatOutputFunction)(const char* lpcMsg, int iType,int iLoc,DWORD dwColor);ZChatOutputFunction ZChatOutput = (ZChatOutputFunction)ZChat;void EchoOutput(const char *szMsg, ...){char szBuf[0x4000];va_list vaArgs;va_start(vaArgs, szMsg);_vsnprintf(szBuf, sizeof(szBuf), szMsg, vaArgs);va_end(vaArgs);ZChatOutput(szBuf, 2, 0, 0xFFFFFFFF);//ZChatOutput You Get From An Address In OllyDBG, That Works...}To Work In Inline asmLike So#define ZChatOutput 0x0042ABC0;//This Is The Address void Echo(const char *szMsg, ...){ _asm{pushadPUSH eaxmov eax,ZChatOutputPUSH 0xFFFFFFFF PUSH 0 PUSH 2 PUSH szMsg call eaxpop eaxpopad}}Now... It Works, SomewhatIt Outputs A Sample Message Lets Say When I Call It Like SoEcho("Hello, This Is Testing ZChatOutput!");It Outputs That String In-GameBut Then A Second Later It Crashes, And I Get This Message [image Attached]The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with calling convention with a function pointer declared with a different calling convention.Any Help is Appreciated!Thanks~-Marneus901 Link to comment Share on other sites More sharing options...
cluberti Posted November 21, 2007 Share Posted November 21, 2007 When I see code like that, it reminds me that you can have buffer overrun issues when using char *, and also, you should really be using stdcall instead of a C calling convention (like you are doing). It would be interesting for you to try and have it compile in VS 2005 or 2008. Link to comment Share on other sites More sharing options...
Marneus901 Posted November 21, 2007 Author Share Posted November 21, 2007 (edited) Well The Thing Is, I Want To Use Inline asm, Not The Calling Conventions. With The Inline asm, I Have No Calling Conventions, It Works Like I Said, It Outputs, Then Gives Me That ESP Error >.>So, It Shouldnt* Have To Deal With The Calling Conventions.An Example Of Perfect Working Code Isvoid SetAP(){ if(InGame()){//Check If In Game So We Dont Crash _asm{ mov ecx,MyZChar //Get Our Character ID mov eax,ZCharacter__SetAPOffset //Get The SetAP Offset PUSH 999 //Push The Value We Want Our AP At call eax //And Send To The Offset } }}It Perfectly Sets My AP, With No Errors. Which Is Weird Why Output Gives Me An Error... Edited November 21, 2007 by Marneus901 Link to comment Share on other sites More sharing options...
cluberti Posted November 23, 2007 Share Posted November 23, 2007 It is odd, and your initial post of sample code above doesn't have any glaring errors I can see. However, you may want to consider trying to save the register before you go in, and restore it on your way out. It's something you could try, although I'm thinking the compiler should catch it for you.Again, not sure - it's not obvious what the problem is. Link to comment Share on other sites More sharing options...
wintertiger Posted November 24, 2007 Share Posted November 24, 2007 It is odd, and your initial post of sample code above doesn't have any glaring errors I can see. However, you may want to consider trying to save the register before you go in, and restore it on your way out. It's something you could try, although I'm thinking the compiler should catch it for you.Again, not sure - it's not obvious what the problem is.Yeah, I told him basically the same thing, I figured it was something with the way the call was returning, since it executes all the code just fine. I myself have only looked at it for a few minutes here and there, but I agree that nothing jumped out at me. I'll have to remember that we have some ASM gurus out there too, been so long since I've used anything besides VBScript or C# that I almost forgot other languages existed. Link to comment Share on other sites More sharing options...
Marneus901 Posted November 26, 2007 Author Share Posted November 26, 2007 Ok, I Found The Solution, And I Got It To Work.I Needed To Clean Up The Stack Usingadd esp,[# of pushed values * 4]I Found The Solution Here: http://www.codeproject.com/cpp/calling_con...demystified.aspThe Way It Should Look Like Is Like Sovoid Echo(const char *szMsg, ...){ _asm{mov eax,ZChatOutputPUSH 0xFFFFFFFF PUSH 0 PUSH 2 PUSH szMsg call eaxadd esp,16}}I Had To add esp,16, 16 Because 4 Pushed Values * 4 = 16, Hence add esp,16Thanks For Your Attempts To Help Otherwise!-Marneus901 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now