evmar / retrowin32

windows emulator
https://evmar.github.io/retrowin32/
Apache License 2.0
582 stars 26 forks source link

Zero out entire struct in GetStartupInfoA #40

Closed LinusU closed 2 months ago

LinusU commented 2 months ago

As I've understand GetStartupInfoA, the caller always passes a pointer to uninitialized memory, and the function will then fill in the values. Before this change, GetStartupInfoA read the value of cb as an input parameter to get the length of the struct. In my program that part of the memory was uninitialized and happened to be 0, so the rest of the values were never zeroed out, leading to garbage data being returned in the other field.

This change make sure to zero out the entire struct, and then sets cb to the actual length of the struct.

Lifted from #39

evmar commented 2 months ago

(copy-paste of my review comment from before, just for history reasons)

By the way, I checked and I now believe that STARTUPINFOA has never changed in size, so my worries about callers passing in an undersized buffer or something like that are unfounded. And further I checked and at least win2k's kernel32.dll does exactly what you've done here, so I think this is correct.