cosmo0920 / win32-api

A different, better variant of the Win32API Ruby library
61 stars 10 forks source link

fix stdcall stack corruption #13

Closed rickerliang closed 9 years ago

rickerliang commented 9 years ago

The calling convention of window api is stdcall, callee pops its own arguments from the stack, so windows api's return statement usually like this (assembly) ret xxh, xxh == number of arguments * 4 byte. Number of arguments are vary from api to api, not all windows api uses 20 arguments (and ret 50h) especially some api has no argument, in that situation, before and after api call, esp register can not keep the same value, stack corruption occurs. Pass the argument according to api's prototype could fix this problem.