www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - RtlAdjustPrivilege and NtRaiseHardError

reply Arsium <mehdi81101 gmail.com> writes:
Just I tried to launch those functions from win32 api and seems 
doesn't work

Here is my code

module D_Programming_Test;

import core.sys.windows.windows;


pragma(lib, "ntdll.lib");

alias extern(C) int function(string[] args) MainFunc;
extern (C) int _d_run_main(int argc, char **argv, MainFunc 
mainFunc);

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 
lpCmdLine, int nCmdShow)
{
     return _d_run_main(0, null, &main); // arguments unused, 
retrieved via CommandLineToArgvW
}

extern (Windows)
LRESULT NtRaiseHardError(int az512 , uint az56 , uint sqd56 , int 
sqd52  , int foazeo ,   uint azd);


extern (Windows)
int RtlAdjustPrivilege(ulong az512 , bool az56 , bool sqd56 , 
bool sqd52 )
{
	return 1;
}

extern(C) int main(string[] args)
{
     MessageBoxW(null, "Hello D World!"w.ptr, "D Windows 
Application"w.ptr, MB_OK);

	    bool t1 ;
         uint t2  ;
         int i  = 0xC0000022 ;

         RtlAdjustPrivilege(19, true, false, t1);

         NtRaiseHardError(i, 0, 0, 0, 6, t2);


     return 0;
}
May 22 2020
parent reply Mike Parker <aldacron gmail.com> writes:
On Friday, 22 May 2020 at 19:19:19 UTC, Arsium wrote:
 Just I tried to launch those functions from win32 api and seems 
 doesn't work
"doesn't work" isn't very helpful. Are you seeing compiler errors? Linker errors? Runtime errors? Please describe your problem.
May 22 2020
parent reply Arsium <mehdi81101 gmail.com> writes:
On Saturday, 23 May 2020 at 01:33:13 UTC, Mike Parker wrote:
 On Friday, 22 May 2020 at 19:19:19 UTC, Arsium wrote:
 Just I tried to launch those functions from win32 api and 
 seems doesn't work
"doesn't work" isn't very helpful. Are you seeing compiler errors? Linker errors? Runtime errors? Please describe your problem.
Solved my problem alone : wrong signatures with functions ;)
May 24 2020
parent reply novice2 <sorry noem.ail> writes:
 "doesn't work" isn't very helpful. Are you seeing compiler 
 errors? Linker errors? Runtime errors? Please describe your 
 problem.
Solved my problem alone : wrong signatures with functions ;)
and this reply isn't very helpful. what is right signature? you go to forum to ask help. but wish you help to other readers, those will have the ame problems?
May 24 2020
parent Arsium <mehdi81101 gmail.com> writes:
On Sunday, 24 May 2020 at 20:35:58 UTC, novice2 wrote:
 "doesn't work" isn't very helpful. Are you seeing compiler 
 errors? Linker errors? Runtime errors? Please describe your 
 problem.
Solved my problem alone : wrong signatures with functions ;)
and this reply isn't very helpful. what is right signature? you go to forum to ask help. but wish you help to other readers, those will have the ame problems?
here is the solved code : module D_Lang_LowLevelBSOD; import core.sys.windows.windows; pragma(lib , "ntdll.lib"); alias extern(C) int function(string[] args) MainFunc; extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc); extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { return _d_run_main(0, null, &main); // arguments unused, retrieved via CommandLineToArgvW } extern(C) int main(string[] args) { bool Resp; uint RespOnse; int errorCode = 0xC0000022; //you can change it RtlAdjustPrivilege(19 , true , false , Resp); NtRaiseHardError(errorCode , 0,0,0,6 , RespOnse ); return 0; } extern(Windows) int RtlAdjustPrivilege(int Priv_To_Enable ,bool Enable , bool WasEnable , out bool response ); extern(Windows) int NtRaiseHardError(int ErrorCode , int n , int j , int k , int m , out uint respons
May 25 2020