Sorry for this massive push but I thought it wouldn't be necessary to create a new thread.
When I write a dll which uses code like this and call the Procedure from a highlevel language (in my case C++) then something strange happens: When I run the code in a the "Debug" setting the debugger tells me that ESP wasn't saved properly or something like this.
The called code looks like this:
Struc VersionInfo
.Stepping resd 1
.Model resd 1
.Family resd 1
.ExModel resd 1
.ExFamily resd 1
.CpuId resd 1
EndStruc
GLOBAL _GetCpuInfo@4
EXTERN _GetCpuInfo@4
_GetCpuInfo@4:
MOV esi, [esp+4]
MOV eax, 1h
CPUID
MOV [esi+VersionInfo.CpuId], eax
MOV ecx, eax
AND ecx, 1111b ;Stepping
MOV [esi+VersionInfo.Stepping], ecx
MOV ecx, eax
SHR ecx, 8
AND ecx, 1111b ;Family
MOV [esi+VersionInfo.Family], ecx
CMP ecx, 0Fh ;ExFamily supported?
JB .exfamily
MOV edx, eax
SHR edx, 20
AND edx, 11111111b
ADD ecx, edx
.exfamily:
MOV [esi+VersionInfo.ExFamily], ecx
MOV ecx, eax
SHR ecx, 4
AND ecx, 1111b
MOV [esi+VersionInfo.Model], ecx
CMP dword [esi+VersionInfo.Family], 0Fh
JE .new_exmodel
CMP dword [g_vendorId], INTEL
JNE .store_exmodel
CMP dword [esi+VersionInfo.Family], 6
JNE .store_exmodel
.new_exmodel:
MOV edx, eax
SHR edx, 16
AND edx, 1111b
SHL edx, 4
ADD ecx, edx
.store_exmodel:
MOV dword [esi+VersionInfo.ExModel], ecx
RET 4
When I write a pseudo-prologue (push esi and esp) and a pseudo-epilogue (pop esi and esp) I get no runtime errors, but the value stored in the structure are extremely strange.
Some things I can assure: The C++ mapped structure looks exactly the same (resd -> int32_t) and I handled the calling convention right (STDCALL)
Thanks in advance, aVoX.