As we know, MS prohibits using most of standard Win32 API in Windows Store applications. Obviously there are lots of ways to overcome this limit and to call any API you like, if you are not going to publish your app on Windows Store. And here is one of them.
Idea is really simple and rather old (lots of viruses use it): search for kernel32.dll base in memory, then parse its exports for LoadLibraryA and GetProcAddress, call them - and get profit.
void DoThings()
{
char *Tmp=(char*)GetTickCount64;
Tmp=(char*)((~0xFFF)&(DWORD_PTR)Tmp);
while(Tmp)
{
__try
{
if(Tmp[0]=='M' && Tmp[1]=='Z')
break;
} __except(EXCEPTION_EXECUTE_HANDLER)
{
}
Tmp-=0x1000;
}
if(Tmp==0)
return;
LoadLibraryA=(t_LLA*)PeGetProcAddressA(Tmp,"LoadLibraryA");
GetProcAddressA=(t_GPA*)PeGetProcAddressA(Tmp,"GetProcAddress");
CreateProcessA=(t_CPA*)PeGetProcAddressA(Tmp,"CreateProcessA");
HMODULE hUser=LoadLibraryA("user32.dll");
MessageBoxA=(t_MBA*)GetProcAddressA(hUser,"MessageBoxA");
MessageBoxA(0,"A native MessageBox!","Test",MB_OK);
STARTUPINFO si;
memset(&si,0,sizeof(si));
si.cb=sizeof(si);
PROCESS_INFORMATION pi;
CreateProcessA("c:\\Windows\\system32\\cmd.exe",0,0,0,FALSE,0,0,0,&si,&pi);
}
ShellExecute(, "open", "TabTip.Exe")
#define HKEY_CURRENT_USER 2147483649
#define ERROR_SUCCESS 0
//---------------------------------------------------------------------------//
//HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\ScrollHeight
function Main()
local hKey := NIL
local cName := NIL
local uValue := NIL
local n := 0
*----------------------------------------------------------
logfile ( "regestry.log", { "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics " })
RegOpenKey( HKEY_CURRENT_USER,;
"Control Panel\Desktop\WindowMetrics", @hKey )
while RegEnumValue( hKey, n++, @cName, @uValue ) == ERROR_SUCCESS
logfile ( "regestry.log", { n ,"Name ", cName, " Value ", uValue })
end
RegSetValue( hKey, "ScrollHeightn" ,-500 )
RegQueryValue( hKey, "ScrollHeight" , @uValue )
msginfo( uValue )
RegCloseKey( hKey )
msginfo( procname() + " " + str(procline()) + " " + str( 1 ) )
return nil
//---------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], nageswaragunupudi and 39 guests